12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Aitex.Core.Util;
- namespace Aitex.Core.RT.IOCore
- {
- /// <summary>
- /// 源DI 一段时间无变化,设置
- /// </summary>
- public class HoldDIMonitor
- {
- private DIAccessor diSource = null;
- private DIAccessor diDest = null;
-
- private DeviceTimer timer = new DeviceTimer();
- private bool last;
- private int period;
- private bool initValue;
-
- public HoldDIMonitor(string source, string dest, int period, bool value)
- {
- diSource = IO.DI[source];
- diDest = IO.DI[dest];
- this.period = period;
- initValue = value;
- }
- public void Gernerate()
- {
- if (last != diSource.Value)
- {
- timer.Start(period);
- }
- last = diSource.Value;
- diDest.RawData = initValue ? timer.IsTimeout() : !timer.IsTimeout();
- }
- }
- }
|