QuidoRS : Watchdog is optional, configurable, ver. 2 12.455

This commit is contained in:
Milan Hanajik
2017-02-09 20:59:00 +01:00
parent 46cc618300
commit 93513100eb
4 changed files with 144 additions and 90 deletions
@@ -19,7 +19,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
private ushort currentOutputs;
const ushort WatchdogBitMask = 0x0010;
ushort watchdogBitMask;
public QuidoRS()
{
@@ -33,6 +33,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
modbus = (GenericDevices.IModbus)TbfComponents.FindComponent(cfg.ParentName, components);
if (modbus == null) throw new Exception("Cannot find " + Name + " parent");
watchdogBitMask = (ushort)(quidoRSCfg.WatchdogEnabled ? (1 << quidoRSCfg.WatchdogBitNr) : 0);
log.Debug(this.ToString());
}
@@ -49,7 +51,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
/// <summary>Run this device</summary>
public void RunDeviceAfter()
{
currentOutputs = (UInt16)((Int32)currentOutputs ^ (Int32)WatchdogBitMask);
currentOutputs = (UInt16)((Int32)currentOutputs ^ (Int32)watchdogBitMask);
SendOutputs(currentOutputs);
}
@@ -64,7 +66,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
/// <param name="outputs">output value</param>
public void SetOutputs(ushort outputs)
{
currentOutputs = (UInt16)((Int32)outputs | ((Int32)currentOutputs & (Int32)WatchdogBitMask));
currentOutputs = (UInt16)((Int32)outputs | ((Int32)currentOutputs & (Int32)watchdogBitMask));
SendOutputs(currentOutputs);
}