Added: (1) IParallelOutput, (2) StateMachine.BenchWaitingOp/BenchErrorOp, (3) Modbus.QuidoRS support for Quido RS 8/8 (4) etc., ver. 2.18.1147
This commit is contained in:
parent
86c063caee
commit
a40b4ff606
@ -276,7 +276,14 @@ namespace DeviceTest
|
||||
radioButton3.Text = "SelectTank 3";
|
||||
radioButton4.Text = "SelectTank -";
|
||||
}
|
||||
else radioButton1.Text = "spare";
|
||||
else if (className == "Modbus.QuidoRS")
|
||||
{
|
||||
radioButton1.Text = "Close relay 1";
|
||||
radioButton2.Text = "Close relay 2";
|
||||
radioButton3.Text = "Close relay 3";
|
||||
radioButton4.Text = "Open all relays";
|
||||
}
|
||||
else radioButton1.Text = "spare";
|
||||
}
|
||||
///
|
||||
void UpdateOperations2(string className)
|
||||
@ -296,7 +303,14 @@ namespace DeviceTest
|
||||
radioButton23.Text = "SelectTank 3";
|
||||
radioButton24.Text = "SelectTank -";
|
||||
}
|
||||
else radioButton21.Text = "spare";
|
||||
else if (className == "Modbus.QuidoRS")
|
||||
{
|
||||
radioButton21.Text = "Close relay 1";
|
||||
radioButton22.Text = "Close relay 2";
|
||||
radioButton23.Text = "Close relay 3";
|
||||
radioButton24.Text = "Open all relays";
|
||||
}
|
||||
else radioButton21.Text = "spare";
|
||||
}
|
||||
///
|
||||
void UpdateOperations3(string className)
|
||||
@ -316,7 +330,14 @@ namespace DeviceTest
|
||||
radioButton33.Text = "SelectTank 3";
|
||||
radioButton34.Text = "SelectTank -";
|
||||
}
|
||||
else radioButton31.Text = "spare";
|
||||
else if (className == "Modbus.QuidoRS")
|
||||
{
|
||||
radioButton31.Text = "Close relay 1";
|
||||
radioButton32.Text = "Close relay 2";
|
||||
radioButton33.Text = "Close relay 3";
|
||||
radioButton34.Text = "Open all relays";
|
||||
}
|
||||
else radioButton31.Text = "spare";
|
||||
}
|
||||
|
||||
|
||||
@ -672,6 +693,13 @@ namespace DeviceTest
|
||||
//operation3 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(3);
|
||||
//operation4 = (tbfComponent1forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(0);
|
||||
}
|
||||
else if (tbfComponent3forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
|
||||
{
|
||||
operation1 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(1);
|
||||
operation2 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(2);
|
||||
operation3 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(4);
|
||||
operation4 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(0);
|
||||
}
|
||||
|
||||
|
||||
if (tbfComponent2forOp is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter)
|
||||
@ -704,6 +732,13 @@ namespace DeviceTest
|
||||
//operation23 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(3);
|
||||
//operation24 = (tbfComponent2forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(0);
|
||||
}
|
||||
else if (tbfComponent3forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
|
||||
{
|
||||
operation21 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(1);
|
||||
operation22 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(2);
|
||||
operation23 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(4);
|
||||
operation24 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(0);
|
||||
}
|
||||
|
||||
|
||||
if (tbfComponent3forOp is TBF.BenchControl.Modbus.PressureMeter.Meret.PressureMeter)
|
||||
@ -736,6 +771,13 @@ namespace DeviceTest
|
||||
//operation33 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(3);
|
||||
//operation34 = (tbfComponent3forOp as TBF.BenchControl.Modbus.TankSelector.TankSelector).SelectTankOp(0);
|
||||
}
|
||||
else if (tbfComponent3forOp is TBF.BenchControl.Modbus.TankSelector.TankSelector)
|
||||
{
|
||||
operation31 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(1);
|
||||
operation32 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(2);
|
||||
operation33 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(4);
|
||||
operation34 = (tbfComponent3forOp as TBF.BenchControl.Modbus.QuidoRS.QuidoRS).SetOutputsOp(0);
|
||||
}
|
||||
|
||||
|
||||
int time = 0;
|
||||
|
||||
15
TBF/BenchControl/GenericDevices/IParallelOutput.cs
Normal file
15
TBF/BenchControl/GenericDevices/IParallelOutput.cs
Normal file
@ -0,0 +1,15 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.GenericDevices
|
||||
{
|
||||
public interface IParallelOutput : IComponent
|
||||
{
|
||||
IOperation SetOutputsOp(ushort outValue);
|
||||
IOperation ShowBenchWaitingOp();
|
||||
IOperation ShowBenchErrorOp();
|
||||
}
|
||||
}
|
||||
@ -28,6 +28,7 @@ namespace TBF.BenchControl.Modbus.Common
|
||||
/// Private fields
|
||||
SerialPort serialPort;
|
||||
DateTime lastSerialPortWrite;
|
||||
bool initialRunDeviceCommComplete;
|
||||
|
||||
public Queue<byte[]>[] ReceivedTelegrams
|
||||
{
|
||||
@ -82,6 +83,8 @@ namespace TBF.BenchControl.Modbus.Common
|
||||
//workerThread = new Thread(Worker);
|
||||
//workerThread.Start();
|
||||
|
||||
initialRunDeviceCommComplete = false; /// Causes search for Quido RS modules in the first RunDeviceAfter() call
|
||||
|
||||
log.FatalFormat("{0} - Device successfully initialized", Name);
|
||||
}
|
||||
|
||||
@ -99,7 +102,7 @@ namespace TBF.BenchControl.Modbus.Common
|
||||
|
||||
Telegram.UpdateTelegramCRC(message);
|
||||
|
||||
if ((DateTime.Now - lastSerialPortWrite) > new TimeSpan(0, 0, 0, 0, 100))
|
||||
if ((DateTime.Now - lastSerialPortWrite) > new TimeSpan(0, 0, 0, 0, 100) && initialRunDeviceCommComplete)
|
||||
{
|
||||
/// More then 100 ms since last 'send' --> do not enqueue the message
|
||||
SendMessageNow(message);
|
||||
@ -174,12 +177,12 @@ namespace TBF.BenchControl.Modbus.Common
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
string s = Telegram.LogTelegram(string.Format("{0} - Invalid data received ", Name), buffer);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
string s = Telegram.LogTelegram(string.Format("{0} - Invalid data received ", Name), buffer);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -188,6 +191,16 @@ namespace TBF.BenchControl.Modbus.Common
|
||||
{
|
||||
if (serialPort == null) return;
|
||||
|
||||
if (!initialRunDeviceCommComplete)
|
||||
{
|
||||
initialRunDeviceCommComplete = true; /// Prevent 2nd invocation of the subsequent code
|
||||
|
||||
/// Search Quido RS modules
|
||||
byte[] searchTelegram = new byte[] { 0xF8, 0x11, 0, 0 };
|
||||
Telegram.UpdateTelegramCRC(searchTelegram);
|
||||
SendMessageNow(searchTelegram);
|
||||
}
|
||||
|
||||
if (telegramsToSend.Count > 0 && (DateTime.Now - lastSerialPortWrite) > new TimeSpan(0, 0, 0, 0, 500))
|
||||
{
|
||||
SendMessageNow(telegramsToSend.Dequeue());
|
||||
@ -197,15 +210,27 @@ namespace TBF.BenchControl.Modbus.Common
|
||||
/// <summary>Stop this device</summary>
|
||||
public void StopDevice()
|
||||
{
|
||||
if (serialPort != null)
|
||||
{
|
||||
//stopWorkerThread = true;
|
||||
//workerThread.Join(2000);
|
||||
serialPort.Close();
|
||||
serialPort = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopDevice2() { }
|
||||
public void StopDevice2()
|
||||
{
|
||||
if (serialPort != null)
|
||||
{
|
||||
/// Send telegrams currently in the queue
|
||||
while (telegramsToSend.Count > 0)
|
||||
{
|
||||
while ((DateTime.Now - lastSerialPortWrite) <= new TimeSpan(0, 0, 0, 0, 200))
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
SendMessageNow(telegramsToSend.Dequeue());
|
||||
}
|
||||
|
||||
//stopWorkerThread = true;
|
||||
//workerThread.Join(2000);
|
||||
serialPort.Close();
|
||||
serialPort = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
/// Copyright (c) 2015-2016 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
@ -1,15 +1,17 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Boxes;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
{
|
||||
public class QuidoRS : ComponentBase, IDevice
|
||||
public class QuidoRS : ComponentBase, IDevice, GenericDevices.IParallelOutput
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(QuidoRS));
|
||||
public override string ToString() { return string.Format("QuidoRS({0})", Cfg.ToString(1)); }
|
||||
@ -60,12 +62,22 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
|
||||
if (modbus.ReceivedTelegrams[quidoRSCfg.ModbusAddress].Count > 0)
|
||||
{
|
||||
modbus.ReceivedTelegrams[quidoRSCfg.ModbusAddress].Dequeue();
|
||||
byte[] telegram = modbus.ReceivedTelegrams[quidoRSCfg.ModbusAddress].Dequeue();
|
||||
|
||||
if ((telegram.Length >= 8) && (telegram[1] == 0x11) && (telegram[2] == telegram.Length - 5))
|
||||
{
|
||||
int msgLen = telegram.Length - 7;
|
||||
byte modbusAddress = telegram[3];
|
||||
string msg = Encoding.ASCII.GetString(telegram, 5, msgLen);
|
||||
string s = string.Format("QuidoRS detected: Address={0}, Message={1}", modbusAddress, msg);
|
||||
Debug.WriteLine(s);
|
||||
log.Warn(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RunDeviceAfter() { }
|
||||
public void StopDevice() { }
|
||||
public void StopDevice() { SendOutputs(0); }
|
||||
public void StopDevice2() { }
|
||||
|
||||
|
||||
@ -124,19 +136,19 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
|
||||
private void SendOutputs(ushort outputs)
|
||||
{
|
||||
byte[] msg = new byte[11];
|
||||
byte addr = quidoRSCfg.ModbusAddress;
|
||||
byte cmd = (byte)Function.ForceMultipleCoils;
|
||||
byte dataLo = (byte)(outputs & 0xFF);
|
||||
byte dataHi = (byte)(outputs >> 8);
|
||||
|
||||
msg[0] = quidoRSCfg.ModbusAddress;
|
||||
msg[1] = (byte)Function.ForceMultipleCoils;
|
||||
msg[2] = 0; /// Data Hi
|
||||
msg[3] = 0; /// Data Lo
|
||||
msg[4] = 0; /// Nr. of coils Hi
|
||||
msg[5] = 16; /// Nr. of coils Lo
|
||||
msg[6] = 2; /// Byte count
|
||||
msg[7] = (byte)(outputs & 0xFF); /// Output data Lo
|
||||
msg[8] = (byte)(outputs >> 8); /// Output data Hi
|
||||
|
||||
modbus.SendMessage(msg);
|
||||
if (quidoRSCfg.Variant == QuidoVariant.QuidoRS_2_16)
|
||||
{
|
||||
modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 16, 2, dataLo, dataHi, 0, 0 });
|
||||
}
|
||||
else if (quidoRSCfg.Variant == QuidoVariant.QuidoRS_8_8)
|
||||
{
|
||||
modbus.SendMessage(new byte[] { addr, cmd, 0, 0, 0, 8, 1, dataLo, 0, 0 });
|
||||
}
|
||||
|
||||
lastOutputsChange = DateTime.Now;
|
||||
}
|
||||
@ -145,22 +157,29 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
/// <summary>
|
||||
/// Events: SetOpututsDone, Error
|
||||
/// </summary>
|
||||
/// <param name="outValue">Reference to a variable for the pressure in Bar</param>
|
||||
/// <returns>SetOutputsOp instance reference casted to IOperaton</returns>
|
||||
/// <param name="outValue">Parallel output data</param>
|
||||
/// <returns>SetOutputsOp operation casted to IOperaton</returns>
|
||||
public IOperation SetOutputsOp(ushort outValue)
|
||||
{
|
||||
return new SetOutputsOp(this, outValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: pressureDone, Error
|
||||
/// Events: Event.None
|
||||
/// </summary>
|
||||
/// <param name="outValue">Reference to a variable for the pressure in Bar</param>
|
||||
/// <param name="setOutputsDone">Event returned when SetOutput is done</param>
|
||||
/// <returns>SetOutputsOp instance reference casted to IOperaton</returns>
|
||||
public IOperation ReadPressureOp(ushort outValue, Event setOutputsDone)
|
||||
/// <returns>ShowBenchWaitingOp operation casted to generic IOperaton</returns>
|
||||
public IOperation ShowBenchWaitingOp()
|
||||
{
|
||||
return new SetOutputsOp(this, outValue, setOutputsDone);
|
||||
return new ShowBenchWaitingOp(this);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: Event.None
|
||||
/// </summary>
|
||||
/// <returns>ShowBenchErrorOp operation casted to generic IOperaton</returns>
|
||||
public IOperation ShowBenchErrorOp()
|
||||
{
|
||||
return new ShowBenchErrorOp(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2016 Sensus Metering Systems
|
||||
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -9,6 +9,13 @@ using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
{
|
||||
public enum QuidoVariant
|
||||
{
|
||||
QuidoRS_2_16,
|
||||
QuidoRS_8_8,
|
||||
Count
|
||||
}
|
||||
|
||||
public class QuidoRSCfg : ComponentCfgBase, Generic.IChildComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(QuidoRSCfg) })[0];
|
||||
@ -19,7 +26,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public byte ModbusAddress; /// 1..255
|
||||
public byte ModbusAddress; /// 1..247
|
||||
public QuidoVariant Variant; /// 'QuidoRS_2_16' or 'QuidoRS_8_8'
|
||||
public bool WatchdogEnabled;
|
||||
public int WatchdogBitNr; /// 0..15
|
||||
|
||||
@ -29,7 +37,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
Name = "QuidoRS";
|
||||
ParentName = "Modbus";
|
||||
ModbusAddress = 49;
|
||||
WatchdogEnabled = true;
|
||||
Variant = QuidoVariant.QuidoRS_2_16;
|
||||
WatchdogEnabled = false;
|
||||
WatchdogBitNr = 4;
|
||||
}
|
||||
|
||||
@ -41,9 +50,10 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, ModbusAddr={1}, Parent={2}",
|
||||
return string.Format("Name={0}, ModbusAddress={1}, Variant={2}, Parent={2}",
|
||||
Name,
|
||||
ModbusAddress,
|
||||
Variant,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
/// Copyright (c) 2015-2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
@ -46,6 +46,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
}
|
||||
}
|
||||
|
||||
for (QuidoVariant v = 0; v < QuidoVariant.Count; v++) variantComboBox.Items.Add(v.ToString());
|
||||
|
||||
Redraw();
|
||||
}
|
||||
|
||||
@ -61,6 +63,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
nameTextBox.Text = config.Name;
|
||||
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
||||
modbusAddressTextBox.Text = config.ModbusAddress.ToString();
|
||||
variantComboBox.Text = config.Variant.ToString();
|
||||
watchdogCheckBox.Checked = config.WatchdogEnabled;
|
||||
watchdogBitNrTextBox.Text = config.WatchdogBitNr.ToString();
|
||||
}
|
||||
@ -70,6 +73,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
nameTextBox.Enabled = true;
|
||||
parentNameComboBox.Enabled = true;
|
||||
modbusAddressTextBox.Enabled = true;
|
||||
variantComboBox.Enabled = true;
|
||||
watchdogCheckBox.Enabled = true;
|
||||
watchdogBitNrTextBox.Enabled = true;
|
||||
}
|
||||
@ -84,11 +88,16 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(modbusAddressTextBox.Text, out dummy) || dummy < 0 || dummy > 255)
|
||||
if (!int.TryParse(modbusAddressTextBox.Text, out dummy) || dummy < 1 || dummy > 247)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Modbus Address' should be between 0 and 255";
|
||||
}
|
||||
if (!variantComboBox.Items.Contains(variantComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Variant'";
|
||||
}
|
||||
if (!int.TryParse(watchdogBitNrTextBox.Text, out dummy) || dummy < 0 || dummy > 15)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
@ -106,6 +115,10 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
config.Name = nameTextBox.Text;
|
||||
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
config.ModbusAddress = (byte)int.Parse(modbusAddressTextBox.Text);
|
||||
for (QuidoVariant v = 0; v < QuidoVariant.Count; v++)
|
||||
{
|
||||
if (variantComboBox.Text == v.ToString()) { config.Variant = v; break; }
|
||||
}
|
||||
config.WatchdogEnabled = watchdogCheckBox.Checked;
|
||||
config.WatchdogBitNr = int.Parse(watchdogBitNrTextBox.Text);
|
||||
|
||||
|
||||
@ -41,6 +41,8 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
this.watchdogCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.watchdogBitNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.watchdogBitNrLabel = new System.Windows.Forms.Label();
|
||||
this.variantComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.variantLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// parentNameLabel
|
||||
@ -84,7 +86,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
this.modbusAddressLabel.Location = new System.Drawing.Point(28, 108);
|
||||
this.modbusAddressLabel.Name = "modbusAddressLabel";
|
||||
this.modbusAddressLabel.Size = new System.Drawing.Size(86, 13);
|
||||
this.modbusAddressLabel.TabIndex = 7;
|
||||
this.modbusAddressLabel.TabIndex = 5;
|
||||
this.modbusAddressLabel.Text = "Modbus Address";
|
||||
//
|
||||
// modbusAddressTextBox
|
||||
@ -93,7 +95,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
this.modbusAddressTextBox.Location = new System.Drawing.Point(138, 105);
|
||||
this.modbusAddressTextBox.Name = "modbusAddressTextBox";
|
||||
this.modbusAddressTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.modbusAddressTextBox.TabIndex = 8;
|
||||
this.modbusAddressTextBox.TabIndex = 6;
|
||||
//
|
||||
// parentNameComboBox
|
||||
//
|
||||
@ -108,7 +110,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
//
|
||||
this.watchdogCheckBox.AutoSize = true;
|
||||
this.watchdogCheckBox.Enabled = false;
|
||||
this.watchdogCheckBox.Location = new System.Drawing.Point(31, 131);
|
||||
this.watchdogCheckBox.Location = new System.Drawing.Point(31, 164);
|
||||
this.watchdogCheckBox.Name = "watchdogCheckBox";
|
||||
this.watchdogCheckBox.Size = new System.Drawing.Size(99, 17);
|
||||
this.watchdogCheckBox.TabIndex = 9;
|
||||
@ -118,7 +120,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
// watchdogBitNrTextBox
|
||||
//
|
||||
this.watchdogBitNrTextBox.Enabled = false;
|
||||
this.watchdogBitNrTextBox.Location = new System.Drawing.Point(138, 153);
|
||||
this.watchdogBitNrTextBox.Location = new System.Drawing.Point(138, 186);
|
||||
this.watchdogBitNrTextBox.Name = "watchdogBitNrTextBox";
|
||||
this.watchdogBitNrTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.watchdogBitNrTextBox.TabIndex = 11;
|
||||
@ -126,16 +128,36 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
// watchdogBitNrLabel
|
||||
//
|
||||
this.watchdogBitNrLabel.AutoSize = true;
|
||||
this.watchdogBitNrLabel.Location = new System.Drawing.Point(28, 156);
|
||||
this.watchdogBitNrLabel.Location = new System.Drawing.Point(28, 189);
|
||||
this.watchdogBitNrLabel.Name = "watchdogBitNrLabel";
|
||||
this.watchdogBitNrLabel.Size = new System.Drawing.Size(81, 13);
|
||||
this.watchdogBitNrLabel.TabIndex = 10;
|
||||
this.watchdogBitNrLabel.Text = "Watchdog bit #";
|
||||
//
|
||||
// variantComboBox
|
||||
//
|
||||
this.variantComboBox.Enabled = false;
|
||||
this.variantComboBox.FormattingEnabled = true;
|
||||
this.variantComboBox.Location = new System.Drawing.Point(138, 131);
|
||||
this.variantComboBox.Name = "variantComboBox";
|
||||
this.variantComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.variantComboBox.TabIndex = 8;
|
||||
//
|
||||
// variantLabel
|
||||
//
|
||||
this.variantLabel.AutoSize = true;
|
||||
this.variantLabel.Location = new System.Drawing.Point(28, 134);
|
||||
this.variantLabel.Name = "variantLabel";
|
||||
this.variantLabel.Size = new System.Drawing.Size(40, 13);
|
||||
this.variantLabel.TabIndex = 7;
|
||||
this.variantLabel.Text = "Variant";
|
||||
//
|
||||
// QuidoRSCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.variantComboBox);
|
||||
this.Controls.Add(this.variantLabel);
|
||||
this.Controls.Add(this.watchdogBitNrTextBox);
|
||||
this.Controls.Add(this.watchdogBitNrLabel);
|
||||
this.Controls.Add(this.watchdogCheckBox);
|
||||
@ -147,7 +169,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.componentNameLabel);
|
||||
this.Name = "QuidoRSCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Size = new System.Drawing.Size(374, 268);
|
||||
this.Load += new System.EventHandler(this.QuidoRSCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
@ -166,5 +188,7 @@ namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
private System.Windows.Forms.CheckBox watchdogCheckBox;
|
||||
private System.Windows.Forms.TextBox watchdogBitNrTextBox;
|
||||
private System.Windows.Forms.Label watchdogBitNrLabel;
|
||||
private System.Windows.Forms.ComboBox variantComboBox;
|
||||
private System.Windows.Forms.Label variantLabel;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
/// Copyright (c) 2015 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
|
||||
51
TBF/BenchControl/Modbus/QuidoRS/ShowBenchErrorOp.cs
Normal file
51
TBF/BenchControl/Modbus/QuidoRS/ShowBenchErrorOp.cs
Normal file
@ -0,0 +1,51 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
{
|
||||
public class ShowBenchErrorOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ShowBenchErrorOp));
|
||||
public override string ToString() { return string.Format("ShowBenchErrorOp(.)"); }
|
||||
|
||||
const ushort BenchReadyValue = 0x01;
|
||||
const ushort BenchErrorValue = 0x06;
|
||||
|
||||
/// Set by the constructor
|
||||
readonly QuidoRS quidoRS;
|
||||
|
||||
/// <summary>
|
||||
/// Events: Event.None
|
||||
/// </summary>
|
||||
/// <param name="quidoRS">Pressure meter reference</param>
|
||||
public ShowBenchErrorOp(QuidoRS quidoRS)
|
||||
{
|
||||
if (quidoRS == null) throw new ArgumentNullException("quidoRS");
|
||||
this.quidoRS = quidoRS;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
quidoRS.SetOutputs(BenchErrorValue);
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
public Event Run()
|
||||
{
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
quidoRS.SetOutputs(BenchReadyValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
TBF/BenchControl/Modbus/QuidoRS/ShowBenchWaitingOp.cs
Normal file
51
TBF/BenchControl/Modbus/QuidoRS/ShowBenchWaitingOp.cs
Normal file
@ -0,0 +1,51 @@
|
||||
///
|
||||
/// Copyright (c) 2019 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.Modbus.QuidoRS
|
||||
{
|
||||
public class ShowBenchWaitingOp : IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(ShowBenchWaitingOp));
|
||||
public override string ToString() { return string.Format("ShowBenchWaitingOp(.)"); }
|
||||
|
||||
const ushort BenchReadyValue = 0x01;
|
||||
const ushort BenchWaitingValue = 0x06;
|
||||
|
||||
/// Set by the constructor
|
||||
readonly QuidoRS quidoRS;
|
||||
|
||||
/// <summary>
|
||||
/// Events: Event.None
|
||||
/// </summary>
|
||||
/// <param name="quidoRS">Pressure meter reference</param>
|
||||
public ShowBenchWaitingOp(QuidoRS quidoRS)
|
||||
{
|
||||
if (quidoRS == null) throw new ArgumentNullException("quidoRS");
|
||||
this.quidoRS = quidoRS;
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
quidoRS.SetOutputs(BenchWaitingValue);
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
public Event Run()
|
||||
{
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
quidoRS.SetOutputs(BenchReadyValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1245,6 +1245,7 @@ namespace TBF.BenchControl.Sequences
|
||||
//--------------------------------
|
||||
State.Create("MainSeq : Procedure configuration error")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.BenchErrorOp)
|
||||
.AddOperation(new Operations.MessageBoxOp("Test configration error"))
|
||||
.EnterState();
|
||||
do
|
||||
@ -1259,6 +1260,7 @@ namespace TBF.BenchControl.Sequences
|
||||
//--------------------------------
|
||||
State.Create("MainSeq : ERROR -> Closing the valves")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.BenchErrorOp)
|
||||
.AddOperation(StateMachine.ControlBoard.SetValvesOp(StateMachine.DefaultValvesOpen,
|
||||
StateMachine.DefaultValvesClose))
|
||||
.EnterState();
|
||||
@ -1270,6 +1272,7 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
//--------------------------------
|
||||
State.Create("MainSeq : ERROR state")
|
||||
.AddOperation(StateMachine.BenchErrorOp)
|
||||
.EnterState();
|
||||
while (true) StateMachine.WaitRunDevsRunOps();
|
||||
}
|
||||
@ -1359,6 +1362,7 @@ namespace TBF.BenchControl.Sequences
|
||||
|
||||
State.Create("MainSeq : Select an activity")
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.BenchWaitingOp)
|
||||
.AddOperation((StateMachine.Tank1 is IScale) ? (StateMachine.Tank1 as IScale).ReadMassOp(ref mass1) : null)
|
||||
.AddOperation((StateMachine.Tank2 is IScale) ? (StateMachine.Tank2 as IScale).ReadMassOp(ref mass2) : null)
|
||||
.AddOperation((StateMachine.Tank3 is IScale) ? (StateMachine.Tank3 as IScale).ReadMassOp(ref mass3) : null)
|
||||
@ -1400,6 +1404,7 @@ namespace TBF.BenchControl.Sequences
|
||||
Bridge.OnActivity(this, Strings.Error);
|
||||
///------------------------------------
|
||||
State.Create("MainSeq : ERROR state")
|
||||
.AddOperation(StateMachine.BenchErrorOp)
|
||||
.EnterState();
|
||||
while (true) StateMachine.WaitRunDevsRunOps(); /// Endless loop
|
||||
}
|
||||
|
||||
@ -171,8 +171,6 @@ namespace TBF.BenchControl
|
||||
/// </summary>
|
||||
public State EnterState()
|
||||
{
|
||||
log.Debug(this.ToString());
|
||||
|
||||
StopAndStartOperations(State.currentState, this);
|
||||
State.currentState = this;
|
||||
UiBridge.Bridge.OnStateChanged(this, State.currentState.ToString());
|
||||
@ -236,7 +234,7 @@ namespace TBF.BenchControl
|
||||
}
|
||||
}
|
||||
|
||||
log.WarnFormat("---------------( {0} )---------------", newState.ToString());
|
||||
log.WarnFormat("---------------( {0} )---------------", newState);
|
||||
|
||||
/// Start() the operations that are in the current (new) state, but aren't in the previous state.
|
||||
foreach (IOperation operation in newState.Operations)
|
||||
|
||||
@ -45,7 +45,9 @@ namespace TBF.BenchControl
|
||||
/// Public components
|
||||
public static Elde.ControlBoardDev ControlBoard;
|
||||
public static GenericDevices.IAmbient Ambient;
|
||||
public static GenericDevices.IScaleOrTank Tank1;
|
||||
public static IOperation BenchWaitingOp;
|
||||
public static IOperation BenchErrorOp;
|
||||
public static GenericDevices.IScaleOrTank Tank1;
|
||||
public static GenericDevices.IScaleOrTank Tank2;
|
||||
public static GenericDevices.IScaleOrTank Tank3;
|
||||
public static GenericDevices.IValve DrainValve1;
|
||||
@ -241,6 +243,13 @@ namespace TBF.BenchControl
|
||||
if (cmpnt is IWaterMeter) SequenceBase.WaterMeters.Add(cmpnt as IWaterMeter);
|
||||
if (cmpnt is ICamera) SequenceBase.Cameras.Add(cmpnt as ICamera);
|
||||
if (cmpnt is GenericDevices.IAmbient) Ambient = cmpnt as GenericDevices.IAmbient;
|
||||
|
||||
if (cmpnt is GenericDevices.IParallelOutput && cmpnt.Name.ToLower().Contains("tower"))
|
||||
{
|
||||
BenchWaitingOp = (cmpnt as GenericDevices.IParallelOutput).ShowBenchWaitingOp();
|
||||
BenchErrorOp = (cmpnt as GenericDevices.IParallelOutput).ShowBenchErrorOp();
|
||||
}
|
||||
|
||||
if (cmpnt is IScaleOrTank)
|
||||
{
|
||||
IScaleOrTank tank = cmpnt as IScaleOrTank;
|
||||
|
||||
@ -67,6 +67,7 @@ namespace TBF.BenchControl.TestMethods.ChangeFlowDirection
|
||||
Bridge.OnActivity(this, test.Method);
|
||||
State.Create(string.Format("{0}({1}) : Turn the direction of watermeters", test.Method, test.Name))
|
||||
.AddOperation(checkUiOp)
|
||||
.AddOperation(StateMachine.BenchWaitingOp)
|
||||
.AddOperation(new Operations.MessageBoxOp("Otočte iPerly prosím."))
|
||||
.EnterState();
|
||||
do
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.1144.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1144.0")]
|
||||
[assembly: AssemblyVersion("2.18.1147.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1147.0")]
|
||||
|
||||
@ -549,6 +549,7 @@
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Elde\ValveEx\ValveFactory.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\ICalibInfoCfg.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IParallelOutput.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IReceivesDataFromRadio.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IStartInfoReader.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IHart.cs" />
|
||||
@ -687,6 +688,8 @@
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Modbus\QuidoRS\Factory.cs" />
|
||||
<Compile Include="BenchControl\Modbus\QuidoRS\SetOutputsOp.cs" />
|
||||
<Compile Include="BenchControl\Modbus\QuidoRS\ShowBenchErrorOp.cs" />
|
||||
<Compile Include="BenchControl\Modbus\QuidoRS\ShowBenchWaitingOp.cs" />
|
||||
<Compile Include="BenchControl\Modbus\TankSelector\Factory.cs" />
|
||||
<Compile Include="BenchControl\Modbus\TankSelector\SelectTankOp.cs" />
|
||||
<Compile Include="BenchControl\Modbus\TankSelector\SetQuidoBitOp.cs" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user