OptoTelegram serial port data parsing, OptoData and RfidData logging, opto-measurement ready to be tested.
This commit is contained in:
parent
a6aa6739ad
commit
e302cb9335
1
TODO.txt
1
TODO.txt
@ -1,4 +1,5 @@
|
|||||||
iPerl:
|
iPerl:
|
||||||
|
- OptoTelegram parsing, odkial prat MeterType?
|
||||||
- STOP nefunguje pocas communikacie
|
- STOP nefunguje pocas communikacie
|
||||||
- na Process obrazovke posunut stupacku a rezervoar uplne doprava
|
- na Process obrazovke posunut stupacku a rezervoar uplne doprava
|
||||||
|
|
||||||
|
|||||||
@ -9,10 +9,12 @@ using TBF.BenchControl;
|
|||||||
|
|
||||||
namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
||||||
{
|
{
|
||||||
public class TestMethod : ComponentBase, GenericDevices.ITestMethod
|
public class TestMethod : ComponentBase, GenericDevices.ITestMethod, Generic.IDevice
|
||||||
{
|
{
|
||||||
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
|
private static readonly ILog log = LogManager.GetLogger(typeof(TestMethod));
|
||||||
public override string ToString() { return string.Format("TestMethods.Adjustment({0})", Cfg.ToString(1)); }
|
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||||
|
|
||||||
|
public override string ToString() { return string.Format("TestMethods.Adjustment({0})", Cfg.ToString(1)); }
|
||||||
|
|
||||||
readonly TestMethodCfg testMethodCfg;
|
readonly TestMethodCfg testMethodCfg;
|
||||||
|
|
||||||
@ -31,6 +33,16 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
log.Debug(this.ToString());
|
log.Debug(this.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
rfidDataLogger.Fatal("------------------------------------------------------------------------");
|
||||||
|
rfidDataLogger.Fatal("Program restarted");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RunDeviceBefore() { }
|
||||||
|
public void RunDeviceAfter() { }
|
||||||
|
public void StopDevice() { }
|
||||||
|
|
||||||
public IList<Event> Execute(Entities.Test test)
|
public IList<Event> Execute(Entities.Test test)
|
||||||
{
|
{
|
||||||
return (new iPerlCommunicationSeq()).Execute(test, testMethodCfg.TestParams);
|
return (new iPerlCommunicationSeq()).Execute(test, testMethodCfg.TestParams);
|
||||||
|
|||||||
@ -18,6 +18,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
public partial class iPerlCommunicationForm : Form, GenericDevices.IHasCompleted
|
public partial class iPerlCommunicationForm : Form, GenericDevices.IHasCompleted
|
||||||
{
|
{
|
||||||
private static readonly ILog log = LogManager.GetLogger(typeof(iPerlCommunicationForm));
|
private static readonly ILog log = LogManager.GetLogger(typeof(iPerlCommunicationForm));
|
||||||
|
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||||
|
|
||||||
#region DLL_Interface
|
#region DLL_Interface
|
||||||
|
|
||||||
@ -36,8 +37,20 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
[DllImport("libRfid.dll", EntryPoint = "writeRequestPort")]
|
[DllImport("libRfid.dll", EntryPoint = "writeRequestPort")]
|
||||||
static extern unsafe int writeRequestPort(MessageID messageId, int offset, int lenght, byte* ptr, int timeout_ms);
|
static extern unsafe int writeRequestPort(MessageID messageId, int offset, int lenght, byte* ptr, int timeout_ms);
|
||||||
|
|
||||||
|
static int currentPort;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper function with safe interface and unsafe body
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Value returned by openPort(...)</returns>
|
||||||
|
public static unsafe int OpenPort(int comPort)
|
||||||
|
{
|
||||||
|
currentPort = comPort;
|
||||||
|
return openPort(comPort);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Wrapper function with safe interface adn unsafe body
|
/// Wrapper function with safe interface and unsafe body
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Value returned by readRequestPort(...)</returns>
|
/// <returns>Value returned by readRequestPort(...)</returns>
|
||||||
public static unsafe int ReadRequestPort(MessageID messageID, int offset, int lenght, out byte[] buffer, int timeout)
|
public static unsafe int ReadRequestPort(MessageID messageID, int offset, int lenght, out byte[] buffer, int timeout)
|
||||||
@ -48,6 +61,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
fixed (byte* pBuf = buf)
|
fixed (byte* pBuf = buf)
|
||||||
{
|
{
|
||||||
retv = readRequestPort(messageID, offset, lenght, pBuf, timeout);
|
retv = readRequestPort(messageID, offset, lenght, pBuf, timeout);
|
||||||
|
rfidDataLogger.InfoFormat("Group={0}, Port={1}, ReadRequestPort({2}, {3}, {4}, ...) returned {5} {6}", currentGroup, currentPort, messageID, offset, lenght, retv, (retv != 0) ? "!" : "");
|
||||||
|
|
||||||
buffer = new byte[lenght];
|
buffer = new byte[lenght];
|
||||||
for (int i = 0; i < lenght; i++) buffer[i] = buf[i];
|
for (int i = 0; i < lenght; i++) buffer[i] = buf[i];
|
||||||
@ -66,7 +80,19 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
fixed (byte* pBuf = buffer)
|
fixed (byte* pBuf = buffer)
|
||||||
{
|
{
|
||||||
retv = writeRequestPort(messageID, offset, lenght, pBuf, timeout);
|
retv = writeRequestPort(messageID, offset, lenght, pBuf, timeout);
|
||||||
}
|
if (lenght == 1)
|
||||||
|
{
|
||||||
|
rfidDataLogger.InfoFormat("Group={0}, Port={1}, WriteRequestPort({3}, {4}, {5}, {6}) returned {2} {7}", currentGroup, currentPort, retv, messageID, offset, lenght, pBuf[0].ToString("X2"), (retv != 0) ? "!" : "");
|
||||||
|
}
|
||||||
|
else if (lenght == 2)
|
||||||
|
{
|
||||||
|
rfidDataLogger.InfoFormat("Group={0}, Port={1}, WriteRequestPort({3}, {4}, {5}, {6} {7}) returned {2} {8}", currentGroup, currentPort, retv, messageID, offset, lenght, pBuf[0].ToString("X2"), pBuf[1].ToString("X2"), (retv != 0) ? "!" : "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rfidDataLogger.InfoFormat("Group={0}, Port={1}, WriteRequestPort({3}, {4}, {5}, {6} {7} ...) returned {2} {8}", currentGroup, currentPort, retv, messageID, offset, lenght, pBuf[0].ToString("X2"), pBuf[1].ToString("X2"), (retv != 0) ? "!" : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,6 +413,10 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
{
|
{
|
||||||
int threadId = (threadData as Boxes.IntBox).Val;
|
int threadId = (threadData as Boxes.IntBox).Val;
|
||||||
|
|
||||||
|
rfidDataLogger.InfoFormat(""); /// Makes the log more readable when there is a lot of data
|
||||||
|
rfidDataLogger.WarnFormat("Activity = {0}", activity);
|
||||||
|
rfidDataLogger.InfoFormat(""); /// Makes the log more readable when there is a lot of data
|
||||||
|
|
||||||
for (int group = 1; group <= lastGroup; group++)
|
for (int group = 1; group <= lastGroup; group++)
|
||||||
{
|
{
|
||||||
while (currentGroup != group && !stopWorkerThreads[threadId]) Thread.Sleep(50);
|
while (currentGroup != group && !stopWorkerThreads[threadId]) Thread.Sleep(50);
|
||||||
@ -426,8 +456,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
else if (wm.Disabled) OnCommCompleted(null, new CommCompletedEventArgs(threadId, wmNr, "Watermeter is disabled"));
|
else if (wm.Disabled) OnCommCompleted(null, new CommCompletedEventArgs(threadId, wmNr, "Watermeter is disabled"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OnCommCompleted(null, new CommCompletedEventArgs(threadId, wmNr, "Cannot " + activity));
|
OnCommCompleted(null, new CommCompletedEventArgs(threadId, wmNr, activity + " failed !!!"));
|
||||||
wm.Disabled = true;
|
rfidDataLogger.ErrorFormat("Group={0}, Port={1}, {2} failed !!!", currentGroup, currentPort, activity);
|
||||||
|
wm.Disabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -464,7 +495,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
|
|
||||||
if (wm.Disabled) return false;
|
if (wm.Disabled) return false;
|
||||||
|
|
||||||
if (openPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
if (OpenPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
@ -519,7 +550,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Communication necessary
|
/// Communication necessary
|
||||||
if (openPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
if (OpenPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
@ -596,7 +627,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
{
|
{
|
||||||
if (wm.Disabled) return false;
|
if (wm.Disabled) return false;
|
||||||
|
|
||||||
if (openPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
if (OpenPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
@ -641,7 +672,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
{
|
{
|
||||||
if (wm.Disabled) return false;
|
if (wm.Disabled) return false;
|
||||||
|
|
||||||
if (openPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
if (OpenPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
@ -675,7 +706,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
{
|
{
|
||||||
if (wm.Disabled) return false;
|
if (wm.Disabled) return false;
|
||||||
|
|
||||||
if (openPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
if (OpenPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
@ -727,7 +758,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
{
|
{
|
||||||
if (wm.Disabled) return false;
|
if (wm.Disabled) return false;
|
||||||
|
|
||||||
if (openPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
if (OpenPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
@ -776,7 +807,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
|
|||||||
{
|
{
|
||||||
if (wm.Disabled) return false;
|
if (wm.Disabled) return false;
|
||||||
|
|
||||||
if (openPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
if (OpenPort(wm.RfidComPortNr) != 0) return false; /// Open RFID port
|
||||||
|
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,150 @@
|
|||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace TBF.BenchControl.WaterMeters.iPerl
|
||||||
|
{
|
||||||
|
public class OptoTelegram
|
||||||
|
{
|
||||||
|
public static readonly int Length = 42;
|
||||||
|
|
||||||
|
public double EMF;
|
||||||
|
public Int16 MagneticField;
|
||||||
|
public double Flow;
|
||||||
|
public double Volume;
|
||||||
|
public Int16 Impedance;
|
||||||
|
public UInt32 Timestamp;
|
||||||
|
public byte GG;
|
||||||
|
|
||||||
|
string sourceStr;
|
||||||
|
|
||||||
|
|
||||||
|
public OptoTelegram()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return sourceStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a configuration structure from a complete byte array
|
||||||
|
///
|
||||||
|
/// Telegram description:
|
||||||
|
///
|
||||||
|
/// AAAAAA[tab]BBBB[tab]CCCC[tab]DDDDDD[tab]EEEE[tab]FFFFFFFF[tab]GG[cr][lf] (42 bytes)
|
||||||
|
///
|
||||||
|
/// Data Comment Type Calculate to decimal
|
||||||
|
/// ----------------------------------------------------------------
|
||||||
|
/// AAAAAA EMF Int24 Value * 0.000000333
|
||||||
|
/// BBBB Magnetic field Int16 Value
|
||||||
|
/// CCCC Flow Int16 Value * 0.225 * Scalig factor
|
||||||
|
/// DDDDDD Volume Int24 Value / 16000 * Scaling factor
|
||||||
|
/// EEEE Impedance Int16 Value
|
||||||
|
/// FFFFFFFF Timestamp Uint32 Value / 8192
|
||||||
|
/// GG
|
||||||
|
/// ----------------------------------------------------------------
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// FFFFFE 51EA 0000 65324E 0087 F6319DFF 86
|
||||||
|
/// FFDD3A 51F9 0000 65324E 0088 F631A60B 45
|
||||||
|
/// ...
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">A complete byte array data</param>
|
||||||
|
/// <returns>ConfigStruct or null when byte array was not complete</returns>
|
||||||
|
public static OptoTelegram FromString(string telegram, MeterType meterType)
|
||||||
|
{
|
||||||
|
if ((telegram == null) || (telegram.Length < Length) ||
|
||||||
|
(telegram[6] != '\t') || (telegram[11] != '\t') ||
|
||||||
|
(telegram[16] != '\t') || (telegram[23] != '\t') ||
|
||||||
|
(telegram[28] != '\t') || (telegram[37] != '\t') ||
|
||||||
|
(telegram[40] != '\r') || (telegram[41] != '\n'))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
OptoTelegram opto = new OptoTelegram();
|
||||||
|
|
||||||
|
Int32 value;
|
||||||
|
if (Int32.TryParse(telegram.Substring(0, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out value))
|
||||||
|
{
|
||||||
|
Int32 svalue = (value >= 0x00800000) ? (value - 0x01000000) : value;
|
||||||
|
opto.EMF = 0.000000333 * (double)svalue;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
|
||||||
|
if (Int32.TryParse(telegram.Substring(7, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out value))
|
||||||
|
{
|
||||||
|
Int32 svalue = (value >= 0x00008000) ? (value - 0x00010000) : value;
|
||||||
|
opto.MagneticField = (Int16)svalue;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
|
||||||
|
double factor = ScalingFactor(meterType);
|
||||||
|
|
||||||
|
if (Int32.TryParse(telegram.Substring(12, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out value))
|
||||||
|
{
|
||||||
|
Int32 svalue = (value >= 0x00008000) ? (value - 0x00010000) : value;
|
||||||
|
opto.Flow = 0.225 * (double)svalue * factor;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
|
||||||
|
if (Int32.TryParse(telegram.Substring(17, 6), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out value))
|
||||||
|
{
|
||||||
|
Int32 svalue = (value >= 0x00800000) ? (value - 0x01000000) : value;
|
||||||
|
opto.Volume = (double)svalue / 16000.0 * factor;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
|
||||||
|
if (Int32.TryParse(telegram.Substring(24, 4), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out value))
|
||||||
|
{
|
||||||
|
Int32 svalue = (value >= 0x00008000) ? (value - 0x00010000) : value;
|
||||||
|
opto.Impedance = (Int16)svalue;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
|
||||||
|
UInt32 uvalue;
|
||||||
|
if (UInt32.TryParse(telegram.Substring(29, 8), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out uvalue))
|
||||||
|
{
|
||||||
|
opto.Timestamp = uvalue;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
|
||||||
|
if (UInt32.TryParse(telegram.Substring(38, 2), NumberStyles.HexNumber, CultureInfo.CurrentCulture, out uvalue))
|
||||||
|
{
|
||||||
|
opto.GG = (byte)uvalue;
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
|
||||||
|
opto.sourceStr = telegram.Substring(0, Length - 2);
|
||||||
|
|
||||||
|
return opto;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scaling factor:
|
||||||
|
/// 0, 1 (DN15, Coax) . . . . 1
|
||||||
|
/// 2 (DN20) . . . . . . . . 2
|
||||||
|
/// 3 (DN25) . . . . . . . . 4
|
||||||
|
/// 4, 5 (DN26, DN32) . . . . 8
|
||||||
|
/// 6 (DN40) . . . . . . . . 16
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="meterType">MeterType (0..6)</param>
|
||||||
|
/// <returns>Scaling factor</returns>
|
||||||
|
public static double ScalingFactor(MeterType meterType)
|
||||||
|
{
|
||||||
|
switch (meterType)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case MeterType.DN15:
|
||||||
|
case MeterType.CoaxManifold: return 1.0;
|
||||||
|
case MeterType.DN20: return 2.0;
|
||||||
|
case MeterType.DN25: return 4.0;
|
||||||
|
case MeterType.DN26:
|
||||||
|
case MeterType.DN32: return 8.0;
|
||||||
|
case MeterType.DN40: return 16.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,7 +18,8 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
public class WaterMeter : ComponentBase, IDevice, GenericDevices.IWaterMeter, GenericDevices.IRegisterReader, IOperation
|
public class WaterMeter : ComponentBase, IDevice, GenericDevices.IWaterMeter, GenericDevices.IRegisterReader, IOperation
|
||||||
{
|
{
|
||||||
private static readonly ILog log = LogManager.GetLogger(typeof(WaterMeter));
|
private static readonly ILog log = LogManager.GetLogger(typeof(WaterMeter));
|
||||||
public override string ToString() { return string.Format("iPerl({0})", Cfg.ToString(1)); }
|
protected static readonly ILog optoDataLogger = LogManager.GetLogger("OptoData");
|
||||||
|
public override string ToString() { return string.Format("iPerl({0})", Cfg.ToString(1)); }
|
||||||
|
|
||||||
readonly WaterMeterCfg iPerlCfg;
|
readonly WaterMeterCfg iPerlCfg;
|
||||||
|
|
||||||
@ -69,10 +70,30 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
bool disabled;
|
bool disabled;
|
||||||
|
|
||||||
/// <summary> ConfigStruct of the water meter obtained or updated by iPerlCommunication </summary>
|
/// <summary> ConfigStruct of the water meter obtained or updated by iPerlCommunication </summary>
|
||||||
public ConfigStruct ConfigStruct;
|
public ConfigStruct ConfigStruct
|
||||||
|
{
|
||||||
|
get { return configStruct; }
|
||||||
|
set { configStruct = value; }
|
||||||
|
}
|
||||||
|
ConfigStruct configStruct;
|
||||||
|
|
||||||
/// <summary> CalibrationStruct of the water meter obtained or updated by iPerlCommunication </summary>
|
/// <summary> CalibrationStruct of the water meter obtained or updated by iPerlCommunication </summary>
|
||||||
public CalibrationStruct CalibrationStruct;
|
public CalibrationStruct CalibrationStruct
|
||||||
|
{
|
||||||
|
get { return calibrationStruct; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
calibrationStruct = value;
|
||||||
|
switch (calibrationStruct.VolumeUnits)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case VolumeUnits.m3: volumeUnit = 1000.0; break; /// liter per m3
|
||||||
|
case VolumeUnits.US_gallon: volumeUnit = 3.785; break; /// liter per US gallon
|
||||||
|
case VolumeUnits.UK_gallon: volumeUnit = 4.54609; break; /// liter per UK gallon
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CalibrationStruct calibrationStruct;
|
||||||
|
|
||||||
|
|
||||||
public ushort CalibrationFactor { get { return CalibrationStruct.Calibration; } }
|
public ushort CalibrationFactor { get { return CalibrationStruct.Calibration; } }
|
||||||
@ -86,21 +107,37 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Boxes.IntBox pulses;
|
/// <summary>
|
||||||
Boxes.IntBox refPulses;
|
/// Volume of water in liter set by OptoTelegramRreceived(...)
|
||||||
|
/// </summary>
|
||||||
|
private double volumeLtr;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Volume of one water meter unit in liter. Set when reading the configuration.
|
||||||
|
/// </summary>
|
||||||
|
private double volumeUnit;
|
||||||
|
|
||||||
|
private Boxes.IntBox pulses;
|
||||||
|
private Boxes.IntBox refPulses;
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Opto serial port and worker thread related private variables
|
/// Opto serial port and worker thread related private variables
|
||||||
///
|
///
|
||||||
private SerialPort optoSerialPort;
|
private SerialPort optoSerialPort;
|
||||||
private bool optoPortOpen;
|
|
||||||
|
#if USE_SEPARATE_WORKER_THREAD
|
||||||
private Thread workerThread;
|
private Thread workerThread;
|
||||||
private bool stopWorkerThread;
|
private bool stopWorkerThread;
|
||||||
|
#endif
|
||||||
|
|
||||||
public WaterMeter()
|
|
||||||
|
public WaterMeter()
|
||||||
{
|
{
|
||||||
|
synchronized = false;
|
||||||
|
synchronized2 = false;
|
||||||
|
partOfTelegram = string.Empty;
|
||||||
|
volumeUnit = 1000.0; /// liter / m3
|
||||||
}
|
}
|
||||||
|
|
||||||
public WaterMeter(WaterMeterCfg cfg)
|
public WaterMeter(WaterMeterCfg cfg)
|
||||||
@ -110,26 +147,38 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
log.Debug(this.ToString());
|
log.Debug(this.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool initOnceDone;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
if (DebugLevel == Entities.DebugMode.Normal)
|
if (DebugLevel == Entities.DebugMode.Normal)
|
||||||
{
|
{
|
||||||
|
if (!initOnceDone)
|
||||||
|
{
|
||||||
|
initOnceDone = true;
|
||||||
|
optoDataLogger.Fatal("------------------------------------------------------------------------");
|
||||||
|
optoDataLogger.Fatal("Program restarted");
|
||||||
|
}
|
||||||
|
|
||||||
optoSerialPort = new SerialPort(string.Format("COM{0}", iPerlCfg.OptoComPortNr),
|
optoSerialPort = new SerialPort(string.Format("COM{0}", iPerlCfg.OptoComPortNr),
|
||||||
9600, Parity.None, 8, StopBits.One);
|
9600, Parity.None, 8, StopBits.One);
|
||||||
optoSerialPort.Handshake = Handshake.None;
|
optoSerialPort.Handshake = Handshake.None;
|
||||||
optoSerialPort.Open();
|
optoSerialPort.Open();
|
||||||
optoPortOpen = true;
|
|
||||||
|
|
||||||
|
#if USE_SEPARATE_WORKER_THREAD
|
||||||
stopWorkerThread = false;
|
stopWorkerThread = false;
|
||||||
workerThread = new Thread(Worker);
|
workerThread = new Thread(Worker);
|
||||||
workerThread.Start();
|
workerThread.Start();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RunDeviceBefore()
|
public void RunDeviceBefore()
|
||||||
{
|
{
|
||||||
}
|
#if !USE_SEPARATE_WORKER_THREAD
|
||||||
|
ReadOptoSerialPort();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public void RunDeviceAfter()
|
public void RunDeviceAfter()
|
||||||
{
|
{
|
||||||
@ -139,12 +188,13 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
{
|
{
|
||||||
if (DebugLevel == Entities.DebugMode.Normal)
|
if (DebugLevel == Entities.DebugMode.Normal)
|
||||||
{
|
{
|
||||||
|
#if USE_SEPARATE_WORKER_THREAD
|
||||||
stopWorkerThread = true;
|
stopWorkerThread = true;
|
||||||
workerThread.Join(2000);
|
workerThread.Join(2000);
|
||||||
optoSerialPort.Close();
|
#endif
|
||||||
optoPortOpen = false;
|
optoSerialPort.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Events: Event.ReadRegisterDone, Event.Error
|
/// Events: Event.ReadRegisterDone, Event.Error
|
||||||
@ -205,33 +255,108 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
|
|
||||||
void ReadPulses()
|
void ReadPulses()
|
||||||
{
|
{
|
||||||
/// Do something meaningfull here
|
pulses.Val = (int)(volumeLtr / (double)PulsesPerLtr + 0.5);
|
||||||
pulses.Val = 1;
|
refPulses.Val = 2; /// Do something meaningfull here
|
||||||
refPulses.Val = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if USE_SEPARATE_WORKER_THREAD
|
||||||
void Worker()
|
void Worker()
|
||||||
{
|
{
|
||||||
while (!stopWorkerThread)
|
while (!stopWorkerThread)
|
||||||
{
|
{
|
||||||
Thread.Sleep(250);
|
Thread.Sleep(250);
|
||||||
if (stopWorkerThread) break;
|
if (stopWorkerThread) break;
|
||||||
int nrBytes = optoSerialPort.BytesToRead;
|
ReadOptoSerialPort();
|
||||||
if (nrBytes > 0)
|
|
||||||
{
|
|
||||||
char[] buffer = new char[nrBytes];
|
|
||||||
optoSerialPort.Read(buffer, 0, nrBytes);
|
|
||||||
string s = new string(buffer);
|
|
||||||
OnOptoReceived(this, new OptoReceivedEventArgs(s));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//OnOptoReceived(this, new OptoReceivedEventArgs("."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool synchronized;
|
||||||
|
bool synchronized2;
|
||||||
|
string partOfTelegram;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 9600 Bd, 8 data bits, 1 stop bit, no parity
|
||||||
|
///
|
||||||
|
/// Telegram description:
|
||||||
|
///
|
||||||
|
/// AAAAAA[tab]BBBB[tab]CCCC[tab]DDDDDD[tab]EEEE[tab]FFFFFFFF[tab]GG[cr][lf] (42 bytes)
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
/// FFFFFE 51EA 0000 65324E 0087 F6319DFF 86
|
||||||
|
/// FFDD3A 51F9 0000 65324E 0088 F631A60B 45
|
||||||
|
/// ...
|
||||||
|
/// </summary>
|
||||||
|
void ReadOptoSerialPort()
|
||||||
|
{
|
||||||
|
if (DebugLevel == Entities.DebugMode.Normal || DebugLevel == Entities.DebugMode.Record)
|
||||||
|
{
|
||||||
|
int nrBytes = optoSerialPort.BytesToRead;
|
||||||
|
if (nrBytes > 0)
|
||||||
|
{
|
||||||
|
char[] buffer = new char[nrBytes];
|
||||||
|
optoSerialPort.Read(buffer, 0, nrBytes);
|
||||||
|
string received = new string(buffer);
|
||||||
|
|
||||||
|
string allRcvd = partOfTelegram + received;
|
||||||
|
|
||||||
|
OptoTelegram opto;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
int pos = allRcvd.IndexOf("\r\n");
|
||||||
|
|
||||||
|
if (pos < 0)
|
||||||
|
{
|
||||||
|
/// No CR+LF found, wait for more characters in the next invocation
|
||||||
|
partOfTelegram = allRcvd;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// CR+LF found
|
||||||
|
else if (pos < OptoTelegram.Length - 2)
|
||||||
|
{
|
||||||
|
/// CR+LF found too early, truncate the beginning incl CR+LF and keep scanning in this loop
|
||||||
|
allRcvd = allRcvd.Substring(pos + 2);
|
||||||
|
if (synchronized)
|
||||||
|
{
|
||||||
|
optoDataLogger.ErrorFormat("{0}: Opto data syncronisation error", Name);
|
||||||
|
}
|
||||||
|
synchronized = true;
|
||||||
|
}
|
||||||
|
// CR+LF found and (pos >= OptoTelegram.Length - 2)
|
||||||
|
else if ((null != (opto = OptoTelegram.FromString(allRcvd.Substring(pos - OptoTelegram.Length + 2), iPerlCfg.MeterType))))
|
||||||
|
{
|
||||||
|
OptoTelegramRreceived(opto, synchronized2);
|
||||||
|
synchronized2 = synchronized;
|
||||||
|
allRcvd = allRcvd.Substring(pos + 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
optoDataLogger.ErrorFormat("{0}: Wrong format of opto data", Name);
|
||||||
|
allRcvd = allRcvd.Substring(pos + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//OnOptoReceived(this, new OptoReceivedEventArgs(s));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//OnOptoReceived(this, new OptoReceivedEventArgs("."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DebugLevel == Entities.DebugMode.Simulate)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (DebugLevel == Entities.DebugMode.Reply)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptoTelegramRreceived(OptoTelegram optoTelegram, bool async)
|
||||||
|
{
|
||||||
|
volumeLtr = optoTelegram.Volume * volumeUnit;
|
||||||
|
optoDataLogger.InfoFormat("{0}: {1}", Name, optoTelegram);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called from the state machine when a test is selected and UI needs to be updated.
|
/// Called from the state machine when a test is selected and UI needs to be updated.
|
||||||
|
|||||||
@ -19,6 +19,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
///
|
///
|
||||||
/// Serialized parameters
|
/// Serialized parameters
|
||||||
///
|
///
|
||||||
|
public MeterType MeterType;
|
||||||
public int OptoComPortNr;
|
public int OptoComPortNr;
|
||||||
public int RfidComPortNr;
|
public int RfidComPortNr;
|
||||||
public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort
|
public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort
|
||||||
|
|||||||
@ -35,6 +35,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
private void WaterMeterCfgCtrl_Load(object sender, EventArgs e)
|
private void WaterMeterCfgCtrl_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
nameLabel.Text = Strings.Name;
|
nameLabel.Text = Strings.Name;
|
||||||
|
for (byte i = 0; i < (byte)MeterType.Count; i++) meterTypeComboBox.Items.Add(((MeterType)i).ToString());
|
||||||
Redraw();
|
Redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||||
classNameLabel.Text = config.Factory.ClassName;
|
classNameLabel.Text = config.Factory.ClassName;
|
||||||
nameTextBox.Text = config.Name;
|
nameTextBox.Text = config.Name;
|
||||||
|
meterTypeComboBox.Text = config.MeterType.ToString();
|
||||||
optoPortNrTextBox.Text = config.OptoComPortNr.ToString();
|
optoPortNrTextBox.Text = config.OptoComPortNr.ToString();
|
||||||
rfidPortNrTextBox.Text = config.RfidComPortNr.ToString();
|
rfidPortNrTextBox.Text = config.RfidComPortNr.ToString();
|
||||||
groupTextBox.Text = config.Group.ToString();
|
groupTextBox.Text = config.Group.ToString();
|
||||||
@ -55,6 +57,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
public void Unlock()
|
public void Unlock()
|
||||||
{
|
{
|
||||||
nameTextBox.Enabled = true;
|
nameTextBox.Enabled = true;
|
||||||
|
meterTypeComboBox.Enabled = true;
|
||||||
optoPortNrTextBox.Enabled = true;
|
optoPortNrTextBox.Enabled = true;
|
||||||
rfidPortNrTextBox.Enabled = true;
|
rfidPortNrTextBox.Enabled = true;
|
||||||
groupTextBox.Enabled = true;
|
groupTextBox.Enabled = true;
|
||||||
@ -64,6 +67,12 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
{
|
{
|
||||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||||
|
|
||||||
|
if (!meterTypeComboBox.Items.Contains(meterTypeComboBox.Text))
|
||||||
|
{
|
||||||
|
flags |= CfgUpdateFlags.Error;
|
||||||
|
message += Environment.NewLine + "Meter type is not valid";
|
||||||
|
}
|
||||||
|
|
||||||
int dummy;
|
int dummy;
|
||||||
if (!int.TryParse(optoPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
if (!int.TryParse(optoPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||||
{
|
{
|
||||||
@ -91,6 +100,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||||
|
|
||||||
config.Name = nameTextBox.Text;
|
config.Name = nameTextBox.Text;
|
||||||
|
config.MeterType = (MeterType)meterTypeComboBox.SelectedIndex;
|
||||||
config.OptoComPortNr = int.Parse(optoPortNrTextBox.Text);
|
config.OptoComPortNr = int.Parse(optoPortNrTextBox.Text);
|
||||||
config.RfidComPortNr = int.Parse(rfidPortNrTextBox.Text);
|
config.RfidComPortNr = int.Parse(rfidPortNrTextBox.Text);
|
||||||
config.Group = int.Parse(groupTextBox.Text);
|
config.Group = int.Parse(groupTextBox.Text);
|
||||||
|
|||||||
@ -32,112 +32,134 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||||
this.nameLabel = new System.Windows.Forms.Label();
|
this.nameLabel = new System.Windows.Forms.Label();
|
||||||
this.classNameLabel = new System.Windows.Forms.Label();
|
this.classNameLabel = new System.Windows.Forms.Label();
|
||||||
this.optoPortNrTextBox = new System.Windows.Forms.TextBox();
|
this.optoPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||||
this.optoPortNrLabel = new System.Windows.Forms.Label();
|
this.optoPortNrLabel = new System.Windows.Forms.Label();
|
||||||
this.rfidPortNrTextBox = new System.Windows.Forms.TextBox();
|
this.rfidPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||||
this.rfidPortNrLabel = new System.Windows.Forms.Label();
|
this.rfidPortNrLabel = new System.Windows.Forms.Label();
|
||||||
this.groupTextBox = new System.Windows.Forms.TextBox();
|
this.groupTextBox = new System.Windows.Forms.TextBox();
|
||||||
this.groupLabel = new System.Windows.Forms.Label();
|
this.groupLabel = new System.Windows.Forms.Label();
|
||||||
this.SuspendLayout();
|
this.meterTypeLabel = new System.Windows.Forms.Label();
|
||||||
//
|
this.meterTypeComboBox = new System.Windows.Forms.ComboBox();
|
||||||
// nameTextBox
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
this.nameTextBox.Enabled = false;
|
// nameTextBox
|
||||||
this.nameTextBox.Location = new System.Drawing.Point(135, 55);
|
//
|
||||||
this.nameTextBox.Name = "nameTextBox";
|
this.nameTextBox.Enabled = false;
|
||||||
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
|
this.nameTextBox.Location = new System.Drawing.Point(135, 55);
|
||||||
this.nameTextBox.TabIndex = 5;
|
this.nameTextBox.Name = "nameTextBox";
|
||||||
//
|
this.nameTextBox.Size = new System.Drawing.Size(121, 20);
|
||||||
// nameLabel
|
this.nameTextBox.TabIndex = 5;
|
||||||
//
|
//
|
||||||
this.nameLabel.AutoSize = true;
|
// nameLabel
|
||||||
this.nameLabel.Location = new System.Drawing.Point(25, 58);
|
//
|
||||||
this.nameLabel.Name = "nameLabel";
|
this.nameLabel.AutoSize = true;
|
||||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
this.nameLabel.Location = new System.Drawing.Point(25, 58);
|
||||||
this.nameLabel.TabIndex = 4;
|
this.nameLabel.Name = "nameLabel";
|
||||||
this.nameLabel.Text = "Name";
|
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||||
//
|
this.nameLabel.TabIndex = 4;
|
||||||
// classNameLabel
|
this.nameLabel.Text = "Name";
|
||||||
//
|
//
|
||||||
this.classNameLabel.AutoSize = true;
|
// classNameLabel
|
||||||
this.classNameLabel.Location = new System.Drawing.Point(132, 31);
|
//
|
||||||
this.classNameLabel.Name = "classNameLabel";
|
this.classNameLabel.AutoSize = true;
|
||||||
this.classNameLabel.Size = new System.Drawing.Size(60, 13);
|
this.classNameLabel.Location = new System.Drawing.Point(132, 31);
|
||||||
this.classNameLabel.TabIndex = 3;
|
this.classNameLabel.Name = "classNameLabel";
|
||||||
this.classNameLabel.Text = "ClassName";
|
this.classNameLabel.Size = new System.Drawing.Size(60, 13);
|
||||||
//
|
this.classNameLabel.TabIndex = 3;
|
||||||
// optoPortNrTextBox
|
this.classNameLabel.Text = "ClassName";
|
||||||
//
|
//
|
||||||
this.optoPortNrTextBox.Enabled = false;
|
// optoPortNrTextBox
|
||||||
this.optoPortNrTextBox.Location = new System.Drawing.Point(135, 79);
|
//
|
||||||
this.optoPortNrTextBox.Name = "optoPortNrTextBox";
|
this.optoPortNrTextBox.Enabled = false;
|
||||||
this.optoPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
this.optoPortNrTextBox.Location = new System.Drawing.Point(135, 104);
|
||||||
this.optoPortNrTextBox.TabIndex = 7;
|
this.optoPortNrTextBox.Name = "optoPortNrTextBox";
|
||||||
//
|
this.optoPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||||
// optoPortNrLabel
|
this.optoPortNrTextBox.TabIndex = 7;
|
||||||
//
|
//
|
||||||
this.optoPortNrLabel.AutoSize = true;
|
// optoPortNrLabel
|
||||||
this.optoPortNrLabel.Location = new System.Drawing.Point(25, 82);
|
//
|
||||||
this.optoPortNrLabel.Name = "optoPortNrLabel";
|
this.optoPortNrLabel.AutoSize = true;
|
||||||
this.optoPortNrLabel.Size = new System.Drawing.Size(101, 13);
|
this.optoPortNrLabel.Location = new System.Drawing.Point(25, 107);
|
||||||
this.optoPortNrLabel.TabIndex = 6;
|
this.optoPortNrLabel.Name = "optoPortNrLabel";
|
||||||
this.optoPortNrLabel.Text = "Opto Serial Port Nr.:";
|
this.optoPortNrLabel.Size = new System.Drawing.Size(101, 13);
|
||||||
//
|
this.optoPortNrLabel.TabIndex = 6;
|
||||||
// rfidPortNrTextBox
|
this.optoPortNrLabel.Text = "Opto Serial Port Nr.:";
|
||||||
//
|
//
|
||||||
this.rfidPortNrTextBox.Enabled = false;
|
// rfidPortNrTextBox
|
||||||
this.rfidPortNrTextBox.Location = new System.Drawing.Point(135, 103);
|
//
|
||||||
this.rfidPortNrTextBox.Name = "rfidPortNrTextBox";
|
this.rfidPortNrTextBox.Enabled = false;
|
||||||
this.rfidPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
this.rfidPortNrTextBox.Location = new System.Drawing.Point(135, 128);
|
||||||
this.rfidPortNrTextBox.TabIndex = 9;
|
this.rfidPortNrTextBox.Name = "rfidPortNrTextBox";
|
||||||
//
|
this.rfidPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||||
// rfidPortNrLabel
|
this.rfidPortNrTextBox.TabIndex = 9;
|
||||||
//
|
//
|
||||||
this.rfidPortNrLabel.AutoSize = true;
|
// rfidPortNrLabel
|
||||||
this.rfidPortNrLabel.Location = new System.Drawing.Point(25, 106);
|
//
|
||||||
this.rfidPortNrLabel.Name = "rfidPortNrLabel";
|
this.rfidPortNrLabel.AutoSize = true;
|
||||||
this.rfidPortNrLabel.Size = new System.Drawing.Size(103, 13);
|
this.rfidPortNrLabel.Location = new System.Drawing.Point(25, 131);
|
||||||
this.rfidPortNrLabel.TabIndex = 8;
|
this.rfidPortNrLabel.Name = "rfidPortNrLabel";
|
||||||
this.rfidPortNrLabel.Text = "RFID Serial Port Nr.:";
|
this.rfidPortNrLabel.Size = new System.Drawing.Size(103, 13);
|
||||||
//
|
this.rfidPortNrLabel.TabIndex = 8;
|
||||||
// groupTextBox
|
this.rfidPortNrLabel.Text = "RFID Serial Port Nr.:";
|
||||||
//
|
//
|
||||||
this.groupTextBox.Enabled = false;
|
// groupTextBox
|
||||||
this.groupTextBox.Location = new System.Drawing.Point(135, 127);
|
//
|
||||||
this.groupTextBox.Name = "groupTextBox";
|
this.groupTextBox.Enabled = false;
|
||||||
this.groupTextBox.Size = new System.Drawing.Size(34, 20);
|
this.groupTextBox.Location = new System.Drawing.Point(135, 152);
|
||||||
this.groupTextBox.TabIndex = 11;
|
this.groupTextBox.Name = "groupTextBox";
|
||||||
//
|
this.groupTextBox.Size = new System.Drawing.Size(34, 20);
|
||||||
// groupLabel
|
this.groupTextBox.TabIndex = 11;
|
||||||
//
|
//
|
||||||
this.groupLabel.AutoSize = true;
|
// groupLabel
|
||||||
this.groupLabel.Location = new System.Drawing.Point(25, 130);
|
//
|
||||||
this.groupLabel.Name = "groupLabel";
|
this.groupLabel.AutoSize = true;
|
||||||
this.groupLabel.Size = new System.Drawing.Size(39, 13);
|
this.groupLabel.Location = new System.Drawing.Point(25, 155);
|
||||||
this.groupLabel.TabIndex = 10;
|
this.groupLabel.Name = "groupLabel";
|
||||||
this.groupLabel.Text = "Group:";
|
this.groupLabel.Size = new System.Drawing.Size(39, 13);
|
||||||
//
|
this.groupLabel.TabIndex = 10;
|
||||||
// WaterMeterCfgCtrl
|
this.groupLabel.Text = "Group:";
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
// meterTypeLabel
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
//
|
||||||
this.Controls.Add(this.groupTextBox);
|
this.meterTypeLabel.AutoSize = true;
|
||||||
this.Controls.Add(this.groupLabel);
|
this.meterTypeLabel.Location = new System.Drawing.Point(25, 82);
|
||||||
this.Controls.Add(this.rfidPortNrTextBox);
|
this.meterTypeLabel.Name = "meterTypeLabel";
|
||||||
this.Controls.Add(this.rfidPortNrLabel);
|
this.meterTypeLabel.Size = new System.Drawing.Size(57, 13);
|
||||||
this.Controls.Add(this.optoPortNrTextBox);
|
this.meterTypeLabel.TabIndex = 12;
|
||||||
this.Controls.Add(this.optoPortNrLabel);
|
this.meterTypeLabel.Text = "Meter type";
|
||||||
this.Controls.Add(this.nameTextBox);
|
//
|
||||||
this.Controls.Add(this.nameLabel);
|
// meterTypeComboBox
|
||||||
this.Controls.Add(this.classNameLabel);
|
//
|
||||||
this.Name = "WaterMeterCfgCtrl";
|
this.meterTypeComboBox.Enabled = false;
|
||||||
this.Size = new System.Drawing.Size(300, 200);
|
this.meterTypeComboBox.FormattingEnabled = true;
|
||||||
this.Load += new System.EventHandler(this.WaterMeterCfgCtrl_Load);
|
this.meterTypeComboBox.Location = new System.Drawing.Point(135, 79);
|
||||||
this.ResumeLayout(false);
|
this.meterTypeComboBox.Name = "meterTypeComboBox";
|
||||||
this.PerformLayout();
|
this.meterTypeComboBox.Size = new System.Drawing.Size(121, 21);
|
||||||
|
this.meterTypeComboBox.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// WaterMeterCfgCtrl
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.meterTypeComboBox);
|
||||||
|
this.Controls.Add(this.meterTypeLabel);
|
||||||
|
this.Controls.Add(this.groupTextBox);
|
||||||
|
this.Controls.Add(this.groupLabel);
|
||||||
|
this.Controls.Add(this.rfidPortNrTextBox);
|
||||||
|
this.Controls.Add(this.rfidPortNrLabel);
|
||||||
|
this.Controls.Add(this.optoPortNrTextBox);
|
||||||
|
this.Controls.Add(this.optoPortNrLabel);
|
||||||
|
this.Controls.Add(this.nameTextBox);
|
||||||
|
this.Controls.Add(this.nameLabel);
|
||||||
|
this.Controls.Add(this.classNameLabel);
|
||||||
|
this.Name = "WaterMeterCfgCtrl";
|
||||||
|
this.Size = new System.Drawing.Size(300, 200);
|
||||||
|
this.Load += new System.EventHandler(this.WaterMeterCfgCtrl_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,5 +174,7 @@ namespace TBF.BenchControl.WaterMeters.iPerl
|
|||||||
private System.Windows.Forms.Label rfidPortNrLabel;
|
private System.Windows.Forms.Label rfidPortNrLabel;
|
||||||
private System.Windows.Forms.TextBox groupTextBox;
|
private System.Windows.Forms.TextBox groupTextBox;
|
||||||
private System.Windows.Forms.Label groupLabel;
|
private System.Windows.Forms.Label groupLabel;
|
||||||
|
private System.Windows.Forms.Label meterTypeLabel;
|
||||||
|
private System.Windows.Forms.ComboBox meterTypeComboBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,24 +6,34 @@
|
|||||||
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
|
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
|
||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
<appender name="LogFile-UI" type="log4net.Appender.FileAppender">
|
|
||||||
<file value="C:\TBF\Logs\Log-UI.txt" />
|
<!-- Process data appenders -->
|
||||||
|
<appender name="OptoData" type="log4net.Appender.FileAppender">
|
||||||
|
<file value="C:\TBF\ProcessData\OptoData.log" />
|
||||||
<appendToFile value="true" />
|
<appendToFile value="true" />
|
||||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
<layout type="log4net.Layout.PatternLayout">
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
|
<conversionPattern value="%date %message%newline" />
|
||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
<appender name="LogFile-WT" type="log4net.Appender.FileAppender">
|
<appender name="RfidData" type="log4net.Appender.FileAppender">
|
||||||
<file value="C:\TBF\Logs\Log-WT.txt" />
|
<file value="C:\TBF\ProcessData\RfidData.log" />
|
||||||
<appendToFile value="true" />
|
<appendToFile value="true" />
|
||||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
<layout type="log4net.Layout.PatternLayout">
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
|
<conversionPattern value="%date %message%newline" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<appender name="ProcessData" type="log4net.Appender.FileAppender">
|
||||||
|
<file value="C:\TBF\ProcessData\process-data.txt" />
|
||||||
|
<appendToFile value="true" />
|
||||||
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="%message%newline" />
|
||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
<appender name="AllResults" type="log4net.Appender.FileAppender">
|
<appender name="AllResults" type="log4net.Appender.FileAppender">
|
||||||
<file value="C:\TBF\Logs\AllResults.txt" />
|
<file value="C:\TBF\ProcessData\AllResults.txt" />
|
||||||
<appendToFile value="true" />
|
<appendToFile value="true" />
|
||||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
<layout type="log4net.Layout.PatternLayout">
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
@ -31,7 +41,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
<appender name="SummaryResults" type="log4net.Appender.FileAppender">
|
<appender name="SummaryResults" type="log4net.Appender.FileAppender">
|
||||||
<file value="C:\TBF\Logs\SummaryResults.txt" />
|
<file value="C:\TBF\Results\SummaryResults.txt" />
|
||||||
<appendToFile value="true" />
|
<appendToFile value="true" />
|
||||||
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
<layout type="log4net.Layout.PatternLayout">
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
@ -39,20 +49,40 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<!-- Program log appenders -->
|
||||||
|
<appender name="LogFile-UI" type="log4net.Appender.FileAppender">
|
||||||
|
<file value="C:\TBF\Logs\Log-UI.txt" />
|
||||||
|
<appendToFile value="true" />
|
||||||
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="%date %-5level %logger - %message%newline" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
<appender name="LogFile-WT" type="log4net.Appender.FileAppender">
|
||||||
|
<file value="C:\TBF\Logs\Log-WT.txt" />
|
||||||
|
<appendToFile value="true" />
|
||||||
|
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
|
||||||
|
<layout type="log4net.Layout.PatternLayout">
|
||||||
|
<conversionPattern value="%date %-5level %logger - %message%newline" />
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
<!-- Set root logger -->
|
<!-- Set root logger -->
|
||||||
<root>
|
<root>
|
||||||
<level value="INFO" />
|
<level value="INFO" />
|
||||||
<appender-ref ref="LogFile-UI" />
|
<appender-ref ref="LogFile-UI" />
|
||||||
</root>
|
</root>
|
||||||
<!-- Set loggers -->
|
|
||||||
<logger name="AllResults">
|
|
||||||
<level value="INFO" />
|
<!-- Set process loggers -->
|
||||||
<appender-ref ref="AllResults" />
|
<logger name="AllResults"><level value="INFO" /><appender-ref ref="AllResults" /></logger>
|
||||||
</logger>
|
<logger name="SummaryResults"> <level value="INFO" /><appender-ref ref="SummaryResults" /></logger>
|
||||||
<logger name="SummaryResults">
|
<logger name="ProcessData"><level value="INFO" /><appender-ref ref="ProcessData" /></logger>
|
||||||
<level value="INFO" />
|
<logger name="OptoData"><level value="INFO" /><appender-ref ref="OptoData" /></logger>
|
||||||
<appender-ref ref="SummaryResults" />
|
<logger name="RfidData"><level value="INFO" /><appender-ref ref="RfidData" /></logger>
|
||||||
</logger>
|
|
||||||
|
|
||||||
|
<!-- Set program loggers -->
|
||||||
<logger name="NHibernate"> <level value="ERROR" /> </logger>
|
<logger name="NHibernate"> <level value="ERROR" /> </logger>
|
||||||
<logger name="TBF.BenchControl">
|
<logger name="TBF.BenchControl">
|
||||||
<appender-ref ref="A1" />
|
<appender-ref ref="A1" />
|
||||||
@ -60,8 +90,16 @@
|
|||||||
</logger>
|
</logger>
|
||||||
<logger name="TBF.BenchControl.StateMachine"> <level value="INFO" /> </logger>
|
<logger name="TBF.BenchControl.StateMachine"> <level value="INFO" /> </logger>
|
||||||
<logger name="TBF.BenchControl.State"> <level value="WARN" /> </logger>
|
<logger name="TBF.BenchControl.State"> <level value="WARN" /> </logger>
|
||||||
<logger name="TBF.BenchControl.Elde.ControlBoardDev"> <level value="DEBUG" /> </logger>
|
<logger name="TBF.BenchControl.Elde.ControlBoardWrap"> <level value="DEBUG" /> </logger>
|
||||||
<logger name="TBF.BenchControl.MettlerToledo"> <level value="INFO" /> </logger>
|
<logger name="TBF.BenchControl.Elde.Pump"> <level value="DEBUG" /> </logger>
|
||||||
<logger name="TBF.BenchControl.IdcCamera"> <level value="INFO" /> </logger>
|
<logger name="TBF.BenchControl.Elde.PumpWithFM"> <level value="DEBUG" /> </logger>
|
||||||
|
|
||||||
|
<logger name="TBF.BenchControl.MettlerToledo"> <level value="INFO" /> </logger>
|
||||||
|
<logger name="TBF.BenchControl.MettlerToledo.BalanceDev"> <level value="WARN" /> </logger>
|
||||||
|
<logger name="TBF.BenchControl.MettlerToledo.BalanceNewDev"> <level value="WARN" /> </logger>
|
||||||
|
<logger name="TBF.BenchControl.MettlerToledo.ReadMassOp"> <level value="INFO" /> </logger>
|
||||||
|
<logger name="TBF.BenchControl.MettlerToledo.ReadStableMassOp"> <level value="INFO" /> </logger>
|
||||||
|
|
||||||
|
<logger name="TBF.BenchControl.IdcCamera"> <level value="INFO" /> </logger>
|
||||||
|
<logger name="TBF.BenchControl.Elde.StartMeasurementOp"> <level value="DEBUG" /> </logger>
|
||||||
</log4net>
|
</log4net>
|
||||||
|
|||||||
@ -358,6 +358,7 @@
|
|||||||
<Compile Include="BenchControl\WaterMeters\iPerl\ConfigStruct.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\ConfigStruct.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\Enums.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\Enums.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\OptoReceivedEventArgs.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\OptoReceivedEventArgs.cs" />
|
||||||
|
<Compile Include="BenchControl\WaterMeters\iPerl\OptoTelegram.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\ProcParams.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\ProcParams.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\StatusStruct.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\StatusStruct.cs" />
|
||||||
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeter.cs" />
|
<Compile Include="BenchControl\WaterMeters\iPerl\WaterMeter.cs" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user