示例#1
0
        public void Blink(EngineData.DO signalEnum, bool turnOnOff, int freq)
        {
            if (!_runningBlinks.ContainsKey(signalEnum) && turnOnOff)
            {
                var MyTimer = new System.Timers.Timer();

                MyTimer.Elapsed += (sender, e) => ToggleOutput(sender, e, signalEnum);
                _runningBlinks.Add(signalEnum, MyTimer);

                if (!MyTimer.Enabled)
                {
                    MyTimer.Interval = freq;
                    MyTimer.Start();
                }
            }

            if (_runningBlinks.ContainsKey(signalEnum) && !turnOnOff)
            {
                System.Timers.Timer TimerToStop;

                if (_runningBlinks.TryGetValue(signalEnum, out TimerToStop))
                {
                    if (TimerToStop.Enabled)
                    {
                        TimerToStop.Stop();
                        TimerToStop = null;
                        WriteDO(signalEnum, false);
                    }
                    _runningBlinks.Remove(signalEnum);
                }
            }
        }
示例#2
0
 public void WriteDO(EngineData.DO e, bool est)
 {
     NeedToWrite = true;
     try
     {
         UpdateDIORows((int)e, "ValueToWrite", est, IOCycle.ReadWriteIO.WriteDO, "");
     }
     catch (Exception exp)
     {
         Log.Instance.Error(exp, "WriteDO Error in Cycle: " + exp.ToString());
     }
 }
示例#3
0
        public void WriteDO(EngineData.DO e, bool est)
        {
            NeedToWrite = true;

            try
            {
                if (InhibitOutputs[(int)e])
                {
                    UpdateDIORows((int)e, "ValueToWrite", est, ReadWriteIO.WriteDO, "");
                }
            }
            catch (Exception exp)
            {
                Error?.Invoke("WriteDO Error: " + exp.ToString());
            }
        }
示例#4
0
 public bool ReadDO(EngineData.DO e)
 {
     try
     {
         return(UpdateDIORows((int)e, "Value", null, ReadWriteIO.ReadDO, ""));
     }
     catch (Exception)
     {
         Delay(10);
         try
         {
             return(UpdateDIORows((int)e, "Value", null, ReadWriteIO.ReadDO, ""));
         }
         catch (Exception) { return(false); }
     }
 }
示例#5
0
 public bool ReadDO(EngineData.DO e)
 {
     try
     {
         return(UpdateDIORows((int)e, "Value", null, IOCycle.ReadWriteIO.ReadDO, ""));
     }
     catch (Exception)
     {
         try
         {
             return(UpdateDIORows((int)e, "Value", null, IOCycle.ReadWriteIO.ReadDO, ""));
         }
         catch (Exception exp)
         {
             Log.Instance.Error(exp, "ReadDO Error in Cycle: " + exp.ToString());
             return(false);
         }
     }
 }
示例#6
0
 private void ToggleOutput(object source, System.Timers.ElapsedEventArgs e, EngineData.DO output)
 {
     WriteDO(output, !ReadDO(output));
 }