Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0385c0782 | ||
|
|
db43bdb652 | ||
|
|
6bdc10f4a7 | ||
|
|
6795793858 | ||
|
|
a2c564d789 | ||
|
|
3bc9e731e8 | ||
|
|
95c5f09238 | ||
|
|
0a45d66c0b | ||
|
|
96408eaef3 | ||
|
|
4395516216 | ||
|
|
9281b52464 |
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="JetBrains.Annotations" Version="2023.3.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.10.4" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.10.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NfcC7_DLL\NfcC7_DLL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using NfcC7_DLL.NfcHanler;
|
||||
using NfcC7_DLL.NfcHanler.Protocols;
|
||||
using NfcC7_DLL.NfcHanler.Utils;
|
||||
|
||||
namespace NfcC7_DLL.Tests.NfcHanler;
|
||||
|
||||
[TestClass]
|
||||
[TestSubject(typeof(NFCHeadService))]
|
||||
public class NFCHeadServiceTest
|
||||
{
|
||||
|
||||
[TestMethod]
|
||||
public void SetTestingMode_Optohead_C7_ON_LiveMeterTest()
|
||||
{
|
||||
SerialPortData serialPortData = new SerialPortData(
|
||||
"COM5",
|
||||
"HatCliDemo.exe",
|
||||
74);
|
||||
|
||||
NFCHeadService service = new NFCHeadService(serialPortData);
|
||||
OptoHeadStatus status = service.SetTestingMode(OptoHeadStatus.OptoHeadC7);
|
||||
Assert.AreEqual(OptoHeadStatus.OptoHeadC7, status);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SetTestingMode_Optohead_OFF_LiveMeterTest()
|
||||
{
|
||||
SerialPortData serialPortData = new SerialPortData(
|
||||
"COM5",
|
||||
"HatCliDemo.exe",
|
||||
74);
|
||||
|
||||
NFCHeadService service = new NFCHeadService(serialPortData);
|
||||
OptoHeadStatus status = service.SetTestingMode(OptoHeadStatus.OptoHeadDisabled);
|
||||
Assert.AreEqual(OptoHeadStatus.OptoHeadDisabled, status);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SetTestingMode_LiveMeterTest()
|
||||
{
|
||||
SerialPortData serialPortData = new SerialPortData(
|
||||
"COM5",
|
||||
"HatCliDemo.exe",
|
||||
74);
|
||||
|
||||
NFCHeadService service = new NFCHeadService(serialPortData);
|
||||
OptoHeadStatus status = service.SetTestingMode(OptoHeadStatus.OptoHeadC2);
|
||||
Assert.AreEqual(OptoHeadStatus.OptoHeadC2, status);
|
||||
|
||||
status = service.SetTestingMode(OptoHeadStatus.OptoHeadC7);
|
||||
Assert.AreEqual(OptoHeadStatus.OptoHeadC7, status);
|
||||
|
||||
status = service.SetTestingMode(OptoHeadStatus.OptoHeadDisabled);
|
||||
Assert.AreEqual(OptoHeadStatus.OptoHeadDisabled, status);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetSerialNr_LiveMeterTest()
|
||||
{
|
||||
SerialPortData serialPortData = new SerialPortData(
|
||||
"COM5",
|
||||
"HatCliDemo.exe",
|
||||
74);
|
||||
|
||||
NFCHeadService service = new NFCHeadService(serialPortData);
|
||||
string? serialNr = service.GetSerialNr();
|
||||
Assert.IsFalse(string.IsNullOrEmpty(serialNr));
|
||||
Console.WriteLine("Found serial no: {0}",serialNr);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetTestingMode_LiveMeterTest()
|
||||
{
|
||||
SerialPortData serialPortData = new SerialPortData(
|
||||
"COM5",
|
||||
"HatCliDemo.exe",
|
||||
74);
|
||||
|
||||
NFCHeadService service = new NFCHeadService(serialPortData);
|
||||
OptoHeadStatus status = service.GetTestingMode();
|
||||
Assert.IsFalse(OptoHeadStatus.Unknown == status);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Helpers;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using NfcC7_DLL.NfcHanler;
|
||||
using NfcC7_DLL.NfcHanler.Protocols;
|
||||
using NfcC7_DLL.NfcHanler.Utils;
|
||||
|
||||
namespace NfcC7_DLL.Tests.NfcHanler;
|
||||
|
||||
[TestClass]
|
||||
[TestSubject(typeof(OptoHeadService))]
|
||||
public class OptoHeadServiceTest
|
||||
{
|
||||
|
||||
[TestMethod]
|
||||
public void RunLoop_Test()
|
||||
{
|
||||
//Switch meter to Optohead C7 testing mode
|
||||
SerialPortData serialPortData = new SerialPortData(
|
||||
"COM5",
|
||||
"HatCliDemo.exe",
|
||||
74);
|
||||
|
||||
NFCHeadService service = new NFCHeadService(serialPortData);
|
||||
OptoHeadStatus status = service.SetTestingMode(OptoHeadStatus.OptoHeadC7);
|
||||
Assert.AreEqual(OptoHeadStatus.OptoHeadC7, status);
|
||||
//Open serial connection to Optohead
|
||||
OptoHeadService.Con con = new OptoHeadService.Con();
|
||||
con.com = "COM6";
|
||||
OptoHeadService optoHeadService = new OptoHeadService(con);
|
||||
Assert.IsTrue(optoHeadService.CreateSerialConnection());
|
||||
//start loop to receive data
|
||||
optoHeadService.RunLoop();
|
||||
WaterMetrologyData lastData = null;
|
||||
int iCycles = 0, iCyclesMax = 10;
|
||||
for (int i = 0; i < iCyclesMax; i++)
|
||||
{
|
||||
|
||||
bool finished = false;
|
||||
while (!finished)
|
||||
{
|
||||
//optoHeadService.Run();
|
||||
if (optoHeadService.WaterMetrologyData != null
|
||||
&& lastData != optoHeadService.WaterMetrologyData
|
||||
&& optoHeadService.WaterMetrologyData.OptoHeadStatus != OptoHeadStatus.Unknown)
|
||||
{
|
||||
lastData = optoHeadService.WaterMetrologyData;
|
||||
finished = true;
|
||||
iCycles++;
|
||||
if (lastData.OptoHeadStatus.HasFlag(OptoHeadStatus.OptoHeadC7))
|
||||
{
|
||||
Assert.IsNotNull(lastData.C7Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsNotNull(lastData.C2Data);
|
||||
}
|
||||
System.Console.WriteLine("Cycle: {0} lastData: {1}", iCycles, lastData);
|
||||
}
|
||||
}
|
||||
}
|
||||
optoHeadService.CloseSerialConnection();
|
||||
|
||||
Assert.IsTrue(iCycles > 0);
|
||||
Assert.IsTrue(iCycles == iCyclesMax);
|
||||
|
||||
//Close Optohead
|
||||
status = service.SetTestingMode(OptoHeadStatus.OptoHeadDisabled);
|
||||
Assert.AreEqual(OptoHeadStatus.OptoHeadDisabled, status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.IO.Ports;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using NfcC7_DLL.NfcHanler.Utils;
|
||||
|
||||
namespace NfcC7_DLL.Tests.NfcHanler.Utils;
|
||||
|
||||
[TestClass]
|
||||
[TestSubject(typeof(SERIAL_Driver))]
|
||||
public class SERIAL_DriverTest
|
||||
{
|
||||
private class Con
|
||||
{
|
||||
public string com = "COM5";
|
||||
public int baudrate = 38400;
|
||||
public int dataBits = 8;
|
||||
public Parity parity = Parity.None;
|
||||
public StopBits stopbits = StopBits.Two;
|
||||
public int readTimeout = 5000;
|
||||
public int writeTimeout = 1000;
|
||||
}
|
||||
|
||||
private readonly byte[] Open =
|
||||
{ 107 ,128 ,1 ,16 ,0 ,48 ,0 ,71 ,108 ,111 ,98 ,97 ,108 ,73 ,80 ,101 ,114
|
||||
,108 ,85 ,116 ,105 ,108 ,105 ,116 ,121 ,0 ,0 ,39 ,215 };
|
||||
private readonly byte[] CommDeviceSessionEnd = { 0x6B, 0x61, 0x00, 0x10, 0x05, 0x31, 0x00, 0x1F, 0x29, 0xF9, 0xC5 };
|
||||
|
||||
private readonly byte[] ProductDetails =
|
||||
{ 107, 48, 1, 16, 3, 33, 1, 2, 107, 144, 0, 0, 17, 64, 5, 0, 2, 4, 96, 98, 66, 4, 165, 100 };
|
||||
|
||||
private readonly byte[] ProductDetails2 =
|
||||
{ 107, 48, 1, 16, 3, 33, 1, 2, 107, 144, 0, 0, 17, 64, 5, 0, 2, 4, 96 };
|
||||
|
||||
static Con con5 = new Con(){
|
||||
com = "COM5",
|
||||
baudrate = 38400,
|
||||
dataBits = 8,
|
||||
parity = Parity.None,
|
||||
stopbits = StopBits.Two,
|
||||
readTimeout = 5000,
|
||||
writeTimeout = 1000
|
||||
};
|
||||
static Con con6 = new Con()
|
||||
{
|
||||
com = "COM6",
|
||||
baudrate = 38400,
|
||||
dataBits = 8,
|
||||
parity = Parity.None,
|
||||
stopbits = StopBits.Two,
|
||||
readTimeout = 5000,
|
||||
writeTimeout = 1000
|
||||
};
|
||||
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessage_Test()
|
||||
{
|
||||
Con con = con6;
|
||||
|
||||
byte[] message = Open;
|
||||
byte[] bytesReceived;
|
||||
|
||||
SERIAL_Driver driver = new SERIAL_Driver();
|
||||
bool isopen = driver.OpenConnection(
|
||||
con.com,
|
||||
con.baudrate,
|
||||
con.dataBits,
|
||||
con.parity,
|
||||
con.stopbits,
|
||||
con.readTimeout,
|
||||
con.writeTimeout);
|
||||
Assert.IsTrue(isopen);
|
||||
driver.SendMessage(message, message.Length);
|
||||
//Assert.IsTrue(driver.GetRawData().Length == 0);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
string response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}",response);
|
||||
|
||||
message = CommDeviceSessionEnd;
|
||||
driver.SendMessage(message, message.Length);
|
||||
|
||||
driver.Close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessage_TestLoop()
|
||||
{
|
||||
Con con = con6;
|
||||
|
||||
byte[] message = {0x00};
|
||||
byte[] bytesReceived;
|
||||
|
||||
SERIAL_Driver driver = new SERIAL_Driver();
|
||||
bool isopen = driver.OpenConnection(
|
||||
con.com,
|
||||
con.baudrate,
|
||||
con.dataBits,
|
||||
con.parity,
|
||||
con.stopbits,
|
||||
con.readTimeout,
|
||||
con.writeTimeout);
|
||||
Assert.IsTrue(isopen);
|
||||
|
||||
for (int iStep = 0; iStep < 100; iStep++)
|
||||
{
|
||||
driver.SendMessage(message, message.Length);
|
||||
//Assert.IsTrue(driver.GetRawData().Length == 0);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
string response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}", response);
|
||||
}
|
||||
|
||||
//message = CommDeviceSessionEnd;
|
||||
//driver.SendMessage(message, message.Length);
|
||||
|
||||
driver.CloseConnection();
|
||||
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void SendMessage_TestGetSerialNo()
|
||||
{
|
||||
Con con = con6;
|
||||
byte[] message = Open;
|
||||
byte[] bytesReceived;
|
||||
|
||||
SERIAL_Driver driver = new SERIAL_Driver();
|
||||
bool isopen = driver.OpenConnection(
|
||||
con.com,
|
||||
con.baudrate,
|
||||
con.dataBits,
|
||||
con.parity,
|
||||
con.stopbits,
|
||||
con.readTimeout,
|
||||
con.writeTimeout);
|
||||
Assert.IsTrue(isopen);
|
||||
|
||||
driver.SendMessage(message, message.Length,con.readTimeout);
|
||||
//Assert.IsTrue(driver.GetRawData().Length == 0);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
if (bytesReceived[0] == 0xFF)
|
||||
Console.WriteLine("Error message: {0}", driver.ErrorMessage);
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
string response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}",response);
|
||||
|
||||
// --- Get Serial No ---
|
||||
message = ProductDetails;
|
||||
driver.SendMessage(message, message.Length,con.readTimeout);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
if (bytesReceived[0] == 0xFF)
|
||||
Console.WriteLine("Error message: {0}", driver.ErrorMessage);
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}",response);
|
||||
|
||||
// --- Get Serial No ---
|
||||
message = ProductDetails2;
|
||||
driver.SendMessage(message, message.Length,con.readTimeout);
|
||||
bytesReceived = driver.GetRawData();
|
||||
Assert.IsTrue(bytesReceived.Length > 0);
|
||||
if (bytesReceived[0] == 0xFF)
|
||||
Console.WriteLine("Error message: {0}", driver.ErrorMessage);
|
||||
// Display raw bytes (as hex or byte count)
|
||||
Console.WriteLine("IsOpened: {0}", driver.isOpen());
|
||||
Console.WriteLine(string.Format("Bytes received: {0}", bytesReceived.Length));
|
||||
Console.WriteLine(string.Format("Bytes (hex): {0}", BitConverter.ToString(bytesReceived)));
|
||||
response = System.Text.Encoding.UTF8.GetString(bytesReceived);
|
||||
Console.WriteLine("Bytes string: {0}",response);
|
||||
|
||||
|
||||
message = CommDeviceSessionEnd;
|
||||
driver.SendMessage(message, message.Length);
|
||||
|
||||
driver.Close();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,43 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<DefineConstants>TRACE;</DefineConstants>
|
||||
<DefineConstants>TRACE;IPERL;</DefineConstants>
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<DefineConstants>TRACE;IPERL;</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Include="System.IO.Ports" Version="10.0.0-rc.1.25451.107" />
|
||||
<PackageReference Include="System.Security.Cryptography.Cng" Version="5.0.0" />
|
||||
<PackageReference Include="System.Threading" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="NA2WNFC">
|
||||
<HintPath>NfcHanler\NfcReaderLibrary\NA2WNFC.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OBIDISC4NET">
|
||||
<HintPath>NfcHanler\NfcReaderLibrary\OBIDISC4NET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OBIDISC4NETnative">
|
||||
<HintPath>NfcHanler\NfcReaderLibrary\OBIDISC4NETnative.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OBIDISC4NET_API">
|
||||
<HintPath>NfcHanler\NfcReaderLibrary\OBIDISC4NET_API.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore">
|
||||
<HintPath>..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationFramework">
|
||||
<HintPath>..\..\..\..\..\Windows\Microsoft.NET\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Sensus">
|
||||
<HintPath>NfcHanler\FieldLogicLibrary\Sensus.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using NfcC7_DLL.NfcHanler.Protocols;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler;
|
||||
|
||||
public class HeadInfo
|
||||
{
|
||||
string SerialNr { get; set; }
|
||||
OptoHeadStatus OptoHeadStatus { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler
|
||||
{
|
||||
public class JsonDataFromPoseidon
|
||||
{
|
||||
public bool? NfcTagDetected { get; set; }
|
||||
public int? ProductType { get; set; }
|
||||
public string ProductTypeVersion { get; set; }
|
||||
public string DeviceId { get; set; }
|
||||
public string Reading { get; set; }
|
||||
public string Reading_Totalizer { get; set; }
|
||||
public string Reading_Digits { get; set; }
|
||||
public string Reading_Shift { get; set; }
|
||||
public string Reading_Resolution { get; set; }
|
||||
public string Reading_Units { get; set; }
|
||||
public string Reading_FlowDirection { get; set; }
|
||||
public string Reading_FlowRate { get; set; }
|
||||
public string CalibrationFactor { get; set; }
|
||||
public bool? ReadingComplete { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using NfcC7_DLL.NfcHanler.Protocols;
|
||||
using NfcC7_DLL.NfcHanler.Utils;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler;
|
||||
|
||||
public class NFCHeadService
|
||||
{
|
||||
|
||||
private bool activeHandlerSessioEnabled = false;
|
||||
private CliRunner _cliRunner;
|
||||
|
||||
private SerialPortData serialPort;
|
||||
|
||||
public NFCHeadService(SerialPortData serialPort)
|
||||
{
|
||||
this.serialPort = serialPort;
|
||||
ValidateCliFileExistence(true);
|
||||
}
|
||||
|
||||
private CliRunner CliRunner
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_cliRunner != null ?
|
||||
_cliRunner :
|
||||
(_cliRunner = new CliRunner(CliLogging)));
|
||||
}
|
||||
}
|
||||
|
||||
private bool CliLogging{get {return false; }}
|
||||
|
||||
private static readonly Regex OpticalDataModeRegex = new Regex(
|
||||
@"(?im)(?:" +
|
||||
@"^\s*OpticalDataMode\s*Id\s*:\s*([^\r\n]+)\s*$" + // old format
|
||||
@"|" +
|
||||
@"""OpticalDataMode""\s*:\s*""?(0x[0-9A-Fa-f]+|\d+)""?" + // JSON format (handles hex and decimal)
|
||||
@")",
|
||||
RegexOptions.Compiled);
|
||||
public bool TryGetOpticalDataMode(string result, out string s)
|
||||
{
|
||||
s = null;
|
||||
if (string.IsNullOrEmpty(result))
|
||||
return false;
|
||||
|
||||
var m = OpticalDataModeRegex.Match(result);
|
||||
if (!m.Success)
|
||||
return false;
|
||||
|
||||
// one of the groups will be filled
|
||||
s = !string.IsNullOrEmpty(m.Groups[1].Value)
|
||||
? m.Groups[1].Value.Trim()
|
||||
: m.Groups[2].Value.Trim();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static readonly Regex DeviceIdRegex = new Regex(
|
||||
@"(?im)(?:" +
|
||||
@"^\s*Device\s*Id\s*:\s*([^\r\n]+)\s*$" + // old format
|
||||
@"|" +
|
||||
@"""DeviceId""\s*:\s*""?([0-9]+)""?" + // JSON format
|
||||
@")",
|
||||
RegexOptions.Compiled);
|
||||
public bool TryGetDeviceId(string result, out string s)
|
||||
{
|
||||
s = null;
|
||||
if (string.IsNullOrEmpty(result))
|
||||
return false;
|
||||
|
||||
var m = DeviceIdRegex.Match(result);
|
||||
if (!m.Success)
|
||||
return false;
|
||||
|
||||
// one of the groups will be filled
|
||||
s = !string.IsNullOrEmpty(m.Groups[1].Value)
|
||||
? m.Groups[1].Value.Trim()
|
||||
: m.Groups[2].Value.Trim();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void ValidateCliFileExistence(bool showErrorIfMissing)
|
||||
{
|
||||
if (serialPort != null)
|
||||
{
|
||||
if (!serialPort.CliExists)
|
||||
{
|
||||
throw new Exception("CLI file " + serialPort.SerialPortCmdClientPath + " does not exist! Current path: " + Environment.CurrentDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ////////////
|
||||
/// </summary>
|
||||
public string? GetSerialNr()
|
||||
{
|
||||
if (serialPort == null)
|
||||
throw new Exception("Serial port not initialized");
|
||||
|
||||
|
||||
Task optoheadDeviceIdTask = CliRunner.AddSendAsync(serialPort, SerialPortData.EMeterArg.DeviceId);
|
||||
var timeOut = CliRunner.AddTimeOut(5000);
|
||||
var doneTask = CliRunner.WhenAny();
|
||||
if (timeOut == doneTask)
|
||||
{
|
||||
throw new Exception("Timeout");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (optoheadDeviceIdTask is Task<string>)
|
||||
{
|
||||
string serialNr;
|
||||
if (optoheadDeviceIdTask.Status == TaskStatus.Faulted)
|
||||
throw new Exception("Error TaskStatus.Faulted");
|
||||
string result = (optoheadDeviceIdTask as Task<string>).Result;
|
||||
if (TryGetDeviceId(result, out serialNr))
|
||||
{
|
||||
return serialNr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public OptoHeadStatus SetTestingMode(OptoHeadStatus status)
|
||||
{
|
||||
if (serialPort == null)
|
||||
throw new Exception("Serial port not initialized");
|
||||
|
||||
|
||||
Task optoheadMode = CliRunner.AddSendAsync(serialPort, SerialPortData.EMeterArg.Optohead, $"0x{((byte)status):X2}");
|
||||
var timeOut = CliRunner.AddTimeOut(5000);
|
||||
var doneTask = CliRunner.WhenAny();
|
||||
if (timeOut == doneTask)
|
||||
{
|
||||
throw new Exception("Timeout");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (optoheadMode is Task<string>)
|
||||
{
|
||||
string strOpticalDataMode;
|
||||
if (optoheadMode.Status == TaskStatus.Faulted)
|
||||
throw new Exception("Error TaskStatus.Faulted");
|
||||
string result = (optoheadMode as Task<string>).Result;
|
||||
if (TryGetOpticalDataMode(result, out strOpticalDataMode))
|
||||
{
|
||||
byte value;
|
||||
|
||||
if (strOpticalDataMode.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
|
||||
value = Convert.ToByte(strOpticalDataMode, 16); // interpret as hex
|
||||
else
|
||||
value = Convert.ToByte(strOpticalDataMode); // interpret as decimal
|
||||
|
||||
OptoHeadStatus optoheadStatus = (OptoHeadStatus)value;
|
||||
return optoheadStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OptoHeadStatus.Unknown;
|
||||
}
|
||||
|
||||
public OptoHeadStatus GetTestingMode()
|
||||
{
|
||||
if (serialPort == null)
|
||||
throw new Exception("Serial port not initialized");
|
||||
|
||||
|
||||
Task optoheadMode = CliRunner.AddSendAsync(serialPort, SerialPortData.EMeterArg.Optohead);
|
||||
var timeOut = CliRunner.AddTimeOut(5000);
|
||||
var doneTask = CliRunner.WhenAny();
|
||||
if (timeOut == doneTask)
|
||||
{
|
||||
throw new Exception("Timeout");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (optoheadMode is Task<string>)
|
||||
{
|
||||
string strOpticalDataMode;
|
||||
if (optoheadMode.Status == TaskStatus.Faulted)
|
||||
throw new Exception("Error TaskStatus.Faulted");
|
||||
string result = (optoheadMode as Task<string>).Result;
|
||||
if (TryGetOpticalDataMode(result, out strOpticalDataMode))
|
||||
{
|
||||
byte value;
|
||||
|
||||
if (strOpticalDataMode.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
|
||||
value = Convert.ToByte(strOpticalDataMode, 16); // interpret as hex
|
||||
else
|
||||
value = Convert.ToByte(strOpticalDataMode); // interpret as decimal
|
||||
|
||||
OptoHeadStatus optoheadStatus = (OptoHeadStatus)value;
|
||||
return optoheadStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return OptoHeadStatus.Unknown;
|
||||
}
|
||||
|
||||
private void SendCommand()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private string RawDataAnswer()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using System.IO.Ports;
|
||||
using System.Windows.Documents;
|
||||
using NfcC7_DLL.NfcHanler.Protocols;
|
||||
using NfcC7_DLL.NfcHanler.Utils;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler;
|
||||
|
||||
public class OptoHeadService
|
||||
{
|
||||
|
||||
public class Con
|
||||
{
|
||||
public string com = "COM5";
|
||||
public int baudrate = 38400;
|
||||
public int dataBits = 8;
|
||||
public Parity parity = Parity.None;
|
||||
public StopBits stopbits = StopBits.Two;
|
||||
public int readTimeout = 5000;
|
||||
public int writeTimeout = 1000;
|
||||
}
|
||||
|
||||
private Con Connection { get; set; }
|
||||
private SERIAL_Driver driver;
|
||||
/// <summary>
|
||||
/// Filed After Run() is called.
|
||||
/// </summary>
|
||||
public WaterMetrologyData? WaterMetrologyData { get; private set; }
|
||||
|
||||
public OptoHeadService(Con con)
|
||||
{
|
||||
Connection = con;
|
||||
driver = new SERIAL_Driver();
|
||||
}
|
||||
|
||||
public bool CreateSerialConnection()
|
||||
{
|
||||
bool isopen = false;
|
||||
Con con = Connection;
|
||||
|
||||
byte[] message = {0x00};
|
||||
byte[] bytesReceived;
|
||||
|
||||
if (!driver.isOpen())
|
||||
{
|
||||
|
||||
isopen = driver.OpenConnection(
|
||||
con.com,
|
||||
con.baudrate,
|
||||
con.dataBits,
|
||||
con.parity,
|
||||
con.stopbits,
|
||||
con.readTimeout,
|
||||
con.writeTimeout);
|
||||
}
|
||||
|
||||
return isopen;
|
||||
}
|
||||
|
||||
public void CloseSerialConnection()
|
||||
{
|
||||
dissableRunLoop = true;
|
||||
driver.Close();
|
||||
}
|
||||
|
||||
public void RunLoop()
|
||||
{
|
||||
Task.Run(() => Run());
|
||||
}
|
||||
|
||||
|
||||
private bool dissableRunLoop = false;
|
||||
/// <summary>
|
||||
/// Run the service. Catch one communication to WaterMetrologyData field.
|
||||
/// </summary>
|
||||
public void Run()
|
||||
{
|
||||
while (!dissableRunLoop)
|
||||
{
|
||||
WaterMetrologyData = ParseData(RunReading());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
byte[] RunReading()
|
||||
{
|
||||
if (driver.isOpen())
|
||||
{
|
||||
driver.SendMessage(new byte[] {0x00}, 1);
|
||||
return driver.GetRawData();
|
||||
}
|
||||
else
|
||||
{
|
||||
dissableRunLoop = true;
|
||||
}
|
||||
|
||||
return [0xFF];
|
||||
}
|
||||
|
||||
public WaterMetrologyData? ParseData(byte[] data)
|
||||
{
|
||||
try
|
||||
{
|
||||
return WaterMetrologyData.Parse(data, DateTime.Now, "");
|
||||
}catch(Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace NfcC7_DLL.NfcHanler.Protocols;
|
||||
|
||||
public enum OptoHeadStatus : byte
|
||||
{
|
||||
Unknown = 0xFF,
|
||||
OptoHeadDisabled = 0x00,
|
||||
OptoHeadC2 = 0xC2,
|
||||
OptoHeadC7 = 0xC7,
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace NfcC7_DLL.NfcHanler.Protocols;
|
||||
|
||||
public class WaterMetrologyData
|
||||
{
|
||||
private OptoHeadStatus _optoHeadStatus;
|
||||
private WaterMetrologyDataC7 c7Data;
|
||||
private WaterMetrologyDataC2 c2Data;
|
||||
|
||||
public WaterMetrologyDataC7 C7Data { get => c7Data; }
|
||||
public WaterMetrologyDataC2 C2Data { get => c2Data; }
|
||||
public OptoHeadStatus OptoHeadStatus { get => _optoHeadStatus; }
|
||||
|
||||
public static WaterMetrologyData? Parse(byte[] data, DateTime dt, string dutinfo)
|
||||
{
|
||||
if (data.Length < 24)
|
||||
{
|
||||
throw new ArgumentException("Invalid data length for WaterMetrologyData C2.");
|
||||
}
|
||||
WaterMetrologyData waterMetrologyData = new WaterMetrologyData();
|
||||
waterMetrologyData._optoHeadStatus = OptoHeadStatus.Unknown;
|
||||
// Probably C2
|
||||
if(data.Length > 24 && data.Length < 48)
|
||||
{
|
||||
waterMetrologyData.c2Data = WaterMetrologyDataC2.Parse(data, dt, dutinfo);
|
||||
waterMetrologyData._optoHeadStatus = OptoHeadStatus.OptoHeadC2;
|
||||
}
|
||||
// Probably C7
|
||||
else if(data.Length >= 48)
|
||||
{
|
||||
waterMetrologyData.c7Data = WaterMetrologyDataC7.Parse(data, dt, dutinfo);
|
||||
waterMetrologyData._optoHeadStatus = OptoHeadStatus.OptoHeadC7;
|
||||
}
|
||||
|
||||
return waterMetrologyData;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Status: {_optoHeadStatus}, C7Data: {c7Data}, C2Data: {c2Data}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
namespace NfcC7_DLL.NfcHanler.Protocols
|
||||
{
|
||||
public class WaterMetrologyDataC2
|
||||
{
|
||||
public string DutInfo { get; set; }
|
||||
public DateTime Dt { get; set; }
|
||||
public int AdcSample { get; set; }
|
||||
public short LastField { get; set; }
|
||||
public short FlowRate { get; set; }
|
||||
public uint Accumulator { get; set; }
|
||||
public ushort FlipPeriod { get; set; }
|
||||
public ushort VinfStart { get; set; }
|
||||
public ushort VinfEnd { get; set; }
|
||||
public short ElectrodeDelta { get; set; }
|
||||
public ushort Impedance { get; set; }
|
||||
public byte FieldDriveTime { get; set; }
|
||||
public bool IsInLowFlow { get; set; }
|
||||
public bool IsInEmptyPipe { get; set; }
|
||||
public bool FastHPFC { get; set; }
|
||||
public bool FieldPolarity { get; set; }
|
||||
public bool ImpedancePolarity { get; set; }
|
||||
|
||||
public double CalcFlowmLps
|
||||
{
|
||||
get { return FlowRate / 4.0; } // FlowRate is in 1/4 mL/s
|
||||
}
|
||||
public double CalcFlowGPM
|
||||
{
|
||||
get { return CalcFlowmLps * 0.015850323141489; } // mL/s to gal/min conversion
|
||||
}
|
||||
public double CalcAccGal
|
||||
{
|
||||
get { return (Accumulator / 4.0) * 0.000264172; } // Accumulator is in 1/4 mL, convert to gallons
|
||||
}
|
||||
|
||||
public static WaterMetrologyDataC2 Parse(string base64Data, DateTime dt, string dutinfo)
|
||||
{
|
||||
byte[] data = Convert.FromBase64String(base64Data);
|
||||
return Parse(data, dt, dutinfo);
|
||||
}
|
||||
|
||||
public static WaterMetrologyDataC2 Parse(byte[] data, DateTime dt, string dutinfo)
|
||||
{
|
||||
if (data.Length < 24)
|
||||
{
|
||||
throw new ArgumentException("Invalid data length for WaterMetrologyData C2.");
|
||||
}
|
||||
|
||||
|
||||
WaterMetrologyDataC2 result = new WaterMetrologyDataC2();
|
||||
|
||||
result.DutInfo = dutinfo;
|
||||
result.Dt = dt;
|
||||
result.AdcSample = BitConverter.ToInt32(data, 0);
|
||||
result.LastField = BitConverter.ToInt16(data, 4);
|
||||
result.FlowRate = BitConverter.ToInt16(data, 6);
|
||||
result.Accumulator = BitConverter.ToUInt32(data, 8);
|
||||
result.FlipPeriod = BitConverter.ToUInt16(data, 12);
|
||||
result.VinfStart = BitConverter.ToUInt16(data, 14);
|
||||
result.VinfEnd = BitConverter.ToUInt16(data, 16);
|
||||
result.ElectrodeDelta = BitConverter.ToInt16(data, 18);
|
||||
result.Impedance = BitConverter.ToUInt16(data, 20);
|
||||
result.FieldDriveTime = data[22];
|
||||
|
||||
byte flags = data[23];
|
||||
result.IsInLowFlow = (flags & 0x01) != 0;
|
||||
result.IsInEmptyPipe = (flags & 0x02) != 0;
|
||||
result.FastHPFC = (flags & 0x04) != 0; // Fast High Pass Filter Constant in bit 2
|
||||
result.FieldPolarity = (flags & 0x08) != 0; // Field Polarity in bit 3
|
||||
result.ImpedancePolarity = (flags & 0x10) != 0; // Impedance Polarity in bit 4
|
||||
return result;
|
||||
}
|
||||
|
||||
//public override string ToString()
|
||||
//{
|
||||
// return $"ADC Sample: {AdcSample}, Last Field: {LastField}, Flow Rate: {FlowRate}, Accumulator: {Accumulator}, " +
|
||||
// $"Flip Period Ticks: {FlipPeriodTicks}, Vinf Start: {VinfStart}, Vinf End: {VinfEnd}, Electrode Delta: {ElectrodeDelta}, " +
|
||||
// $"Impedance: {Impedance}, Field Drive Time: {FieldDriveTime}, Is Low Flow: {IsInLowFlow}, Is Empty Pipe: {IsInEmptyPipe}, " +
|
||||
// $"Fast High Pass Filter: {FastHighPassFilterConstant}, Field Polarity: {FieldPolarity}, Impedance Polarity: {ImpedancePolarity}";
|
||||
//}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"DutInfo: {DutInfo}, Dt: {Dt}, ADC Sample: {AdcSample}, Last Field: {LastField}, Flow Rate: {FlowRate}, Accumulator: {Accumulator}, " +
|
||||
$"Flip Period: {FlipPeriod}, Vinf Start: {VinfStart}, Vinf End: {VinfEnd}, Electrode Delta: {ElectrodeDelta}, " +
|
||||
$"Impedance: {Impedance}, Field Drive Time: {FieldDriveTime}, Is Low Flow: {IsInLowFlow}, Is Empty Pipe: {IsInEmptyPipe}, " +
|
||||
$"Fast HPFC: {FastHPFC}, Field Polarity: {FieldPolarity}, Impedance Polarity: {ImpedancePolarity}, " +
|
||||
$"Calc Flow mL/s: {CalcFlowmLps:F2}, Calc Flow GPM: {CalcFlowGPM:F2}, Calc Acc Gal: {CalcAccGal:F2}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
namespace NfcC7_DLL.NfcHanler.Protocols
|
||||
{
|
||||
public class WaterMetrologyDataC7 : WaterMetrologyDataC2
|
||||
{
|
||||
// New fields for C7
|
||||
public int LastFieldmilliGauss { get; set; }
|
||||
public int ImpedanceI { get; set; } // In-phase impedance
|
||||
public int ImpedanceQ { get; set; } // Out-of-phase impedance
|
||||
public int NoiseMetric { get; set; }
|
||||
public short LearningLockout { get; set; }
|
||||
public short ReverseBuffer { get; set; }
|
||||
public int ConditionedAdc { get; set; }
|
||||
public uint Totalalizer { get; set; }
|
||||
|
||||
//public bool IsInLowFlow { get; set; }
|
||||
//public bool IsInEmptyPipe { get; set; }
|
||||
//public bool FastHPFC { get; set; }
|
||||
//public bool FieldPolarity { get; set; }
|
||||
//public bool ImpedancePolarity { get; set; }
|
||||
public bool MagTamperState { get; set; }
|
||||
public bool IsLearningActive { get; set; }
|
||||
public bool AdcShiftsUpdated { get; set; }
|
||||
|
||||
|
||||
public static WaterMetrologyDataC7 Parse(string base64Data, DateTime dt, string dutinfo)
|
||||
{
|
||||
byte[] data = Convert.FromBase64String(base64Data);
|
||||
return Parse(data, dt, dutinfo);
|
||||
}
|
||||
|
||||
public static WaterMetrologyDataC7 Parse(byte[] data, DateTime dt, string dutinfo)
|
||||
{
|
||||
|
||||
// You may want to check for the minimum length required for C7
|
||||
if (data.Length < 48) /* minimum required length for C7 */
|
||||
{
|
||||
throw new ArgumentException("Invalid data length for WaterMetrologyData C7.");
|
||||
}
|
||||
|
||||
var result = new WaterMetrologyDataC7();
|
||||
|
||||
// Parse base C2 fields
|
||||
var c2 = WaterMetrologyDataC2.Parse(data, dt, dutinfo);
|
||||
|
||||
//Copy base fields
|
||||
result.DutInfo = c2.DutInfo;
|
||||
result.Dt = c2.Dt;
|
||||
result.AdcSample = c2.AdcSample;
|
||||
result.LastField = c2.LastField;
|
||||
result.FlowRate = c2.FlowRate;
|
||||
result.Accumulator = c2.Accumulator;
|
||||
result.FlipPeriod = c2.FlipPeriod;
|
||||
result.VinfStart = c2.VinfStart;
|
||||
result.VinfEnd = c2.VinfEnd;
|
||||
result.ElectrodeDelta = c2.ElectrodeDelta;
|
||||
result.Impedance = c2.Impedance;
|
||||
result.FieldDriveTime = c2.FieldDriveTime;
|
||||
|
||||
|
||||
result.IsInLowFlow = c2.IsInLowFlow;
|
||||
result.IsInEmptyPipe = c2.IsInEmptyPipe;
|
||||
result.FieldPolarity = c2.FieldPolarity;
|
||||
result.ImpedancePolarity = c2.ImpedancePolarity;
|
||||
|
||||
|
||||
// Parse new C7 fields (replace ENUM_OptPack0xC7.FIELD_MILLI_GAUSS etc. with actual offsets)
|
||||
byte flags = data[23];
|
||||
result.MagTamperState = (flags & 0x60) != 0; // bits 5 and 6 represent MagTamperState
|
||||
result.IsLearningActive = (flags & 0x80) != 0; // bit 7 represents IsLearningActive
|
||||
|
||||
byte flagTwo = data[24];
|
||||
|
||||
result.AdcShiftsUpdated = (flagTwo & 0x01) != 0; // bit 0 represents AdcShiftsUpdated
|
||||
|
||||
result.LastFieldmilliGauss = BitConverter.ToInt32(data, 25);
|
||||
result.ImpedanceI = BitConverter.ToInt32(data, 29); // in phase
|
||||
result.ImpedanceQ = BitConverter.ToInt32(data, 33); // out of phase
|
||||
result.NoiseMetric = BitConverter.ToInt32(data, 37); //
|
||||
result.LearningLockout = BitConverter.ToInt16(data, 41);
|
||||
result.ReverseBuffer = BitConverter.ToInt16(data, 43);
|
||||
result.ConditionedAdc = BitConverter.ToInt32(data, 45);
|
||||
result.Totalalizer = BitConverter.ToUInt32(data, 49);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"C7: LastFieldmilliGauss={LastFieldmilliGauss}, ImpedanceI={ImpedanceI}, ImpedanceQ={ImpedanceQ}, NoiseMetric={NoiseMetric}, LearningLockout={LearningLockout}, ReverseBuffer={ReverseBuffer}, ConditionedAdc={ConditionedAdc}, Totalalizer={Totalalizer}, MagTamperState={MagTamperState}, IsLearningActive={IsLearningActive}, AdcShiftsUpdated={AdcShiftsUpdated}" + base.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
# Protocol Description
|
||||
@@ -0,0 +1,262 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class CliRunner
|
||||
{
|
||||
//static readonly Logger log = LogManager.GetLogger(typeof(CliRunner));
|
||||
//private readonly ILog log;
|
||||
private List<Task> taskPool = new List<Task>();
|
||||
private long startTime;
|
||||
|
||||
public List<Task> TaskPool { get { return taskPool; } }
|
||||
public void AddTask(Task task) { taskPool.Add(task); }
|
||||
public void WaitAll() { Task.WaitAll(taskPool.ToArray()); }
|
||||
|
||||
/// <summary>
|
||||
/// continue with WhenAny() to commpare results if time out is reached
|
||||
/// </summary>
|
||||
/// <param name="timeout"></param>
|
||||
/// <returns></returns>
|
||||
public Task AddTimeOut(int timeout)
|
||||
{
|
||||
Task timeOut = Task.Delay(timeout);
|
||||
taskPool.Add(timeOut);
|
||||
return timeOut;
|
||||
}
|
||||
/// <summary>
|
||||
/// mainly used for time out additional task to compare results
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task WhenAny() { return Task.WhenAny(taskPool.ToArray()); }
|
||||
|
||||
public void Clear() { taskPool.Clear(); }
|
||||
public void CancelAll() { Task.WhenAll(taskPool).ContinueWith(t => { }); }
|
||||
|
||||
|
||||
public void StartAll()
|
||||
{
|
||||
taskPool.ForEach(t => t.Start());
|
||||
}
|
||||
|
||||
public bool AreTasksDone()
|
||||
{
|
||||
return taskPool.All(task => task.IsCompleted);
|
||||
}
|
||||
|
||||
public long StartTime
|
||||
{
|
||||
get => startTime;
|
||||
}
|
||||
|
||||
public bool TimeOutReceived(long timeout)
|
||||
{
|
||||
return (DateTime.Now.Ticks - startTime) > timeout;
|
||||
}
|
||||
|
||||
public CliRunner(bool isCliLogging)
|
||||
{
|
||||
startTime = DateTime.Now.Ticks;
|
||||
|
||||
if (isCliLogging)
|
||||
{
|
||||
try
|
||||
{
|
||||
/*log = new ScopedLoggerFactory().CreateLogger<CliRunner>(
|
||||
@"C:\TBF\Logs\CliRunner.txt",
|
||||
10, // maxFileSizeMB
|
||||
7, // maxBackups
|
||||
log4net.Core.Level.Debug,
|
||||
true, // zipRolledFiles
|
||||
true, // singleZipPerDay
|
||||
TimeSpan.FromMinutes(2) // zipScanInterval
|
||||
);*/
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Fallback to console or handle gracefully
|
||||
Console.WriteLine($"Failed to initialize logger: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="args"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public Task AddSendAsync(SerialPortData data, SerialPortData.EMeterArg eMeterArg)
|
||||
{
|
||||
var task = SendAsync(data.SerialPortCmdClientPath, data.DefaultArgSettingsRead(eMeterArg));
|
||||
taskPool.Add(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
public Task AddSendAsync(SerialPortData data, SerialPortData.EMeterArg eMeterArg, string arg)
|
||||
{
|
||||
var task = SendAsync(data.SerialPortCmdClientPath, data.DefaultArgSettingsWrite(eMeterArg, arg));
|
||||
taskPool.Add(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
public void AddSendAsync(string fileName, string args)
|
||||
{
|
||||
var task = SendAsync(fileName, args);
|
||||
taskPool.Add(task);
|
||||
}
|
||||
|
||||
|
||||
public async Task<string> SendAsync(string fileName, string args, CancellationToken ct = default)
|
||||
{
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
Arguments = args,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
|
||||
using var process = new Process { StartInfo = psi, EnableRaisingEvents = true };
|
||||
process.Start();
|
||||
|
||||
Task<string> stdOutTask = process.StandardOutput.ReadToEndAsync();
|
||||
Task<string> stdErrTask = process.StandardError.ReadToEndAsync();
|
||||
|
||||
try
|
||||
{
|
||||
await Task.WhenAll(stdOutTask, stdErrTask, process.WaitForExitAsync(ct));
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
if (!process.HasExited)
|
||||
{
|
||||
process.Kill();
|
||||
}
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
string allOutput = (stdOutTask.Result ?? "") + (stdErrTask.Result ?? "");
|
||||
//log?.Debug(allOutput);
|
||||
return allOutput;
|
||||
}
|
||||
|
||||
public Task<T> AddRunAndCaptureJsonAsync<T>(SerialPortData data, SerialPortData.EMeterArg eMeterArg) where T : new()
|
||||
{
|
||||
var task = RunAndCaptureJsonAsync<T>(data.SerialPortCmdClientPath, data.DefaultArgSettingsRead(eMeterArg));
|
||||
taskPool.Add(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
public async Task<T> RunAndCaptureJsonAsync<T>(string fileName, string args, CancellationToken ct = default) where T : new()
|
||||
{
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
Arguments = args,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true
|
||||
};
|
||||
|
||||
using var process = new Process { StartInfo = psi, EnableRaisingEvents = true };
|
||||
process.Start();
|
||||
|
||||
var stdoutTask = process.StandardOutput.ReadToEndAsync();
|
||||
var stderrTask = process.StandardError.ReadToEndAsync();
|
||||
|
||||
await Task.WhenAll(stdoutTask, stderrTask, process.WaitForExitAsync(ct));
|
||||
|
||||
string allOutput = (stdoutTask.Result ?? "") + (stderrTask.Result ?? "");
|
||||
//log?.Debug(allOutput);
|
||||
|
||||
string json = ExtractJson(allOutput);
|
||||
if (TryJsonStringDeserialize(json, out T result)) return result;
|
||||
return default;
|
||||
}
|
||||
|
||||
public bool TryJsonStringDeserialize<T>(string json, out T runAndCaptureJsonAsync) where T : new()
|
||||
{
|
||||
if (json != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
runAndCaptureJsonAsync = JsonConvert.DeserializeObject<T>(json);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// log.Debug(ex.Message);
|
||||
runAndCaptureJsonAsync = TryConvert<T>(json);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
runAndCaptureJsonAsync = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private static T TryConvert<T>(string json) where T : new()
|
||||
{
|
||||
|
||||
T obj = new T();
|
||||
|
||||
try
|
||||
{
|
||||
JObject jObject = JObject.Parse(json);
|
||||
|
||||
foreach (PropertyInfo prop in typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance))
|
||||
{
|
||||
if (!prop.CanWrite) continue;
|
||||
|
||||
JToken token;
|
||||
if (jObject.TryGetValue(prop.Name, StringComparison.OrdinalIgnoreCase, out token))
|
||||
{
|
||||
try
|
||||
{
|
||||
object value = token.ToObject(prop.PropertyType);
|
||||
prop.SetValue(obj, value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// leave default if conversion fails
|
||||
}
|
||||
}
|
||||
// else → keep default value
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"TryConvert failed: {ex.Message}");
|
||||
}
|
||||
|
||||
return obj;
|
||||
|
||||
}
|
||||
|
||||
public string ExtractJson(string text)
|
||||
{
|
||||
int start = text.IndexOf('{');
|
||||
int end = text.LastIndexOf('}');
|
||||
|
||||
if (start >= 0 && end > start)
|
||||
{
|
||||
return text.Substring(start, end - start + 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO.Ports;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class SERIAL_Driver
|
||||
{
|
||||
public string ErrorMessage { get; private set; }
|
||||
public Collection<byte> SerialPortReadBuffer = new Collection<byte>();
|
||||
private SerialPort _serialPort;
|
||||
|
||||
private List<byte[]> _binMessages = new List<byte[]>();
|
||||
private bool _isReading;
|
||||
private Parity Parity { get; set; }
|
||||
private StopBits StopBits { get; set; }
|
||||
|
||||
public SERIAL_Driver()
|
||||
{
|
||||
_serialPort = new SerialPort();
|
||||
}
|
||||
|
||||
public bool OpenConnection(string comPort, int baudrate, int dataBits, Parity parity, StopBits stopbits, int readTimeout=1000, int writeTimeout = 1000)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
if ((_serialPort != null) && (_serialPort.IsOpen))
|
||||
{
|
||||
_serialPort.DataReceived -= DataReceivedHandler;
|
||||
_serialPort.Close();
|
||||
_serialPort.Dispose();
|
||||
_serialPort = null;
|
||||
}
|
||||
try
|
||||
{
|
||||
ErrorMessage = "";
|
||||
//_serialPort = new SerialPort(comPort, 57600, Parity.None, 8, StopBits.Two);
|
||||
_serialPort = new SerialPort(comPort, baudrate, parity, dataBits, stopbits);
|
||||
_serialPort.ReadTimeout = readTimeout;
|
||||
_serialPort.WriteTimeout = writeTimeout;
|
||||
_serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
|
||||
_serialPort.Open();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorMessage = String.Format("COM error: Open failed {0}.{1}", comPort, ex.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_serialPort.IsOpen)
|
||||
{
|
||||
ErrorMessage = String.Format("COM error: Can't Open {0}.", comPort);
|
||||
return false;
|
||||
}
|
||||
}//End Lock
|
||||
return true;
|
||||
}
|
||||
public bool SendMessage(byte[] sendDataBytes, int length, int readTimeout = 1000, int writeTimeout=1000)
|
||||
{
|
||||
if (!isOpen()) return false;
|
||||
if (sendDataBytes.Length == 0) return true; // nothing to send - no error
|
||||
try
|
||||
{
|
||||
PrepareReading(); //clear read buffer etc.
|
||||
_serialPort.WriteTimeout = writeTimeout;
|
||||
_serialPort.ReadTimeout = readTimeout;
|
||||
_serialPort.Write(sendDataBytes, 0, length);
|
||||
_isReading = true;
|
||||
Thread.Sleep(100);
|
||||
var stopWatch = Stopwatch.StartNew(); //start stop watch for data recevie timeout
|
||||
while (_isReading) //wait until reading finishes or timeout occur
|
||||
{
|
||||
if (stopWatch.ElapsedMilliseconds > readTimeout)
|
||||
{
|
||||
stopWatch.Stop();
|
||||
ErrorMessage = "COM error: Receive timeout";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ErrorMessage = String.Format("COM error: Transmit timeout {0}.{1}", _serialPort.PortName, ex.Message);
|
||||
return false; // Exception in send function
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void PrepareReading()
|
||||
{
|
||||
_serialPort.DiscardInBuffer();
|
||||
if(_binMessages != null) _binMessages.Clear();
|
||||
_isReading = true;
|
||||
}
|
||||
public byte[] GetRawData()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_binMessages.Count > 0)
|
||||
return _binMessages[0].ToArray();
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
byte[] err = { 0xFF };
|
||||
return err;
|
||||
}
|
||||
}
|
||||
private void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
|
||||
{
|
||||
if (!_serialPort.IsOpen) return;
|
||||
lock (this)
|
||||
{
|
||||
Thread.Sleep(100);
|
||||
if (!_serialPort.IsOpen) return;
|
||||
SerialPortReadBuffer = new Collection<byte>();
|
||||
while (_serialPort.BytesToRead > 0)
|
||||
{
|
||||
SerialPortReadBuffer.Add((byte)_serialPort.ReadByte());
|
||||
}
|
||||
|
||||
_binMessages.Add(SerialPortReadBuffer.ToArray());
|
||||
_isReading = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseConnection()
|
||||
{
|
||||
if ((_serialPort != null) && (_serialPort.IsOpen))
|
||||
{
|
||||
_serialPort.DataReceived -= DataReceivedHandler;
|
||||
_serialPort.Close();
|
||||
_serialPort.Dispose();
|
||||
_serialPort = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (isOpen())
|
||||
{
|
||||
_serialPort.Close();
|
||||
}
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
if (_serialPort != null)
|
||||
{
|
||||
_serialPort.Dispose();
|
||||
}
|
||||
}
|
||||
public bool isOpen()
|
||||
{
|
||||
if(_serialPort != null)
|
||||
return _serialPort.IsOpen;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class SerialPortData
|
||||
{
|
||||
private Boolean? _cliExists;
|
||||
public bool CliExists { get {
|
||||
if (_cliExists == null || !_cliExists.HasValue)
|
||||
{
|
||||
_cliExists = File.Exists(SerialPortCmdClientPath);
|
||||
}
|
||||
return _cliExists.Value;
|
||||
} }
|
||||
public string SerialPortCmdClientPath {
|
||||
get {
|
||||
#if DEBUG
|
||||
return Path.Combine("C:","TBF","Cli", CmdClientName);
|
||||
#else
|
||||
return Path.Combine("..","Cli", CmdClientName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
public string CmdClientName { get; set; } = "HalCli.exe";
|
||||
public string PortName { get; set; }
|
||||
public int MeterType { get; set; }
|
||||
|
||||
public enum EMeterArg {
|
||||
Calibration = 0,
|
||||
AllParams = 2,
|
||||
DeviceId = 3,
|
||||
Optohead = 4,
|
||||
}
|
||||
EMeterArg _eMeterArg = EMeterArg.AllParams;
|
||||
|
||||
public string DefaultArgSettingsRead(EMeterArg eMeterArg)
|
||||
{
|
||||
switch (eMeterArg)
|
||||
{
|
||||
case EMeterArg.AllParams:
|
||||
return $"-p {PortName} -m {MeterType} --operation readall";
|
||||
case EMeterArg.DeviceId:
|
||||
return $"-p {PortName} -m {MeterType} --operation read --parameter DeviceId";
|
||||
case EMeterArg.Optohead:
|
||||
return $"-p {PortName} -m {MeterType} --operation read --parameter \"OpticalDataMode\"";
|
||||
default:
|
||||
throw new Exception("Not implemented correct command!");
|
||||
}
|
||||
}
|
||||
|
||||
public string DefaultArgSettingsWrite(EMeterArg eMeterArg, string arg)
|
||||
{
|
||||
switch (eMeterArg)
|
||||
{
|
||||
case EMeterArg.Calibration:
|
||||
return $"-p {PortName} -m {MeterType} --operation write --parameter Calibration --value {arg}";
|
||||
case EMeterArg.Optohead:
|
||||
return $"-p {PortName} -m {MeterType} --operation write --parameter \"OpticalDataMode\" --value {arg}";
|
||||
default:
|
||||
throw new Exception("Not implemented correct command!");
|
||||
}
|
||||
}
|
||||
|
||||
public SerialPortData(
|
||||
string portName,
|
||||
string cmdClientName,
|
||||
int meterType)
|
||||
{
|
||||
PortName = portName;
|
||||
CmdClientName = cmdClientName;
|
||||
MeterType = meterType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
|
||||
//*****************************************************************************
|
||||
// Copyright 2020 Sensus GmbH Ludwigshafen. All rights reserved.
|
||||
// Author: Venkat, Rajeshwar
|
||||
//*****************************************************************************
|
||||
|
||||
namespace Sensus.Poseidon.NfcHandler
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public static class Tools
|
||||
{
|
||||
@@ -121,6 +121,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NfcS5_DLL", "..\NfcS5_DLL\N
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NfcC7_DLL", "NfcC7_DLL\NfcC7_DLL.csproj", "{53E75979-B530-4805-8FC9-B314F14A62BE}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NfcC7_DLL.Tests", "NfcC7_DLL.Tests\NfcC7_DLL.Tests.csproj", "{715605C5-568B-48D6-9C09-2DC5F2E81F66}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -553,6 +555,18 @@ Global
|
||||
{53E75979-B530-4805-8FC9-B314F14A62BE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{53E75979-B530-4805-8FC9-B314F14A62BE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{53E75979-B530-4805-8FC9-B314F14A62BE}.Release|x86.Build.0 = Release|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{715605C5-568B-48D6-9C09-2DC5F2E81F66}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
///
|
||||
/// Copyright (c) 2013-2018 Sensus Slovensko a.s.
|
||||
///
|
||||
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
|
||||
namespace TBF.Rig.Generic
|
||||
{
|
||||
public interface ITestParams
|
||||
public interface ITestParams : IParamsProvider
|
||||
{
|
||||
|
||||
public string Activity { get; set; } /// Communication activity
|
||||
public bool SimultWithPrevious { get; set; }
|
||||
public bool SimultWithNext { get; set; }
|
||||
|
||||
void UpdateFromDbEntity(ComponentTest dbEntity);
|
||||
void FromDbEntity(string componentName, Test test);
|
||||
ComponentTest ToDbEntity(string componentName, Test test);
|
||||
|
||||
+1
-5
@@ -1,12 +1,8 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2021 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR
|
||||
{
|
||||
public enum MessageID
|
||||
{
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR
|
||||
{
|
||||
public interface IArg
|
||||
{
|
||||
int Value { get; }
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.IO.Ports;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl
|
||||
{
|
||||
public interface ICombiHeadParams
|
||||
{
|
||||
///
|
||||
/// NFC S4.5 Combihead params
|
||||
///
|
||||
public int MciTimeoutMs { get; set; }
|
||||
public int BaudRate { get; set; }
|
||||
public int DataBits { get; set; }
|
||||
public Parity ParityBit { get; set; }
|
||||
public StopBits StopBits { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl
|
||||
{
|
||||
public interface ICommunicationTimeOuts
|
||||
{
|
||||
/// Communication timeout in ms (500 .. 5000)
|
||||
public int DelayBetweenRetries { get; set; } /// Delay between communication retries in ms (0 .. 5000)
|
||||
public int MaxCommRetries { get; set; } /// Max. number of retries (1 .. 10)
|
||||
public int WaitTimeAfterFailure { get; set; } /// Wait time after communication failure in ms
|
||||
public int PassThroughWaitTime { get; set; } /// Pass Through wait time for radio parameters in ms
|
||||
public int NrThreads { get; set; } /// Numbwr of parallel threads (1, 2 or 4)
|
||||
public int CommTimeout { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl
|
||||
{
|
||||
public interface ISerialPortData
|
||||
{
|
||||
|
||||
public Boolean? CliExists { get;}
|
||||
public string CmdClientName { get; set; }
|
||||
public string PortName { get; set; }
|
||||
public int MeterType { get; set; }
|
||||
public string SerialPortCmdClientPath { get; }
|
||||
public IArg MeterArg { get; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl
|
||||
{
|
||||
public interface ITestMethodCfg : IComponentCfg, ICommunicationTimeOuts, ICombiHeadParams, IWebService
|
||||
{
|
||||
|
||||
public abstract IComponentCfgCtrl GetControl(IList<Component> cmpntEntities);
|
||||
public abstract string ToString(int i);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl
|
||||
{
|
||||
public interface IWebService
|
||||
{
|
||||
public bool UseWebService { get; set; }
|
||||
public string BaseUrl { get; set; }
|
||||
public string RelativeUrl { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.IO.Ports;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl
|
||||
{
|
||||
public interface IiPerlTestMethodCfg : ITestMethodCfg
|
||||
{
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
|
||||
|
||||
|
||||
public int IperlCheckErrorsToStop { get; set; }
|
||||
|
||||
|
||||
|
||||
public int DfltQ2c_15_rl { get; set; }
|
||||
public int DfltQ2c_15_lr { get; set; }
|
||||
public int DfltQ2c_20_rl { get; set; }
|
||||
public int DfltQ2c_20_lr { get; set; }
|
||||
public int DfltQ2c_25_63_rl { get; set; }
|
||||
public int DfltQ2c_25_63_lr { get; set; }
|
||||
public int DfltQ2c_25_10_rl { get; set; }
|
||||
public int DfltQ2c_25_10_lr { get; set; }
|
||||
public int DfltQ2c_32_rl { get; set; }
|
||||
public int DfltQ2c_32_lr { get; set; }
|
||||
public int DfltQ2c_40_rl { get; set; }
|
||||
public int DfltQ2c_40_lr { get; set; }
|
||||
|
||||
public bool UseWebService { get; set; }
|
||||
public string BaseUrl { get; set; }
|
||||
public string RelativeUrl { get; set; }
|
||||
|
||||
/// <summary> Test parameters </summary>
|
||||
/// Remember to Ignore in XmlSerializer !!
|
||||
[XmlIgnore]
|
||||
public ITestParams TestParams { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Sensus.iPerl.RfidCom.Structures;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
|
||||
|
||||
namespace NfcC7_DLL.NfcHanler.Utils
|
||||
{
|
||||
public class SerialPortData : ISerialPortData
|
||||
{
|
||||
private Boolean? _cliExists;
|
||||
public bool? CliExists
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cliExists == null || !_cliExists.HasValue)
|
||||
{
|
||||
_cliExists = File.Exists(SerialPortCmdClientPath);
|
||||
}
|
||||
|
||||
return _cliExists.Value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string SerialPortCmdClientPath {
|
||||
get {
|
||||
#if DEBUG
|
||||
return Path.Combine("C:","TBF","Cli", CmdClientName);
|
||||
#else
|
||||
return Path.Combine("..","Cli", CmdClientName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
public string CmdClientName { get; set; } = "HalCli.exe";
|
||||
public string PortName { get; set; }
|
||||
public int MeterType { get; set; }
|
||||
|
||||
public class EMeterArg : IArg{
|
||||
public int Value { get; }
|
||||
public string Name { get; }
|
||||
|
||||
private EMeterArg(int value, string name)
|
||||
{
|
||||
Value = value;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public static readonly EMeterArg Calibration = new EMeterArg(0, "Calibration");
|
||||
public static readonly EMeterArg AllParams = new EMeterArg(2, "AllParams");
|
||||
public static readonly EMeterArg DeviceId = new EMeterArg(3, "DeviceId");
|
||||
public static readonly EMeterArg OptoHead = new EMeterArg(4, "OptoHead");
|
||||
|
||||
}
|
||||
|
||||
public IArg MeterArg { get{return _eMeterArg;} }
|
||||
|
||||
EMeterArg _eMeterArg = EMeterArg.AllParams;
|
||||
|
||||
private static readonly Dictionary<EMeterArg, string> _commandsRead = new Dictionary<EMeterArg, string>
|
||||
{
|
||||
{ EMeterArg.AllParams, "-p {0} -m {1} --operation readall" },
|
||||
{ EMeterArg.DeviceId, "-p {0} -m {1} --operation read --parameter DeviceId" },
|
||||
{ EMeterArg.OptoHead, "-p {0} -m {1} --operation read --parameter \"OpticalDataMode\"" }
|
||||
};
|
||||
|
||||
public string DefaultArgSettingsRead(IArg eMeterArg)
|
||||
{
|
||||
EMeterArg meterArg = eMeterArg as EMeterArg;
|
||||
if (meterArg != null && _commandsRead.TryGetValue(meterArg, out var cmd))
|
||||
return string.Format(cmd, PortName, MeterType);
|
||||
|
||||
throw new Exception("Not implemented correct command!");
|
||||
}
|
||||
|
||||
private static readonly Dictionary<EMeterArg, string> _commandsWrite = new Dictionary<EMeterArg, string>
|
||||
{
|
||||
{ EMeterArg.Calibration, "-p {0} -m {1} --operation write --parameter Calibration --value {2}" },
|
||||
{ EMeterArg.OptoHead, "-p {0} -m {1} --operation write --parameter \"OpticalDataMode\" --value {arg}" },
|
||||
|
||||
};
|
||||
|
||||
public string DefaultArgSettingsWrite(IArg eMeterArg, string arg)
|
||||
{
|
||||
EMeterArg meterArg = eMeterArg as EMeterArg;
|
||||
if (meterArg != null && _commandsRead.TryGetValue(meterArg, out var cmd))
|
||||
return string.Format(cmd, PortName, MeterType);
|
||||
|
||||
throw new Exception("Not implemented correct command!");
|
||||
}
|
||||
|
||||
public SerialPortData(
|
||||
string portName,
|
||||
string cmdClientName,
|
||||
int meterType)
|
||||
{
|
||||
PortName = portName;
|
||||
CmdClientName = cmdClientName;
|
||||
MeterType = meterType;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2020 Sensus Metering Systems
|
||||
///
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl.communication
|
||||
{
|
||||
public class CalibrationStruct
|
||||
{
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2018-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl.communication
|
||||
{
|
||||
public class CalibrationStructV4
|
||||
{
|
||||
@@ -0,0 +1,42 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2019 Sensus Metering Systems
|
||||
/// Author: Milan Hanajík
|
||||
///
|
||||
|
||||
using System;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl.communication
|
||||
{
|
||||
public class CommCompletedEventArgs : EventArgs
|
||||
{
|
||||
public int ThreadId;
|
||||
public int WMNr0; /// 0-based water meter position
|
||||
public IPerlReader Ihead;
|
||||
public Results.Entities.WaterMeter Wm;
|
||||
public string CommMessage;
|
||||
public CommErr CommErr;
|
||||
|
||||
public CommCompletedEventArgs(int threadId, int wmNr0, IPerlReader ihead, Results.Entities.WaterMeter wm, string commMessage, CommErr commErr)
|
||||
{
|
||||
this.ThreadId = threadId;
|
||||
this.WMNr0 = wmNr0;
|
||||
this.Ihead = ihead;
|
||||
this.Wm = wm;
|
||||
this.CommMessage = commMessage;
|
||||
this.CommErr = commErr;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Thread={0} WMNr0={1} IHead={2} WM={3} CommMsg={4} CommErr={5}",
|
||||
ThreadId,
|
||||
WMNr0,
|
||||
(Ihead != null) ? Ihead.Name : "null",
|
||||
Wm.WMPosition,
|
||||
(CommMessage != null) ? CommMessage : "null",
|
||||
CommErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2020 Sensus Metering Systems
|
||||
///
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl.communication
|
||||
{
|
||||
public class ConfigStruct
|
||||
{
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl.communication
|
||||
{
|
||||
public class IPerlCommunicationsTimeOut : ICommunicationTimeOuts
|
||||
{
|
||||
public int DelayBetweenRetries { get; set; }
|
||||
public int MaxCommRetries { get; set; }
|
||||
public int WaitTimeAfterFailure { get; set; }
|
||||
public int PassThroughWaitTime { get; set; }
|
||||
public int NrThreads { get; set; }
|
||||
public int CommTimeout { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using Sensus.iPerl.NfcHandler;
|
||||
using Sensus.iPerl.RfidCom.Exceptions;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
using static Sensus.iPerl.NfcHandler.MCI_Protocol;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl.communication
|
||||
{
|
||||
internal class NfcServices
|
||||
{
|
||||
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||
internal static int ReadRequest(ITestMethodCfg cfg, IntIPerlReader iperlHead, MCI_Protocol.StructName structName, int offset, int length, out byte[] buffer)
|
||||
{
|
||||
for (int i = 0; i < cfg.MaxCommRetries; i++)
|
||||
{
|
||||
|
||||
NfcDataHandler _nfcDataHandler = new NfcDataHandler();
|
||||
MessageEventHandlers(_nfcDataHandler);
|
||||
CR95HF_MessageEventHandlers(_nfcDataHandler._CR95HF_Reader);
|
||||
ST25DV_MessageEventHandlers(_nfcDataHandler._ST25DV_Device);
|
||||
MCI_MessageEventHandlers(_nfcDataHandler._MCI_Protocol);
|
||||
NFCHeadConfig_MessageEventHandlers(_nfcDataHandler._NFCHead_Config);
|
||||
try
|
||||
{
|
||||
rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} ReadRequest : {structName}, {offset}, {length}");
|
||||
OpenConnection(_nfcDataHandler, cfg, iperlHead);
|
||||
|
||||
buffer = MciRead(_nfcDataHandler, cfg, structName, (ushort)offset, length);
|
||||
_nfcDataHandler.RFProtocolOFF(); // turn off rf antenna due to possible interference
|
||||
|
||||
CloseComPort(_nfcDataHandler);
|
||||
|
||||
rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} ReadRequest : {structName}, {offset}, {length} ; Response= {ByteArrayToHexString(buffer)} ; Error: {_nfcDataHandler.LastErrorMessage}");
|
||||
|
||||
if (_nfcDataHandler.LastErrorCode != 0)
|
||||
{
|
||||
throw new RfidValidationException(_nfcDataHandler.LastErrorMessage);
|
||||
}
|
||||
|
||||
return Convert.ToInt32(_nfcDataHandler.LastErrorCode); //return 0;
|
||||
}
|
||||
catch (RfidValidationException)
|
||||
{
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} ReadRequest Error: {ex.Message}");
|
||||
buffer = new byte[length];
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
buffer = new byte[length];
|
||||
return 3;
|
||||
}
|
||||
|
||||
internal static int WriteRequest(ITestMethodCfg cfg, IntIPerlReader iperlHead, MCI_Protocol.StructName structName, int offset, int length, byte[] buffer)
|
||||
{
|
||||
NfcDataHandler _nfcDataHandler = new NfcDataHandler();
|
||||
MessageEventHandlers(_nfcDataHandler);
|
||||
CR95HF_MessageEventHandlers(_nfcDataHandler._CR95HF_Reader);
|
||||
ST25DV_MessageEventHandlers(_nfcDataHandler._ST25DV_Device);
|
||||
MCI_MessageEventHandlers(_nfcDataHandler._MCI_Protocol);
|
||||
NFCHeadConfig_MessageEventHandlers(_nfcDataHandler._NFCHead_Config);
|
||||
try
|
||||
{
|
||||
rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} WriteRequest : {structName}, {offset}, {length}, {ByteArrayToHexString(buffer)}");
|
||||
OpenConnection(_nfcDataHandler, cfg, iperlHead);
|
||||
|
||||
MciWrite(_nfcDataHandler, cfg, structName, (ushort)offset, length, buffer);
|
||||
_nfcDataHandler.RFProtocolOFF(); // turn off rf antenna due to possible interference
|
||||
|
||||
CloseComPort(_nfcDataHandler);
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} WriteRequest Error: {ex.Message}");
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
private static void OpenConnection(NfcDataHandler nfcDataHandler, ITestMethodCfg cfg, IntIPerlReader iperlHead)
|
||||
{
|
||||
string comPort = $"COM{iperlHead.RfidComPortNr}";
|
||||
int retryCount = 0 ;
|
||||
Open:
|
||||
nfcDataHandler.Close();
|
||||
Thread.Sleep(100);
|
||||
if (nfcDataHandler.OpenConnection(comPort, cfg.BaudRate, cfg.DataBits, cfg.ParityBit, cfg.StopBits))
|
||||
{
|
||||
rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} Port Open");
|
||||
|
||||
if (nfcDataHandler.ConnectReader())
|
||||
{
|
||||
rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} Reader connected");
|
||||
if (!nfcDataHandler.ConnectDevice())
|
||||
{
|
||||
rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} Error connect device.");
|
||||
for (int i = 0; i < cfg.MaxCommRetries; i++)
|
||||
{
|
||||
if (nfcDataHandler.Echo()) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retryCount++;
|
||||
rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} Error connect reader. Reconnect comport {retryCount}");
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
{
|
||||
nfcDataHandler.Close();
|
||||
iperlHead.ResetNfcInterface(); // reset NFC head via optoport - switch to RFID and back to NFC interface
|
||||
goto Open;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
rfidDataLogger.Error($"Open NFC COM{iperlHead.RfidComPortNr} Port Failed");
|
||||
}
|
||||
|
||||
private static void CloseComPort(NfcDataHandler nfcDataHandler)
|
||||
{
|
||||
nfcDataHandler.Close();
|
||||
}
|
||||
|
||||
private static byte[] MciRead(NfcDataHandler nfcDataHandler, ITestMethodCfg cfg, StructName structName, ushort offset, int length)
|
||||
{
|
||||
bool isReadValues = false;
|
||||
int retryCount = 0;
|
||||
Read:
|
||||
try
|
||||
{
|
||||
isReadValues = false;
|
||||
long num1 = (long)length;
|
||||
int timeoutMs = 4000;
|
||||
byte payloadlength = Convert.ToByte(num1.ToString("X2"), 16);
|
||||
if (nfcDataHandler.MCI_Read(structName, offset, payloadlength, timeoutMs))
|
||||
{
|
||||
byte[] lastData = nfcDataHandler.LastData;
|
||||
if ((long)lastData.Length >= num1)
|
||||
{
|
||||
rfidDataLogger.Info($"COM: MciRead ({structName},{offset},{length}) = {ByteArrayToHexString(lastData)}");
|
||||
return lastData;
|
||||
}
|
||||
else
|
||||
rfidDataLogger.Info($"COM: MciRead ({structName},{offset},{length}) = {ByteArrayToHexString(lastData)}");
|
||||
}
|
||||
else if (nfcDataHandler.LastErrorCode == (byte)0)
|
||||
{
|
||||
rfidDataLogger.Info($"MCI Error: Unidentified");
|
||||
retryCount++;
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
goto Read;
|
||||
}
|
||||
else
|
||||
{
|
||||
rfidDataLogger.Info("Last error message: " + nfcDataHandler.LastErrorMessage);
|
||||
retryCount++;
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
goto Read;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rfidDataLogger.Error("MciRead Last error message: " + ex.Message);
|
||||
retryCount++;
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
goto Read;
|
||||
}
|
||||
return new byte[length];
|
||||
}
|
||||
|
||||
private static void MciWrite(NfcDataHandler nfcDataHandler, ITestMethodCfg cfg, MCI_Protocol.StructName structName, ushort offset, int length, byte[] payload)
|
||||
{
|
||||
int retryCount = 0;
|
||||
Write:
|
||||
try
|
||||
{
|
||||
long num1 = (long)length;
|
||||
int timeoutMs = 4000;
|
||||
byte payloadlength = Convert.ToByte(num1);
|
||||
if ((int)payloadlength != payload.Length)
|
||||
rfidDataLogger.Error("Insufficient Payload -- Payload lenth : " + (object)payload.Length);
|
||||
else if (nfcDataHandler.MCI_Write(structName, offset, payloadlength, payload, timeoutMs))
|
||||
{
|
||||
// OK
|
||||
}
|
||||
else if (nfcDataHandler.LastErrorCode > (byte)0)
|
||||
{
|
||||
rfidDataLogger.Error("Last error message: " + nfcDataHandler.LastErrorMessage);
|
||||
//int num2 = (int)MessageBox.Show(this._nfcDataHandler.LastErrorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rfidDataLogger.Error("MciWrite error message: " + ex.Message);
|
||||
retryCount++;
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
goto Write;
|
||||
}
|
||||
}
|
||||
|
||||
private static void MciWriteCommand(NfcDataHandler nfcDataHandler, byte commandcode)
|
||||
{
|
||||
try
|
||||
{
|
||||
ushort offset = 0;
|
||||
int timeoutMs = 4000;
|
||||
byte payloadlength = 1;
|
||||
byte[] payload = new byte[1] { commandcode };
|
||||
if (nfcDataHandler.MCI_Write(MCI_Protocol.StructName.Command, offset, payloadlength, payload, timeoutMs) || nfcDataHandler.LastErrorCode <= (byte)0)
|
||||
return;
|
||||
rfidDataLogger.Error("MciWriteCommand Last error message: " + nfcDataHandler.LastErrorMessage);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rfidDataLogger.Error("MciWriteCommand Last error message: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public static string ByteArrayToHexString(byte[] data)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
foreach (byte num in data)
|
||||
stringBuilder.Append(num.ToString("X2"));
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
private static byte[] BuildPayLoad(string strPayLoad, int length)
|
||||
{
|
||||
byte[] collection;
|
||||
|
||||
if (strPayLoad.Split(':').Length > 1)
|
||||
{
|
||||
uint timestamp = ConvertDateTimeToTimestamp(Convert.ToDateTime(DateTime.ParseExact(strPayLoad, "HH:mm:ss dd/MM/yyyy", (IFormatProvider)CultureInfo.InvariantCulture)));
|
||||
byte[] bytes = BitConverter.GetBytes(timestamp);
|
||||
return bytes;
|
||||
}
|
||||
else if (strPayLoad.Split(',').Length > 1)
|
||||
{
|
||||
string[] strArray = strPayLoad.Split(',');
|
||||
collection = new byte[strArray.Length];
|
||||
for (int index3 = 0; index3 < strArray.Length; ++index3)
|
||||
collection[index3] = Convert.ToByte(strArray[index3], 16);
|
||||
return collection;
|
||||
}
|
||||
else
|
||||
{
|
||||
//int num = strPayLoad.Split(',').Length;
|
||||
collection = HexStringToByteArray(strPayLoad.Substring(strPayLoad.Length - length * 2).ToUpper());
|
||||
Array.Reverse((Array)collection);
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] HexStringToByteArray(string hexString)
|
||||
{
|
||||
int length = hexString.Length;
|
||||
byte[] byteArray = new byte[length / 2];
|
||||
for (int startIndex = 0; startIndex < length; startIndex += 2)
|
||||
byteArray[startIndex / 2] = Convert.ToByte(hexString.Substring(startIndex, 2), 16);
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
private static uint ConvertDateTimeToTimestamp(DateTime datetime)
|
||||
{
|
||||
TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
|
||||
return (uint)((datetime - new DateTime(2000, 1, 1, 0, 0, 0).ToLocalTime()).TotalSeconds + utcOffset.TotalSeconds);
|
||||
}
|
||||
|
||||
#region EventHandlers
|
||||
public static void MCI_MessageEventHandlers(MCI_Protocol e)
|
||||
{
|
||||
DelNfc_MCI_MessageHandler mciMessageHandler = new DelNfc_MCI_MessageHandler(OnHandler);
|
||||
e.MessageEvent += mciMessageHandler;
|
||||
}
|
||||
|
||||
public static void ST25DV_MessageEventHandlers(ST25DV_Device e)
|
||||
{
|
||||
DelNfc_ST25DV_MessageHandler dvMessageHandler = new DelNfc_ST25DV_MessageHandler(OnHandler);
|
||||
e.MessageEvent += dvMessageHandler;
|
||||
}
|
||||
|
||||
public static void CR95HF_MessageEventHandlers(CR95HF_Reader e)
|
||||
{
|
||||
DelNfc_CR95HF_MessageHandler hfMessageHandler = new DelNfc_CR95HF_MessageHandler(OnHandler);
|
||||
e.MessageEvent += hfMessageHandler;
|
||||
}
|
||||
|
||||
public static void NFCHeadConfig_MessageEventHandlers(NFCHeadConfig e)
|
||||
{
|
||||
DelNfc_NFCHeadConfig_MessageHandler configMessageHandler = new DelNfc_NFCHeadConfig_MessageHandler(OnHandler);
|
||||
e.MessageEvent += configMessageHandler;
|
||||
}
|
||||
|
||||
public static void MessageEventHandlers(NfcDataHandler e)
|
||||
{
|
||||
DelNfcMessageHandler nfcMessageHandler = new DelNfcMessageHandler(OnHandler);
|
||||
e.MessageEvent += nfcMessageHandler;
|
||||
}
|
||||
|
||||
public static void OnHandler(object sender, NfcMessageEventArgs e)
|
||||
{
|
||||
if (e.Message == null)
|
||||
return;
|
||||
string message = e.Message.Replace("\n", " ").Replace("\r", "");
|
||||
rfidDataLogger.Debug(message);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+3
-5
@@ -1,12 +1,10 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication
|
||||
using System;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl.communication
|
||||
{
|
||||
public class OptoReceivedEventArgs : EventArgs
|
||||
{
|
||||
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using Sensus.iPerl.RfidCom;
|
||||
using Sensus.iPerl.RfidCom.Exceptions;
|
||||
using Sensus.iPerl.RfidCom.Helper;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl.communication
|
||||
{
|
||||
internal class RfidServices
|
||||
{
|
||||
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(SmartCommunicationForm));
|
||||
|
||||
internal static int ReadRequest(ITestMethodCfg cfg, IntIPerlReader iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
|
||||
{
|
||||
for (int i = 0; i < cfg.MaxCommRetries; i++)
|
||||
{
|
||||
rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} reading: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},{offset}, {length}... timeout {cfg.CommTimeout})");
|
||||
using (RfidLogic writer = new RfidLogic($"COM{iperlHead.RfidComPortNr}"))
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] response = writer.ReadRequest((byte)messageID, offset, length, cfg.CommTimeout);
|
||||
string hexString = RfidHelper.ConvertByteArrayToHexString(response);
|
||||
string swapHexString = RfidHelper.SwapHexcode(hexString);
|
||||
string decString = RfidHelper.HexLiteral2Unsigned(RfidHelper.SwapHexcode(hexString)).ToString();
|
||||
|
||||
if (length > 10)
|
||||
{
|
||||
//if the result only contains "00"s we are working on the wrong COM port
|
||||
// or the module just isn't connected
|
||||
if (Regex.IsMatch(hexString, @"^(00)\1+$"))
|
||||
{
|
||||
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) <- Error: No RFID signal.");
|
||||
throw new RfidValidationException("Error_Rfid_NoSignal");
|
||||
}
|
||||
|
||||
//if the result only contains "03"s the meter did not answer.
|
||||
// Might be due to the module being positioned incorrectly.
|
||||
if (Regex.IsMatch(hexString, @"^(03)\1+$"))
|
||||
{
|
||||
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) <- Error: No meter signal.");
|
||||
throw new RfidValidationException("Error_Rfid_NoAnswerFromMeter");
|
||||
}
|
||||
}
|
||||
|
||||
writer.ClosePort();
|
||||
buffer = response;
|
||||
rfidDataLogger.Info($"{iperlHead.Name} ({iperlHead.SerialNr}): ReadRequestPort(COM{iperlHead.RfidComPortNr},...) returned HEX: {hexString}; SwapHexCodeToDecimal: {decString}");
|
||||
return 0;
|
||||
}
|
||||
catch (RfidDataNotAvailableException)
|
||||
{
|
||||
if (/*RfidHelper.IsPassThrough(messageID)*/ messageID == MessageID.ASICRegisterReadTest || messageID == MessageID.RadioPassthrough)
|
||||
{
|
||||
rfidDataLogger.Info($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) {(i > 0 ? "<- Error: Invalid Pass-Through data." : "<- Info: Wait for Pass-Through data.")}");
|
||||
Thread.Sleep(cfg.PassThroughWaitTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
}
|
||||
}
|
||||
catch (RfidValidationException)
|
||||
{
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) {ex.Message}");
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
}
|
||||
}
|
||||
}
|
||||
rfidDataLogger.Error($"{iperlHead.CommInterface} reading failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...)");
|
||||
log.Error($"{iperlHead.CommInterface} reading failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...)");
|
||||
buffer = new byte[length];
|
||||
return 3;
|
||||
}
|
||||
|
||||
internal static int WriteRequest(ITestMethodCfg cfg, IntIPerlReader iperlHead, MessageID messageID, int offset, int length, byte[] buffer)
|
||||
{
|
||||
RfidLogic writer = new RfidLogic($"COM{iperlHead.RfidComPortNr}");
|
||||
string payload = RfidHelper.ConvertByteArrayToHexString(buffer);
|
||||
|
||||
for (var i = 0; i < cfg.MaxCommRetries; i++)
|
||||
{
|
||||
rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} writting: COM{iperlHead.RfidComPortNr}: WriteRequest ({messageID},{offset}, {length}, {payload}... timeout {cfg.CommTimeout})");
|
||||
try
|
||||
{
|
||||
if (writer.ClosePort()) writer.OpenPort();
|
||||
writer.WriteRequest((byte)messageID, offset, length, buffer, cfg.CommTimeout, false);
|
||||
writer.ClosePort();
|
||||
rfidDataLogger.InfoFormat($"{iperlHead.Name}({iperlHead.SerialNr},COM{iperlHead.RfidComPortNr}): WriteRequestPort({messageID}, {offset}, {length}, {payload})");
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (messageID == MessageID.RadioPassthrough || messageID == MessageID.ASICRegisterReadTest)
|
||||
{
|
||||
Thread.Sleep(1500);
|
||||
}
|
||||
else
|
||||
{
|
||||
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: Error: {ex.Message}");
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
if (i > 1)
|
||||
{
|
||||
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: Reopen the com port.");
|
||||
writer.ClosePort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.ClosePort();
|
||||
rfidDataLogger.Error($"RFID writing failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: WriteRequestPort ({messageID},...) {System.Text.Encoding.UTF8.GetString(buffer)}");
|
||||
log.Error($"RFID writing failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: WriteRequestPort ({messageID},...) {System.Text.Encoding.UTF8.GetString(buffer)}");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.CommonRR.IPerl.communication
|
||||
{
|
||||
internal class SimulationServices
|
||||
{
|
||||
const int Q2CorrFactorsAddr = iPerlCommunicationConstants.Q2CorrFactorsAddr;
|
||||
|
||||
internal static int ReadRequest(IntIPerlReader iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
|
||||
{
|
||||
byte[] configurationBuffer = new byte[ConfigStruct.Length] { 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
byte[] calibrationBuffer = new byte[CalibrationStructV4.Length] { 3, 0, 150, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 150, 10 };
|
||||
buffer = new byte[length];
|
||||
|
||||
if (messageID == MessageID.Configuration)
|
||||
{
|
||||
Array.Copy(GetPCB(iperlHead), 0, configurationBuffer, 16, 5); // set PCB Number according to iPerlHead configuration
|
||||
Array.Copy(configurationBuffer,offset,buffer,0,length);
|
||||
}
|
||||
else if (messageID == MessageID.Calibration)
|
||||
{
|
||||
Array.Copy(calibrationBuffer, offset, buffer, 0, length);
|
||||
}
|
||||
else if ((messageID == MessageID.MetrologyMemory) && (offset == Q2CorrFactorsAddr) && (length == 2))
|
||||
{
|
||||
buffer = new byte[2] { 0, 0 };
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer = new byte[length];
|
||||
}
|
||||
|
||||
return iperlHead.Name.Equals("iPerl13") ? 2 : 0; /// Simulates an error on position 13
|
||||
}
|
||||
|
||||
internal static int WriteRequest(ITestMethodCfg cfg, IntIPerlReader iperlHead, MessageID messageID, int offset,
|
||||
int length, byte[] buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static Array GetPCB(IntIPerlReader iperlHead)
|
||||
{
|
||||
string pcbStr = iperlHead.RfidComPortNr.ToString().PadRight(10,'0') + iperlHead.Position.ToString("D2");
|
||||
long decVal = Convert.ToInt64(pcbStr);
|
||||
string nHexStr = decVal.ToString("X4");
|
||||
|
||||
string hexStr = "";
|
||||
for (int a = nHexStr.Length; a >= 1; a = a - 2)
|
||||
{
|
||||
hexStr = hexStr + nHexStr.Substring(a - 2, 2);
|
||||
}
|
||||
|
||||
return Enumerable.Range(0, hexStr.Length)
|
||||
.Where(x => x % 2 == 0)
|
||||
.Select(x => Convert.ToByte(hexStr.Substring(x, 2), 16))
|
||||
.ToArray();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using log4net;
|
||||
using log4net.Config;
|
||||
@@ -53,15 +54,23 @@ namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
|
||||
|
||||
if (isCliLogging)
|
||||
{
|
||||
log = new ScopedLoggerFactory().CreateLogger<CliRunner>(
|
||||
@"C:\TBF\Logs\CliRunner.txt",
|
||||
10, // maxFileSizeMB
|
||||
7, // maxBackups
|
||||
log4net.Core.Level.Debug,
|
||||
true, // zipRolledFiles
|
||||
true, // singleZipPerDay
|
||||
TimeSpan.FromMinutes(2) // zipScanInterval
|
||||
);
|
||||
try
|
||||
{
|
||||
log = new ScopedLoggerFactory().CreateLogger<CliRunner>(
|
||||
@"C:\TBF\Logs\CliRunner.txt",
|
||||
10, // maxFileSizeMB
|
||||
7, // maxBackups
|
||||
log4net.Core.Level.Debug,
|
||||
true, // zipRolledFiles
|
||||
true, // singleZipPerDay
|
||||
TimeSpan.FromMinutes(2) // zipScanInterval
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Fallback to console or handle gracefully
|
||||
Console.WriteLine($"Failed to initialize logger: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +93,7 @@ namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
|
||||
}
|
||||
|
||||
|
||||
public async Task<string> SendAsync(string fileName, string args)
|
||||
public async Task<string> SendAsync(string fileName, string args, CancellationToken ct = default)
|
||||
{
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
@@ -96,26 +105,31 @@ namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
|
||||
CreateNoWindow = true
|
||||
};
|
||||
|
||||
var process = new Process { StartInfo = psi };
|
||||
var sb = new StringBuilder();
|
||||
|
||||
process.OutputDataReceived += (sender, e) =>
|
||||
{
|
||||
if (e.Data != null)
|
||||
sb.AppendLine(e.Data);
|
||||
};
|
||||
|
||||
using var process = new Process { StartInfo = psi, EnableRaisingEvents = true };
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
|
||||
process.WaitForExit();
|
||||
Task<string> stdOutTask = process.StandardOutput.ReadToEndAsync();
|
||||
Task<string> stdErrTask = process.StandardError.ReadToEndAsync();
|
||||
|
||||
try
|
||||
{
|
||||
await Task.WhenAll(stdOutTask, stdErrTask, process.WaitForExitAsync(ct));
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
if (!process.HasExited)
|
||||
{
|
||||
process.Kill();
|
||||
}
|
||||
|
||||
// Now all outputs are available
|
||||
string allOutput = sb.ToString();
|
||||
throw;
|
||||
}
|
||||
|
||||
string allOutput = (stdOutTask.Result ?? "") + (stdErrTask.Result ?? "");
|
||||
log?.Debug(allOutput);
|
||||
|
||||
return allOutput;
|
||||
}
|
||||
|
||||
|
||||
public void AddRunAndCaptureJsonAsync<T>(SerialPortData data, SerialPortData.EMeterArg eMeterArg) where T : new()
|
||||
{
|
||||
@@ -123,7 +137,7 @@ namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
|
||||
taskPool.Add(task);
|
||||
}
|
||||
|
||||
public async Task<T> RunAndCaptureJsonAsync<T>(string fileName, string args) where T : new()
|
||||
public async Task<T> RunAndCaptureJsonAsync<T>(string fileName, string args, CancellationToken ct = default) where T : new()
|
||||
{
|
||||
var psi = new ProcessStartInfo
|
||||
{
|
||||
@@ -135,29 +149,19 @@ namespace TBF.Rig.RegisterReaders.PoseidonCmdStartStop
|
||||
CreateNoWindow = true
|
||||
};
|
||||
|
||||
var process = new Process { StartInfo = psi };
|
||||
var sb = new StringBuilder();
|
||||
|
||||
process.OutputDataReceived += (sender, e) =>
|
||||
{
|
||||
if (e.Data != null)
|
||||
sb.AppendLine(e.Data);
|
||||
};
|
||||
|
||||
using var process = new Process { StartInfo = psi, EnableRaisingEvents = true };
|
||||
process.Start();
|
||||
process.BeginOutputReadLine();
|
||||
|
||||
process.WaitForExit();
|
||||
var stdoutTask = process.StandardOutput.ReadToEndAsync();
|
||||
var stderrTask = process.StandardError.ReadToEndAsync();
|
||||
|
||||
// Now sb contains all output text
|
||||
string allOutput = sb.ToString();
|
||||
await Task.WhenAll(stdoutTask, stderrTask, process.WaitForExitAsync(ct));
|
||||
|
||||
string allOutput = (stdoutTask.Result ?? "") + (stderrTask.Result ?? "");
|
||||
log?.Debug(allOutput);
|
||||
|
||||
// Extract JSON part
|
||||
string json = ExtractJson(allOutput);
|
||||
|
||||
if (TryJsonStringDeserialize(json, out T runAndCaptureJsonAsync)) return runAndCaptureJsonAsync;
|
||||
|
||||
if (TryJsonStringDeserialize(json, out T result)) return result;
|
||||
return default;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using TBF.Rig.Generic;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader
|
||||
{
|
||||
public class Factory: IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
|
||||
|
||||
public override string ToString() { return ClassName; }
|
||||
|
||||
public IComponent DummyComponent() { return new IPerlReader(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new IPerlReader(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new IPerlCfg(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(IPerlCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader
|
||||
{
|
||||
public class IPerlCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(IPerlCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
public IComponentCfgCtrl GetControl(IList<Component> cmpntEntities)
|
||||
{
|
||||
return new IPerlCfgCtrl();
|
||||
}
|
||||
|
||||
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public bool UseTcpIP;
|
||||
public string OptoIPAddress;
|
||||
public ushort OptoTcpipPortNr;
|
||||
public int HeadCommunicationComPortNr;
|
||||
public int OptoComPortNr;
|
||||
public int RfidComPortNr; /// 0 = use MuxBoardNr
|
||||
public int MuxBoardNr; /// 0 = use RfidComPort(Nr), otherwise mux. board nr. 1 .. 4
|
||||
public int Group; /// Number written to QuidoRS to connct the watermeter to RfidComPort, 1 .. 10
|
||||
public CommunicationInterface CommunicationInterface; /// Communication Interface: RFID or NFC
|
||||
|
||||
/// <summary> Procedure parameters </summary>
|
||||
[XmlIgnore]
|
||||
public ProcParams ProcParams;
|
||||
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
|
||||
public override IParamsProvider CreateProcParamsProvider() { return new ProcParams(true); }
|
||||
|
||||
[XmlIgnore]
|
||||
public MeterType MeterType { get { return (ProcParams != null) ? ProcParams.MeterType : MeterType.AutoDetect; } }
|
||||
|
||||
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
IPerlCfg()
|
||||
{
|
||||
Name = "iPerl";
|
||||
ParentName = string.Empty;
|
||||
OptoComPortNr = 10;
|
||||
RfidComPortNr = 0; /// = use mux. board
|
||||
MuxBoardNr = 1;
|
||||
ProcParams = CreateProcParamsProvider() as ProcParams;
|
||||
CommunicationInterface = CommunicationInterface.RFID;
|
||||
HeadCommunicationComPortNr = 0;
|
||||
}
|
||||
|
||||
public IPerlCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return $"{Name} Group1 (mux#)={MuxBoardNr}, Group2={Group}, Opto=Com{OptoComPortNr}, {CommunicationInterface}=Com{RfidComPortNr}";
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -1,15 +1,17 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
///
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
using Common;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Resources;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader
|
||||
{
|
||||
public partial class IPerlCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
///
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader
|
||||
{
|
||||
partial class IPerlCfgCtrl
|
||||
{
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader
|
||||
{
|
||||
partial class IperlHeadTestCtrl
|
||||
{
|
||||
+17
-16
@@ -2,16 +2,17 @@ using System;
|
||||
using System.Threading;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Windows.Forms;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication;
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl.communication;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI.test;
|
||||
using TBF.Rig.Sequences;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader
|
||||
{
|
||||
public partial class IperlHeadTestCtrl : UserControl
|
||||
{
|
||||
IPerlCfg config;
|
||||
IPerlReader _iPerlReader;
|
||||
IntIPerlReader _iPerlReader;
|
||||
Thread optoThread;
|
||||
|
||||
private bool stopWorkerThread;
|
||||
@@ -84,23 +85,23 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
switch (rfidCommandComboBox.SelectedValue)
|
||||
{
|
||||
case "ReadPCB":
|
||||
rfidListItem.Text = $"PCB: {OpticalHeadTest.ReadRequest_PCB(_iPerlReader)}";
|
||||
// rfidListItem.Text = $"PCB: {OpticalHeadTest.ReadRequest_PCB(_iPerlReader)}";
|
||||
break;
|
||||
case "SetTestMode":
|
||||
rfidListItem.Text = OpticalHeadTest.SetTestMode(_iPerlReader);
|
||||
optoListBox.Items.Clear();
|
||||
stopWorkerThread = false;
|
||||
optoThread = new Thread(OptoWorker);
|
||||
if (!optoThread.IsAlive)
|
||||
{
|
||||
_iPerlReader.StartDataStreamProcessing(); // open opto port
|
||||
optoThread.Start();
|
||||
}
|
||||
// rfidListItem.Text = OpticalHeadTest.SetTestMode(_iPerlReader);
|
||||
// optoListBox.Items.Clear();
|
||||
// stopWorkerThread = false;
|
||||
// optoThread = new Thread(OptoWorker);
|
||||
// if (!optoThread.IsAlive)
|
||||
// {
|
||||
// _iPerlReader.StartDataStreamProcessing(); // open opto port
|
||||
// optoThread.Start();
|
||||
// }
|
||||
break;
|
||||
case "SetActiveMode":
|
||||
rfidListItem.Text = OpticalHeadTest.SetActiveMode(_iPerlReader);
|
||||
stopWorkerThread = true;
|
||||
_iPerlReader.StopDataStreamProcessing(); // close opto port
|
||||
// rfidListItem.Text = OpticalHeadTest.SetActiveMode(_iPerlReader);
|
||||
// stopWorkerThread = true;
|
||||
// _iPerlReader.StopDataStreamProcessing(); // close opto port
|
||||
break;
|
||||
case "ResetNfcHead":
|
||||
_iPerlReader.ResetNfcInterface();
|
||||
@@ -0,0 +1,184 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader
|
||||
{
|
||||
public class ProcParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
||||
{
|
||||
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcParams) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public int WMType_ID;
|
||||
public MeterType MeterType;
|
||||
public float CalibTarget; /// Target error after calibration in [%]
|
||||
public int FactorLimitLo; /// Lower limit for the calibration factor
|
||||
public int FactorLimitHi; /// Upper limit for the calibration factor
|
||||
public Counting Counting; /// Initial iPerl counting (Artbitrary, Positive or Negative)
|
||||
|
||||
|
||||
public override void InitializeAll()
|
||||
{
|
||||
MeterType = MeterType.AutoDetect;
|
||||
CalibTarget = 0;
|
||||
FactorLimitLo = 1000;
|
||||
FactorLimitHi = 8000;
|
||||
Counting = Counting.Arbitrary;
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
{
|
||||
"iPerl type",
|
||||
"Calib. target [%]",
|
||||
"Calib. factor Lo",
|
||||
"Calib. factor Hi",
|
||||
"Counting",
|
||||
};
|
||||
public override string ParamName(int i) { return paramNames[i]; }
|
||||
public override int ParamsCount() { return paramNames.Length; }
|
||||
|
||||
public override ICollection<string> ParamValues(int i)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
var retVal = new List<string>();
|
||||
for (MeterType mt = 0; mt < MeterType.Count; mt++) retVal.Add(mt.ToString());
|
||||
return retVal;
|
||||
}
|
||||
else if (i == 5)
|
||||
{
|
||||
var retVal = new List<string>();
|
||||
for (Counting c = 0; c < Counting.Count; c++) retVal.Add(c.ToString());
|
||||
return retVal;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override string ToString(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: return MeterType.ToString();
|
||||
case 1: return CalibTarget.ToString();
|
||||
case 2: return FactorLimitLo.ToString();
|
||||
case 3: return FactorLimitHi.ToString();
|
||||
case 4: return Counting.ToString();
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//implement IParamsProvider
|
||||
public bool ValidateParam(int i, string strValue, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
|
||||
int iDummy;
|
||||
float fDummy;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
for (MeterType mt = 0; mt < MeterType.Count; mt++) if (mt.ToString().Equals(strValue)) return true;
|
||||
break;
|
||||
case 1:
|
||||
if (Utils.TryParseSFloat(strValue, out fDummy) && fDummy >= -10.0f && fDummy <= 10.0f) return true;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
if (int.TryParse(strValue, out iDummy) && iDummy >= 1000 && iDummy <= 8000) return true;
|
||||
break;
|
||||
case 4:
|
||||
for (Counting c = 0; c < Counting.Count; c++) if (c.ToString().Equals(strValue)) return true;
|
||||
break;
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
}
|
||||
|
||||
message = ParamName(i) + " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
for (MeterType mt = 0; mt < MeterType.Count; mt++)
|
||||
{
|
||||
if (mt.ToString().Equals(strValue)) { MeterType = mt; return CfgUpdateFlags.None; }
|
||||
}
|
||||
break;
|
||||
case 1: CalibTarget = Utils.ParseSFloat(strValue); return CfgUpdateFlags.None;
|
||||
case 2: FactorLimitLo = int.Parse(strValue); return CfgUpdateFlags.None;
|
||||
case 3: FactorLimitHi = int.Parse(strValue); return CfgUpdateFlags.None;
|
||||
case 4:
|
||||
for (Counting c = 0; c < Counting.Count; c++)
|
||||
{
|
||||
if (c.ToString().Equals(strValue)) { Counting = c; return CfgUpdateFlags.None; }
|
||||
}
|
||||
break;
|
||||
default: return CfgUpdateFlags.None;
|
||||
}
|
||||
|
||||
return CfgUpdateFlags.None;
|
||||
}
|
||||
|
||||
void CopyContentTo(ProcParams prms)
|
||||
{
|
||||
prms.MeterType = this.MeterType;
|
||||
prms.CalibTarget = this.CalibTarget;
|
||||
prms.FactorLimitLo = this.FactorLimitLo;
|
||||
prms.FactorLimitHi = this.FactorLimitHi;
|
||||
prms.Counting = this.Counting;
|
||||
}
|
||||
|
||||
public IParamsProvider Clone()
|
||||
{
|
||||
ProcParams pars = new ProcParams();
|
||||
CopyContentTo(pars);
|
||||
return pars;
|
||||
}
|
||||
|
||||
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
|
||||
{
|
||||
if (dbEntity == null) return;
|
||||
try
|
||||
{
|
||||
ProcParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcParams;
|
||||
|
||||
procedureParamsEntity = dbEntity;
|
||||
componentName = dbEntity.CmpntName;
|
||||
procedure = dbEntity.Procedure;
|
||||
|
||||
if (tmp != null) tmp.CopyContentTo(this);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ProcParams()
|
||||
{
|
||||
}
|
||||
|
||||
public ProcParams(bool initialize)
|
||||
{
|
||||
if (initialize) InitializeAll();
|
||||
}
|
||||
|
||||
public ProcParams(ComponentProcedure procParamsEntity, string componentName, Procedure procedure)
|
||||
{
|
||||
this.procedureParamsEntity = procParamsEntity;
|
||||
this.componentName = componentName;
|
||||
this.procedure = procedure;
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -1,17 +1,19 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Threading;
|
||||
using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.TestMethods.SmartTest;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader
|
||||
{
|
||||
public class TestMethodCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
public class TestMethodCfg : ComponentCfgBase, IComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
@@ -0,0 +1,245 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2020 Sensus Metering Systems
|
||||
///
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.RegisterReaders.PoseidonReader.comminication;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader.communication
|
||||
{
|
||||
public class CalibrationStruct
|
||||
{
|
||||
public const int Length = 35;
|
||||
|
||||
public Byte Version;
|
||||
public MeterType MeterType;
|
||||
public UInt16 Calibration;
|
||||
public VolumeUnits VolumeUnits;
|
||||
public FlowArrow FlowArrow;
|
||||
public UInt16 FWVersion;
|
||||
public UInt16[] TargetField;
|
||||
public UInt16 RecipMeanCurrent;
|
||||
public UInt16 ThresholdVolume;
|
||||
public UInt16 ThresholdTime;
|
||||
public UInt16 FlowActivationThr;
|
||||
public UInt16 VolumeArrowThr;
|
||||
public UInt32 CalibrationTime;
|
||||
public ulong SerialNumber;
|
||||
public MeterSealed MeterSealed;
|
||||
public byte CheckSum;
|
||||
|
||||
|
||||
public CalibrationStruct()
|
||||
{
|
||||
TargetField = new UInt16[3];
|
||||
}
|
||||
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
byte[] result = new byte[Length];
|
||||
|
||||
result[0] = Version;
|
||||
result[1] = (byte)MeterType;
|
||||
|
||||
result[2] = (byte)(Calibration & 0x00FF);
|
||||
result[3] = (byte)((Calibration >> 8) & 0x00FF);
|
||||
|
||||
result[4] = (byte)VolumeUnits;
|
||||
|
||||
result[5] = (byte)FlowArrow;
|
||||
|
||||
result[6] = (byte)(FWVersion & 0x00FF);
|
||||
result[7] = (byte)((FWVersion >> 8) & 0x00FF);
|
||||
|
||||
result[8] = (byte)( TargetField[0] & 0x00FF);
|
||||
result[9] = (byte)((TargetField[0] >> 8) & 0x00FF);
|
||||
result[10] = (byte)( TargetField[1] & 0x00FF);
|
||||
result[11] = (byte)((TargetField[1] >> 8) & 0x00FF);
|
||||
result[12] = (byte)( TargetField[2] & 0x00FF);
|
||||
result[13] = (byte)((TargetField[2] >> 8) & 0x00FF);
|
||||
|
||||
result[14] = (byte)(RecipMeanCurrent & 0x00FF);
|
||||
result[15] = (byte)((RecipMeanCurrent >> 8) & 0x00FF);
|
||||
|
||||
result[16] = (byte)(ThresholdVolume & 0x00FF);
|
||||
result[17] = (byte)((ThresholdVolume >> 8) & 0x00FF);
|
||||
|
||||
result[18] = (byte)(ThresholdTime & 0x00FF);
|
||||
result[19] = (byte)((ThresholdTime >> 8) & 0x00FF);
|
||||
|
||||
result[20] = (byte)(FlowActivationThr & 0x00FF);
|
||||
result[21] = (byte)((FlowActivationThr >> 8) & 0x00FF);
|
||||
|
||||
result[22] = (byte)(VolumeArrowThr & 0x00FF);
|
||||
result[23] = (byte)((VolumeArrowThr >> 8) & 0x00FF);
|
||||
|
||||
result[24] = (byte)(CalibrationTime & 0x000000FF);
|
||||
result[25] = (byte)((CalibrationTime >> 8) & 0x000000FF);
|
||||
result[26] = (byte)((CalibrationTime >> 16) & 0x000000FF);
|
||||
result[27] = (byte)((CalibrationTime >> 24) & 0x000000FF);
|
||||
|
||||
result[28] = (byte)(SerialNumber & 0x00000000000000FF);
|
||||
result[29] = (byte)((SerialNumber >> 8) & 0x00000000000000FF);
|
||||
result[30] = (byte)((SerialNumber >> 16) & 0x00000000000000FF);
|
||||
result[31] = (byte)((SerialNumber >> 24) & 0x00000000000000FF);
|
||||
result[32] = (byte)((SerialNumber >> 32) & 0x00000000000000FF);
|
||||
|
||||
result[33] = (byte)MeterSealed;
|
||||
result[34] = CheckSum;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a calibration structure from a complete byte array
|
||||
/// </summary>
|
||||
/// <param name="data">A complete byte array data</param>
|
||||
/// <returns>CalibrationStruct or null when byte array was not complete</returns>
|
||||
public static CalibrationStruct FromByteArray(byte[] data)
|
||||
{
|
||||
if (data.Length != Length) return null;
|
||||
|
||||
CalibrationStruct result = new CalibrationStruct();
|
||||
|
||||
result.Version = data[0];
|
||||
result.MeterType = (MeterType)data[1];
|
||||
result.Calibration = (UInt16)(data[2] + 256 * data[3]);
|
||||
result.VolumeUnits = (VolumeUnits)data[4];
|
||||
result.FlowArrow = (FlowArrow)data[5];
|
||||
result.FWVersion = (UInt16)(data[6] + 256 * data[7]);
|
||||
result.TargetField[0] = (UInt16)(data[8] + 256 * data[9]);
|
||||
result.TargetField[1] = (UInt16)(data[10] + 256 * data[11]);
|
||||
result.TargetField[2] = (UInt16)(data[12] + 256 * data[13]);
|
||||
result.RecipMeanCurrent = (UInt16)(data[14] + 256 * data[15]);
|
||||
result.ThresholdVolume = (UInt16)(data[16] + 256 * data[17]);
|
||||
result.ThresholdTime = (UInt16)(data[18] + 256 * data[19]);
|
||||
result.FlowActivationThr = (UInt16)(data[20] + 256 * data[21]);
|
||||
result.VolumeArrowThr = (UInt16)(data[22] + 256 * data[23]);
|
||||
result.CalibrationTime = (((UInt32)data[27] * 256 + data[26]) * 256 + data[25]) * 256 + data[24];
|
||||
result.SerialNumber = ((((UInt64)data[32] * 256 + data[31]) * 256 + data[30]) * 256 + data[29]) * 256 + data[28];
|
||||
result.MeterSealed = (MeterSealed)data[33];
|
||||
result.CheckSum = data[34];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the calibration structure from an incomplete byte array
|
||||
/// </summary>
|
||||
/// <param name="data">Byte array data</param>
|
||||
/// <param name="offset">Offset of byte array data in CalibrationStruct</param>
|
||||
/// <returns>true when successful, false when data are not appropriate</returns>
|
||||
public bool Update(byte[] data, int offset)
|
||||
{
|
||||
if ((data.Length == 2) && (offset == 2))
|
||||
{
|
||||
/// Data containing iPerl calibration factor
|
||||
Calibration = (UInt16)(data[0] + 256 * data[1]);
|
||||
return true;
|
||||
}
|
||||
else if ((data.Length == Length) && (offset == 0))
|
||||
{
|
||||
/// Data containing a complete CalibrationStruct
|
||||
Version = data[0];
|
||||
MeterType = (MeterType)data[1];
|
||||
Calibration = (UInt16)(data[2] + 256 * data[3]);
|
||||
VolumeUnits = (VolumeUnits)data[4];
|
||||
FlowArrow = (FlowArrow)data[5];
|
||||
FWVersion = (UInt16)(data[6] + 256 * data[7]);
|
||||
TargetField[0] = (UInt16)(data[8] + 256 * data[9]);
|
||||
TargetField[1] = (UInt16)(data[10] + 256 * data[11]);
|
||||
TargetField[2] = (UInt16)(data[12] + 256 * data[13]);
|
||||
RecipMeanCurrent = (UInt16)(data[14] + 256 * data[15]);
|
||||
ThresholdVolume = (UInt16)(data[16] + 256 * data[17]);
|
||||
ThresholdTime = (UInt16)(data[18] + 256 * data[19]);
|
||||
FlowActivationThr = (UInt16)(data[20] + 256 * data[21]);
|
||||
VolumeArrowThr = (UInt16)(data[22] + 256 * data[23]);
|
||||
CalibrationTime = (((UInt32)data[27] * 256 + data[26]) * 256 + data[25]) * 256 + data[24];
|
||||
SerialNumber = ((((UInt64)data[32] * 256 + data[31]) * 256 + data[30]) * 256 + data[29]) * 256 + data[28];
|
||||
MeterSealed = (MeterSealed)data[33];
|
||||
CheckSum = data[34];
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public string FWVersionStr()
|
||||
{
|
||||
int d1 = (FWVersion >> 8) & 0x000F;
|
||||
int d2 = (FWVersion >> 12) & 0x000F;
|
||||
int d3 = (FWVersion >> 4) & 0x000F;
|
||||
int d4 = FWVersion & 0x000F;
|
||||
return string.Format("{0}.{1}{2}{3}", d1, d2, d3, d4);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Calibration: V{0} Type={1} Cal={2} Units={3} FlowArrow.{4} FW={5} Hi={6} Norm={7} Low={8} RMC={9} ThrVol={10} ThrTime={11} FlActThr={12} VolArrThr={13} CalTm={14} SN={15} MeterSealed={16} Chksum={17}",
|
||||
Version,
|
||||
MeterType,
|
||||
Calibration,
|
||||
VolumeUnits,
|
||||
FlowArrow,
|
||||
FWVersion,
|
||||
TargetField[0],
|
||||
TargetField[1],
|
||||
TargetField[2],
|
||||
RecipMeanCurrent,
|
||||
ThresholdVolume,
|
||||
ThresholdTime,
|
||||
FlowActivationThr,
|
||||
VolumeArrowThr,
|
||||
CalibrationTime,
|
||||
SerialNumber,
|
||||
MeterSealed,
|
||||
CheckSum.ToString("X2"));
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Version);
|
||||
writer.Write((byte)MeterType);
|
||||
writer.Write(Calibration);
|
||||
writer.Write((byte)VolumeUnits);
|
||||
writer.Write((byte)FlowArrow);
|
||||
writer.Write(FWVersion);
|
||||
writer.Write(TargetField[0]);
|
||||
writer.Write(TargetField[1]);
|
||||
writer.Write(TargetField[2]);
|
||||
writer.Write(RecipMeanCurrent);
|
||||
writer.Write(ThresholdVolume);
|
||||
writer.Write(ThresholdTime);
|
||||
writer.Write(FlowActivationThr);
|
||||
writer.Write(VolumeArrowThr);
|
||||
writer.Write(CalibrationTime);
|
||||
writer.Write(SerialNumber);
|
||||
writer.Write((byte)MeterSealed);
|
||||
writer.Write(CheckSum);
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
Version = reader.ReadByte();
|
||||
MeterType = (MeterType)reader.ReadByte();
|
||||
Calibration = reader.ReadUInt16();
|
||||
VolumeUnits = (VolumeUnits)reader.ReadByte();
|
||||
FlowArrow = (FlowArrow)reader.ReadByte();
|
||||
FWVersion = reader.ReadUInt16();
|
||||
TargetField[0] = reader.ReadUInt16();
|
||||
TargetField[1] = reader.ReadUInt16();
|
||||
TargetField[2] = reader.ReadUInt16();
|
||||
RecipMeanCurrent = reader.ReadUInt16();
|
||||
ThresholdVolume = reader.ReadUInt16();
|
||||
ThresholdTime = reader.ReadUInt16();
|
||||
FlowActivationThr = reader.ReadUInt16();
|
||||
VolumeArrowThr = reader.ReadUInt16();
|
||||
CalibrationTime = reader.ReadUInt32();
|
||||
SerialNumber = reader.ReadUInt64();
|
||||
MeterSealed = (MeterSealed)reader.ReadByte();
|
||||
CheckSum = reader.ReadByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
///
|
||||
/// Copyright (c) 2018-2020 Sensus Slovensko a.s.
|
||||
///
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.RegisterReaders.PoseidonReader.comminication;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader.communication
|
||||
{
|
||||
public class CalibrationStructV4
|
||||
{
|
||||
public const int Length = 37;
|
||||
|
||||
public Byte Version;
|
||||
public MeterType MeterType;
|
||||
public UInt16 Calibration;
|
||||
public VolumeUnits VolumeUnits;
|
||||
public FlowArrow FlowArrow;
|
||||
public UInt16 FWVersion;
|
||||
public UInt16[] TargetField;
|
||||
public UInt16 RecipMeanCurrent;
|
||||
public UInt16 ThresholdVolume;
|
||||
public UInt16 ThresholdTime;
|
||||
public UInt16 FlowActivationThr;
|
||||
public UInt16 VolumeArrowThr;
|
||||
public UInt32 CalibrationTime;
|
||||
public ulong SerialNumber;
|
||||
public MeterSealed MeterSealed;
|
||||
public UInt16 CalibrationLNA;
|
||||
public byte CheckSum;
|
||||
|
||||
|
||||
public CalibrationStructV4()
|
||||
{
|
||||
TargetField = new UInt16[3];
|
||||
}
|
||||
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
byte[] result = new byte[Length];
|
||||
|
||||
result[0] = Version;
|
||||
result[1] = (byte)MeterType;
|
||||
|
||||
result[2] = (byte)(Calibration & 0x00FF);
|
||||
result[3] = (byte)((Calibration >> 8) & 0x00FF);
|
||||
|
||||
result[4] = (byte)VolumeUnits;
|
||||
|
||||
result[5] = (byte)FlowArrow;
|
||||
|
||||
result[6] = (byte)(FWVersion & 0x00FF);
|
||||
result[7] = (byte)((FWVersion >> 8) & 0x00FF);
|
||||
|
||||
result[8] = (byte)( TargetField[0] & 0x00FF);
|
||||
result[9] = (byte)((TargetField[0] >> 8) & 0x00FF);
|
||||
result[10] = (byte)( TargetField[1] & 0x00FF);
|
||||
result[11] = (byte)((TargetField[1] >> 8) & 0x00FF);
|
||||
result[12] = (byte)( TargetField[2] & 0x00FF);
|
||||
result[13] = (byte)((TargetField[2] >> 8) & 0x00FF);
|
||||
|
||||
result[14] = (byte)(RecipMeanCurrent & 0x00FF);
|
||||
result[15] = (byte)((RecipMeanCurrent >> 8) & 0x00FF);
|
||||
|
||||
result[16] = (byte)(ThresholdVolume & 0x00FF);
|
||||
result[17] = (byte)((ThresholdVolume >> 8) & 0x00FF);
|
||||
|
||||
result[18] = (byte)(ThresholdTime & 0x00FF);
|
||||
result[19] = (byte)((ThresholdTime >> 8) & 0x00FF);
|
||||
|
||||
result[20] = (byte)(FlowActivationThr & 0x00FF);
|
||||
result[21] = (byte)((FlowActivationThr >> 8) & 0x00FF);
|
||||
|
||||
result[22] = (byte)(VolumeArrowThr & 0x00FF);
|
||||
result[23] = (byte)((VolumeArrowThr >> 8) & 0x00FF);
|
||||
|
||||
result[24] = (byte)(CalibrationTime & 0x000000FF);
|
||||
result[25] = (byte)((CalibrationTime >> 8) & 0x000000FF);
|
||||
result[26] = (byte)((CalibrationTime >> 16) & 0x000000FF);
|
||||
result[27] = (byte)((CalibrationTime >> 24) & 0x000000FF);
|
||||
|
||||
result[28] = (byte)(SerialNumber & 0x00000000000000FF);
|
||||
result[29] = (byte)((SerialNumber >> 8) & 0x00000000000000FF);
|
||||
result[30] = (byte)((SerialNumber >> 16) & 0x00000000000000FF);
|
||||
result[31] = (byte)((SerialNumber >> 24) & 0x00000000000000FF);
|
||||
result[32] = (byte)((SerialNumber >> 32) & 0x00000000000000FF);
|
||||
|
||||
result[33] = (byte)MeterSealed;
|
||||
|
||||
result[34] = (byte)(CalibrationLNA & 0x00FF);
|
||||
result[35] = (byte)((CalibrationLNA >> 8) & 0x00FF);
|
||||
|
||||
result[36] = CheckSum;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a calibration structure from a complete byte array
|
||||
/// </summary>
|
||||
/// <param name="data">A complete byte array data</param>
|
||||
/// <returns>CalibrationStructV4 or null when byte array was not complete</returns>
|
||||
public static CalibrationStructV4 FromByteArray(byte[] data)
|
||||
{
|
||||
if (data.Length != Length) return null;
|
||||
|
||||
CalibrationStructV4 result = new CalibrationStructV4();
|
||||
|
||||
result.Version = data[0];
|
||||
result.MeterType = (MeterType)data[1];
|
||||
result.Calibration = (UInt16)(data[2] + 256 * data[3]);
|
||||
result.VolumeUnits = (VolumeUnits)data[4];
|
||||
result.FlowArrow = (FlowArrow)data[5];
|
||||
result.FWVersion = (UInt16)(data[6] + 256 * data[7]);
|
||||
result.TargetField[0] = (UInt16)(data[8] + 256 * data[9]);
|
||||
result.TargetField[1] = (UInt16)(data[10] + 256 * data[11]);
|
||||
result.TargetField[2] = (UInt16)(data[12] + 256 * data[13]);
|
||||
result.RecipMeanCurrent = (UInt16)(data[14] + 256 * data[15]);
|
||||
result.ThresholdVolume = (UInt16)(data[16] + 256 * data[17]);
|
||||
result.ThresholdTime = (UInt16)(data[18] + 256 * data[19]);
|
||||
result.FlowActivationThr = (UInt16)(data[20] + 256 * data[21]);
|
||||
result.VolumeArrowThr = (UInt16)(data[22] + 256 * data[23]);
|
||||
result.CalibrationTime = (((UInt32)data[27] * 256 + data[26]) * 256 + data[25]) * 256 + data[24];
|
||||
result.SerialNumber = ((((UInt64)data[32] * 256 + data[31]) * 256 + data[30]) * 256 + data[29]) * 256 + data[28];
|
||||
result.MeterSealed = (MeterSealed)data[33];
|
||||
result.CalibrationLNA = (UInt16)(data[34] + 256 * data[35]);
|
||||
result.CheckSum = data[36];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the calibration structure from an incomplete byte array
|
||||
/// </summary>
|
||||
/// <param name="data">Byte array data</param>
|
||||
/// <param name="offset">Offset of byte array data in CalibrationStructV2</param>
|
||||
/// <returns>true when successful, false when data are not appropriate</returns>
|
||||
public bool Update(byte[] data, int offset)
|
||||
{
|
||||
if ((data.Length == 2) && (offset == 2))
|
||||
{
|
||||
/// Data containing iPerl calibration factor
|
||||
Calibration = (UInt16)(data[0] + 256 * data[1]);
|
||||
return true;
|
||||
}
|
||||
else if ((data.Length == 2) && (offset == 34))
|
||||
{
|
||||
/// Data containing iPerl calibration factor
|
||||
CalibrationLNA = (UInt16)(data[0] + 256 * data[1]);
|
||||
return true;
|
||||
}
|
||||
else if ((data.Length == Length) && (offset == 0))
|
||||
{
|
||||
/// Data containing a complete CalibrationStruct
|
||||
Version = data[0];
|
||||
MeterType = (MeterType)data[1];
|
||||
Calibration = (UInt16)(data[2] + 256 * data[3]);
|
||||
VolumeUnits = (VolumeUnits)data[4];
|
||||
FlowArrow = (FlowArrow)data[5];
|
||||
FWVersion = (UInt16)(data[6] + 256 * data[7]);
|
||||
TargetField[0] = (UInt16)(data[8] + 256 * data[9]);
|
||||
TargetField[1] = (UInt16)(data[10] + 256 * data[11]);
|
||||
TargetField[2] = (UInt16)(data[12] + 256 * data[13]);
|
||||
RecipMeanCurrent = (UInt16)(data[14] + 256 * data[15]);
|
||||
ThresholdVolume = (UInt16)(data[16] + 256 * data[17]);
|
||||
ThresholdTime = (UInt16)(data[18] + 256 * data[19]);
|
||||
FlowActivationThr = (UInt16)(data[20] + 256 * data[21]);
|
||||
VolumeArrowThr = (UInt16)(data[22] + 256 * data[23]);
|
||||
CalibrationTime = (((UInt32)data[27] * 256 + data[26]) * 256 + data[25]) * 256 + data[24];
|
||||
SerialNumber = ((((UInt64)data[32] * 256 + data[31]) * 256 + data[30]) * 256 + data[29]) * 256 + data[28];
|
||||
MeterSealed = (MeterSealed)data[33];
|
||||
CalibrationLNA = (UInt16)(data[34] + 256 * data[35]);
|
||||
CheckSum = data[36];
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public string FWVersionStr()
|
||||
{
|
||||
int d1 = (FWVersion >> 8) & 0x000F;
|
||||
int d2 = (FWVersion >> 12) & 0x000F;
|
||||
int d3 = (FWVersion >> 4) & 0x000F;
|
||||
int d4 = FWVersion & 0x000F;
|
||||
return string.Format("{0}.{1}{2}{3}", d1, d2, d3, d4);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Calibration: V{0} Type={1} Cal={2} Units={3} FlowArrow.{4} FW={5} Hi={6} Norm={7} Low={8} RMC={9} ThrVol={10} ThrTime={11} FlActThr={12} VolArrThr={13} CalTm={14} SN={15} MeterSealed={16} CalLNA={17} Chksum={18}",
|
||||
Version,
|
||||
MeterType,
|
||||
Calibration,
|
||||
VolumeUnits,
|
||||
FlowArrow,
|
||||
FWVersion,
|
||||
TargetField[0],
|
||||
TargetField[1],
|
||||
TargetField[2],
|
||||
RecipMeanCurrent,
|
||||
ThresholdVolume,
|
||||
ThresholdTime,
|
||||
FlowActivationThr,
|
||||
VolumeArrowThr,
|
||||
CalibrationTime,
|
||||
SerialNumber,
|
||||
MeterSealed,
|
||||
CalibrationLNA,
|
||||
CheckSum.ToString("X2"));
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Version);
|
||||
writer.Write((byte)MeterType);
|
||||
writer.Write(Calibration);
|
||||
writer.Write((byte)VolumeUnits);
|
||||
writer.Write((byte)FlowArrow);
|
||||
writer.Write(FWVersion);
|
||||
writer.Write(TargetField[0]);
|
||||
writer.Write(TargetField[1]);
|
||||
writer.Write(TargetField[2]);
|
||||
writer.Write(RecipMeanCurrent);
|
||||
writer.Write(ThresholdVolume);
|
||||
writer.Write(ThresholdTime);
|
||||
writer.Write(FlowActivationThr);
|
||||
writer.Write(VolumeArrowThr);
|
||||
writer.Write(CalibrationTime);
|
||||
writer.Write(SerialNumber);
|
||||
writer.Write((byte)MeterSealed);
|
||||
writer.Write(CalibrationLNA);
|
||||
writer.Write(CheckSum);
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
Version = reader.ReadByte();
|
||||
MeterType = (MeterType)reader.ReadByte();
|
||||
Calibration = reader.ReadUInt16();
|
||||
VolumeUnits = (VolumeUnits)reader.ReadByte();
|
||||
FlowArrow = (FlowArrow)reader.ReadByte();
|
||||
FWVersion = reader.ReadUInt16();
|
||||
TargetField[0] = reader.ReadUInt16();
|
||||
TargetField[1] = reader.ReadUInt16();
|
||||
TargetField[2] = reader.ReadUInt16();
|
||||
RecipMeanCurrent = reader.ReadUInt16();
|
||||
ThresholdVolume = reader.ReadUInt16();
|
||||
ThresholdTime = reader.ReadUInt16();
|
||||
FlowActivationThr = reader.ReadUInt16();
|
||||
VolumeArrowThr = reader.ReadUInt16();
|
||||
CalibrationTime = reader.ReadUInt32();
|
||||
SerialNumber = reader.ReadUInt64();
|
||||
MeterSealed = (MeterSealed)reader.ReadByte();
|
||||
CalibrationLNA = reader.ReadUInt16();
|
||||
CheckSum = reader.ReadByte();
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -2,10 +2,11 @@
|
||||
/// Copyright (c) 2015-2019 Sensus Metering Systems
|
||||
/// Author: Milan Hanajík
|
||||
///
|
||||
using System;
|
||||
using TBF.Rig.Uni.SharedDialogs.iPerlCommunication;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication
|
||||
using System;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader.communication
|
||||
{
|
||||
public class CommCompletedEventArgs : EventArgs
|
||||
{
|
||||
@@ -0,0 +1,269 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2020 Sensus Metering Systems
|
||||
///
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.RegisterReaders.PoseidonReader.comminication;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader.communication
|
||||
{
|
||||
public class ConfigStruct
|
||||
{
|
||||
public const int Length = 32;
|
||||
|
||||
public Byte Version; /// 0: 1 byte
|
||||
public MeterState MeterState; /// 1: 1 byte
|
||||
public UInt32 TargetTimeVeryLowBatt; /// 2: 4 bytes in seconds
|
||||
public UInt32 TargetTimeLowBatt; /// 6: 4 bytes, in seconds
|
||||
public UInt32 TestModeTime; /// 10: 4 bytes, Max. test mode time in seconds
|
||||
public UInt16 EmptyPipeThreshold; /// 14: 2 bytes
|
||||
public byte[] PCBNumber; /// 16: 5 bytes
|
||||
public byte TestModeConfig; /// 21: 1 byte
|
||||
public UInt32 RadioAddress; /// 22: 4 bytes
|
||||
public UInt16 TempCalibration; /// 26: 2 bytes
|
||||
public UInt16 AlarmMask; /// 28: 2 bytes, Default 0xA3F7
|
||||
public UInt16 ConfigCheckSum; /// 30: 2 bytes
|
||||
|
||||
public ConfigStruct()
|
||||
{
|
||||
PCBNumber = new byte[5];
|
||||
}
|
||||
|
||||
public byte[] ToByteArray()
|
||||
{
|
||||
byte[] result = new byte[Length];
|
||||
|
||||
result[0] = Version;
|
||||
result[1] = (byte)MeterState;
|
||||
|
||||
result[2] = (byte)(TargetTimeVeryLowBatt & 0x000000FF);
|
||||
result[3] = (byte)((TargetTimeVeryLowBatt >> 8) & 0x000000FF);
|
||||
result[4] = (byte)((TargetTimeVeryLowBatt >> 16) & 0x000000FF);
|
||||
result[5] = (byte)((TargetTimeVeryLowBatt >> 24) & 0x000000FF);
|
||||
|
||||
result[6] = (byte)(TargetTimeLowBatt & 0x000000FF);
|
||||
result[7] = (byte)((TargetTimeLowBatt >> 8) & 0x000000FF);
|
||||
result[8] = (byte)((TargetTimeLowBatt >> 16) & 0x000000FF);
|
||||
result[9] = (byte)((TargetTimeLowBatt >> 24) & 0x000000FF);
|
||||
|
||||
result[10] = (byte)(TestModeTime & 0x000000FF);
|
||||
result[11] = (byte)((TestModeTime >> 8) & 0x000000FF);
|
||||
result[12] = (byte)((TestModeTime >> 16) & 0x000000FF);
|
||||
result[13] = (byte)((TestModeTime >> 24) & 0x000000FF);
|
||||
|
||||
result[14] = (byte)(EmptyPipeThreshold & 0x00FF);
|
||||
result[15] = (byte)((EmptyPipeThreshold >> 8) & 0x00FF);
|
||||
|
||||
result[16] = PCBNumber[0];
|
||||
result[17] = PCBNumber[1];
|
||||
result[18] = PCBNumber[2];
|
||||
result[19] = PCBNumber[3];
|
||||
result[20] = PCBNumber[4];
|
||||
|
||||
result[21] = TestModeConfig;
|
||||
|
||||
result[22] = (byte)(RadioAddress & 0x000000FF);
|
||||
result[23] = (byte)((RadioAddress >> 8) & 0x000000FF);
|
||||
result[24] = (byte)((RadioAddress >> 16) & 0x000000FF);
|
||||
result[25] = (byte)((RadioAddress >> 24) & 0x000000FF);
|
||||
|
||||
result[26] = (byte)(TempCalibration & 0x00FF);
|
||||
result[27] = (byte)((TempCalibration >> 8) & 0x00FF);
|
||||
|
||||
result[28] = (byte)(AlarmMask & 0x00FF);
|
||||
result[29] = (byte)((AlarmMask >> 8) & 0x00FF);
|
||||
|
||||
result[30] = (byte)(ConfigCheckSum & 0x00FF);
|
||||
result[31] = (byte)((ConfigCheckSum >> 8) & 0x00FF);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a configuration structure from a complete byte array
|
||||
/// </summary>
|
||||
/// <param name="data">A complete byte array data</param>
|
||||
/// <returns>ConfigStruct or null when byte array was not complete</returns>
|
||||
public static ConfigStruct FromByteArray(byte[] data)
|
||||
{
|
||||
if (data.Length != Length) return null;
|
||||
|
||||
ConfigStruct result = new ConfigStruct();
|
||||
|
||||
result.Version = data[0];
|
||||
result.MeterState = (MeterState)data[1];
|
||||
result.TargetTimeVeryLowBatt = (((UInt32)data[5] * 256 + data[4]) * 256 + data[3]) * 256 + data[2];
|
||||
result.TargetTimeLowBatt = (((UInt32)data[9] * 256 + data[8]) * 256 + data[7]) * 256 + data[6];
|
||||
result.TestModeTime = (((UInt32)data[13] * 256 + data[12]) * 256 + data[11]) * 256 + data[10];
|
||||
result.EmptyPipeThreshold = (UInt16)(data[15] * 256 + data[14]);
|
||||
result.PCBNumber[0] = data[16];
|
||||
result.PCBNumber[1] = data[17];
|
||||
result.PCBNumber[2] = data[18];
|
||||
result.PCBNumber[3] = data[19];
|
||||
result.PCBNumber[4] = data[20];
|
||||
result.TestModeConfig = data[21];
|
||||
result.RadioAddress = (((UInt32)data[25] * 256 + data[24]) * 256 + data[23]) * 256 + data[22];
|
||||
result.TempCalibration = (UInt16)(data[27] * 256 + data[26]);
|
||||
result.AlarmMask = (UInt16)(data[29] * 256 + data[28]);
|
||||
result.ConfigCheckSum = (UInt16)(data[31] * 256 + data[30]);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the configuration structure from an incomplete byte array
|
||||
/// </summary>
|
||||
/// <param name="offset">Offset of byte array data in ConfigStruct</param>
|
||||
/// <param name="data">Byte array data</param>
|
||||
/// <returns>true when successful, false when data are not appropriate</returns>
|
||||
public bool Update(int offset, byte[] data)
|
||||
{
|
||||
if (offset == 0 && data.Length == 2)
|
||||
{
|
||||
/// iPerl mode of function
|
||||
Version = data[0];
|
||||
MeterState = (MeterState)data[1];
|
||||
return true;
|
||||
}
|
||||
else if (offset == 0 && data.Length == 4)
|
||||
{
|
||||
/// iPerl mode of function and extra 2 bytes
|
||||
Version = data[0];
|
||||
MeterState = (MeterState)data[1];
|
||||
return true;
|
||||
}
|
||||
else if (offset == 21 && data.Length == 1)
|
||||
{
|
||||
/// TestModeConfig value
|
||||
TestModeConfig = data[21 - offset];
|
||||
return true;
|
||||
}
|
||||
else if (offset == 0 && data.Length == Length)
|
||||
{
|
||||
/// Complete ConfigStruct
|
||||
Version = data[0];
|
||||
MeterState = (MeterState)data[1];
|
||||
TargetTimeVeryLowBatt = (((UInt32)data[5] * 256 + data[4]) * 256 + data[3]) * 256 + data[2];
|
||||
TargetTimeLowBatt = (((UInt32)data[9] * 256 + data[8]) * 256 + data[7]) * 256 + data[6];
|
||||
TestModeTime = (((UInt32)data[13] * 256 + data[12]) * 256 + data[11]) * 256 + data[10];
|
||||
EmptyPipeThreshold = (UInt16)(data[15] * 256 + data[14]);
|
||||
PCBNumber[0] = data[16];
|
||||
PCBNumber[1] = data[17];
|
||||
PCBNumber[2] = data[18];
|
||||
PCBNumber[3] = data[19];
|
||||
PCBNumber[4] = data[20];
|
||||
TestModeConfig = data[21];
|
||||
RadioAddress = (((UInt32)data[25] * 256 + data[24]) * 256 + data[23]) * 256 + data[22];
|
||||
TempCalibration = (UInt16)(data[27] * 256 + data[26]);
|
||||
AlarmMask = (UInt16)(data[29] * 256 + data[28]);
|
||||
ConfigCheckSum = (UInt16)(data[31] * 256 + data[30]);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns PCB number string (12 characters, 12 decimal digits)
|
||||
/// </summary>
|
||||
/// <returns>PCB number STRING</returns>
|
||||
public string GetPcbNrString()
|
||||
{
|
||||
return PCBNumber2String(this.PCBNumber);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts PCBNumber to string (12 characters, 12 decimal digits)
|
||||
/// </summary>
|
||||
/// <param name="pcbNumber"></param>
|
||||
/// <returns>PCB number string</returns>
|
||||
public static string PCBNumber2String(byte[] pcbNumber)
|
||||
{
|
||||
if (pcbNumber.Length != 5) return string.Empty;
|
||||
|
||||
Int64 number = 0;
|
||||
for (int i = 4; i >= 0; i--)
|
||||
{
|
||||
number = 256 * number + (Int64)pcbNumber[i];
|
||||
}
|
||||
|
||||
return number.ToString();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("Config: V{0} State={1} VLoBattT={2}s LoBattT={3}s TestModeT={4}s EPThld={5} PCB#={6} TMCfg={7} RadioAddr={8} TempCalib={9} AlarmMask={10} CfgCheckSum={11}",
|
||||
Version,
|
||||
MeterState,
|
||||
TargetTimeVeryLowBatt,
|
||||
TargetTimeLowBatt,
|
||||
TestModeTime,
|
||||
EmptyPipeThreshold,
|
||||
GetPcbNrString(),
|
||||
TestModeConfig.ToString("X2"),
|
||||
RadioAddress,
|
||||
TempCalibration,
|
||||
AlarmMask.ToString("X4"),
|
||||
ConfigCheckSum.ToString("X4"));
|
||||
}
|
||||
|
||||
public string ToString(int sel)
|
||||
{
|
||||
return string.Format("{1} PCB#={6} TMCfg={7}",
|
||||
Version,
|
||||
MeterState,
|
||||
TargetTimeVeryLowBatt,
|
||||
TargetTimeLowBatt,
|
||||
TestModeTime,
|
||||
EmptyPipeThreshold,
|
||||
GetPcbNrString(),
|
||||
TestModeConfig.ToString("X2"),
|
||||
RadioAddress,
|
||||
TempCalibration,
|
||||
AlarmMask.ToString("X4"),
|
||||
ConfigCheckSum.ToString("X4"));
|
||||
}
|
||||
|
||||
public virtual void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(Version);
|
||||
writer.Write((byte)MeterState);
|
||||
writer.Write(TargetTimeVeryLowBatt);
|
||||
writer.Write(TargetTimeLowBatt);
|
||||
writer.Write(TestModeTime);
|
||||
writer.Write(EmptyPipeThreshold);
|
||||
writer.Write(PCBNumber[0]);
|
||||
writer.Write(PCBNumber[1]);
|
||||
writer.Write(PCBNumber[2]);
|
||||
writer.Write(PCBNumber[3]);
|
||||
writer.Write(PCBNumber[4]);
|
||||
writer.Write(TestModeConfig);
|
||||
writer.Write(RadioAddress);
|
||||
writer.Write(TempCalibration);
|
||||
writer.Write(AlarmMask);
|
||||
writer.Write(ConfigCheckSum);
|
||||
}
|
||||
|
||||
public virtual void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
Version = reader.ReadByte();
|
||||
MeterState = (MeterState)reader.ReadByte();
|
||||
TargetTimeVeryLowBatt = reader.ReadUInt32();
|
||||
TargetTimeLowBatt = reader.ReadUInt32();
|
||||
TestModeTime = reader.ReadUInt32();
|
||||
EmptyPipeThreshold = reader.ReadUInt16();
|
||||
PCBNumber[0] = reader.ReadByte();
|
||||
PCBNumber[1] = reader.ReadByte();
|
||||
PCBNumber[2] = reader.ReadByte();
|
||||
PCBNumber[3] = reader.ReadByte();
|
||||
PCBNumber[4] = reader.ReadByte();
|
||||
TestModeConfig = reader.ReadByte();
|
||||
RadioAddress = reader.ReadUInt32();
|
||||
TempCalibration = reader.ReadUInt16();
|
||||
AlarmMask = reader.ReadUInt16();
|
||||
ConfigCheckSum = reader.ReadUInt16();
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -1,14 +1,13 @@
|
||||
using log4net;
|
||||
using Sensus.iPerl.NfcHandler;
|
||||
using Sensus.iPerl.RfidCom.Exceptions;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
using log4net;
|
||||
using Sensus.iPerl.NfcHandler;
|
||||
using Sensus.iPerl.RfidCom.Exceptions;
|
||||
using static Sensus.iPerl.NfcHandler.MCI_Protocol;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader.communication
|
||||
{
|
||||
internal class NfcServices
|
||||
{
|
||||
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using Config.Resources;
|
||||
using log4net;
|
||||
using Sensus.iPerl.RfidCom.Helper;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
using static Sensus.iPerl.NfcHandler.MCI_Protocol;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader.communication
|
||||
{
|
||||
internal class OpticalHeadTest
|
||||
{
|
||||
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||
|
||||
internal static string OpenSealing(IPerlReader iHead)
|
||||
{
|
||||
if (RfidCommands.OpenSealing($"COM{iHead.RfidComPortNr}")) return "OK";
|
||||
return "Error Open Sealing";
|
||||
}
|
||||
|
||||
internal static string ReadRequest_PCB(IPerlReader iHead)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] pcb = null;
|
||||
int readRetVal = IPerlCorrections.ReadRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, CommonRR.MessageID.Configuration, Sensus.iPerl.NfcHandler.MCI_Protocol.StructName.Configuration, 16, 5, out pcb);
|
||||
if (readRetVal == 0)
|
||||
{
|
||||
return RfidHelper.HexLiteral2Unsigned(RfidHelper.SwapHexcode(BitConverter.ToString(pcb).Replace("-", string.Empty))).ToString();
|
||||
}
|
||||
rfidDataLogger.Error($"COM{iHead.RfidComPortNr}: ReadRequest_PCB ({CommonRR.MessageID.Configuration},16,5...) <- Error: {readRetVal}");
|
||||
return "Error";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return (ex.Message.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
internal static string SetActiveMode(IPerlReader iHead)
|
||||
{
|
||||
byte[] cmd = new byte[1] { (byte)CommonRR.Command.SetActiveMode };
|
||||
if (0 == IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, CommonRR.MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Error Set Active Mode";
|
||||
}
|
||||
}
|
||||
|
||||
internal static string SetTestMode(IPerlReader iHead)
|
||||
{
|
||||
byte[] cmd = new byte[1] { (byte)CommonRR.Command.SetTestMode };
|
||||
if (0 == IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, CommonRR.MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Error Set Test Mode";
|
||||
}
|
||||
}
|
||||
|
||||
#if IPERL
|
||||
internal static string TurnOffRadio(IPerlReader iHead)
|
||||
{
|
||||
try
|
||||
{
|
||||
int retValue = IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, MessageID.RadioPassthrough, StructName.RadioParams, 0x1898, 1, new byte[] { (byte)3 }); // WakeUpInterval
|
||||
return 0 == retValue ? "OK" : "Error";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return (ex.Message.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
internal static string SetProductionMode(IPerlReader iHead)
|
||||
{
|
||||
try
|
||||
{
|
||||
int retValue = IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, MessageID.RadioPassthrough, StructName.RadioInfo, 0x1804, 1, new byte[] { (byte)1 }); // System Status
|
||||
return 0 == retValue ? "OK" : "Error";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return (ex.Message.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
internal static string WriteRequestPort_u8_Customer_Text(IPerlReader iHead)
|
||||
{
|
||||
string custText = "FF0123456789ABCDEF"; // Sample text to test write function
|
||||
/*try
|
||||
{
|
||||
byte[] cmd = RfidHelper.HexStringToByteArray(custText);
|
||||
if (0 == iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.RadioPassthrough, Sensus.iPerl.NfcHandler.MCI_Protocol.StructName.RadioParams, 0x1899, 9, cmd))
|
||||
{
|
||||
RfidCommunicationService rfidCommunicationService = new RfidCommunicationService { ComPort = $"COM{iHead.RfidComPortNr}", WaitTimeAfterFailure = 2200, PassThroughWaitTime = 1500, MaxRetries = 3, TimeOut = 5000 };
|
||||
//rfidCommunicationService.RfidWrite(Params.u8_Customer_Text, custText);
|
||||
return rfidCommunicationService.RfidRead<string>(Params.u8_Customer_Text).ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return (ex.Message.ToString());
|
||||
}*/
|
||||
return $"Error COM{iHead.RfidComPortNr}";
|
||||
}
|
||||
|
||||
internal static string SetRfidMode(IPerlReader iHead)
|
||||
{
|
||||
iHead.SetRfidInterface();
|
||||
iHead.SetCommunicationInterface(CommunicationInterface.RFID);
|
||||
return ($"OK - {Strings.Program_restart_is_required_to_apply_some_settings}");
|
||||
}
|
||||
|
||||
internal static string SetNfcMode(IPerlReader iHead)
|
||||
{
|
||||
iHead.SetNfcInterface();
|
||||
iHead.SetCommunicationInterface(CommunicationInterface.NFC);
|
||||
return ($"OK - {Strings.Program_restart_is_required_to_apply_some_settings}");
|
||||
}
|
||||
#endif /// IPERL
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
///
|
||||
|
||||
using System;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader.communication
|
||||
{
|
||||
public class OptoReceivedEventArgs : EventArgs
|
||||
{
|
||||
public string Data;
|
||||
|
||||
public OptoReceivedEventArgs(string data)
|
||||
{
|
||||
this.Data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,20 +1,20 @@
|
||||
using Sensus.iPerl.RfidCom.Exceptions;
|
||||
using Sensus.iPerl.RfidCom.Helper;
|
||||
using Sensus.iPerl.RfidCom;
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using TBF.Rig.Uni.SharedDialogs.iPerlCommunication;
|
||||
using static TBF.Rig.Uni.SharedDialogs.iPerlCommunication.iPerlCommunicationForm;
|
||||
using Sensus.iPerl.RfidCom;
|
||||
using Sensus.iPerl.RfidCom.Exceptions;
|
||||
using Sensus.iPerl.RfidCom.Helper;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader.comminication
|
||||
{
|
||||
internal class RfidServices
|
||||
{
|
||||
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(iPerlCommunicationForm));
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(SmartCommunicationForm));
|
||||
|
||||
internal static int ReadRequest(TestMethodCfg cfg, IPerlReader iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
|
||||
{
|
||||
+5
-2
@@ -1,11 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl.communication;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication
|
||||
namespace TBF.Rig.RegisterReaders.PoseidonReader.comminication
|
||||
{
|
||||
internal class SimulationServices
|
||||
{
|
||||
const int Q2CorrFactorsAddr = Uni.SharedDialogs.iPerlCommunication.iPerlCommunicationConstants.Q2CorrFactorsAddr;
|
||||
const int Q2CorrFactorsAddr = iPerlCommunicationConstants.Q2CorrFactorsAddr;
|
||||
|
||||
internal static int ReadRequest(IPerlReader iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
|
||||
{
|
||||
@@ -3,7 +3,7 @@ using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
@@ -14,7 +14,7 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
public IComponentCfgCtrl GetControl(IList<Component> cmpntEntities)
|
||||
{
|
||||
return new IPerlCfgCtrl();
|
||||
return new RegisterReaders.iPerlReaderUNI.IPerlUniCfgCtrl();
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,163 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
using Common;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Resources;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
{
|
||||
public partial class IPerlUniCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
IPerlCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as IPerlCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public IPerlUniCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void WaterMeterCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
nameLabel.Text = Strings.Name;
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
nameTextBox.Text = config.Name;
|
||||
radioButton1.Checked = config.UseTcpIP;
|
||||
radioButton2.Checked = !config.UseTcpIP;
|
||||
ipAddressTextBox.Text = (config.OptoIPAddress != null) ? config.OptoIPAddress : "0.0.0.0";
|
||||
tcpipPortTextBox.Text = config.OptoTcpipPortNr.ToString();
|
||||
headPortNrTextBox.Text = config.HeadCommunicationComPortNr.ToString();
|
||||
optoSerialPortTextBox.Text = config.OptoComPortNr.ToString();
|
||||
rfidPortNrTextBox.Text = config.RfidComPortNr.ToString();
|
||||
muxBoardNrTextBox.Text = config.MuxBoardNr.ToString();
|
||||
groupTextBox.Text = config.Group.ToString();
|
||||
comboBoxCommunicationInterface.SelectedItem = config.CommunicationInterface.ToString();
|
||||
tabPage2.Controls.Add(new IperlUniHeadTestCtrl(config));
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
radioButton1.Enabled = true;
|
||||
radioButton2.Enabled = true;
|
||||
ipAddressTextBox.Enabled = true;
|
||||
tcpipPortTextBox.Enabled = true;
|
||||
optoSerialPortTextBox.Enabled = true;
|
||||
rfidPortNrTextBox.Enabled = true;
|
||||
headPortNrTextBox.Enabled = true;
|
||||
muxBoardNrTextBox.Enabled = true;
|
||||
groupTextBox.Enabled = true;
|
||||
comboBoxCommunicationInterface.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
int dummy;
|
||||
if (radioButton1.Checked)
|
||||
{
|
||||
IPAddress dummyIPAddress;
|
||||
if (!IPAddress.TryParse(ipAddressTextBox.Text, out dummyIPAddress))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'IP address' is not valid";
|
||||
}
|
||||
|
||||
ushort sdummy;
|
||||
if (!ushort.TryParse(tcpipPortTextBox.Text, out sdummy))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'TCP/IP port nr.' is not valid";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!int.TryParse(optoSerialPortTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Opto serial port nr.' is not valid";
|
||||
}
|
||||
}
|
||||
|
||||
if (!int.TryParse(rfidPortNrTextBox.Text, out dummy) || dummy < 0 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'RFID serial port nr.' is not valid";
|
||||
}
|
||||
|
||||
if (!int.TryParse(headPortNrTextBox.Text, out dummy) || dummy < 0 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Head communication serial port nr.' is not valid";
|
||||
}
|
||||
|
||||
if (!int.TryParse(muxBoardNrTextBox.Text, out dummy) || dummy < 1 || dummy > 4)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + string.Format(Strings.Invalid_0, muxBoardNrLabel.Text);
|
||||
}
|
||||
|
||||
if (!int.TryParse(groupTextBox.Text, out dummy) || dummy < 1 || dummy > 10)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + string.Format(Strings.Invalid_0, groupLabel.Text);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
||||
|
||||
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
||||
|
||||
config.Name = nameTextBox.Text;
|
||||
|
||||
if (radioButton1.Checked)
|
||||
{
|
||||
config.UseTcpIP = true;
|
||||
config.OptoIPAddress = ipAddressTextBox.Text;
|
||||
config.OptoTcpipPortNr = ushort.Parse(tcpipPortTextBox.Text);
|
||||
}
|
||||
else
|
||||
{
|
||||
config.UseTcpIP = false;
|
||||
config.OptoComPortNr = int.Parse(optoSerialPortTextBox.Text);
|
||||
}
|
||||
|
||||
config.RfidComPortNr = int.Parse(rfidPortNrTextBox.Text);
|
||||
config.MuxBoardNr = int.Parse(muxBoardNrTextBox.Text);
|
||||
config.Group = int.Parse(groupTextBox.Text);
|
||||
config.CommunicationInterface = (CommunicationInterface)comboBoxCommunicationInterface.SelectedIndex;
|
||||
config.HeadCommunicationComPortNr = int.Parse(headPortNrTextBox.Text);
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2017 Sensus Metering Systems
|
||||
///
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
{
|
||||
partial class IPerlUniCfgCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.comboBoxCommunicationInterface = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.rfidPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.rfidSerialPortNrLabel = new System.Windows.Forms.Label();
|
||||
this.optoDataGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.tcpipPortLabel = new System.Windows.Forms.Label();
|
||||
this.tcpipPortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ipAddressLabel = new System.Windows.Forms.Label();
|
||||
this.ipAddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.radioButton1 = new System.Windows.Forms.RadioButton();
|
||||
this.radioButton2 = new System.Windows.Forms.RadioButton();
|
||||
this.optoSerialPortLabel = new System.Windows.Forms.Label();
|
||||
this.optoSerialPortTextBox = new System.Windows.Forms.TextBox();
|
||||
this.groupTextBox = new System.Windows.Forms.TextBox();
|
||||
this.groupLabel = new System.Windows.Forms.Label();
|
||||
this.muxBoardNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.muxBoardNrLabel = new System.Windows.Forms.Label();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.headPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.tabControl1.SuspendLayout();
|
||||
this.tabPage1.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.optoDataGroupBox.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Controls.Add(this.tabPage1);
|
||||
this.tabControl1.Controls.Add(this.tabPage2);
|
||||
this.tabControl1.Location = new System.Drawing.Point(3, 3);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(611, 432);
|
||||
this.tabControl1.TabIndex = 0;
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.groupBox2);
|
||||
this.tabPage1.Controls.Add(this.label4);
|
||||
this.tabPage1.Controls.Add(this.label3);
|
||||
this.tabPage1.Controls.Add(this.groupBox1);
|
||||
this.tabPage1.Controls.Add(this.optoDataGroupBox);
|
||||
this.tabPage1.Controls.Add(this.groupTextBox);
|
||||
this.tabPage1.Controls.Add(this.groupLabel);
|
||||
this.tabPage1.Controls.Add(this.muxBoardNrTextBox);
|
||||
this.tabPage1.Controls.Add(this.muxBoardNrLabel);
|
||||
this.tabPage1.Controls.Add(this.nameTextBox);
|
||||
this.tabPage1.Controls.Add(this.nameLabel);
|
||||
this.tabPage1.Controls.Add(this.classNameLabel);
|
||||
this.tabPage1.Location = new System.Drawing.Point(4, 25);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage1.Size = new System.Drawing.Size(603, 403);
|
||||
this.tabPage1.TabIndex = 0;
|
||||
this.tabPage1.Text = "Config";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(208, 101);
|
||||
this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(40, 16);
|
||||
this.label4.TabIndex = 25;
|
||||
this.label4.Text = "1 .. 10";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(208, 72);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(33, 16);
|
||||
this.label3.TabIndex = 24;
|
||||
this.label3.Text = "1 .. 4";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.comboBoxCommunicationInterface);
|
||||
this.groupBox1.Controls.Add(this.label1);
|
||||
this.groupBox1.Controls.Add(this.rfidPortNrTextBox);
|
||||
this.groupBox1.Controls.Add(this.rfidSerialPortNrLabel);
|
||||
this.groupBox1.Location = new System.Drawing.Point(10, 259);
|
||||
this.groupBox1.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Padding = new System.Windows.Forms.Padding(4);
|
||||
this.groupBox1.Size = new System.Drawing.Size(552, 68);
|
||||
this.groupBox1.TabIndex = 23;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "RFID / NFC communication (in case mux. board is not used)";
|
||||
//
|
||||
// comboBoxCommunicationInterface
|
||||
//
|
||||
this.comboBoxCommunicationInterface.Enabled = false;
|
||||
this.comboBoxCommunicationInterface.FormattingEnabled = true;
|
||||
this.comboBoxCommunicationInterface.Items.AddRange(new object[] {
|
||||
"RFID",
|
||||
"NFC"});
|
||||
this.comboBoxCommunicationInterface.Location = new System.Drawing.Point(201, 27);
|
||||
this.comboBoxCommunicationInterface.Name = "comboBoxCommunicationInterface";
|
||||
this.comboBoxCommunicationInterface.Size = new System.Drawing.Size(71, 24);
|
||||
this.comboBoxCommunicationInterface.TabIndex = 9;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(41, 30);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(153, 16);
|
||||
this.label1.TabIndex = 8;
|
||||
this.label1.Text = "Communication Interface";
|
||||
//
|
||||
// rfidPortNrTextBox
|
||||
//
|
||||
this.rfidPortNrTextBox.Enabled = false;
|
||||
this.rfidPortNrTextBox.Location = new System.Drawing.Point(439, 26);
|
||||
this.rfidPortNrTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.rfidPortNrTextBox.Name = "rfidPortNrTextBox";
|
||||
this.rfidPortNrTextBox.Size = new System.Drawing.Size(44, 22);
|
||||
this.rfidPortNrTextBox.TabIndex = 7;
|
||||
//
|
||||
// rfidSerialPortNrLabel
|
||||
//
|
||||
this.rfidSerialPortNrLabel.AutoSize = true;
|
||||
this.rfidSerialPortNrLabel.Location = new System.Drawing.Point(321, 30);
|
||||
this.rfidSerialPortNrLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.rfidSerialPortNrLabel.Name = "rfidSerialPortNrLabel";
|
||||
this.rfidSerialPortNrLabel.Size = new System.Drawing.Size(88, 16);
|
||||
this.rfidSerialPortNrLabel.TabIndex = 6;
|
||||
this.rfidSerialPortNrLabel.Text = "Serial port nr.:";
|
||||
//
|
||||
// optoDataGroupBox
|
||||
//
|
||||
this.optoDataGroupBox.Controls.Add(this.tcpipPortLabel);
|
||||
this.optoDataGroupBox.Controls.Add(this.tcpipPortTextBox);
|
||||
this.optoDataGroupBox.Controls.Add(this.ipAddressLabel);
|
||||
this.optoDataGroupBox.Controls.Add(this.ipAddressTextBox);
|
||||
this.optoDataGroupBox.Controls.Add(this.radioButton1);
|
||||
this.optoDataGroupBox.Controls.Add(this.radioButton2);
|
||||
this.optoDataGroupBox.Controls.Add(this.optoSerialPortLabel);
|
||||
this.optoDataGroupBox.Controls.Add(this.optoSerialPortTextBox);
|
||||
this.optoDataGroupBox.Location = new System.Drawing.Point(10, 131);
|
||||
this.optoDataGroupBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.optoDataGroupBox.Name = "optoDataGroupBox";
|
||||
this.optoDataGroupBox.Padding = new System.Windows.Forms.Padding(4);
|
||||
this.optoDataGroupBox.Size = new System.Drawing.Size(552, 119);
|
||||
this.optoDataGroupBox.TabIndex = 18;
|
||||
this.optoDataGroupBox.TabStop = false;
|
||||
this.optoDataGroupBox.Text = "Opto-data";
|
||||
//
|
||||
// tcpipPortLabel
|
||||
//
|
||||
this.tcpipPortLabel.AutoSize = true;
|
||||
this.tcpipPortLabel.Location = new System.Drawing.Point(41, 87);
|
||||
this.tcpipPortLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.tcpipPortLabel.Name = "tcpipPortLabel";
|
||||
this.tcpipPortLabel.Size = new System.Drawing.Size(54, 16);
|
||||
this.tcpipPortLabel.TabIndex = 4;
|
||||
this.tcpipPortLabel.Text = "Port nr..:";
|
||||
//
|
||||
// tcpipPortTextBox
|
||||
//
|
||||
this.tcpipPortTextBox.Enabled = false;
|
||||
this.tcpipPortTextBox.Location = new System.Drawing.Point(143, 84);
|
||||
this.tcpipPortTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.tcpipPortTextBox.Name = "tcpipPortTextBox";
|
||||
this.tcpipPortTextBox.Size = new System.Drawing.Size(51, 22);
|
||||
this.tcpipPortTextBox.TabIndex = 5;
|
||||
//
|
||||
// ipAddressLabel
|
||||
//
|
||||
this.ipAddressLabel.AutoSize = true;
|
||||
this.ipAddressLabel.Location = new System.Drawing.Point(41, 59);
|
||||
this.ipAddressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.ipAddressLabel.Name = "ipAddressLabel";
|
||||
this.ipAddressLabel.Size = new System.Drawing.Size(78, 16);
|
||||
this.ipAddressLabel.TabIndex = 2;
|
||||
this.ipAddressLabel.Text = "IP address.:";
|
||||
//
|
||||
// ipAddressTextBox
|
||||
//
|
||||
this.ipAddressTextBox.Enabled = false;
|
||||
this.ipAddressTextBox.Location = new System.Drawing.Point(143, 55);
|
||||
this.ipAddressTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.ipAddressTextBox.Name = "ipAddressTextBox";
|
||||
this.ipAddressTextBox.Size = new System.Drawing.Size(129, 22);
|
||||
this.ipAddressTextBox.TabIndex = 3;
|
||||
//
|
||||
// radioButton1
|
||||
//
|
||||
this.radioButton1.AutoSize = true;
|
||||
this.radioButton1.Checked = true;
|
||||
this.radioButton1.Enabled = false;
|
||||
this.radioButton1.Location = new System.Drawing.Point(29, 23);
|
||||
this.radioButton1.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.radioButton1.Name = "radioButton1";
|
||||
this.radioButton1.Size = new System.Drawing.Size(99, 20);
|
||||
this.radioButton1.TabIndex = 0;
|
||||
this.radioButton1.TabStop = true;
|
||||
this.radioButton1.Text = "Use TCP/IP";
|
||||
this.radioButton1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// radioButton2
|
||||
//
|
||||
this.radioButton2.AutoSize = true;
|
||||
this.radioButton2.Enabled = false;
|
||||
this.radioButton2.Location = new System.Drawing.Point(312, 23);
|
||||
this.radioButton2.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.radioButton2.Name = "radioButton2";
|
||||
this.radioButton2.Size = new System.Drawing.Size(115, 20);
|
||||
this.radioButton2.TabIndex = 1;
|
||||
this.radioButton2.Text = "Use serial port";
|
||||
this.radioButton2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// optoSerialPortLabel
|
||||
//
|
||||
this.optoSerialPortLabel.AutoSize = true;
|
||||
this.optoSerialPortLabel.Location = new System.Drawing.Point(321, 55);
|
||||
this.optoSerialPortLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.optoSerialPortLabel.Name = "optoSerialPortLabel";
|
||||
this.optoSerialPortLabel.Size = new System.Drawing.Size(88, 16);
|
||||
this.optoSerialPortLabel.TabIndex = 6;
|
||||
this.optoSerialPortLabel.Text = "Serial port nr.:";
|
||||
//
|
||||
// optoSerialPortTextBox
|
||||
//
|
||||
this.optoSerialPortTextBox.Enabled = false;
|
||||
this.optoSerialPortTextBox.Location = new System.Drawing.Point(439, 52);
|
||||
this.optoSerialPortTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.optoSerialPortTextBox.Name = "optoSerialPortTextBox";
|
||||
this.optoSerialPortTextBox.Size = new System.Drawing.Size(44, 22);
|
||||
this.optoSerialPortTextBox.TabIndex = 7;
|
||||
//
|
||||
// groupTextBox
|
||||
//
|
||||
this.groupTextBox.Enabled = false;
|
||||
this.groupTextBox.Location = new System.Drawing.Point(153, 97);
|
||||
this.groupTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.groupTextBox.Name = "groupTextBox";
|
||||
this.groupTextBox.Size = new System.Drawing.Size(44, 22);
|
||||
this.groupTextBox.TabIndex = 22;
|
||||
//
|
||||
// groupLabel
|
||||
//
|
||||
this.groupLabel.AutoSize = true;
|
||||
this.groupLabel.Location = new System.Drawing.Point(6, 101);
|
||||
this.groupLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.groupLabel.Name = "groupLabel";
|
||||
this.groupLabel.Size = new System.Drawing.Size(54, 16);
|
||||
this.groupLabel.TabIndex = 21;
|
||||
this.groupLabel.Text = "Group 2";
|
||||
//
|
||||
// muxBoardNrTextBox
|
||||
//
|
||||
this.muxBoardNrTextBox.Enabled = false;
|
||||
this.muxBoardNrTextBox.Location = new System.Drawing.Point(153, 69);
|
||||
this.muxBoardNrTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.muxBoardNrTextBox.Name = "muxBoardNrTextBox";
|
||||
this.muxBoardNrTextBox.Size = new System.Drawing.Size(44, 22);
|
||||
this.muxBoardNrTextBox.TabIndex = 20;
|
||||
//
|
||||
// muxBoardNrLabel
|
||||
//
|
||||
this.muxBoardNrLabel.AutoSize = true;
|
||||
this.muxBoardNrLabel.Location = new System.Drawing.Point(6, 72);
|
||||
this.muxBoardNrLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.muxBoardNrLabel.Name = "muxBoardNrLabel";
|
||||
this.muxBoardNrLabel.Size = new System.Drawing.Size(131, 16);
|
||||
this.muxBoardNrLabel.TabIndex = 19;
|
||||
this.muxBoardNrLabel.Text = "Group 1 (mux. board)";
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(153, 40);
|
||||
this.nameTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(160, 22);
|
||||
this.nameTextBox.TabIndex = 17;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(6, 44);
|
||||
this.nameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(44, 16);
|
||||
this.nameLabel.TabIndex = 16;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(149, 11);
|
||||
this.classNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(78, 16);
|
||||
this.classNameLabel.TabIndex = 15;
|
||||
this.classNameLabel.Text = "ClassName";
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 25);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(603, 403);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Test";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.headPortNrTextBox);
|
||||
this.groupBox2.Controls.Add(this.label2);
|
||||
this.groupBox2.Location = new System.Drawing.Point(10, 335);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(552, 50);
|
||||
this.groupBox2.TabIndex = 26;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Head Communication";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(321, 18);
|
||||
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(88, 16);
|
||||
this.label2.TabIndex = 7;
|
||||
this.label2.Text = "Serial port nr.:";
|
||||
//
|
||||
// headPortNrTextBox
|
||||
//
|
||||
this.headPortNrTextBox.Enabled = false;
|
||||
this.headPortNrTextBox.Location = new System.Drawing.Point(439, 15);
|
||||
this.headPortNrTextBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.headPortNrTextBox.Name = "headPortNrTextBox";
|
||||
this.headPortNrTextBox.Size = new System.Drawing.Size(44, 22);
|
||||
this.headPortNrTextBox.TabIndex = 8;
|
||||
//
|
||||
// IperlHeadCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.tabControl1);
|
||||
this.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.Name = "IPerlUniCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(617, 438);
|
||||
this.Load += new System.EventHandler(this.WaterMeterCfgCtrl_Load);
|
||||
this.tabControl1.ResumeLayout(false);
|
||||
this.tabPage1.ResumeLayout(false);
|
||||
this.tabPage1.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.optoDataGroupBox.ResumeLayout(false);
|
||||
this.optoDataGroupBox.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl tabControl1;
|
||||
private System.Windows.Forms.TabPage tabPage1;
|
||||
private System.Windows.Forms.Label label4;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.ComboBox comboBoxCommunicationInterface;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox rfidPortNrTextBox;
|
||||
private System.Windows.Forms.Label rfidSerialPortNrLabel;
|
||||
private System.Windows.Forms.GroupBox optoDataGroupBox;
|
||||
private System.Windows.Forms.Label tcpipPortLabel;
|
||||
private System.Windows.Forms.TextBox tcpipPortTextBox;
|
||||
private System.Windows.Forms.Label ipAddressLabel;
|
||||
private System.Windows.Forms.TextBox ipAddressTextBox;
|
||||
private System.Windows.Forms.RadioButton radioButton1;
|
||||
private System.Windows.Forms.RadioButton radioButton2;
|
||||
private System.Windows.Forms.Label optoSerialPortLabel;
|
||||
private System.Windows.Forms.TextBox optoSerialPortTextBox;
|
||||
private System.Windows.Forms.TextBox groupTextBox;
|
||||
private System.Windows.Forms.Label groupLabel;
|
||||
private System.Windows.Forms.TextBox muxBoardNrTextBox;
|
||||
private System.Windows.Forms.Label muxBoardNrLabel;
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.TabPage tabPage2;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.TextBox headPortNrTextBox;
|
||||
private System.Windows.Forms.Label label2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,137 @@
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
{
|
||||
partial class IperlUniHeadTestCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.optoTestGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.optoListBox = new System.Windows.Forms.ListBox();
|
||||
this.rfidOutputListBox = new System.Windows.Forms.ListBox();
|
||||
this.RfidTestGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.rfidCommandComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.commandTestButton = new System.Windows.Forms.Button();
|
||||
this.optoTestGroupBox.SuspendLayout();
|
||||
this.RfidTestGroupBox.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// optoTestGroupBox
|
||||
//
|
||||
this.optoTestGroupBox.Controls.Add(this.optoListBox);
|
||||
this.optoTestGroupBox.Location = new System.Drawing.Point(5, 4);
|
||||
this.optoTestGroupBox.Name = "optoTestGroupBox";
|
||||
this.optoTestGroupBox.Size = new System.Drawing.Size(591, 161);
|
||||
this.optoTestGroupBox.TabIndex = 2;
|
||||
this.optoTestGroupBox.TabStop = false;
|
||||
this.optoTestGroupBox.Text = "Opto-data";
|
||||
//
|
||||
// optoListBox
|
||||
//
|
||||
this.optoListBox.FormattingEnabled = true;
|
||||
this.optoListBox.ItemHeight = 16;
|
||||
this.optoListBox.Location = new System.Drawing.Point(7, 22);
|
||||
this.optoListBox.Name = "optoListBox";
|
||||
this.optoListBox.Size = new System.Drawing.Size(573, 132);
|
||||
this.optoListBox.TabIndex = 0;
|
||||
//
|
||||
// rfidOutputListBox
|
||||
//
|
||||
this.rfidOutputListBox.FormattingEnabled = true;
|
||||
this.rfidOutputListBox.ItemHeight = 16;
|
||||
this.rfidOutputListBox.Location = new System.Drawing.Point(5, 54);
|
||||
this.rfidOutputListBox.Name = "rfidOutputListBox";
|
||||
this.rfidOutputListBox.SelectionMode = System.Windows.Forms.SelectionMode.None;
|
||||
this.rfidOutputListBox.Size = new System.Drawing.Size(575, 164);
|
||||
this.rfidOutputListBox.TabIndex = 3;
|
||||
//
|
||||
// RfidTestGroupBox
|
||||
//
|
||||
this.RfidTestGroupBox.Controls.Add(this.rfidOutputListBox);
|
||||
this.RfidTestGroupBox.Controls.Add(this.label2);
|
||||
this.RfidTestGroupBox.Controls.Add(this.rfidCommandComboBox);
|
||||
this.RfidTestGroupBox.Controls.Add(this.commandTestButton);
|
||||
this.RfidTestGroupBox.Location = new System.Drawing.Point(5, 171);
|
||||
this.RfidTestGroupBox.Name = "RfidTestGroupBox";
|
||||
this.RfidTestGroupBox.Size = new System.Drawing.Size(591, 224);
|
||||
this.RfidTestGroupBox.TabIndex = 3;
|
||||
this.RfidTestGroupBox.TabStop = false;
|
||||
this.RfidTestGroupBox.Text = "RFID / NFC data";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(2, 25);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(69, 16);
|
||||
this.label2.TabIndex = 2;
|
||||
this.label2.Text = "Command";
|
||||
//
|
||||
// rfidCommandComboBox
|
||||
//
|
||||
this.rfidCommandComboBox.FormattingEnabled = true;
|
||||
this.rfidCommandComboBox.Location = new System.Drawing.Point(86, 19);
|
||||
this.rfidCommandComboBox.Name = "rfidCommandComboBox";
|
||||
this.rfidCommandComboBox.Size = new System.Drawing.Size(341, 24);
|
||||
this.rfidCommandComboBox.TabIndex = 1;
|
||||
//
|
||||
// commandTestButton
|
||||
//
|
||||
this.commandTestButton.Location = new System.Drawing.Point(449, 19);
|
||||
this.commandTestButton.Name = "commandTestButton";
|
||||
this.commandTestButton.Size = new System.Drawing.Size(126, 24);
|
||||
this.commandTestButton.TabIndex = 0;
|
||||
this.commandTestButton.Text = "Send command";
|
||||
this.commandTestButton.UseVisualStyleBackColor = true;
|
||||
this.commandTestButton.MouseClick += new System.Windows.Forms.MouseEventHandler(this.CommandTestButtonClick);
|
||||
//
|
||||
// IperlHeadTestCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.optoTestGroupBox);
|
||||
this.Controls.Add(this.RfidTestGroupBox);
|
||||
this.Name = "IperlUniHeadTestCtrl";
|
||||
this.Size = new System.Drawing.Size(611, 432);
|
||||
this.Load += new System.EventHandler(this.UserControl_Load);
|
||||
this.optoTestGroupBox.ResumeLayout(false);
|
||||
this.RfidTestGroupBox.ResumeLayout(false);
|
||||
this.RfidTestGroupBox.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.GroupBox optoTestGroupBox;
|
||||
private System.Windows.Forms.ListBox rfidOutputListBox;
|
||||
private System.Windows.Forms.GroupBox RfidTestGroupBox;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.ComboBox rfidCommandComboBox;
|
||||
private System.Windows.Forms.Button commandTestButton;
|
||||
private System.Windows.Forms.ListBox optoListBox;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Windows.Forms;
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl.communication;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI.test;
|
||||
using TBF.Rig.Sequences;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
{
|
||||
public partial class IperlUniHeadTestCtrl : UserControl
|
||||
{
|
||||
IPerlCfg config;
|
||||
IntIPerlReader _iPerlReader;
|
||||
Thread optoThread;
|
||||
|
||||
private bool stopWorkerThread;
|
||||
public event EventHandler<OptoReceivedEventArgs> OptoReceivedHandler;
|
||||
|
||||
public IperlUniHeadTestCtrl(IPerlCfg config)
|
||||
{
|
||||
this.config = config;
|
||||
InitializeComponent();
|
||||
if (config == null) return;
|
||||
|
||||
//TODO fix possibility set test method in config
|
||||
//iPerlCommunicationForm.cfg = new TestMethodCfg(null); // default values for iPerlCommunication
|
||||
|
||||
foreach(var head in ProcessData.IperlHeadsUni)
|
||||
{
|
||||
if (head != null && head.Name == config.Name) { _iPerlReader = head; }
|
||||
}
|
||||
|
||||
rfidCommandComboBox.DisplayMember = "Name";
|
||||
rfidCommandComboBox.ValueMember = "Value";
|
||||
var items = new[]
|
||||
{
|
||||
new {Name = "Read PCB", Value = "ReadPCB" },
|
||||
new {Name = "Set Test Mode", Value = "SetTestMode" },
|
||||
new {Name = "Set Active Mode", Value = "SetActiveMode" },
|
||||
#if DEBUG
|
||||
new {Name = "Start Read Opto Data", Value = "ReadOptoData" },
|
||||
new {Name = "Stop Read Opto Data", Value = "StopReadOptoData" },
|
||||
#endif
|
||||
new {Name = " ", Value = "" },
|
||||
new {Name = "Reset NFC Head", Value = "ResetNfcHead" },
|
||||
new {Name = "Set NFC Head Interface", Value = "SetNfcHead" },
|
||||
new {Name = "Set RFID Head interface", Value = "SetRfidHead" }
|
||||
};
|
||||
/*
|
||||
// CTRL+ALT+double click - hidden poweruser menu
|
||||
if (((Keyboard.ModifierKeys & Keys.Control) == Keys.Control) && ((Keyboard.ModifierKeys & Keys.Alt) == Keys.Alt) && Users.CurrentUser.AuthorizedAs == AuthorizedAs.PowerUser)
|
||||
{
|
||||
Array.Resize(ref items, items.Length + 1);
|
||||
items[items.Length - 1] = new { Name = "Kluc", Value = "Kluc" };
|
||||
}
|
||||
*/
|
||||
rfidCommandComboBox.DataSource = items;
|
||||
|
||||
stopWorkerThread = false;
|
||||
|
||||
OptoReceivedHandler += (EventHandler<OptoReceivedEventArgs>)((sndr, args) =>
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
this.Invoke((Delegate)new EventHandler<OptoReceivedEventArgs>(this.OnOptoReceived2), sndr, (object)args);
|
||||
else
|
||||
this.OnOptoReceived2(sndr, args);
|
||||
});
|
||||
}
|
||||
|
||||
public void OnOptoReceived2(object sender, OptoReceivedEventArgs args)
|
||||
{
|
||||
optoListBox.Items.Insert(0,args.Data);
|
||||
}
|
||||
|
||||
private void CommandTestButtonClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
rfidOutputListBox.Items.Clear();
|
||||
|
||||
using (Tools.LogChecker logChecker = new Tools.LogChecker("RfidData", log4net.Core.Level.Debug))
|
||||
{
|
||||
ListItem rfidListItem = new ListItem();
|
||||
rfidListItem.Attributes.Add("style", "font-weight:bold");
|
||||
switch (rfidCommandComboBox.SelectedValue)
|
||||
{
|
||||
case "ReadPCB":
|
||||
rfidListItem.Text = $"PCB: {OpticalHeadTest.ReadRequest_PCB(_iPerlReader)}";
|
||||
break;
|
||||
case "SetTestMode":
|
||||
rfidListItem.Text = OpticalHeadTest.SetTestMode(_iPerlReader);
|
||||
optoListBox.Items.Clear();
|
||||
stopWorkerThread = false;
|
||||
optoThread = new Thread(OptoWorker);
|
||||
if (!optoThread.IsAlive)
|
||||
{
|
||||
_iPerlReader.StartDataStreamProcessing(); // open opto port
|
||||
optoThread.Start();
|
||||
}
|
||||
break;
|
||||
case "SetActiveMode":
|
||||
rfidListItem.Text = OpticalHeadTest.SetActiveMode(_iPerlReader);
|
||||
stopWorkerThread = true;
|
||||
_iPerlReader.StopDataStreamProcessing(); // close opto port
|
||||
break;
|
||||
case "ResetNfcHead":
|
||||
_iPerlReader.ResetNfcInterface();
|
||||
break;
|
||||
case "SetNfcHead":
|
||||
_iPerlReader.SetNfcInterface();
|
||||
break;
|
||||
case "SetRfidHead":
|
||||
_iPerlReader.SetRfidInterface();
|
||||
break;
|
||||
case "ReadOptoData":
|
||||
optoListBox.Items.Clear();
|
||||
stopWorkerThread = false;
|
||||
optoThread = new Thread(OptoWorker);
|
||||
if (optoThread.IsAlive)
|
||||
{
|
||||
stopWorkerThread = true;
|
||||
_iPerlReader.StopDataStreamProcessing(); // close opto port
|
||||
}
|
||||
if (!optoThread.IsAlive)
|
||||
{
|
||||
_iPerlReader.StartDataStreamProcessing(); // open opto port
|
||||
optoThread.Start();
|
||||
}
|
||||
break;
|
||||
case "StopReadOptoData":
|
||||
stopWorkerThread = true;
|
||||
_iPerlReader.StopDataStreamProcessing(); // close opto port
|
||||
break;
|
||||
}
|
||||
rfidOutputListBox.Items.Add(rfidListItem);
|
||||
rfidOutputListBox.Items.AddRange(logChecker.Messages.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
private void OptoWorker()
|
||||
{
|
||||
while (!this.stopWorkerThread)
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
if (this.stopWorkerThread)
|
||||
break;
|
||||
|
||||
try
|
||||
{
|
||||
string buffer = _iPerlReader.ReadOptoData();
|
||||
if (string.IsNullOrEmpty(buffer))
|
||||
{
|
||||
this.OnOptoReceived((object)this, new OptoReceivedEventArgs("."));
|
||||
}
|
||||
else
|
||||
OnOptoReceived((object)this, new OptoReceivedEventArgs(buffer));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this.OnOptoReceived((object)this, new OptoReceivedEventArgs(ex.Message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnOptoReceived(object sender, OptoReceivedEventArgs args)
|
||||
{
|
||||
if (this.OptoReceivedHandler == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
this.OptoReceivedHandler(sender, args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void UserControl_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.ParentForm.FormClosing += new FormClosingEventHandler(ParentForm_FormClosing);
|
||||
}
|
||||
|
||||
void ParentForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
//OnHandleDestroyed(new EventArgs());
|
||||
stopWorkerThread = true;
|
||||
if (optoThread != null)
|
||||
{
|
||||
optoThread.Abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -4,7 +4,7 @@ using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
{
|
||||
|
||||
@@ -7,58 +7,20 @@ using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
|
||||
using TBF.Rig.TestMethods.SmartTest;
|
||||
using TBF.Rig.Uni.SharedDialogs.iPerlCommunication;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
{
|
||||
public class TestMethodCfg : ComponentCfgBase, IComponentCfg
|
||||
public class TestMethodCfg : ComponentCfgBase, ITestMethodCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new TestMethodCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int CommTimeout; /// Communication timeout in ms (500 .. 5000)
|
||||
public int DelayBetweenRetries; /// Delay between communication retries in ms (0 .. 5000)
|
||||
public int MaxCommRetries; /// Max. number of retries (1 .. 10)
|
||||
public int WaitTimeAfterFailure; /// Wait time after communication failure in ms
|
||||
public int PassThroughWaitTime; /// Pass Through wait time for radio parameters in ms
|
||||
public int NrThreads; /// Numbwr of parallel threads (1, 2 or 4)
|
||||
public int IperlCheckErrorsToStop;
|
||||
|
||||
///
|
||||
/// NFC S4.5 Combihead params
|
||||
///
|
||||
public int MciTimeoutMs;
|
||||
public int BaudRate;
|
||||
public int DataBits;
|
||||
public Parity ParityBit;
|
||||
public StopBits StopBits;
|
||||
|
||||
public int DfltQ2c_15_rl;
|
||||
public int DfltQ2c_15_lr;
|
||||
public int DfltQ2c_20_rl;
|
||||
public int DfltQ2c_20_lr;
|
||||
public int DfltQ2c_25_63_rl;
|
||||
public int DfltQ2c_25_63_lr;
|
||||
public int DfltQ2c_25_10_rl;
|
||||
public int DfltQ2c_25_10_lr;
|
||||
public int DfltQ2c_32_rl;
|
||||
public int DfltQ2c_32_lr;
|
||||
public int DfltQ2c_40_rl;
|
||||
public int DfltQ2c_40_lr;
|
||||
|
||||
public bool UseWebService;
|
||||
public string BaseUrl;
|
||||
public string RelativeUrl;
|
||||
|
||||
/// <summary> Test parameters </summary>
|
||||
[XmlIgnore]
|
||||
public iPerlCommunicationParams TestParams;
|
||||
public override IParamsProvider GetRuntimeTestParamsProvider() { return TestParams; }
|
||||
public override IParamsProvider CreateTestParamsProvider() { return new iPerlCommunicationParams(true); }
|
||||
public override IParamsProvider GetUITestParamsProvider(Test test)
|
||||
@@ -96,5 +58,27 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI
|
||||
{
|
||||
return string.Format("Name={0}, CommTimeout={1}, MaxRetries={2}, NrThreads={3}", Name, CommTimeout, MaxCommRetries, NrThreads);
|
||||
}
|
||||
|
||||
public int CommTimeout { get; set; }
|
||||
public int DelayBetweenRetries { get; set; }
|
||||
public int MaxCommRetries { get; set; }
|
||||
public int WaitTimeAfterFailure { get; set; }
|
||||
public int PassThroughWaitTime { get; set; }
|
||||
public int NrThreads { get; set; }
|
||||
public int IperlCheckErrorsToStop { get; set; }
|
||||
public int MciTimeoutMs { get; set; }
|
||||
public int BaudRate { get; set; }
|
||||
public int DataBits { get; set; }
|
||||
public Parity ParityBit { get; set; }
|
||||
public StopBits StopBits { get; set; }
|
||||
|
||||
/// <summary> Test parameters </summary>
|
||||
[XmlIgnore]
|
||||
public iPerlCommunicationParams TestParams;
|
||||
|
||||
|
||||
public bool UseWebService { get; set; }
|
||||
public string BaseUrl { get; set; }
|
||||
public string RelativeUrl { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,29 +2,29 @@ using Config.Resources;
|
||||
using log4net;
|
||||
using Sensus.iPerl.RfidCom.Helper;
|
||||
using System;
|
||||
using TBF.Rig.Uni.SharedDialogs.iPerlCommunication;
|
||||
using TBF.Rig.RegisterReaders.CommonRR;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
using static Sensus.iPerl.NfcHandler.MCI_Protocol;
|
||||
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication;
|
||||
|
||||
namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.test
|
||||
{
|
||||
internal class OpticalHeadTest
|
||||
{
|
||||
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||
|
||||
internal static string OpenSealing(IPerlReader iHead)
|
||||
internal static string OpenSealing(IntIPerlReader iHead)
|
||||
{
|
||||
if (RfidCommands.OpenSealing($"COM{iHead.RfidComPortNr}")) return "OK";
|
||||
return "Error Open Sealing";
|
||||
}
|
||||
|
||||
internal static string ReadRequest_PCB(IPerlReader iHead)
|
||||
internal static string ReadRequest_PCB(IntIPerlReader iHead)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] pcb = null;
|
||||
int readRetVal = iPerlCommunicationForm.ReadRequestPort(iHead, MessageID.Configuration, Sensus.iPerl.NfcHandler.MCI_Protocol.StructName.Configuration, 16, 5, out pcb);
|
||||
int readRetVal = IPerlCorrections.ReadRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, MessageID.Configuration, Sensus.iPerl.NfcHandler.MCI_Protocol.StructName.Configuration, 16, 5, out pcb);
|
||||
if (readRetVal == 0)
|
||||
{
|
||||
return RfidHelper.HexLiteral2Unsigned(RfidHelper.SwapHexcode(BitConverter.ToString(pcb).Replace("-", string.Empty))).ToString();
|
||||
@@ -38,10 +38,10 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.test
|
||||
}
|
||||
}
|
||||
|
||||
internal static string SetActiveMode(IPerlReader iHead)
|
||||
internal static string SetActiveMode(IntIPerlReader iHead)
|
||||
{
|
||||
byte[] cmd = new byte[1] { (byte)Command.SetActiveMode };
|
||||
if (0 == iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
if (0 == IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
@@ -51,10 +51,10 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.test
|
||||
}
|
||||
}
|
||||
|
||||
internal static string SetTestMode(IPerlReader iHead)
|
||||
internal static string SetTestMode(IntIPerlReader iHead)
|
||||
{
|
||||
byte[] cmd = new byte[1] { (byte)Command.SetTestMode };
|
||||
if (0 == iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
if (0 == IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
@@ -65,11 +65,11 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.test
|
||||
}
|
||||
|
||||
#if IPERL
|
||||
internal static string TurnOffRadio(IPerlReader iHead)
|
||||
internal static string TurnOffRadio(IntIPerlReader iHead)
|
||||
{
|
||||
try
|
||||
{
|
||||
int retValue = iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.RadioPassthrough, StructName.RadioParams, 0x1898, 1, new byte[] { (byte)3 }); // WakeUpInterval
|
||||
int retValue = IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, MessageID.RadioPassthrough, StructName.RadioParams, 0x1898, 1, new byte[] { (byte)3 }); // WakeUpInterval
|
||||
return 0 == retValue ? "OK" : "Error";
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -78,11 +78,11 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.test
|
||||
}
|
||||
}
|
||||
|
||||
internal static string SetProductionMode(IPerlReader iHead)
|
||||
internal static string SetProductionMode(IntIPerlReader iHead)
|
||||
{
|
||||
try
|
||||
{
|
||||
int retValue = iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.RadioPassthrough, StructName.RadioInfo, 0x1804, 1, new byte[] { (byte)1 }); // System Status
|
||||
int retValue = IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, MessageID.RadioPassthrough, StructName.RadioInfo, 0x1804, 1, new byte[] { (byte)1 }); // System Status
|
||||
return 0 == retValue ? "OK" : "Error";
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -91,7 +91,7 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.test
|
||||
}
|
||||
}
|
||||
|
||||
internal static string WriteRequestPort_u8_Customer_Text(IPerlReader iHead)
|
||||
internal static string WriteRequestPort_u8_Customer_Text(IntIPerlReader iHead)
|
||||
{
|
||||
string custText = "FF0123456789ABCDEF"; // Sample text to test write function
|
||||
/*try
|
||||
@@ -111,14 +111,14 @@ namespace TBF.Rig.RegisterReaders.iPerlReaderUNI.test
|
||||
return $"Error COM{iHead.RfidComPortNr}";
|
||||
}
|
||||
|
||||
internal static string SetRfidMode(IPerlReader iHead)
|
||||
internal static string SetRfidMode(IntIPerlReader iHead)
|
||||
{
|
||||
iHead.SetRfidInterface();
|
||||
iHead.SetCommunicationInterface(CommunicationInterface.RFID);
|
||||
return ($"OK - {Strings.Program_restart_is_required_to_apply_some_settings}");
|
||||
}
|
||||
|
||||
internal static string SetNfcMode(IPerlReader iHead)
|
||||
internal static string SetNfcMode(IntIPerlReader iHead)
|
||||
{
|
||||
iHead.SetNfcInterface();
|
||||
iHead.SetCommunicationInterface(CommunicationInterface.NFC);
|
||||
|
||||
@@ -20,6 +20,8 @@ using TBF.Rig.Output.Printers.GroupPrinting.Single;
|
||||
using TBF.UiBridge;
|
||||
using SharedComponents;
|
||||
using System.Text;
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.Sequences
|
||||
{
|
||||
@@ -55,19 +57,19 @@ namespace TBF.Rig.Sequences
|
||||
try
|
||||
{
|
||||
/// 1nd argument
|
||||
TestMethods.iPerlCommunication.TestMethodCfg iPerlCfg = cfg as TestMethods.iPerlCommunication.TestMethodCfg;
|
||||
ITestMethodCfg iPerlCfgIPerl = cfg as ITestMethodCfg;
|
||||
|
||||
/// 2rd argument: as is
|
||||
|
||||
/// 3th argument
|
||||
IList<TestMethods.iPerlCommunication.iPerlCommunicationParams> iPerlCommParams = new List<TestMethods.iPerlCommunication.iPerlCommunicationParams>();
|
||||
foreach (var tp in multiTestParams) iPerlCommParams.Add(tp as TestMethods.iPerlCommunication.iPerlCommunicationParams);
|
||||
IList<iPerlCommunicationParams> iPerlCommParams = new List<iPerlCommunicationParams>();
|
||||
foreach (var tp in multiTestParams) iPerlCommParams.Add(tp as iPerlCommunicationParams);
|
||||
|
||||
/*myRef.modelessDlg = new TestMethods.iPerlCommunication.iPerlCommunicationForm(iPerlCfg, tests, iPerlCommParams);
|
||||
myRef.modelessDlg.Show();*/
|
||||
|
||||
myRef.modelessDlg = new TestMethods.iPerlCommunication.iPerlCommunicationForm(
|
||||
testMethod as TBF.Rig.TestMethods.iPerlCommunication.TestMethod, tests, iPerlCommParams);
|
||||
myRef.modelessDlg = new SmartCommunicationForm(
|
||||
testMethod , tests, iPerlCommParams);
|
||||
myRef.modelessDlg.Show();
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
@@ -11,6 +11,7 @@ using TBF.Rig.GenericDevices;
|
||||
using TBF.Boxes;
|
||||
using TBF.Resources;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
|
||||
namespace TBF.Rig.Sequences
|
||||
{
|
||||
@@ -110,7 +111,7 @@ namespace TBF.Rig.Sequences
|
||||
/// iPERL related state variables to be saved after each completed test
|
||||
///
|
||||
public static IList<TestMethods.iPerlCommunication.iPerlHead.IperlHead> IperlHeads;
|
||||
public static IList<RegisterReaders.iPerlReaderUNI.IPerlReader> IperlHeadsUni;
|
||||
public static IList<IntIPerlReader> IperlHeadsUni;
|
||||
public static bool IsQ2PreCorrectionCalculated;
|
||||
public static int CalculatedQ2PreCorrectionLR;
|
||||
public static int CalculatedQ2PreCorrectionRL;
|
||||
|
||||
@@ -14,7 +14,7 @@ using TBF.UiBridge;
|
||||
using Results;
|
||||
using Results.Entities;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
using TBF.Rig.Uni.SharedDialogs.iPerlCommunication;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.Sequences
|
||||
{
|
||||
@@ -29,7 +29,7 @@ namespace TBF.Rig.Sequences
|
||||
///
|
||||
void OpenIPerlCommForm(iPerlCommunicationSeq myRef, SmartComponentBase method, Test test, iPerlCommunicationParams testParams)
|
||||
{
|
||||
myRef.modelessDlg = new iPerlCommunicationForm(method, test, testParams);
|
||||
myRef.modelessDlg = new SmartCommunicationForm(method, test, testParams);
|
||||
myRef.modelessDlg.Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ using TBF.Rig.Sequences;
|
||||
using Dirichlet.Numerics;
|
||||
using TBF.Resources;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
|
||||
namespace TBF.Rig
|
||||
{
|
||||
@@ -155,7 +156,7 @@ namespace TBF.Rig
|
||||
TestMethod2Class = new Dictionary<string, string>();
|
||||
|
||||
ProcessData.IperlHeads = new List<TestMethods.iPerlCommunication.iPerlHead.IperlHead>();
|
||||
ProcessData.IperlHeadsUni = new List<IPerlReader>();
|
||||
ProcessData.IperlHeadsUni = new List<IntIPerlReader>();
|
||||
SequenceBase.FlowMeters = new List<IFlowMeter>();
|
||||
SequenceBase.RegVPositions = new List<RegValvePosition>();
|
||||
SequenceBase.PumpsWithFM = new List<IPumpFM>();
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
/// Copyright (c) 2022 Sensus Slovensko a.s.
|
||||
///
|
||||
using TBF.Resources;
|
||||
using TBF.Rig.Uni.SharedDialogs.iPerlCommunication;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.TestMethods.SmartTest
|
||||
{
|
||||
|
||||
public class SequenceConditionOp : ISequenceConditionOp, IOperation
|
||||
{
|
||||
public SequenceConditionOp(TestMethod testMethodComponent, ConditionID id)
|
||||
public SequenceConditionOp(TestMethod testMethodComponent, ConditionId id)
|
||||
: base(testMethodComponent, id)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.GenericDevices;
|
||||
using TBF.Rig.Sequences;
|
||||
using TBF.Rig.Uni.SharedDialogs.iPerlCommunication;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
using TBF.UiBridge;
|
||||
using ConditionID = TBF.Rig.Uni.SharedDialogs.iPerlCommunication.ConditionID;
|
||||
using iPerlCommunicationSeq = TBF.Rig.Sequences.iPerlCommunicationSeq;
|
||||
using TestMethodCfg = TBF.Rig.RegisterReaders.iPerlReaderUNI.TestMethodCfg;
|
||||
|
||||
@@ -93,10 +92,10 @@ namespace TBF.Rig.TestMethods.SmartTest
|
||||
|
||||
void CreateMilestonesAndConditions()
|
||||
{
|
||||
IperlCommMilestone = new bool[(int)ConditionID.Count];
|
||||
IperlCommMilestone = new bool[(int)ConditionId.Count];
|
||||
|
||||
sequenceConditionOps = new List<IOperation>();
|
||||
for (ConditionID id = ConditionID.A; id < ConditionID.Count; id++)
|
||||
for (ConditionId id = ConditionId.A; id < ConditionId.Count; id++)
|
||||
{
|
||||
sequenceConditionOps.Add(new SequenceConditionOp(this, id));
|
||||
}
|
||||
@@ -135,16 +134,16 @@ namespace TBF.Rig.TestMethods.SmartTest
|
||||
}
|
||||
|
||||
|
||||
public int ConditionsCount { get { return (int)ConditionID.Count; } }
|
||||
public int ConditionsCount { get { return (int)ConditionId.Count; } }
|
||||
|
||||
public string ConditionName(int i)
|
||||
{
|
||||
return (i >= 0 && i < (int)ConditionID.Count) ? ConditionOp(i).ToString() : string.Empty;
|
||||
return (i >= 0 && i < (int)ConditionId.Count) ? ConditionOp(i).ToString() : string.Empty;
|
||||
}
|
||||
|
||||
public IOperation ConditionOp(int i)
|
||||
{
|
||||
return (i >= 0 && i < (int)ConditionID.Count) ? sequenceConditionOps[i] : null;
|
||||
return (i >= 0 && i < (int)ConditionId.Count) ? sequenceConditionOps[i] : null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Resources;
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
|
||||
namespace TBF.Rig.TestMethods.SmartTest
|
||||
@@ -15,7 +16,7 @@ namespace TBF.Rig.TestMethods.SmartTest
|
||||
{
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
TestMethodCfg config;
|
||||
ITestMethodCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
@@ -43,28 +44,32 @@ namespace TBF.Rig.TestMethods.SmartTest
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
commTimeoutTextBox.Text = config.CommTimeout.ToString();
|
||||
maxCommRetriesTextBox.Text = config.MaxCommRetries.ToString();
|
||||
delayBetweenRetriesTextBox.Text = config.DelayBetweenRetries.ToString();
|
||||
nrThreadsTextBox.Text = config.NrThreads.ToString();
|
||||
iperlCheckErrorsToStopTextBox.Text = config.IperlCheckErrorsToStop.ToString();
|
||||
delayBetweenRetriesTextBox.Text = config.DelayBetweenRetries.ToString();
|
||||
nrThreadsTextBox.Text = config.NrThreads.ToString();
|
||||
|
||||
if (config is IiPerlTestMethodCfg cfg)
|
||||
{
|
||||
iperlCheckErrorsToStopTextBox.Text = cfg.IperlCheckErrorsToStop.ToString();
|
||||
textBox15rl.Text = cfg.DfltQ2c_15_rl.ToString();
|
||||
textBox15lr.Text = cfg.DfltQ2c_15_lr.ToString();
|
||||
textBox20rl.Text = cfg.DfltQ2c_20_rl.ToString();
|
||||
textBox20lr.Text = cfg.DfltQ2c_20_lr.ToString();
|
||||
textBox25_63rl.Text = cfg.DfltQ2c_25_63_rl.ToString();
|
||||
textBox25_63lr.Text = cfg.DfltQ2c_25_63_lr.ToString();
|
||||
textBox25_10rl.Text = cfg.DfltQ2c_25_10_rl.ToString();
|
||||
textBox25_10lr.Text = cfg.DfltQ2c_25_10_lr.ToString();
|
||||
textBox32rl.Text = cfg.DfltQ2c_32_rl.ToString();
|
||||
textBox32lr.Text = cfg.DfltQ2c_32_lr.ToString();
|
||||
textBox40rl.Text = cfg.DfltQ2c_40_rl.ToString();
|
||||
textBox40lr.Text = cfg.DfltQ2c_40_lr.ToString();
|
||||
}
|
||||
|
||||
textBox15rl.Text = config.DfltQ2c_15_rl.ToString();
|
||||
textBox15lr.Text = config.DfltQ2c_15_lr.ToString();
|
||||
textBox20rl.Text = config.DfltQ2c_20_rl.ToString();
|
||||
textBox20lr.Text = config.DfltQ2c_20_lr.ToString();
|
||||
textBox25_63rl.Text = config.DfltQ2c_25_63_rl.ToString();
|
||||
textBox25_63lr.Text = config.DfltQ2c_25_63_lr.ToString();
|
||||
textBox25_10rl.Text = config.DfltQ2c_25_10_rl.ToString();
|
||||
textBox25_10lr.Text = config.DfltQ2c_25_10_lr.ToString();
|
||||
textBox32rl.Text = config.DfltQ2c_32_rl.ToString();
|
||||
textBox32lr.Text = config.DfltQ2c_32_lr.ToString();
|
||||
textBox40rl.Text = config.DfltQ2c_40_rl.ToString();
|
||||
textBox40lr.Text = config.DfltQ2c_40_lr.ToString();
|
||||
|
||||
useWebServiceCheckBox.Checked = config.UseWebService;
|
||||
useWebServiceCheckBox.Checked = config.UseWebService;
|
||||
baseUrlTextBox.Text = config.BaseUrl;
|
||||
relativeUrlTextBox.Text = config.RelativeUrl;
|
||||
}
|
||||
@@ -204,29 +209,77 @@ namespace TBF.Rig.TestMethods.SmartTest
|
||||
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
|
||||
}
|
||||
|
||||
flags |= UpdateDifferent(ref config.CommTimeout, commTimeoutTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.MaxCommRetries, maxCommRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DelayBetweenRetries, delayBetweenRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.NrThreads, nrThreadsTextBox.Text, CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.IperlCheckErrorsToStop, iperlCheckErrorsToStopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
var CommTimeout = config.CommTimeout;
|
||||
var MaxCommRetries = config.MaxCommRetries;
|
||||
var DelayBetweenRetries = config.DelayBetweenRetries;
|
||||
var NrThreads = config.NrThreads;
|
||||
var UseWebService = config.UseWebService;
|
||||
var BaseUrl = config.BaseUrl;
|
||||
var RelativeUrl = config.RelativeUrl;
|
||||
|
||||
flags |= UpdateDifferent(ref CommTimeout, commTimeoutTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref MaxCommRetries, maxCommRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DelayBetweenRetries, delayBetweenRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref NrThreads, nrThreadsTextBox.Text, CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
if (config is IiPerlTestMethodCfg cfg)
|
||||
{
|
||||
|
||||
var IperlCheckErrorsToStop = cfg.IperlCheckErrorsToStop;
|
||||
var DfltQ2c_15_rl = cfg.DfltQ2c_15_rl;
|
||||
var DfltQ2c_15_lr = cfg.DfltQ2c_15_lr;
|
||||
var DfltQ2c_20_rl = cfg.DfltQ2c_20_rl;
|
||||
var DfltQ2c_20_lr = cfg.DfltQ2c_20_lr;
|
||||
var DfltQ2c_25_63_rl = cfg.DfltQ2c_25_63_rl;
|
||||
var DfltQ2c_25_63_lr = cfg.DfltQ2c_25_63_lr;
|
||||
var DfltQ2c_25_10_rl = cfg.DfltQ2c_25_10_rl;
|
||||
var DfltQ2c_25_10_lr = cfg.DfltQ2c_25_10_lr;
|
||||
var DfltQ2c_32_rl = cfg.DfltQ2c_32_rl;
|
||||
var DfltQ2c_32_lr = cfg.DfltQ2c_32_lr;
|
||||
var DfltQ2c_40_rl = cfg.DfltQ2c_40_rl;
|
||||
var DfltQ2c_40_lr = cfg.DfltQ2c_40_lr;
|
||||
|
||||
flags |= UpdateDifferent(ref IperlCheckErrorsToStop, iperlCheckErrorsToStopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_15_rl, textBox15rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_15_lr, textBox15lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_20_rl, textBox20rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_20_lr, textBox20lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_25_63_rl, textBox25_63rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_25_63_lr, textBox25_63lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_25_10_rl, textBox25_10rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_25_10_lr, textBox25_10lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_32_rl, textBox32rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_32_lr, textBox32lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_40_rl, textBox40rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_40_lr, textBox40lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
|
||||
cfg.IperlCheckErrorsToStop = IperlCheckErrorsToStop;
|
||||
cfg.DfltQ2c_15_rl = DfltQ2c_15_rl;
|
||||
cfg.DfltQ2c_15_lr = DfltQ2c_15_lr;
|
||||
cfg.DfltQ2c_20_rl = DfltQ2c_20_rl;
|
||||
cfg.DfltQ2c_20_lr = DfltQ2c_20_lr;
|
||||
cfg.DfltQ2c_25_63_rl = DfltQ2c_25_63_rl;
|
||||
cfg.DfltQ2c_25_63_lr = DfltQ2c_25_63_lr;
|
||||
cfg.DfltQ2c_25_10_rl = DfltQ2c_25_10_rl;
|
||||
cfg.DfltQ2c_25_10_lr = DfltQ2c_25_10_lr;
|
||||
cfg.DfltQ2c_32_rl = DfltQ2c_32_rl;
|
||||
cfg.DfltQ2c_32_lr = DfltQ2c_32_lr;
|
||||
cfg.DfltQ2c_40_rl = DfltQ2c_40_rl;
|
||||
cfg.DfltQ2c_40_lr = DfltQ2c_40_lr;
|
||||
}
|
||||
flags |= UpdateDifferent(ref UseWebService, useWebServiceCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref BaseUrl, baseUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref RelativeUrl, relativeUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_15_rl, textBox15rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_15_lr, textBox15lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_20_rl, textBox20rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_20_lr, textBox20lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_25_63_rl, textBox25_63rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_25_63_lr, textBox25_63lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_25_10_rl, textBox25_10rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_25_10_lr, textBox25_10lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_32_rl, textBox32rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_32_lr, textBox32lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_40_rl, textBox40rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_40_lr, textBox40lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
|
||||
flags |= UpdateDifferent(ref config.UseWebService, useWebServiceCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.BaseUrl, baseUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.RelativeUrl, relativeUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
|
||||
config.CommTimeout = CommTimeout;
|
||||
config.MaxCommRetries = MaxCommRetries;
|
||||
config.DelayBetweenRetries = DelayBetweenRetries;
|
||||
config.NrThreads = NrThreads;
|
||||
config.UseWebService = UseWebService;
|
||||
config.BaseUrl = BaseUrl;
|
||||
config.RelativeUrl = RelativeUrl;
|
||||
|
||||
|
||||
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
|
||||
{
|
||||
TestMethod.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
|
||||
|
||||
@@ -7,6 +7,7 @@ using System;
|
||||
using System.Threading;
|
||||
using TBF.Rig.Hart.Common;
|
||||
using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
using static Sensus.iPerl.NfcHandler.MCI_Protocol;
|
||||
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
@@ -26,7 +27,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
try
|
||||
{
|
||||
byte[] pcb = null;
|
||||
int readRetVal = iPerlCommunicationForm.ReadRequestPort(iHead, MessageID.Configuration, Sensus.iPerl.NfcHandler.MCI_Protocol.StructName.Configuration, 16, 5, out pcb);
|
||||
int readRetVal = IPerlCorrections.ReadRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, RegisterReaders.CommonRR.MessageID.Configuration, Sensus.iPerl.NfcHandler.MCI_Protocol.StructName.Configuration, 16, 5, out pcb);
|
||||
if (readRetVal == 0)
|
||||
{
|
||||
return RfidHelper.HexLiteral2Unsigned(RfidHelper.SwapHexcode(BitConverter.ToString(pcb).Replace("-", string.Empty))).ToString();
|
||||
@@ -43,7 +44,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
internal static string SetActiveMode(IperlHead iHead)
|
||||
{
|
||||
byte[] cmd = new byte[1] { (byte)Command.SetActiveMode };
|
||||
if (0 == iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
if (0 == IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, RegisterReaders.CommonRR.MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
@@ -56,7 +57,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
internal static string SetTestMode(IperlHead iHead)
|
||||
{
|
||||
byte[] cmd = new byte[1] { (byte)Command.SetTestMode };
|
||||
if (0 == iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
if (0 == IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, RegisterReaders.CommonRR.MessageID.Command, StructName.Command, 0, 1, cmd))
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
@@ -71,7 +72,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
try
|
||||
{
|
||||
int retValue = iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.RadioPassthrough, StructName.RadioParams, 0x1898, 1, new byte[] { (byte)3 }); // WakeUpInterval
|
||||
int retValue = IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg, iHead, RegisterReaders.CommonRR.MessageID.RadioPassthrough, StructName.RadioParams, 0x1898, 1, new byte[] { (byte)3 }); // WakeUpInterval
|
||||
return 0 == retValue ? "OK" : "Error";
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -84,7 +85,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
try
|
||||
{
|
||||
int retValue = iPerlCommunicationForm.WriteRequestPort(iHead, MessageID.RadioPassthrough, StructName.RadioInfo, 0x1804, 1, new byte[] { (byte)1 }); // System Status
|
||||
int retValue = IPerlCorrections.WriteRequestPort(SmartCommunicationForm.TestMethodCfg,iHead, RegisterReaders.CommonRR.MessageID.RadioPassthrough, StructName.RadioInfo, 0x1804, 1, new byte[] { (byte)1 }); // System Status
|
||||
return 0 == retValue ? "OK" : "Error";
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Collections.Generic;
|
||||
using log4net;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.GenericDevices;
|
||||
using TBF.Rig.Sequences;
|
||||
using TBF.UiBridge;
|
||||
@@ -22,8 +23,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
public bool CanTest(MetersKind meters) { return meters == MetersKind.Single; }
|
||||
public bool DoTransitions() { return false; }
|
||||
|
||||
public bool SimultWithPrevious { get { return testMethodCfg.TestParams.SimultWithPrevious; } }
|
||||
public bool SimultWithNext { get { return testMethodCfg.TestParams.SimultWithNext; } }
|
||||
public bool SimultWithPrevious { get { return _testMethodCfgIPerl.TestParams.SimultWithPrevious; } }
|
||||
public bool SimultWithNext { get { return _testMethodCfgIPerl.TestParams.SimultWithNext; } }
|
||||
|
||||
#region Configuration Change Handling
|
||||
|
||||
@@ -40,18 +41,18 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
CfgChangeHandler += delegate(object sender, CfgChangeArgs args)
|
||||
{
|
||||
TestMethodCfg tmpCfg = args.Cfg as TestMethodCfg;
|
||||
if (tmpCfg != null && tmpCfg.Name.Equals(Name))
|
||||
TestMethodCfg_IPerl tmpCfgIPerl = args.Cfg as TestMethodCfg_IPerl;
|
||||
if (tmpCfgIPerl != null && tmpCfgIPerl.Name.Equals(Name))
|
||||
{
|
||||
if (args.Command == CfgChangeCmd.CfgChange)
|
||||
{
|
||||
testMethodCfg.CommTimeout = tmpCfg.CommTimeout;
|
||||
testMethodCfg.DelayBetweenRetries = tmpCfg.DelayBetweenRetries;
|
||||
testMethodCfg.MaxCommRetries = tmpCfg.MaxCommRetries;
|
||||
testMethodCfg.IperlCheckErrorsToStop = tmpCfg.IperlCheckErrorsToStop;
|
||||
testMethodCfg.UseWebService = tmpCfg.UseWebService;
|
||||
testMethodCfg.BaseUrl = tmpCfg.BaseUrl;
|
||||
testMethodCfg.RelativeUrl = tmpCfg.RelativeUrl;
|
||||
_testMethodCfgIPerl.CommTimeout = tmpCfgIPerl.CommTimeout;
|
||||
_testMethodCfgIPerl.DelayBetweenRetries = tmpCfgIPerl.DelayBetweenRetries;
|
||||
_testMethodCfgIPerl.MaxCommRetries = tmpCfgIPerl.MaxCommRetries;
|
||||
_testMethodCfgIPerl.IperlCheckErrorsToStop = tmpCfgIPerl.IperlCheckErrorsToStop;
|
||||
_testMethodCfgIPerl.UseWebService = tmpCfgIPerl.UseWebService;
|
||||
_testMethodCfgIPerl.BaseUrl = tmpCfgIPerl.BaseUrl;
|
||||
_testMethodCfgIPerl.RelativeUrl = tmpCfgIPerl.RelativeUrl;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -60,7 +61,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
#endregion Configuration Change Handling
|
||||
|
||||
|
||||
readonly TestMethodCfg testMethodCfg;
|
||||
readonly TestMethodCfg_IPerl _testMethodCfgIPerl;
|
||||
|
||||
public bool[] IperlCommMilestone;
|
||||
IList<IOperation> sequenceConditionOps;
|
||||
@@ -73,7 +74,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
public TestMethod(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
testMethodCfg = cfg as TestMethodCfg;
|
||||
_testMethodCfgIPerl = cfg as TestMethodCfg_IPerl;
|
||||
CreateMilestonesAndConditions();
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
if (DebugLevel == DebugMode.Normal)
|
||||
{
|
||||
return (new iPerlCommunicationSeq()).Execute(test, repetNr, this, testMethodCfg.TestParams);
|
||||
return (new iPerlCommunicationSeq()).Execute(test, repetNr, this, _testMethodCfgIPerl.TestParams);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@ using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Resources;
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
|
||||
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
@@ -14,13 +15,13 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
TestMethodCfg config;
|
||||
TestMethodCfg_IPerl config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as TestMethodCfg;
|
||||
config = value as TestMethodCfg_IPerl;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
@@ -203,29 +204,72 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
flags |= (CfgUpdateFlags.AnyChange | CfgUpdateFlags.RestartRqrd);
|
||||
}
|
||||
|
||||
flags |= UpdateDifferent(ref config.CommTimeout, commTimeoutTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.MaxCommRetries, maxCommRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DelayBetweenRetries, delayBetweenRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.NrThreads, nrThreadsTextBox.Text, CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.IperlCheckErrorsToStop, iperlCheckErrorsToStopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
var CommTimeout = config.CommTimeout;;
|
||||
var MaxCommRetries = config.MaxCommRetries;
|
||||
var DelayBetweenRetries = config.DelayBetweenRetries;
|
||||
var NrThreads = config.NrThreads;
|
||||
var IperlCheckErrorsToStop = config.IperlCheckErrorsToStop;
|
||||
var DfltQ2c_15_rl = config.DfltQ2c_15_rl;
|
||||
var DfltQ2c_15_lr = config.DfltQ2c_15_lr;
|
||||
var DfltQ2c_20_rl = config.DfltQ2c_20_rl;
|
||||
var DfltQ2c_20_lr = config.DfltQ2c_20_lr;
|
||||
var DfltQ2c_25_63_rl = config.DfltQ2c_25_63_rl;
|
||||
var DfltQ2c_25_63_lr = config.DfltQ2c_25_63_lr;
|
||||
var DfltQ2c_25_10_rl = config.DfltQ2c_25_10_rl;
|
||||
var DfltQ2c_25_10_lr = config.DfltQ2c_25_10_lr;
|
||||
var DfltQ2c_32_rl = config.DfltQ2c_32_rl;
|
||||
var DfltQ2c_32_lr = config.DfltQ2c_32_lr;
|
||||
var DfltQ2c_40_rl = config.DfltQ2c_40_rl;
|
||||
var DfltQ2c_40_lr = config.DfltQ2c_40_lr;
|
||||
var UseWebService = config.UseWebService;
|
||||
var BaseUrl = config.BaseUrl;
|
||||
var RelativeUrl = config.RelativeUrl;
|
||||
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_15_rl, textBox15rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_15_lr, textBox15lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_20_rl, textBox20rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_20_lr, textBox20lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_25_63_rl, textBox25_63rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_25_63_lr, textBox25_63lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_25_10_rl, textBox25_10rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_25_10_lr, textBox25_10lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_32_rl, textBox32rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_32_lr, textBox32lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_40_rl, textBox40rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.DfltQ2c_40_lr, textBox40lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref CommTimeout, commTimeoutTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref MaxCommRetries, maxCommRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DelayBetweenRetries, delayBetweenRetriesTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref NrThreads, nrThreadsTextBox.Text, CfgUpdateFlags.RestartRqrd | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref IperlCheckErrorsToStop, iperlCheckErrorsToStopTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
|
||||
flags |= UpdateDifferent(ref config.UseWebService, useWebServiceCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.BaseUrl, baseUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref config.RelativeUrl, relativeUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_15_rl, textBox15rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_15_lr, textBox15lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_20_rl, textBox20rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_20_lr, textBox20lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_25_63_rl, textBox25_63rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_25_63_lr, textBox25_63lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_25_10_rl, textBox25_10rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_25_10_lr, textBox25_10lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_32_rl, textBox32rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_32_lr, textBox32lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_40_rl, textBox40rl.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref DfltQ2c_40_lr, textBox40lr.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
|
||||
flags |= UpdateDifferent(ref UseWebService, useWebServiceCheckBox.Checked, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref BaseUrl, baseUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
flags |= UpdateDifferent(ref RelativeUrl, relativeUrlTextBox.Text, CfgUpdateFlags.InvokeCfgChange | CfgUpdateFlags.AnyChange);
|
||||
|
||||
|
||||
config.CommTimeout = CommTimeout;
|
||||
config.MaxCommRetries = MaxCommRetries;
|
||||
config.DelayBetweenRetries = DelayBetweenRetries;
|
||||
config.NrThreads = NrThreads;
|
||||
config.IperlCheckErrorsToStop = IperlCheckErrorsToStop;
|
||||
config.DfltQ2c_15_rl = DfltQ2c_15_rl;
|
||||
config.DfltQ2c_15_lr = DfltQ2c_15_lr;
|
||||
config.DfltQ2c_20_rl = DfltQ2c_20_rl;
|
||||
config.DfltQ2c_20_lr = DfltQ2c_20_lr;
|
||||
config.DfltQ2c_25_63_rl = DfltQ2c_25_63_rl;
|
||||
config.DfltQ2c_25_63_lr = DfltQ2c_25_63_lr;
|
||||
config.DfltQ2c_25_10_rl = DfltQ2c_25_10_rl;
|
||||
config.DfltQ2c_25_10_lr = DfltQ2c_25_10_lr;
|
||||
config.DfltQ2c_32_rl = DfltQ2c_32_rl;
|
||||
config.DfltQ2c_32_lr = DfltQ2c_32_lr;
|
||||
config.DfltQ2c_40_rl = DfltQ2c_40_rl;
|
||||
config.DfltQ2c_40_lr = DfltQ2c_40_lr;
|
||||
config.UseWebService = UseWebService;
|
||||
config.BaseUrl = BaseUrl;
|
||||
config.RelativeUrl = RelativeUrl;
|
||||
|
||||
if ((flags & CfgUpdateFlags.InvokeCfgChange) != 0)
|
||||
{
|
||||
TestMethod.OnCfgChange(this, new CfgChangeArgs(CfgChangeCmd.CfgChange, config));
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
///
|
||||
/// Copyright (c) 2015-2021 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Threading;
|
||||
using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.RegisterReaders.CommonRR.IPerl;
|
||||
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
public class TestMethodCfg_IPerl : ComponentCfgBase, IiPerlTestMethodCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TestMethodCfg_IPerl) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities) { return new TestMethodCfgCtrl(); }
|
||||
|
||||
//
|
||||
public override IParamsProvider GetRuntimeTestParamsProvider() { return TestParams; }
|
||||
public override IParamsProvider CreateTestParamsProvider() { return new iPerlCommunicationParams(true); }
|
||||
public override IParamsProvider GetUITestParamsProvider(Test test)
|
||||
{
|
||||
return (test.Method == Name) ? base.GetUITestParamsProvider(test) : null;
|
||||
}
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
TestMethodCfg_IPerl()
|
||||
{
|
||||
Name = "iPerlCommunication";
|
||||
ParentName = string.Empty;
|
||||
CommTimeout = 1800; /// ms
|
||||
MaxCommRetries = 4;
|
||||
WaitTimeAfterFailure = 2200;
|
||||
PassThroughWaitTime = 1500;
|
||||
NrThreads = 2; /// 1, 2 or 4 threads
|
||||
IperlCheckErrorsToStop = 10;
|
||||
MciTimeoutMs = 4000; // ms, NFC interface
|
||||
BaudRate = 57600; // NFC Interface
|
||||
DataBits = 8; // NFC Interface
|
||||
ParityBit = Parity.None; // NFC Interface
|
||||
StopBits = StopBits.Two; // NFC Interface
|
||||
|
||||
TestParams = CreateTestParamsProvider() as iPerlCommunicationParams;
|
||||
}
|
||||
|
||||
public TestMethodCfg_IPerl(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, CommTimeout={1}, MaxRetries={2}, NrThreads={3}", Name, CommTimeout, MaxCommRetries, NrThreads);
|
||||
}
|
||||
|
||||
|
||||
public int DelayBetweenRetries { get; set; }
|
||||
public int MaxCommRetries { get; set; }
|
||||
public int WaitTimeAfterFailure { get; set; }
|
||||
public int PassThroughWaitTime { get; set; }
|
||||
public int NrThreads { get; set; }
|
||||
public int CommTimeout { get; set; }
|
||||
public int IperlCheckErrorsToStop { get; set; }
|
||||
public int MciTimeoutMs { get; set; }
|
||||
public int BaudRate { get; set; }
|
||||
public int DataBits { get; set; }
|
||||
public Parity ParityBit { get; set; }
|
||||
public StopBits StopBits { get; set; }
|
||||
public int DfltQ2c_15_rl { get; set; }
|
||||
public int DfltQ2c_15_lr { get; set; }
|
||||
public int DfltQ2c_20_rl { get; set; }
|
||||
public int DfltQ2c_20_lr { get; set; }
|
||||
public int DfltQ2c_25_63_rl { get; set; }
|
||||
public int DfltQ2c_25_63_lr { get; set; }
|
||||
public int DfltQ2c_25_10_rl { get; set; }
|
||||
public int DfltQ2c_25_10_lr { get; set; }
|
||||
public int DfltQ2c_32_rl { get; set; }
|
||||
public int DfltQ2c_32_lr { get; set; }
|
||||
public int DfltQ2c_40_rl { get; set; }
|
||||
public int DfltQ2c_40_lr { get; set; }
|
||||
public bool UseWebService { get; set; }
|
||||
public string BaseUrl { get; set; }
|
||||
public string RelativeUrl { get; set; }
|
||||
|
||||
///Remember to Ignore in XmlSerializer !!
|
||||
[XmlIgnore]
|
||||
public ITestParams TestParams { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -14,11 +14,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new TestMethod(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new TestMethodCfg(this); }
|
||||
public IComponentCfg DefaultConfig() { return new TestMethodCfg_IPerl(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg.Serializer, component, this);
|
||||
return ComponentCfgBase.CreateFromDbEntity(TestMethodCfg_IPerl.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+51
-51
@@ -48,9 +48,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
}
|
||||
|
||||
|
||||
public partial class iPerlCommunicationForm : Form, GenericDevices.IHasCompleted
|
||||
public partial class iPerlCommunicationFormTestMethod : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(iPerlCommunicationForm));
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(iPerlCommunicationFormTestMethod));
|
||||
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||
|
||||
const int Hz2CorrFactorsAddr = 0x1875; /// Used by Reset2HzCorrection(...) and Write2HzCorrection(...)
|
||||
@@ -112,21 +112,21 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// <returns>Value returned by readRequestPort(...)</returns>
|
||||
public static int ReadRequestPort(IperlHead iperlHead, MessageID messageID, StructName structName, int offset, int length, out byte[] buffer)
|
||||
{
|
||||
Thread.Sleep(Math.Max(250, cfg.DelayBetweenRetries));
|
||||
Thread.Sleep(Math.Max(250, CfgIPerl.DelayBetweenRetries));
|
||||
if (iperlHead.DebugLevel == DebugMode.FailureDuringOperation) iperlHead.DebugLevel = DebugMode.Normal;
|
||||
|
||||
if (iperlHead.DebugLevel != DebugMode.Normal) // Simulation
|
||||
{
|
||||
return SimulationServices.ReadRequest(cfg, iperlHead, messageID, offset, length, out buffer);
|
||||
return SimulationServices.ReadRequest(CfgIPerl, iperlHead, messageID, offset, length, out buffer);
|
||||
}
|
||||
|
||||
if (iperlHead.CommInterface == CommunicationInterface.NFC) // NFC Interface
|
||||
{
|
||||
return NfcServices.ReadRequest(cfg, iperlHead, structName, offset, length, out buffer);
|
||||
return NfcServices.ReadRequest(CfgIPerl, iperlHead, structName, offset, length, out buffer);
|
||||
}
|
||||
else // RFID Interface
|
||||
{
|
||||
return RfidServices.ReadRequest(cfg, iperlHead, messageID, offset, length, out buffer);
|
||||
return RfidServices.ReadRequest(CfgIPerl, iperlHead, messageID, offset, length, out buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,21 +137,21 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// <returns>Value returned by writeRequestPort(...)</returns>
|
||||
public static int WriteRequestPort(IperlHead iperlHead, MessageID messageID, StructName structName, int offset, int length, byte[] buffer)
|
||||
{
|
||||
Thread.Sleep(Math.Max(250, cfg.DelayBetweenRetries));
|
||||
Thread.Sleep(Math.Max(250, CfgIPerl.DelayBetweenRetries));
|
||||
if (iperlHead.DebugLevel == DebugMode.FailureDuringOperation) iperlHead.DebugLevel = DebugMode.Normal;
|
||||
|
||||
if (iperlHead.DebugLevel != DebugMode.Normal) // Simulation
|
||||
{
|
||||
return SimulationServices.WriteRequest(cfg, iperlHead, messageID, offset, length, buffer);
|
||||
return SimulationServices.WriteRequest(CfgIPerl, iperlHead, messageID, offset, length, buffer);
|
||||
}
|
||||
|
||||
if (iperlHead.CommInterface == CommunicationInterface.NFC) // NFC Interface
|
||||
{
|
||||
return NfcServices.WriteRequest(cfg, iperlHead, structName, offset, length, buffer);
|
||||
return NfcServices.WriteRequest(CfgIPerl, iperlHead, structName, offset, length, buffer);
|
||||
}
|
||||
else // RFID Interface
|
||||
{
|
||||
return RfidServices.WriteRequest(cfg, iperlHead, messageID, offset, length, buffer);
|
||||
return RfidServices.WriteRequest(CfgIPerl, iperlHead, messageID, offset, length, buffer);
|
||||
}
|
||||
}
|
||||
#endregion iPerl_Head_RFID_Interface: ReadRequestPort, WriteRequestPort
|
||||
@@ -192,7 +192,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// RFID multiplexer PCB / RFID serial port and worker thread related variables
|
||||
///
|
||||
static TestMethod testMethod;
|
||||
public static TestMethodCfg cfg;
|
||||
public static TestMethodCfg_IPerl CfgIPerl;
|
||||
static IList<Config.Entities.Test> tests;
|
||||
static IList<iPerlCommunicationParams> multiTestParams;
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
|
||||
|
||||
/// <summary> Parameterless constructor (without watermeters, threads) </summary>
|
||||
public iPerlCommunicationForm()
|
||||
public iPerlCommunicationFormTestMethod()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
@@ -217,10 +217,10 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// Constructor for checkBox states (active/inactive iPerl head) editing.
|
||||
/// </summary>
|
||||
/// <param name="checkBoxes">Initial check box states</param>
|
||||
public iPerlCommunicationForm(bool isCheckBoxesEditMode)
|
||||
public iPerlCommunicationFormTestMethod(bool isCheckBoxesEditMode)
|
||||
: this()
|
||||
{
|
||||
iPerlCommunicationForm.cfg = new TestMethodCfg(null); // default iPerl Head communication params
|
||||
iPerlCommunicationFormTestMethod.CfgIPerl = new TestMethodCfg_IPerl(null); // default iPerl Head communication params
|
||||
if (isCheckBoxesEditMode)
|
||||
{
|
||||
checkBoxesEditMode = true;
|
||||
@@ -252,7 +252,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// Constructor for one iPerlCommunication 'test'
|
||||
/// </summary>
|
||||
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
|
||||
public iPerlCommunicationForm(TestMethod testMethod, Test test, iPerlCommunicationParams testParams)
|
||||
public iPerlCommunicationFormTestMethod(TestMethod testMethod, Test test, iPerlCommunicationParams testParams)
|
||||
: this(testMethod, new List<Test> { test }, new List<iPerlCommunicationParams> { testParams })
|
||||
{
|
||||
}
|
||||
@@ -261,15 +261,15 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// Constructor for multiple iPerlCommunication 'tests'
|
||||
/// </summary>
|
||||
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
|
||||
public iPerlCommunicationForm(TestMethod testMethod, IList<Test> tests, IList<iPerlCommunicationParams> multiTestParams)
|
||||
public iPerlCommunicationFormTestMethod(TestMethod testMethod, IList<Test> tests, IList<iPerlCommunicationParams> multiTestParams)
|
||||
: this()
|
||||
{
|
||||
checkBoxesEditMode = false;
|
||||
|
||||
iPerlCommunicationForm.testMethod = testMethod;
|
||||
iPerlCommunicationForm.cfg = testMethod.Cfg as TestMethodCfg;
|
||||
iPerlCommunicationForm.tests = tests;
|
||||
iPerlCommunicationForm.multiTestParams = multiTestParams;
|
||||
iPerlCommunicationFormTestMethod.testMethod = testMethod;
|
||||
iPerlCommunicationFormTestMethod.CfgIPerl = testMethod.Cfg as TestMethodCfg_IPerl;
|
||||
iPerlCommunicationFormTestMethod.tests = tests;
|
||||
iPerlCommunicationFormTestMethod.multiTestParams = multiTestParams;
|
||||
|
||||
if (multiTestParams.Count > 0)
|
||||
{
|
||||
@@ -347,13 +347,13 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
|
||||
/// group numbers are >=1, lastGroup == 0 means there is no group
|
||||
lastGroup = 0;
|
||||
foreach (var iPerl in iPerlCommunicationForm.iperlHeads)
|
||||
foreach (var iPerl in iPerlCommunicationFormTestMethod.iperlHeads)
|
||||
{
|
||||
if (iPerl.Group > lastGroup) lastGroup = iPerl.Group;
|
||||
}
|
||||
|
||||
workerThreads = new List<Thread>();
|
||||
for (int i = 0; i < cfg.NrThreads; i++)
|
||||
for (int i = 0; i < CfgIPerl.NrThreads; i++)
|
||||
{
|
||||
Thread thread = new Thread(Worker);
|
||||
thread.CurrentCulture = CultureInfo.CurrentCulture;
|
||||
@@ -362,7 +362,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
}
|
||||
|
||||
muxBrdOrGroup14Nrs = new List<int>();
|
||||
foreach (var iPerl in iPerlCommunicationForm.iperlHeads)
|
||||
foreach (var iPerl in iPerlCommunicationFormTestMethod.iperlHeads)
|
||||
{
|
||||
if (!muxBrdOrGroup14Nrs.Contains(iPerl.MuxBoardNrOrGroup14)) muxBrdOrGroup14Nrs.Add(iPerl.MuxBoardNrOrGroup14);
|
||||
}
|
||||
@@ -671,7 +671,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
#if TURA_SPECIAL
|
||||
int threadIx = threadID; /// Just one thread for TURA_SPECIAL
|
||||
#else
|
||||
for (int threadIx = threadID; threadIx < threadID + 4; threadIx += cfg.NrThreads)
|
||||
for (int threadIx = threadID; threadIx < threadID + 4; threadIx += CfgIPerl.NrThreads)
|
||||
#endif
|
||||
{
|
||||
bool wmFound = false;
|
||||
@@ -924,7 +924,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
}
|
||||
|
||||
/// Delay min. 250 ms
|
||||
Thread.Sleep(Math.Max(250, cfg.DelayBetweenRetries));
|
||||
Thread.Sleep(Math.Max(250, CfgIPerl.DelayBetweenRetries));
|
||||
}
|
||||
|
||||
if (error == CommErr.None && (ihead.ConfigStruct.TestModeConfig != testModeConfig))
|
||||
@@ -939,7 +939,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
}
|
||||
|
||||
/// Delay min. 250 ms
|
||||
Thread.Sleep(Math.Max(250, cfg.DelayBetweenRetries));
|
||||
Thread.Sleep(Math.Max(250, CfgIPerl.DelayBetweenRetries));
|
||||
}
|
||||
|
||||
if (error == CommErr.None)
|
||||
@@ -953,7 +953,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
}
|
||||
|
||||
/// Delay min. 250 ms
|
||||
Thread.Sleep(Math.Max(250, cfg.DelayBetweenRetries));
|
||||
Thread.Sleep(Math.Max(250, CfgIPerl.DelayBetweenRetries));
|
||||
}
|
||||
|
||||
/// Now the meter should be in the Test mode ... verify
|
||||
@@ -1635,28 +1635,28 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
switch (ihead.MeterType)
|
||||
{
|
||||
case MeterType.DN15:
|
||||
q2corrRL = cfg.DfltQ2c_15_rl;
|
||||
q2corrLR = cfg.DfltQ2c_15_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_15_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_15_lr;
|
||||
break;
|
||||
case MeterType.DN20:
|
||||
q2corrRL = cfg.DfltQ2c_20_rl;
|
||||
q2corrLR = cfg.DfltQ2c_20_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_20_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_20_lr;
|
||||
break;
|
||||
case MeterType.DN25:
|
||||
q2corrRL = cfg.DfltQ2c_25_63_rl;
|
||||
q2corrLR = cfg.DfltQ2c_25_63_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_25_63_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_25_63_lr;
|
||||
break;
|
||||
case MeterType.DN25_Q3_10:
|
||||
q2corrRL = cfg.DfltQ2c_25_10_rl;
|
||||
q2corrLR = cfg.DfltQ2c_25_10_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_25_10_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_25_10_lr;
|
||||
break;
|
||||
case MeterType.DN32:
|
||||
q2corrRL = cfg.DfltQ2c_32_rl;
|
||||
q2corrLR = cfg.DfltQ2c_32_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_32_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_32_lr;
|
||||
break;
|
||||
case MeterType.DN40:
|
||||
q2corrRL = cfg.DfltQ2c_40_rl;
|
||||
q2corrLR = cfg.DfltQ2c_40_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_40_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_40_lr;
|
||||
break;
|
||||
default:
|
||||
q2corrRL = 0;
|
||||
@@ -1739,28 +1739,28 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
switch (ihead.MeterType)
|
||||
{
|
||||
case MeterType.DN15:
|
||||
q2corrRL = cfg.DfltQ2c_15_rl;
|
||||
q2corrLR = cfg.DfltQ2c_15_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_15_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_15_lr;
|
||||
break;
|
||||
case MeterType.DN20:
|
||||
q2corrRL = cfg.DfltQ2c_20_rl;
|
||||
q2corrLR = cfg.DfltQ2c_20_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_20_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_20_lr;
|
||||
break;
|
||||
case MeterType.DN25:
|
||||
q2corrRL = cfg.DfltQ2c_25_63_rl;
|
||||
q2corrLR = cfg.DfltQ2c_25_63_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_25_63_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_25_63_lr;
|
||||
break;
|
||||
case MeterType.DN25_Q3_10:
|
||||
q2corrRL = cfg.DfltQ2c_25_10_rl;
|
||||
q2corrLR = cfg.DfltQ2c_25_10_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_25_10_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_25_10_lr;
|
||||
break;
|
||||
case MeterType.DN32:
|
||||
q2corrRL = cfg.DfltQ2c_32_rl;
|
||||
q2corrLR = cfg.DfltQ2c_32_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_32_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_32_lr;
|
||||
break;
|
||||
case MeterType.DN40:
|
||||
q2corrRL = cfg.DfltQ2c_40_rl;
|
||||
q2corrLR = cfg.DfltQ2c_40_lr;
|
||||
q2corrRL = CfgIPerl.DfltQ2c_40_rl;
|
||||
q2corrLR = CfgIPerl.DfltQ2c_40_lr;
|
||||
break;
|
||||
default:
|
||||
q2corrRL = 0;
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
///
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
partial class iPerlCommunicationForm
|
||||
partial class iPerlCommunicationFormTestMethod
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -32,7 +32,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(iPerlCommunicationForm));
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(iPerlCommunicationFormTestMethod));
|
||||
this.wmTextBox2 = new System.Windows.Forms.TextBox();
|
||||
this.wmLabel2 = new System.Windows.Forms.Label();
|
||||
this.wmLabel1 = new System.Windows.Forms.Label();
|
||||
@@ -2585,7 +2585,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "iPerlCommunicationForm";
|
||||
this.Name = "iPerlCommunicationFormTestMethod";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Text = "iPerl Communication";
|
||||
this.TopMost = true;
|
||||
@@ -10,17 +10,19 @@ using Config.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Resources;
|
||||
using System.Collections.Generic;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
public class iPerlCommunicationParams : TestParamsBase, IParamsProvider, ITestParams
|
||||
public class iPerlCommunicationParams : TestParamsBase, ITestParams
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(iPerlCommunicationParams) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public string Activity; /// Communication activity
|
||||
public bool SimultWithPrevious;
|
||||
public bool SimultWithNext;
|
||||
|
||||
public string Activity { get; set; } /// Communication activity
|
||||
public bool SimultWithPrevious { get; set; }
|
||||
public bool SimultWithNext { get; set; }
|
||||
|
||||
public override void InitializeAll()
|
||||
{
|
||||
@@ -44,54 +46,54 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
if (i == 0)
|
||||
{
|
||||
var retVal = new List<string>();
|
||||
retVal.Add(iPerlCommunicationForm.ReadConfigurationStr);
|
||||
retVal.Add(string.Format("{0} A0", iPerlCommunicationForm.SetTestModeStr));
|
||||
retVal.Add(string.Format("{0} A4", iPerlCommunicationForm.SetTestModeStr));
|
||||
retVal.Add(iPerlCommunicationForm.ReadCalibrationStr);
|
||||
retVal.Add(iPerlCommunicationForm.ReadCalibrationV4Str);
|
||||
retVal.Add(iPerlCommunicationForm.NormalizeCalibrationFactorStr);
|
||||
retVal.Add(iPerlCommunicationForm.NormalizeCalibrationV4FactorsStr);
|
||||
retVal.Add(iPerlCommunicationForm.GetDefaultQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationForm.ReadQ2CorrectionStr);
|
||||
retVal.Add(iPerlCommunicationForm.ResetQ2CorrectionStr);
|
||||
retVal.Add(iPerlCommunicationForm.WriteDefaultQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationForm.InitOrReadQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationForm.WriteCalibrationFactorStr);
|
||||
retVal.Add(iPerlCommunicationForm.WriteCalibrationV4FactorsStr);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionStr);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionAltStr);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionGreeceStr);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionRLStr);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionLRStr);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionIncl05Str);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionAltIncl05Str);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionPlusIncl05Str);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionPlusAltIncl05Str);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionGreeceIncl05Str);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionRLIncl05Str);
|
||||
retVal.Add(iPerlCommunicationForm.WriteQ2CorrectionLRIncl05Str);
|
||||
retVal.Add(iPerlCommunicationSeq.Q2correctedFromCmd + "Qx");
|
||||
retVal.Add(iPerlCommunicationSeq.StrictQ2ErrorCheckStr + "Qx");
|
||||
retVal.Add(iPerlCommunicationSeq.Q2correctionCheckCmd);
|
||||
retVal.Add(iPerlCommunicationSeq.IperlCheckCmd);
|
||||
retVal.Add(iPerlCommunicationForm.UpdateBothQ2FactorsTestRLOnlyStr);
|
||||
retVal.Add(iPerlCommunicationForm.UpdateBothQ2FactorsTestLROnlyStr);
|
||||
retVal.Add(iPerlCommunicationForm.UpdateQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationForm.ConditnlUpdateQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationForm.ConditnlUpdateQ2CorrRLStr);
|
||||
retVal.Add(iPerlCommunicationForm.ConditnlUpdateQ2CorrLRStr);
|
||||
retVal.Add(iPerlCommunicationConstants.ReadConfigurationStr);
|
||||
retVal.Add(string.Format("{0} A0", iPerlCommunicationConstants.SetTestModeStr));
|
||||
retVal.Add(string.Format("{0} A4", iPerlCommunicationConstants.SetTestModeStr));
|
||||
retVal.Add(iPerlCommunicationConstants.ReadCalibrationStr);
|
||||
retVal.Add(iPerlCommunicationConstants.ReadCalibrationV4Str);
|
||||
retVal.Add(iPerlCommunicationConstants.NormalizeCalibrationFactorStr);
|
||||
retVal.Add(iPerlCommunicationConstants.NormalizeCalibrationV4FactorsStr);
|
||||
retVal.Add(iPerlCommunicationConstants.GetDefaultQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationConstants.ReadQ2CorrectionStr);
|
||||
retVal.Add(iPerlCommunicationConstants.ResetQ2CorrectionStr);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteDefaultQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationConstants.InitOrReadQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteCalibrationFactorStr);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteCalibrationV4FactorsStr);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionStr);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionAltStr);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionGreeceStr);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionRLStr);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionLRStr);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionIncl05Str);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionAltIncl05Str);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionPlusIncl05Str);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionPlusAltIncl05Str);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionGreeceIncl05Str);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionRLIncl05Str);
|
||||
retVal.Add(iPerlCommunicationConstants.WriteQ2CorrectionLRIncl05Str);
|
||||
retVal.Add(iPerlCommunicationConstants.Q2correctedFromCmd + "Qx");
|
||||
retVal.Add(iPerlCommunicationConstants.StrictQ2ErrorCheckStr + "Qx");
|
||||
retVal.Add(iPerlCommunicationConstants.Q2correctionCheckCmd);
|
||||
retVal.Add(iPerlCommunicationConstants.IperlCheckCmd);
|
||||
retVal.Add(iPerlCommunicationConstants.UpdateBothQ2FactorsTestRLOnlyStr);
|
||||
retVal.Add(iPerlCommunicationConstants.UpdateBothQ2FactorsTestLROnlyStr);
|
||||
retVal.Add(iPerlCommunicationConstants.UpdateQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationConstants.ConditnlUpdateQ2CorrectionsStr);
|
||||
retVal.Add(iPerlCommunicationConstants.ConditnlUpdateQ2CorrRLStr);
|
||||
retVal.Add(iPerlCommunicationConstants.ConditnlUpdateQ2CorrLRStr);
|
||||
retVal.Add("Q2 corrected from Q2adj");
|
||||
retVal.Add("Q2 correction check Q2bc Q2ac");
|
||||
retVal.Add(iPerlCommunicationForm.SetActiveModeStr);
|
||||
retVal.Add(iPerlCommunicationConstants.SetActiveModeStr);
|
||||
retVal.Add("---");
|
||||
retVal.Add(iPerlCommunicationForm.Reset2HzCorrectionStr);
|
||||
retVal.Add(iPerlCommunicationForm.Write2HzCorrectionStr);
|
||||
retVal.Add(iPerlCommunicationForm.DewaReworkRLStr);
|
||||
retVal.Add(iPerlCommunicationForm.DewaReworkLRStr);
|
||||
retVal.Add(iPerlCommunicationForm.StartTestingSealedMetersStr);
|
||||
retVal.Add(iPerlCommunicationForm.EndTestingSealedMetersStr);
|
||||
retVal.Add(string.Format("{0} if enabled", iPerlCommunicationForm.ReadConfigurationStr));
|
||||
retVal.Add(string.Format("{0} 80", iPerlCommunicationForm.SetTestModeStr));
|
||||
retVal.Add(iPerlCommunicationConstants.Reset2HzCorrectionStr);
|
||||
retVal.Add(iPerlCommunicationConstants.Write2HzCorrectionStr);
|
||||
retVal.Add(iPerlCommunicationConstants.DewaReworkRLStr);
|
||||
retVal.Add(iPerlCommunicationConstants.DewaReworkLRStr);
|
||||
retVal.Add(iPerlCommunicationConstants.StartTestingSealedMetersStr);
|
||||
retVal.Add(iPerlCommunicationConstants.EndTestingSealedMetersStr);
|
||||
retVal.Add(string.Format("{0} if enabled", iPerlCommunicationConstants.ReadConfigurationStr));
|
||||
retVal.Add(string.Format("{0} 80", iPerlCommunicationConstants.SetTestModeStr));
|
||||
retVal.Add("iPerl_check prevWorkStep direction q2factors");
|
||||
for (ConditionID id = ConditionID.A; id < ConditionID.Count; id++)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@ using TBF.Resources;
|
||||
using TBF.UiBridge;
|
||||
using Results;
|
||||
using Results.Entities;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Rig.TestMethods.iPerlCommunication.iPerlHead;
|
||||
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
@@ -34,7 +35,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
///
|
||||
void OpenIPerlCommForm(iPerlCommunicationSeq myRef, TestMethod method, Test test, iPerlCommunicationParams testParams)
|
||||
{
|
||||
myRef.modelessDlg = new iPerlCommunicationForm(method, test, testParams);
|
||||
myRef.modelessDlg = new iPerlCommunicationFormTestMethod(method, test, testParams);
|
||||
myRef.modelessDlg.Show();
|
||||
}
|
||||
|
||||
@@ -56,9 +57,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// Event.OpArgumentError . Target flow is out of range
|
||||
/// Event.Error . . . . . . Unspecified error
|
||||
/// </returns>
|
||||
public IList<Event> Execute(Test test, int repetitionNr, TestMethod method, iPerlCommunicationParams testParams)
|
||||
public IList<Event> Execute(Test test, int repetitionNr, TestMethod method, ITestParams testParams)
|
||||
{
|
||||
TestMethodCfg cfg = method.Cfg as TestMethodCfg;
|
||||
TestMethodCfg_IPerl cfgIPerl = method.Cfg as TestMethodCfg_IPerl;
|
||||
|
||||
IList<Event> e; /// Events from currently running operations
|
||||
checkUiOp = new Operations.CheckUIOp(true); /// Runs in more then one state
|
||||
@@ -67,7 +68,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
processDataLoggingOp = new TBF.Rig.Operations.ProcessDataLoggingOp(processDataLogger, this, false);
|
||||
|
||||
string cmd;
|
||||
if (testParams.Activity.ToLower().Equals(cmd = iPerlCommunicationForm.GetDefaultQ2CorrectionsStr.ToLower()))
|
||||
if (testParams.Activity.ToLower().Equals(cmd = iPerlCommunicationFormTestMethod.GetDefaultQ2CorrectionsStr.ToLower()))
|
||||
{
|
||||
TestProgressEventArgs.SetEstimatedTimes(new int[] { 0, 0, 0, 30, 0, 30, 0, 0 });
|
||||
Bridge.OnTestProgress(this, new TestProgressEventArgs(test, Progress.JustStarted));
|
||||
@@ -86,9 +87,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
}*/
|
||||
#endif
|
||||
|
||||
if (cfg.UseWebService)
|
||||
if (cfgIPerl.UseWebService)
|
||||
{
|
||||
IsQ2PreCorrectionCalculated = GetQ2PreCorrectionsOrBackups(cfg, wmType, out CalculatedQ2PreCorrectionLR, out CalculatedQ2PreCorrectionRL);
|
||||
IsQ2PreCorrectionCalculated = GetQ2PreCorrectionsOrBackups(cfgIPerl, wmType, out CalculatedQ2PreCorrectionLR, out CalculatedQ2PreCorrectionRL);
|
||||
}
|
||||
|
||||
/// Generate test results
|
||||
@@ -105,7 +106,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
{
|
||||
if (mtr.TestRslt == tstRslt)
|
||||
{
|
||||
mtr.Passed = !cfg.UseWebService || IsQ2PreCorrectionCalculated;
|
||||
mtr.Passed = !cfgIPerl.UseWebService || IsQ2PreCorrectionCalculated;
|
||||
mtr.TestDone = true;
|
||||
break;
|
||||
}
|
||||
@@ -270,7 +271,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
Bridge.OnTestCompleted(this, new TestCompletedEventArgs(test.Name, tstRslt));
|
||||
allResults.Info(TestResult2CsvLine(test.Name, 0)); /// Append the results to the CSV-file
|
||||
|
||||
if (wrongMetersCount >= cfg.IperlCheckErrorsToStop)
|
||||
if (wrongMetersCount >= cfgIPerl.IperlCheckErrorsToStop)
|
||||
{
|
||||
State.Create("iPerlCommunicationSeq : Show check result")
|
||||
.AddOperation(new Operations.LargeMessageBoxOp(message))
|
||||
@@ -408,12 +409,12 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// <summary>
|
||||
/// Read default Q2 correction factors from a REST service (= Web service).
|
||||
/// </summary>
|
||||
/// <param name="cfg">iPerlCommunication component configuration</param>
|
||||
/// <param name="cfgIPerl">iPerlCommunication component configuration</param>
|
||||
/// <param name="wmType">Water meter type (WZ Typ)</param>
|
||||
/// <param name="q2PreCorrectionLR">Default Q2 correction LR</param>
|
||||
/// <param name="q2PreCorrectionRL">Default Q2 correction RL</param>
|
||||
/// <returns>true when successful</returns>
|
||||
static bool ReadCorrectionsFromWebService(TestMethodCfg cfg, int wmType, out int q2PreCorrectionLR, out int q2PreCorrectionRL)
|
||||
static bool ReadCorrectionsFromWebService(TestMethodCfg_IPerl cfgIPerl, int wmType, out int q2PreCorrectionLR, out int q2PreCorrectionRL)
|
||||
{
|
||||
if (wmType == 0)
|
||||
{
|
||||
@@ -425,9 +426,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
|
||||
try
|
||||
{
|
||||
GetQ2PreCorrectionClient client = new GetQ2PreCorrectionClient(cfg.BaseUrl);
|
||||
GetQ2PreCorrectionClient client = new GetQ2PreCorrectionClient(cfgIPerl.BaseUrl);
|
||||
client.GetToken("ReadUser", "sensus", "https://deluh1web03.world.fluidtechnology.net/SensusCore/api/v1/Locations/1/Login2").Wait();
|
||||
Q2PreCorrection response = client.GetQ2Correction(string.Format(cfg.RelativeUrl, wmType)).Result;
|
||||
Q2PreCorrection response = client.GetQ2Correction(string.Format(cfgIPerl.RelativeUrl, wmType)).Result;
|
||||
if (response != null && response.AreDataCalculated)
|
||||
{
|
||||
q2PreCorrectionLR = response.CorrLR;
|
||||
@@ -455,15 +456,15 @@ namespace TBF.Rig.TestMethods.iPerlCommunication
|
||||
/// <summary>
|
||||
/// Obtain Q2 correction factors from a REST service or from local settings (stored backup values)
|
||||
/// </summary>
|
||||
/// <param name="cfg">iPerlCommunication component configuration</param>
|
||||
/// <param name="cfgIPerl">iPerlCommunication component configuration</param>
|
||||
/// <param name="wmType">Water meter type (WZ Typ)</param>
|
||||
/// <param name="q2PreCorrectionLR">Default Q2 correction LR</param>
|
||||
/// <param name="q2PreCorrectionRL">Default Q2 correction RL</param>
|
||||
/// <returns>true when successful</returns>
|
||||
public static bool GetQ2PreCorrectionsOrBackups(TestMethodCfg cfg, int wmType, out int q2PreCorrectionLR, out int q2PreCorrectionRL)
|
||||
public static bool GetQ2PreCorrectionsOrBackups(TestMethodCfg_IPerl cfgIPerl, int wmType, out int q2PreCorrectionLR, out int q2PreCorrectionRL)
|
||||
{
|
||||
/// Get Q2 pre-correction values from REST service
|
||||
bool restOK = ReadCorrectionsFromWebService(cfg, wmType, out q2PreCorrectionLR, out q2PreCorrectionRL);
|
||||
bool restOK = ReadCorrectionsFromWebService(cfgIPerl, wmType, out q2PreCorrectionLR, out q2PreCorrectionRL);
|
||||
|
||||
/// Store / load Q2 pre-correction values
|
||||
Point storedValue;
|
||||
|
||||
@@ -17,13 +17,14 @@ using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq; // This line is correct and does not need to be changed.
|
||||
using System.Windows;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication.common;
|
||||
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
/// <summary>
|
||||
/// This component = instance of this class is a placeholder for a combined main watermeter
|
||||
/// </summary>
|
||||
public class IperlHead : ComponentBase, IDevice,IRegReaderDatastream, ISessionDataMngmnt, IOperation
|
||||
public class IperlHead : ComponentBase, IDevice,IRegReaderDatastream, ISessionDataMngmnt, IOperation, IntIPerlReader
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(IperlHead));
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
@@ -42,7 +43,10 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
|
||||
readonly IperlHeadCfg iperlHeadCfg;
|
||||
|
||||
RegisterReaders.CommonRR.CommunicationInterface IntIPerlReader.CommInterface => _commInterface;
|
||||
|
||||
public int RfidComPortNr { get { return iperlHeadCfg.RfidComPortNr; } }
|
||||
public bool CommFailed { get; set; }
|
||||
public int OptoComPortNr { get { return iperlHeadCfg.OptoComPortNr; } }
|
||||
public int MuxBoardNrOrGroup14 { get { return iperlHeadCfg.MuxBoardNr; } }
|
||||
public int Group { get { return iperlHeadCfg.Group; } }
|
||||
@@ -87,7 +91,6 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
}
|
||||
|
||||
public bool Disabled;
|
||||
public bool CommFailed;
|
||||
public int ResultCode;
|
||||
|
||||
|
||||
@@ -930,6 +933,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
dataStreamState = DataStreamState.ProcessAndSave;
|
||||
}
|
||||
|
||||
public void SetCommunicationInterface(RegisterReaders.CommonRR.CommunicationInterface commInterface)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when processing and saving datastream data is in progress
|
||||
/// </summary>
|
||||
@@ -938,6 +946,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
return dataStreamState == DataStreamState.ProcessAndSave;
|
||||
}
|
||||
|
||||
void IntIPerlReader.SetRfidInterface()
|
||||
{
|
||||
SetRfidInterface();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop processing and saving datastream data
|
||||
/// </summary>
|
||||
@@ -953,8 +966,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
bool synchronized;
|
||||
bool synchronized2;
|
||||
string partOfTelegram;
|
||||
private RegisterReaders.CommonRR.CommunicationInterface _commInterface;
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// Reads opto-datastream via serial port. Invoked from RunDeviceBefore()
|
||||
///
|
||||
/// Telegram description:
|
||||
@@ -1063,6 +1077,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
}
|
||||
}
|
||||
|
||||
void IntIPerlReader.ResetNfcInterface(bool? nfc_on)
|
||||
{
|
||||
ResetNfcInterface(nfc_on);
|
||||
}
|
||||
|
||||
public string ReadOptoData()
|
||||
{
|
||||
if (optoSerialPort is null) return "";
|
||||
@@ -1080,6 +1099,11 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
return received;
|
||||
}
|
||||
|
||||
void IntIPerlReader.SetNfcInterface()
|
||||
{
|
||||
SetNfcInterface();
|
||||
}
|
||||
|
||||
|
||||
void OptoTelegramReceived(int currentIx, bool async, Int64 volumeRawExt, Int64 timestampRawExt)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Threading;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Windows.Forms;
|
||||
using TBF.Rig.Sequences;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
@@ -21,7 +22,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
InitializeComponent();
|
||||
if (config == null) return;
|
||||
|
||||
iPerlCommunicationForm.cfg = new TestMethodCfg(null); // default values for iPerlCommunication
|
||||
SmartCommunicationForm.TestMethodCfg = new TestMethodCfg_IPerl(null); // default values for iPerlCommunication
|
||||
|
||||
foreach(var head in ProcessData.IperlHeads)
|
||||
{
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
internal class NfcServices
|
||||
{
|
||||
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||
internal static int ReadRequest(TestMethodCfg cfg, IperlHead iperlHead, MCI_Protocol.StructName structName, int offset, int length, out byte[] buffer)
|
||||
internal static int ReadRequest(TestMethodCfg_IPerl cfgIPerl, IperlHead iperlHead, MCI_Protocol.StructName structName, int offset, int length, out byte[] buffer)
|
||||
{
|
||||
for (int i = 0; i < cfg.MaxCommRetries; i++)
|
||||
for (int i = 0; i < cfgIPerl.MaxCommRetries; i++)
|
||||
{
|
||||
|
||||
NfcDataHandler _nfcDataHandler = new NfcDataHandler();
|
||||
@@ -26,9 +26,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
try
|
||||
{
|
||||
rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} ReadRequest : {structName}, {offset}, {length}");
|
||||
OpenConnection(_nfcDataHandler, cfg, iperlHead);
|
||||
OpenConnection(_nfcDataHandler, cfgIPerl, iperlHead);
|
||||
|
||||
buffer = MciRead(_nfcDataHandler, cfg, structName, (ushort)offset, length);
|
||||
buffer = MciRead(_nfcDataHandler, cfgIPerl, structName, (ushort)offset, length);
|
||||
_nfcDataHandler.RFProtocolOFF(); // turn off rf antenna due to possible interference
|
||||
|
||||
CloseComPort(_nfcDataHandler);
|
||||
@@ -44,7 +44,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
}
|
||||
catch (RfidValidationException)
|
||||
{
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
Thread.Sleep(cfgIPerl.WaitTimeAfterFailure);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
return 3;
|
||||
}
|
||||
|
||||
internal static int WriteRequest(TestMethodCfg cfg, IperlHead iperlHead, MCI_Protocol.StructName structName, int offset, int length, byte[] buffer)
|
||||
internal static int WriteRequest(TestMethodCfg_IPerl cfgIPerl, IperlHead iperlHead, MCI_Protocol.StructName structName, int offset, int length, byte[] buffer)
|
||||
{
|
||||
NfcDataHandler _nfcDataHandler = new NfcDataHandler();
|
||||
MessageEventHandlers(_nfcDataHandler);
|
||||
@@ -68,9 +68,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
try
|
||||
{
|
||||
rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} WriteRequest : {structName}, {offset}, {length}, {ByteArrayToHexString(buffer)}");
|
||||
OpenConnection(_nfcDataHandler, cfg, iperlHead);
|
||||
OpenConnection(_nfcDataHandler, cfgIPerl, iperlHead);
|
||||
|
||||
MciWrite(_nfcDataHandler, cfg, structName, (ushort)offset, length, buffer);
|
||||
MciWrite(_nfcDataHandler, cfgIPerl, structName, (ushort)offset, length, buffer);
|
||||
_nfcDataHandler.RFProtocolOFF(); // turn off rf antenna due to possible interference
|
||||
|
||||
CloseComPort(_nfcDataHandler);
|
||||
@@ -83,14 +83,14 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
}
|
||||
}
|
||||
|
||||
private static void OpenConnection(NfcDataHandler nfcDataHandler, TestMethodCfg cfg, IperlHead iperlHead)
|
||||
private static void OpenConnection(NfcDataHandler nfcDataHandler, TestMethodCfg_IPerl cfgIPerl, IperlHead iperlHead)
|
||||
{
|
||||
string comPort = $"COM{iperlHead.RfidComPortNr}";
|
||||
int retryCount = 0 ;
|
||||
Open:
|
||||
nfcDataHandler.Close();
|
||||
Thread.Sleep(100);
|
||||
if (nfcDataHandler.OpenConnection(comPort, cfg.BaudRate, cfg.DataBits, cfg.ParityBit, cfg.StopBits))
|
||||
if (nfcDataHandler.OpenConnection(comPort, cfgIPerl.BaudRate, cfgIPerl.DataBits, cfgIPerl.ParityBit, cfgIPerl.StopBits))
|
||||
{
|
||||
rfidDataLogger.Info($"NFC COM{iperlHead.RfidComPortNr} Port Open");
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
if (!nfcDataHandler.ConnectDevice())
|
||||
{
|
||||
rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} Error connect device.");
|
||||
for (int i = 0; i < cfg.MaxCommRetries; i++)
|
||||
for (int i = 0; i < cfgIPerl.MaxCommRetries; i++)
|
||||
{
|
||||
if (nfcDataHandler.Echo()) break;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
retryCount++;
|
||||
rfidDataLogger.Error($"NFC COM{iperlHead.RfidComPortNr} Error connect reader. Reconnect comport {retryCount}");
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
if (retryCount < cfgIPerl.MaxCommRetries)
|
||||
{
|
||||
nfcDataHandler.Close();
|
||||
iperlHead.ResetNfcInterface(); // reset NFC head via optoport - switch to RFID and back to NFC interface
|
||||
@@ -127,7 +127,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
nfcDataHandler.Close();
|
||||
}
|
||||
|
||||
private static byte[] MciRead(NfcDataHandler nfcDataHandler, TestMethodCfg cfg, StructName structName, ushort offset, int length)
|
||||
private static byte[] MciRead(NfcDataHandler nfcDataHandler, TestMethodCfg_IPerl cfgIPerl, StructName structName, ushort offset, int length)
|
||||
{
|
||||
bool isReadValues = false;
|
||||
int retryCount = 0;
|
||||
@@ -153,14 +153,14 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
rfidDataLogger.Info($"MCI Error: Unidentified");
|
||||
retryCount++;
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
if (retryCount < cfgIPerl.MaxCommRetries)
|
||||
goto Read;
|
||||
}
|
||||
else
|
||||
{
|
||||
rfidDataLogger.Info("Last error message: " + nfcDataHandler.LastErrorMessage);
|
||||
retryCount++;
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
if (retryCount < cfgIPerl.MaxCommRetries)
|
||||
goto Read;
|
||||
}
|
||||
}
|
||||
@@ -168,13 +168,13 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
rfidDataLogger.Error("MciRead Last error message: " + ex.Message);
|
||||
retryCount++;
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
if (retryCount < cfgIPerl.MaxCommRetries)
|
||||
goto Read;
|
||||
}
|
||||
return new byte[length];
|
||||
}
|
||||
|
||||
private static void MciWrite(NfcDataHandler nfcDataHandler, TestMethodCfg cfg, MCI_Protocol.StructName structName, ushort offset, int length, byte[] payload)
|
||||
private static void MciWrite(NfcDataHandler nfcDataHandler, TestMethodCfg_IPerl cfgIPerl, MCI_Protocol.StructName structName, ushort offset, int length, byte[] payload)
|
||||
{
|
||||
int retryCount = 0;
|
||||
Write:
|
||||
@@ -199,7 +199,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
rfidDataLogger.Error("MciWrite error message: " + ex.Message);
|
||||
retryCount++;
|
||||
if (retryCount < cfg.MaxCommRetries)
|
||||
if (retryCount < cfgIPerl.MaxCommRetries)
|
||||
goto Write;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,24 +5,25 @@ using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using log4net;
|
||||
using TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication;
|
||||
|
||||
namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
internal class RfidServices
|
||||
{
|
||||
protected static readonly ILog rfidDataLogger = LogManager.GetLogger("RfidData");
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(iPerlCommunicationForm));
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(SmartCommunicationForm));
|
||||
|
||||
internal static int ReadRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
|
||||
internal static int ReadRequest(TestMethodCfg_IPerl cfgIPerl, IperlHead iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
|
||||
{
|
||||
for (int i = 0; i < cfg.MaxCommRetries; i++)
|
||||
for (int i = 0; i < cfgIPerl.MaxCommRetries; i++)
|
||||
{
|
||||
rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} reading: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},{offset}, {length}... timeout {cfg.CommTimeout})");
|
||||
rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} reading: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},{offset}, {length}... timeout {cfgIPerl.CommTimeout})");
|
||||
using (RfidLogic writer = new RfidLogic($"COM{iperlHead.RfidComPortNr}"))
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] response = writer.ReadRequest((byte)messageID, offset, length, cfg.CommTimeout);
|
||||
byte[] response = writer.ReadRequest((byte)messageID, offset, length, cfgIPerl.CommTimeout);
|
||||
string hexString = RfidHelper.ConvertByteArrayToHexString(response);
|
||||
string swapHexString = RfidHelper.SwapHexcode(hexString);
|
||||
string decString = RfidHelper.HexLiteral2Unsigned(RfidHelper.SwapHexcode(hexString)).ToString();
|
||||
@@ -56,42 +57,42 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
if (/*RfidHelper.IsPassThrough(messageID)*/ messageID == MessageID.ASICRegisterReadTest || messageID == MessageID.RadioPassthrough)
|
||||
{
|
||||
rfidDataLogger.Info($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) {(i > 0 ? "<- Error: Invalid Pass-Through data." : "<- Info: Wait for Pass-Through data.")}");
|
||||
Thread.Sleep(cfg.PassThroughWaitTime);
|
||||
Thread.Sleep(cfgIPerl.PassThroughWaitTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
Thread.Sleep(cfgIPerl.WaitTimeAfterFailure);
|
||||
}
|
||||
}
|
||||
catch (RfidValidationException)
|
||||
{
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
Thread.Sleep(cfgIPerl.WaitTimeAfterFailure);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...) {ex.Message}");
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
Thread.Sleep(cfgIPerl.WaitTimeAfterFailure);
|
||||
}
|
||||
}
|
||||
}
|
||||
rfidDataLogger.Error($"{iperlHead.CommInterface} reading failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...)");
|
||||
log.Error($"{iperlHead.CommInterface} reading failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...)");
|
||||
rfidDataLogger.Error($"{iperlHead.CommInterface} reading failed after {cfgIPerl.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...)");
|
||||
log.Error($"{iperlHead.CommInterface} reading failed after {cfgIPerl.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: ReadRequestPort ({messageID},...)");
|
||||
buffer = new byte[length];
|
||||
return 3;
|
||||
}
|
||||
|
||||
internal static int WriteRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, byte[] buffer)
|
||||
internal static int WriteRequest(TestMethodCfg_IPerl cfgIPerl, IperlHead iperlHead, MessageID messageID, int offset, int length, byte[] buffer)
|
||||
{
|
||||
RfidLogic writer = new RfidLogic($"COM{iperlHead.RfidComPortNr}");
|
||||
string payload = RfidHelper.ConvertByteArrayToHexString(buffer);
|
||||
|
||||
for (var i = 0; i < cfg.MaxCommRetries; i++)
|
||||
for (var i = 0; i < cfgIPerl.MaxCommRetries; i++)
|
||||
{
|
||||
rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} writting: COM{iperlHead.RfidComPortNr}: WriteRequest ({messageID},{offset}, {length}, {payload}... timeout {cfg.CommTimeout})");
|
||||
rfidDataLogger.Error($"{iperlHead.CommInterface} Start {i} writting: COM{iperlHead.RfidComPortNr}: WriteRequest ({messageID},{offset}, {length}, {payload}... timeout {cfgIPerl.CommTimeout})");
|
||||
try
|
||||
{
|
||||
if (writer.ClosePort()) writer.OpenPort();
|
||||
writer.WriteRequest((byte)messageID, offset, length, buffer, cfg.CommTimeout, false);
|
||||
writer.WriteRequest((byte)messageID, offset, length, buffer, cfgIPerl.CommTimeout, false);
|
||||
writer.ClosePort();
|
||||
rfidDataLogger.InfoFormat($"{iperlHead.Name}({iperlHead.SerialNr},COM{iperlHead.RfidComPortNr}): WriteRequestPort({messageID}, {offset}, {length}, {payload})");
|
||||
return 0;
|
||||
@@ -105,7 +106,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
else
|
||||
{
|
||||
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: Error: {ex.Message}");
|
||||
Thread.Sleep(cfg.WaitTimeAfterFailure);
|
||||
Thread.Sleep(cfgIPerl.WaitTimeAfterFailure);
|
||||
if (i > 1)
|
||||
{
|
||||
rfidDataLogger.Error($"COM{iperlHead.RfidComPortNr}: Reopen the com port.");
|
||||
@@ -115,8 +116,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
}
|
||||
}
|
||||
writer.ClosePort();
|
||||
rfidDataLogger.Error($"RFID writing failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: WriteRequestPort ({messageID},...) {System.Text.Encoding.UTF8.GetString(buffer)}");
|
||||
log.Error($"RFID writing failed after {cfg.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: WriteRequestPort ({messageID},...) {System.Text.Encoding.UTF8.GetString(buffer)}");
|
||||
rfidDataLogger.Error($"RFID writing failed after {cfgIPerl.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: WriteRequestPort ({messageID},...) {System.Text.Encoding.UTF8.GetString(buffer)}");
|
||||
log.Error($"RFID writing failed after {cfgIPerl.MaxCommRetries} retries: COM{iperlHead.RfidComPortNr}: WriteRequestPort ({messageID},...) {System.Text.Encoding.UTF8.GetString(buffer)}");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
const int Q2CorrFactorsAddr = 0x1878;
|
||||
|
||||
internal static int ReadRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
|
||||
internal static int ReadRequest(TestMethodCfg_IPerl cfgIPerl, IperlHead iperlHead, MessageID messageID, int offset, int length, out byte[] buffer)
|
||||
{
|
||||
byte[] configurationBuffer = new byte[ConfigStruct.Length] { 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
byte[] calibrationBuffer = new byte[CalibrationStructV4.Length] { 3, 0, 150, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 150, 10 };
|
||||
@@ -34,7 +34,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
return iperlHead.Name.Equals("iPerl13") ? 2 : 0; /// Simulates an error on position 13
|
||||
}
|
||||
|
||||
internal static int WriteRequest(TestMethodCfg cfg, IperlHead iperlHead, MessageID messageID, int offset, int length, byte[] buffer)
|
||||
internal static int WriteRequest(TestMethodCfg_IPerl cfgIPerl, IperlHead iperlHead, MessageID messageID, int offset, int length, byte[] buffer)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -36,12 +36,26 @@ namespace TBF.Rig
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary> To be overridden </summary>
|
||||
public bool ValidateParam(int ix, string strValue, out string message)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateParam(int ix, string strValue)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary> To be overridden </summary>
|
||||
public virtual ICollection<string> ParamValues(int ix)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public string Activity { get; set; }
|
||||
public bool SimultWithPrevious { get; set; }
|
||||
public bool SimultWithNext { get; set; }
|
||||
|
||||
/// <summary> To be overridden </summary>
|
||||
public virtual void UpdateFromDbEntity(ComponentTest dbEntity)
|
||||
{
|
||||
@@ -93,6 +107,11 @@ namespace TBF.Rig
|
||||
return true;
|
||||
}
|
||||
|
||||
public IParamsProvider Clone()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual string ParamName(int i) { return string.Empty; }
|
||||
|
||||
public virtual int ParamsCount() { return 0; }
|
||||
|
||||
@@ -10,6 +10,7 @@ using Config.Entities;
|
||||
using SchematicDrawing;
|
||||
using TBF.Rig.Generic;
|
||||
using TBF.Resources;
|
||||
using TBF.Tools;
|
||||
|
||||
namespace TBF.Rig.Uni.FlowMeter
|
||||
{
|
||||
@@ -641,6 +642,10 @@ namespace TBF.Rig.Uni.FlowMeter
|
||||
}
|
||||
public static Unit ParseFlowUnit(string str)
|
||||
{
|
||||
//Check if the string is a valid unit description
|
||||
Unit fromDescription = Units.FromDescription(str);
|
||||
if (fromDescription != Unit.None) return fromDescription;
|
||||
//check if the string is a valid unit name
|
||||
switch (str)
|
||||
{
|
||||
case "l/h": return Unit.lph;
|
||||
|
||||
@@ -202,6 +202,10 @@ namespace TBF.Rig.Uni.FlowMetersInParallel
|
||||
}
|
||||
public static Unit ParseFlowUnit(string str)
|
||||
{
|
||||
//Check if the string is a valid unit description
|
||||
Unit fromDescription = Units.FromDescription(str);
|
||||
if (fromDescription != Unit.None) return fromDescription;
|
||||
//check if the string is a valid unit name
|
||||
switch (str)
|
||||
{
|
||||
case "l/h": return Unit.lph;
|
||||
|
||||
+2
-1
@@ -2,9 +2,10 @@
|
||||
/// Copyright (c) 2015 Sensus Metering Systems
|
||||
/// Author: Milan Hanajík
|
||||
///
|
||||
|
||||
using System;
|
||||
|
||||
namespace TBF.Rig.Uni.SharedDialogs.iPerlCommunication
|
||||
namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
|
||||
{
|
||||
public class AllCompletedEventArgs : EventArgs
|
||||
{
|
||||
+2
-2
@@ -2,11 +2,11 @@
|
||||
/// Copyright (c) 2015-2019 Sensus Metering Systems
|
||||
/// Author: Milan Hanajík
|
||||
///
|
||||
|
||||
using System;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI;
|
||||
using TBF.Rig.RegisterReaders.iPerlReaderUNI.comminication;
|
||||
|
||||
namespace TBF.Rig.Uni.SharedDialogs.iPerlCommunication
|
||||
namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
|
||||
{
|
||||
public class CommCompletedEventArgs : EventArgs
|
||||
{
|
||||
+452
-1201
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -1,6 +1,6 @@
|
||||
namespace TBF.Rig.Uni.SharedDialogs.iPerlCommunication
|
||||
namespace TBF.Rig.Uni.SharedDialogs.SmartMetersCommunication
|
||||
{
|
||||
public enum ConditionID
|
||||
public enum ConditionId
|
||||
{
|
||||
A,
|
||||
B,
|
||||
@@ -11,15 +11,15 @@ namespace TBF.Rig.Uni.SharedDialogs.iPerlCommunication
|
||||
public abstract class ISequenceConditionOp
|
||||
{
|
||||
const string ConditionNameFmt = "iPERL communication milestone {0}";
|
||||
public static string GetConditionNameFmt(ConditionID id)
|
||||
public static string GetConditionNameFmt(ConditionId id)
|
||||
{
|
||||
return string.Format(ConditionNameFmt, id);
|
||||
}
|
||||
|
||||
public ConditionID id;
|
||||
public ConditionId id;
|
||||
public ISmartTestMethod testMethodComponent;
|
||||
|
||||
public ISequenceConditionOp(ISmartTestMethod testMethodComponent, ConditionID id)
|
||||
public ISequenceConditionOp(ISmartTestMethod testMethodComponent, ConditionId id)
|
||||
{
|
||||
this.testMethodComponent = testMethodComponent;
|
||||
this.id = id;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user