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); } } }
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()); } }
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()); } }
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); } } }
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); } } }
private void ToggleOutput(object source, System.Timers.ElapsedEventArgs e, EngineData.DO output) { WriteDO(output, !ReadDO(output)); }