change UI1236 Comamds

This commit is contained in:
Roland Drabesch 2022-08-24 17:23:11 +02:00
parent c5dbb895d2
commit 94e7a04d7b
12 changed files with 121 additions and 9 deletions

View File

@ -155,7 +155,7 @@
</site>
<site name="MeterProcessState" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\drabesch_ro\Repo\lab\la_operations\laa_production\Common\Service\MeterProcessState" />
<virtualDirectory path="/" physicalPath="C:\ProgrammeSensus\Repo\Lab\La_Operations\laa_production\Common\Service\MeterProcessState" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:56011:localhost" />

View File

@ -24,6 +24,8 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
public abstract List<Byte> DecodeDataForLogicLayer(List<Byte> rawData);
public abstract List<byte> DecodeDataForPhysicalLayerUI1236(byte[] payload);
}
}

View File

@ -22,6 +22,8 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
/// </summary>
void SetDefaultResponseTimeout();
List<byte> DecodeDataForPhysicalLayerUI1236(byte[] payload);
/// <summary>
/// Send out data (including transport protocol specific data like CRC) to physical port (like UART or IrDA)
/// </summary>

View File

@ -169,5 +169,25 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
return irdaRecord;
}
public override List<byte> DecodeDataForPhysicalLayerUI1236(byte[] requestProtocolPayload)
{
List<byte> collection = new List<byte>()
{
(byte) 35,
(byte) (requestProtocolPayload.Length / 2)
};
collection.AddRange((IEnumerable<byte>)requestProtocolPayload);
ushort reversedLsb8408 = Xylem.Common.Utils.Crc16Ccitt.Crc16Ccitt.CalculateReversedLsb8408(collection.ToArray());
List<byte> byteList = new List<byte>()
{
(byte) 155
};
byteList.AddRange((IEnumerable<byte>)collection);
byteList.Add((byte)((uint)reversedLsb8408 & (uint)byte.MaxValue));
byteList.Add((byte)((uint)reversedLsb8408 >> 8));
this.Logger.Info("DecodeDataForPhysicalLayerUI1236 PC->Cordonel(" + BitConverter.ToString(byteList.ToArray()) + ")");
return byteList;
}
}
}

View File

@ -47,5 +47,7 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
{
return rawData;
}
public override List<byte> DecodeDataForPhysicalLayerUI1236(byte[] payload) => throw new ApplicationException("Streaming port cannot send data");
}
}

View File

@ -144,7 +144,22 @@ namespace Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol
return uartRecord;
}
public override List<byte> DecodeDataForPhysicalLayerUI1236(byte[] requestProtocolPayload)
{
List<byte> byteList1 = new List<byte>();
List<byte> list = ((IEnumerable<byte>)requestProtocolPayload).ToList<byte>();
List<byte> byteList2 = new List<byte>();
byteList1.Add((byte)(requestProtocolPayload.Length + 4 + 2));
byteList1.Add((byte)0);
byteList1.Add((byte)0);
ushort num = this.CrcCalc(byteList1, list);
byteList2.Add((byte)91);
byteList2.AddRange((IEnumerable<byte>)byteList1);
byteList2.Add((byte)((uint)num & (uint)byte.MaxValue));
byteList2.Add((byte)((uint)num >> 8));
byteList2.AddRange((IEnumerable<byte>)list);
return byteList2;
}
}
}

View File

@ -1878,6 +1878,16 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore
}
}
public byte[] SendUI1236Command(byte[] UI1236Frame,bool waitForResult = true,bool checkRegister = false,ushort skipRetryErrorCode = 4)
{
this._logger.Info(string.Format("Slot:{0} - Sending Ui-1236 frame: {1} ", (object)this.Slot, (object)UI1236Frame));
RequestRecord sendFifoUi1236 = this.RequestProtocol.AddRecordToSendFifoUI1236(UI1236Frame);
this.RequestProtocolProcess();
return sendFifoUi1236.ResponsePayload.ToArray();
}
#endregion
#region Class handling

View File

@ -11,6 +11,8 @@ using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisConfig;
using Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.ProtocolCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol.Consts;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.Interfaces.Protocols.TransmitProtocol;
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
{
@ -305,6 +307,27 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.Protocols.RequestProtocol
return recordForSendFifo;
}
public RequestRecord AddRecordToSendFifoUI1236(
byte[] payload,
RegisterDefinition register = null,
bool hideDataInLog = false,
ushort skipRetryErrorCode = 4)
{
byte maxValue = byte.MaxValue;
List<byte> requestProtocolData = new List<byte>()
{
maxValue
};
requestProtocolData.AddRange((IEnumerable<byte>)payload);
ITransmitProtocol transmitProtocol = this.GetTransmitProtocol();
List<byte> encodedRequestData = transmitProtocol.DecodeDataForPhysicalLayerUI1236(payload);
TransmitPortSettings transmitPortSettings = transmitProtocol.GetTransmitPortSettings();
RequestRecord sendFifoUi1236 = new RequestRecord(maxValue, requestProtocolData, encodedRequestData, transmitPortSettings.ResponseTimeoutMs, register, hideDataInLog, skipRetryErrorCode);
this._recordsSendFifo.Enqueue(sendFifoUi1236);
return sendFifoUi1236;
}
/// <summary>
/// Called after successful response.
/// Decode and check record, handle Errors and dispatch result.

View File

@ -1 +1 @@
5ed75d99ee45ff67821090f1b3dbb001dd9e4fe3
46bd00889699f5a20a4981a22f62b66368323855

View File

@ -1 +1 @@
f64d563def603c89cafafa61a3219ba97e1e344c
81d60b90addc793525740e9993e19bf6665bd401

View File

@ -15,7 +15,8 @@ namespace XylemCommonUiLegacyGenCtl
void AddMeter(string serialNumber, int slot);
void AddAllMeters();
void MeterDone(int slot, bool Succeed);
void MeterDoneWithDetails(int slot, bool Succeed, out string LutCrc, out bool MeterHasPreadjustment);
void SetErrorFrame(int slot, double errorFrame = 0.0);
void PrepareMeters(string meterDn = "-", double refPulseValence = 0.0, double predictedQFlow = 0.0, double predictedTs = 0.0, double refError = 0.0, bool isAdjustment = false, bool IsFlyingStartStop = true);
@ -48,7 +49,6 @@ namespace XylemCommonUiLegacyGenCtl
bool IsBusy();
void Dispose(bool fromCode);
void SetTestSetupContainer(dynamic container);

View File

@ -1,4 +1,5 @@
using ByteArrayStyle;
using Newtonsoft.Json;
using NLog;
using System;
using System.Collections.Concurrent;
@ -14,9 +15,11 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Logic.SoftwareAccessHelper;
using Xylem.Common.Metrology.Measurements;
using Xylem.Common.Metrology.Measurements.Consts;
using Xylem.Common.Utils.Logging;
@ -700,9 +703,39 @@ namespace XylemCommonUiLegacyGenCtl
}
}
public void MeterDoneWithDetails(int slot, bool Succeed, out string LutCrc, out bool MeterHasPreadjustment)
{
LutCrc = "";
MeterHasPreadjustment = false;
MeterDone(slot, Succeed);
var meter = batch.ListOfMeters.First(f => f.Slot == slot);
if (meter != null && meter is GenesisMeter gen)
{
LutCrc = gen.LutCrc;
try
{
var responseJson = LocalWebRequest.GetRequest($"{ServiceUrls.MeterInfoForTestBench()}{gen.PcbId}");
var a = JsonConvert.DeserializeObject<string[]>(responseJson);
var SerialNumber = a[0];
if (!String.IsNullOrEmpty(SerialNumber))
{
int tmp;
MeterHasPreadjustment = int.TryParse(a[4], out tmp);
}
}
catch (Exception)
{
throw;
}
}
}
public void MeterDone(int slot, bool Succeed)
public void MeterDone(int slot, bool Succeed)
{
try
{
@ -750,14 +783,19 @@ namespace XylemCommonUiLegacyGenCtl
if (!genMeter.IsLoggedOn)
{
genMeter.Login();
}
genMeter.WriteRegister(Register.Genesisflow.SampleRate, 2);
genMeter.WriteRegister(Register.Genesisflow.LedMode, 0,true);
meter.WriteLog($"MeterIsDone {state} {genMeter.LutCrc }");
}
else
{
meter.WriteLog($"MeterIsDone {state} ");
}
meter.WriteLog($"MeterIsDone {state}");
}).ContinueWith(delegate
{