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