diff --git a/DeviceTest/DeviceTestDlg.cs b/DeviceTest/DeviceTestDlg.cs
index 57be4d3f4..8ed370351 100644
--- a/DeviceTest/DeviceTestDlg.cs
+++ b/DeviceTest/DeviceTestDlg.cs
@@ -56,7 +56,10 @@ namespace DeviceTest
static TBF.Boxes.FloatBox floatBox;
- static Event evnt;
+ static TBF.Boxes.DoubleBox dblBox1;
+ static TBF.Boxes.DoubleBox dblBox2;
+ static TBF.Boxes.DoubleBox dblBox3;
+ static Event evnt;
static DeviceTestDlg()
@@ -657,7 +660,13 @@ namespace DeviceTest
operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
operation2 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
}
- else if (tbfComponent1forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
+ else if (tbfComponent1forOp is TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter)
+ {
+ operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter).ReadLevelOp(ref dblBox1);
+ operation2 = (tbfComponent1forOp as TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter).ReadVolumeOp(ref dblBox2);
+ operation3 = (tbfComponent1forOp as TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter).ReadTempOp(ref dblBox3);
+ }
+ else if (tbfComponent1forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
{
//operation1 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(1);
//operation2 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(2);
@@ -681,10 +690,16 @@ namespace DeviceTest
}
else if (tbfComponent2forOp is TBF.BenchControl.Modbus.Easytherm.Easytherm)
{
- operation21 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
- operation22 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
+ operation21 = (tbfComponent2forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
+ operation22 = (tbfComponent2forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
}
- else if (tbfComponent2forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
+ else if (tbfComponent2forOp is TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter)
+ {
+ operation21 = (tbfComponent2forOp as TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter).ReadLevelOp(ref dblBox1);
+ operation22 = (tbfComponent2forOp as TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter).ReadVolumeOp(ref dblBox2);
+ operation23 = (tbfComponent2forOp as TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter).ReadTempOp(ref dblBox3);
+ }
+ else if (tbfComponent2forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
{
//operation21 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(1);
//operation22 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(2);
@@ -708,10 +723,16 @@ namespace DeviceTest
}
else if (tbfComponent3forOp is TBF.BenchControl.Modbus.Easytherm.Easytherm)
{
- operation31 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
- operation32 = (tbfComponent1forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
+ operation31 = (tbfComponent3forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(10);
+ operation32 = (tbfComponent3forOp as TBF.BenchControl.Modbus.Easytherm.Easytherm).SetTemperatureOp(20);
}
- else if (tbfComponent3forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
+ else if (tbfComponent3forOp is TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter)
+ {
+ operation31 = (tbfComponent3forOp as TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter).ReadLevelOp(ref dblBox1);
+ operation32 = (tbfComponent3forOp as TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter).ReadVolumeOp(ref dblBox2);
+ operation33 = (tbfComponent3forOp as TBF.BenchControl.Modbus.UltrasoundLevelMeter.LevelMeter).ReadTempOp(ref dblBox3);
+ }
+ else if (tbfComponent3forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
{
//operation31 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(1);
//operation32 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(2);
@@ -720,11 +741,14 @@ namespace DeviceTest
}
- while (workerThreadRunning)
+ int time = 0;
+ while (workerThreadRunning)
{
Thread.Sleep(1000);
- if (workerThreadRunning)
+ StateMachine.Time = ++time;
+
+ if (workerThreadRunning)
{
foreach (var d in tbfDevices) d.RunDeviceBefore();
diff --git a/DeviceTest/Program.cs b/DeviceTest/Program.cs
index 5720fe88c..2f17f29c7 100644
--- a/DeviceTest/Program.cs
+++ b/DeviceTest/Program.cs
@@ -72,10 +72,10 @@ namespace DeviceTest
}
/// Configure and start logging
- log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(LocAppDataDir + log4netConfigFName));
+ log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(Path.Combine(LocAppDataDir, log4netConfigFName)));
log = LogManager.GetLogger(typeof(Program));
log.Fatal("--------------------------------------------------------------------------------");
- log.Fatal(string.Format("TBF ver.{0}", Version));
+ log.FatalFormat("DeviceTest ver.{0}", Version);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
diff --git a/TBF/BenchControl/Events.cs b/TBF/BenchControl/Events.cs
index 316deba1b..830a96f30 100644
--- a/TBF/BenchControl/Events.cs
+++ b/TBF/BenchControl/Events.cs
@@ -1,5 +1,5 @@
///
-/// Copyright (c) 2013-2017 Sensus Metering Systems
+/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
///
namespace TBF.BenchControl
{
@@ -93,6 +93,8 @@ namespace TBF.BenchControl
TempInDone,
TempOutDone,
TempDivDone,
+ LevelDone,
+ VolumeDone,
FlowMeasurementDone,
FlowReached,
PositionReached,
diff --git a/TBF/BenchControl/GenericDevices/ILevelMeter.cs b/TBF/BenchControl/GenericDevices/ILevelMeter.cs
new file mode 100644
index 000000000..2f26a0f46
--- /dev/null
+++ b/TBF/BenchControl/GenericDevices/ILevelMeter.cs
@@ -0,0 +1,37 @@
+///
+/// Copyright (c) 2018 Sensus Slovensko a.s.
+///
+using System;
+using System.Collections.Generic;
+using Config.Entities;
+using TBF.BenchControl.Generic;
+using TBF.Boxes;
+
+namespace TBF.BenchControl.GenericDevices
+{
+ ///
+ /// Basic level meter functions
+ ///
+ public interface ILevelMeter
+ {
+ ///
+ /// Measurement correction table
+ ///
+ IList Corrections { get; }
+
+ ///
+ /// Events: LevelDone, Error
+ ///
+ /// Reference to a variable for the measured level in mm
+ /// ReadLevelOp instance reference casted to IOperaton
+ IOperation ReadLevelOp(ref DoubleBox level);
+
+ ///
+ /// Events: levelDone, Error
+ ///
+ /// Reference to a variable for the measured level in mm
+ /// Event returned when measurement done
+ /// ReadLevelOp instance reference casted to IOperaton
+ IOperation ReadLevelOp(ref DoubleBox level, Event levelDone);
+ }
+}
diff --git a/TBF/BenchControl/GenericDevices/IVolumeMeter.cs b/TBF/BenchControl/GenericDevices/IVolumeMeter.cs
new file mode 100644
index 000000000..e90a02e40
--- /dev/null
+++ b/TBF/BenchControl/GenericDevices/IVolumeMeter.cs
@@ -0,0 +1,34 @@
+///
+/// Copyright (c) 2018 Sensus Slovensko a.s.
+///
+using System;
+using System.Collections.Generic;
+using Config.Entities;
+using TBF.BenchControl.Generic;
+using TBF.Boxes;
+
+namespace TBF.BenchControl.GenericDevices
+{
+ public interface IVolumeMeter
+ {
+ ///
+ /// Measurement correction table
+ ///
+ IList Corrections { get; }
+
+ ///
+ /// Events: VolumeDone, Error
+ ///
+ /// Reference to a variable for the measured volume in l
+ /// ReadPressureOp instance reference casted to IOperaton
+ IOperation ReadVolumeOp(ref DoubleBox volume);
+
+ ///
+ /// Events: volumeDone, Error
+ ///
+ /// Reference to a variable for the measured volume in l
+ /// Event returned when measurement done
+ /// ReadPressureOp instance reference casted to IOperaton
+ IOperation ReadVolumeOp(ref DoubleBox volume, Event volumeDone);
+ }
+}
diff --git a/TBF/BenchControl/Modbus/UltrasoundLevelMeter/LevelMeter.cs b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/LevelMeter.cs
index 726741139..470c67639 100644
--- a/TBF/BenchControl/Modbus/UltrasoundLevelMeter/LevelMeter.cs
+++ b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/LevelMeter.cs
@@ -6,10 +6,12 @@ using System.Collections.Generic;
using log4net;
using TBF.BenchControl.Generic;
using TBF.Boxes;
+using Config.Entities;
+using System.Diagnostics;
namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
{
- public class LevelMeter : ComponentBase, GenericDevices.IPressureMeter, IDevice
+ public class LevelMeter : ComponentBase, GenericDevices.ILevelMeter, GenericDevices.IVolumeMeter, GenericDevices.ITempMeter, IDevice
{
private static readonly ILog log = LogManager.GetLogger(typeof(LevelMeter));
public override string ToString() { return string.Format("LevelMeter({0})", Cfg.ToString(1)); }
@@ -17,9 +19,22 @@ namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
readonly LevelMeterCfg myCfg;
readonly GenericDevices.IModbus modbus;
- private float receivedLevel;
+ /// The state of the measurement
+ MsrmntState msrmntState;
+
+ ///
+ /// Measured values when MsrmntState == MsrmntState.Valid
+ ///
+ double distance; /// [mm]
+ double level; /// [mm]
+ double percentage; /// [%]
+ double volume; /// [l]
+ double temperature; /// [°C]
+ ushort state;
+
+ /// Measurement time stamp when MsrmntState == MsrmntState.Valid
+ int msrmntTimeStamp;
- const ushort WatchdogBitMask = 0x0010;
public LevelMeter()
{
@@ -42,38 +57,37 @@ namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
/// Initialize this device
public void Initialize()
{
+ if (myCfg.DebugLevel == DebugMode.Simulate)
+ {
+ distance = 200.0;
+ level = 0;
+ percentage = 0;
+ volume = 0;
+ temperature = 20.0;
+ state = 0;
+
+ msrmntTimeStamp = StateMachine.Time;
+ msrmntState = MsrmntState.Valid;
+ return;
+ }
+
+ msrmntState = MsrmntState.Busy;
+
+ log.FatalFormat("Successfully initialized device {0}", ToString());
}
- ///
- /// Returns the water pressure
- ///
- /// Pressure in mBar
- public float ReadLevel()
- {
- return (float)Config.Units.ConvertFrom(Config.Unit.mm, receivedLevel);
- }
+ public double ReadLevel() { return level; } /// Returns water level in mm
+ public double ReadVolume() { return volume; } /// Returns volume in l
+ public double ReadTemperature() { return temperature; } /// Returns temperature in °C
- ///
- /// Events: PressureDone, Error
- ///
- /// Reference to a variable for the pressure in Bar
- /// ReadPressureOp instance reference casted to IOperaton
- public IOperation ReadPressureOp(ref FloatBox pressure)
- {
- return new ReadLevelOp(this, ref pressure);
- }
+ public IOperation ReadLevelOp(ref DoubleBox level) { return new ReadLevelOp(this, ref level); }
+ public IOperation ReadVolumeOp(ref DoubleBox volume) { return new ReadVolumeOp(this, ref volume); }
+ public IOperation ReadTempOp(ref DoubleBox temperature) { return new ReadTempOp(this, ref temperature); }
- ///
- /// Events: pressureDone, Error
- ///
- /// Reference to a variable for the pressure in Bar
- /// Event returned when measurement done
- /// ReadPressureOp instance reference casted to IOperaton
- public IOperation ReadPressureOp(ref FloatBox pressure, Event pressureDone)
- {
- return new ReadLevelOp(this, ref pressure, pressureDone);
- }
+ public IOperation ReadLevelOp(ref DoubleBox level, Event eventDone) { return new ReadLevelOp(this, ref level, eventDone); }
+ public IOperation ReadVolumeOp(ref DoubleBox volume, Event eventDone) { return new ReadVolumeOp(this, ref volume, eventDone); }
+ public IOperation ReadTempOp(ref DoubleBox temperature, Event eventDone) { return new ReadTempOp(this, ref temperature, eventDone); }
/// Run this device
@@ -82,33 +96,86 @@ namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
if (myCfg.DebugLevel == Config.Entities.DebugMode.Simulate ||
myCfg.DebugLevel == Config.Entities.DebugMode.FailureDuringOperation)
{
+ msrmntTimeStamp = StateMachine.Time;
return;
}
if (modbus.ReceivedTelegrams[myCfg.ModbusAddress].Count > 0)
{
byte[] telegram = modbus.ReceivedTelegrams[myCfg.ModbusAddress].Dequeue();
- if (telegram.Length == 9 && telegram[1] == 4 && telegram[2] == 4)
- {
- /// Swap byte order
- byte t1 = telegram[3];
- byte t2 = telegram[4];
- byte t3 = telegram[5];
- byte t4 = telegram[6];
- telegram[3] = t4;
- telegram[4] = t3;
- telegram[5] = t2;
- telegram[6] = t1;
- receivedLevel = System.BitConverter.ToSingle(telegram, 3);
+ if (telegram.Length == 15 && telegram[1] == 3 && telegram[2] == 10)
+ {
+ distance = (double)(256 * telegram[3] + telegram[4]);
+ level = (double)(256 * telegram[5] + telegram[6]);
+ percentage = (double)(256 * telegram[7] + telegram[8]);
+ temperature = (double)256 * telegram[9] + telegram[10];
+ state = (ushort)(256 * telegram[11] + telegram[12]);
+ volume = 0; /// TODO
+
+ string line = string.Format("dist={0} mm level={1} mm, %={2} %, temp={3} °C, volume={4} l, state={5}",
+ distance, level, percentage, temperature, volume, state);
+ log.Debug(line);
+ Debug.WriteLine(line);
}
}
- if ((StateMachine.Time % 3) == (myCfg.ModbusAddress % 3)) /// Each 3 seconds
+
+ byte[] msg = new byte[8]; /// Buffer for data to send
+
+ if ((StateMachine.Time % 3) == 0) /// Each 3 seconds
{
- const byte Function = 4; /// Read input registers
- const ushort Address = 0; /// Pressure
- modbus.SendMessage(myCfg.ModbusAddress, Function, Address, 2);
+ ///
+ /// Read distance, level, quantity, percentage and temperature in IEEE754 (DWORD-s)
+ ///
+ UInt16 regAddr = 100;
+ UInt16 count = 5;
+
+ /// Prepare data to be sent
+ msg[0] = myCfg.ModbusAddress;
+ msg[1] = 3; /// CMD =
+ msg[2] = (byte)(regAddr >> 8); /// Control Word Hi
+ msg[3] = (byte)(regAddr & 0xFF); /// Control Word Lo
+ msg[4] = (byte)(count >> 8); /// Serial Com Reference Hi
+ msg[5] = (byte)(count & 0xFF); /// Serial Com Reference Lo
+
+ modbus.SendMessage(msg);
+ }
+ else if ((StateMachine.Time % 3) == 1) /// Each 3 seconds
+ {
+ /////
+ ///// Read STATUS1
+ /////
+ //UInt16 regAddr = 104;
+ //UInt16 count = 1;
+
+ ///// Prepare data to be sent
+ //msg[0] = myCfg.ModbusAddress;
+ //msg[1] = 3; /// CMD =
+ //msg[2] = (byte)(regAddr >> 8); /// Control Word Hi
+ //msg[3] = (byte)(regAddr & 0xFF); /// Control Word Lo
+ //msg[4] = (byte)(count >> 8); /// Serial Com Reference Hi
+ //msg[5] = (byte)(count & 0xFF); /// Serial Com Reference Lo
+
+ //modbus.SendMessage(msg);
+ }
+ else if ((StateMachine.Time % 3) == 2) /// Each 3 seconds
+ {
+ /////
+ ///// Read distance, level, quantity, percentage and temperature in IEEE754 (DWORD-s)
+ /////
+ //UInt16 regAddr = 300;
+ //UInt16 count = 10;
+
+ ///// Prepare data to be sent
+ //msg[0] = myCfg.ModbusAddress;
+ //msg[1] = 3; /// CMD =
+ //msg[2] = (byte)(regAddr >> 8); /// Control Word Hi
+ //msg[3] = (byte)(regAddr & 0xFF); /// Control Word Lo
+ //msg[4] = (byte)(count >> 8); /// Serial Com Reference Hi
+ //msg[5] = (byte)(count & 0xFF); /// Serial Com Reference Lo
+
+ //modbus.SendMessage(msg);
}
}
diff --git a/TBF/BenchControl/Modbus/UltrasoundLevelMeter/LevelMeterCfg.cs b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/LevelMeterCfg.cs
index 2203889a9..d24deb539 100644
--- a/TBF/BenchControl/Modbus/UltrasoundLevelMeter/LevelMeterCfg.cs
+++ b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/LevelMeterCfg.cs
@@ -37,7 +37,7 @@ namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
///
/// Serialized parameters
///
- public byte ModbusAddress; /// 1..255
+ public byte ModbusAddress; /// 1..247
/// Private parameterless constructor invoked by all other (public) constructors
LevelMeterCfg() {}
@@ -55,7 +55,7 @@ namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
public void InitializeAll()
{
- ModbusAddress = 49;
+ ModbusAddress = 1;
}
@@ -111,8 +111,9 @@ namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
switch (i)
{
case 0:
- if (int.TryParse(strValue, out dummy) && dummy >= 0 && dummy <= 255) return true;
- break;
+ if (int.TryParse(strValue, out dummy) && dummy >= 1 && dummy <= 247) return true;
+ message = ParamName(i) + " is invalid. Address range is 1 .. 247";
+ return false;
default:
message = "Invalid index";
return false;
diff --git a/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadLevelOp.cs b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadLevelOp.cs
index 81c4e8f09..0785400cf 100644
--- a/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadLevelOp.cs
+++ b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadLevelOp.cs
@@ -17,25 +17,25 @@ namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
readonly Event eventDone;
/// Measured value
- FloatBox level;
+ DoubleBox level;
///
- /// Events: PressureInDone, PressureOutDone or Error
+ /// Events: LevelDone or Error
///
- /// Pressure meter reference
- /// Reference to the measured pressure variable, value is in bar
+ /// Water level meter reference
+ /// Reference to the measured level variable, value is in mm
/// Event to be returned by Run() when completed OK
- public ReadLevelOp(LevelMeter levelMeter, ref FloatBox pressure, Event eventDone)
+ public ReadLevelOp(LevelMeter levelMeter, ref DoubleBox level, Event eventDone)
{
if (levelMeter == null) throw new ArgumentNullException("levelMeter");
this.levelMeter = levelMeter;
- this.level = pressure;
+ this.level = level;
this.eventDone = eventDone;
log.Debug(this.ToString());
}
- public ReadLevelOp(LevelMeter pressureMeter, ref FloatBox pressure)
- : this(pressureMeter, ref pressure, Event.PressureDone)
+ public ReadLevelOp(LevelMeter levelMeter, ref DoubleBox level)
+ : this(levelMeter, ref level, Event.LevelDone)
{
}
@@ -48,7 +48,7 @@ namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
/// Run this operation
///
- /// Event.PressureInDone or Event.PressureOutDone
+ /// Event.LevelDone
///
public Event Run()
{
diff --git a/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadTempOp.cs b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadTempOp.cs
new file mode 100644
index 000000000..552ccd903
--- /dev/null
+++ b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadTempOp.cs
@@ -0,0 +1,64 @@
+///
+/// Copyright (c) 2018 Sensus Slovensko a.s.
+///
+using System;
+using log4net;
+using TBF.Boxes;
+
+namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
+{
+ public class ReadTempOp : IOperation
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(ReadTempOp));
+ public override string ToString() { return string.Format("ReadTempOp(.,{0},.)", eventDone); }
+
+ /// Set by the constructor
+ readonly LevelMeter levelMeter;
+ readonly Event eventDone;
+
+ /// Measured value
+ DoubleBox temperature;
+
+ ///
+ /// Events: eventDone or Error
+ ///
+ /// Water temperature meter reference
+ /// Reference to the measured temperature variable, value is in l
+ /// Event to be returned by Run() when completed OK
+ public ReadTempOp(LevelMeter levelMeter, ref DoubleBox temperature, Event eventDone)
+ {
+ if (levelMeter == null) throw new ArgumentNullException("levelMeter");
+ this.levelMeter = levelMeter;
+ this.temperature = temperature;
+ this.eventDone = eventDone;
+
+ log.Debug(this.ToString());
+ }
+ public ReadTempOp(LevelMeter levelMeter, ref DoubleBox temperature)
+ : this(levelMeter, ref temperature, Event.TempDone)
+ {
+ }
+
+
+ /// Start this operation
+ public void Start()
+ {
+ temperature.Val = levelMeter.ReadTemperature();
+ }
+
+ /// Run this operation
+ ///
+ /// Event.temperatureDone
+ ///
+ public Event Run()
+ {
+ temperature.Val = levelMeter.ReadTemperature();
+ return eventDone;
+ }
+
+ /// Stop this operation
+ public void Stop()
+ {
+ }
+ }
+}
diff --git a/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadVolumeOp.cs b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadVolumeOp.cs
new file mode 100644
index 000000000..d27b82a09
--- /dev/null
+++ b/TBF/BenchControl/Modbus/UltrasoundLevelMeter/ReadVolumeOp.cs
@@ -0,0 +1,64 @@
+///
+/// Copyright (c) 2018 Sensus Slovensko a.s.
+///
+using System;
+using log4net;
+using TBF.Boxes;
+
+namespace TBF.BenchControl.Modbus.UltrasoundLevelMeter
+{
+ public class ReadVolumeOp : IOperation
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(ReadVolumeOp));
+ public override string ToString() { return string.Format("ReadVolumeOp(.,{0},.)", eventDone); }
+
+ /// Set by the constructor
+ readonly LevelMeter levelMeter;
+ readonly Event eventDone;
+
+ /// Measured value
+ DoubleBox volume;
+
+ ///
+ /// Events: VolumeDone or Error
+ ///
+ /// Water volume meter reference
+ /// Reference to the measured volume variable, value is in l
+ /// Event to be returned by Run() when completed OK
+ public ReadVolumeOp(LevelMeter levelMeter, ref DoubleBox volume, Event eventDone)
+ {
+ if (levelMeter == null) throw new ArgumentNullException("levelMeter");
+ this.levelMeter = levelMeter;
+ this.volume = volume;
+ this.eventDone = eventDone;
+
+ log.Debug(this.ToString());
+ }
+ public ReadVolumeOp(LevelMeter levelMeter, ref DoubleBox volume)
+ : this(levelMeter, ref volume, Event.VolumeDone)
+ {
+ }
+
+
+ /// Start this operation
+ public void Start()
+ {
+ volume.Val = levelMeter.ReadVolume();
+ }
+
+ /// Run this operation
+ ///
+ /// Event.VolumeDone
+ ///
+ public Event Run()
+ {
+ volume.Val = levelMeter.ReadVolume();
+ return eventDone;
+ }
+
+ /// Stop this operation
+ public void Stop()
+ {
+ }
+ }
+}
diff --git a/TBF/BenchControl/StateMachine.cs b/TBF/BenchControl/StateMachine.cs
index 83501f9e7..73382f5dd 100644
--- a/TBF/BenchControl/StateMachine.cs
+++ b/TBF/BenchControl/StateMachine.cs
@@ -121,7 +121,11 @@ namespace TBF.BenchControl
///
/// Current state name
///
- public static int Time { get { return currentTimeSec; } }
+ public static int Time
+ {
+ get { return currentTimeSec; }
+ set { currentTimeSec = value; }
+ }
///
/// Constructor
diff --git a/TBF/TBF.csproj b/TBF/TBF.csproj
index f3ac0cccd..9008dd7f8 100644
--- a/TBF/TBF.csproj
+++ b/TBF/TBF.csproj
@@ -516,6 +516,7 @@
+
@@ -530,6 +531,7 @@
+
@@ -658,6 +660,8 @@
+
+