| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using SKMC.Api.Common;
- using SKMC.Api.Motion;
- using SKMC.Api.Motion.Model;
- using System;
- namespace SKMC.Api.Process.Model
- {
- /// <summary>
- /// 电机运行条件, 可作为触发动作的条件, 也可以作为告警状态的条件
- /// </summary>
- public class AxisCnd
- {
- //static readonly ILogger log = LogFactory.Get(typeof(AxisCnd));
- private readonly MotionCacher motionCacher = ObjectFactory.Resolve<MotionCacher>();
- public Func<MotionAxis, bool> CndExpress { get; set; }
- public MotionAxis DataModel { get; set; }
- // Type: Trigger 0, Validate 1
- public short Type { get; set; } = 0;
- public static AxisCnd Make(string code) => new AxisCnd
- {
- Code = code
- };
- public static AxisCnd Make(string code, Func<MotionAxis, bool> cndExpress) => new AxisCnd
- {
- Code = code,
- CndExpress = cndExpress
- };
- public bool Match() => CndExpress.Invoke(DataModel);
- public bool Match(Func<MotionAxis, bool> cndExpress) => cndExpress.Invoke(DataModel);
- private string _code;
- public string Code
- {
- get { return _code; }
- set
- {
- _code = value;
- DataModel = motionCacher.GetMotionAxis(_code);
- }
- }
- }
- }
|