| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using SKMC.Api.Core;
- using SKMC.Api.Common.Logger;
- using System;
- namespace SKMC.Api.Motion.Model
- {
- /// <summary>
- /// 电机运行条件, 可作为触发动作的条件, 也可以作为告警状态的条件
- /// </summary>
- public class AxisCnd
- {
- protected static readonly ILogger log = LogFactory.Get();
- 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);
- }
- }
- }
- }
|