EOL processes reverted as they were.
RF models prepeared for usage.
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
<appSettings>
|
||||
<add key="Mode" value="1" /> <!--1 = EOL ; 2 = Picking-->
|
||||
<add key="SirtComport433" value="7" /> <!--Individual for Thomas 14-->
|
||||
<add key="SirtComport868" value="16" /> <!--Individual for Thomas 15-->
|
||||
<add key="SirtComport868" value="10" /> <!--Individual for Thomas 15-->
|
||||
<add key="SirtBoxNr" value="2" /> <!--Roland and Thomas, box for development, box at shipping station is 1-->
|
||||
<add key="StationID" value="1" /> <!--Roland and Thomas, shipping station is 1-->
|
||||
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ using Xylem.Common.Logic.ProductionOrderCore.TestResults;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Enum;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.GenericModules;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.GenericProcesses;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.RFTelegrams;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.Properties;
|
||||
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolProcesses
|
||||
|
||||
+2
-5
@@ -17,6 +17,7 @@ using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Logic.ProductionOrderCore;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.Enum;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.RFTelegrams;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.Properties;
|
||||
using Xylem.Common.Production.ProductionUiCordonel.UserControls;
|
||||
using Xylem.Common.Utils.Logging;
|
||||
@@ -274,6 +275,7 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
|
||||
|
||||
_sirtComport = Convert.ToByte(ConfigurationManager.AppSettings[$"SirtComport{freq}"]);
|
||||
_sirtBoxNr = Convert.ToByte(ConfigurationManager.AppSettings["SirtBoxNr"]);
|
||||
|
||||
var ucRadio = (UcRadioCheck)UserControl;
|
||||
ucRadio.SetHeadline($"{Resources.StrStateRadioCheck} BOX: {_sirtBoxNr}");
|
||||
LogNewStatusMsg($"{Resources.StrStateRadioCheck} Port: COM{_sirtComport}, BOX: {_sirtBoxNr}, " +
|
||||
@@ -806,11 +808,6 @@ namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.EolPr
|
||||
_stateMachine.OnStateChanged += StateMachineOnStateChange_Handler;
|
||||
_stateMachine.Start();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ActualProcessProgress++;
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.RFTelegrams.Pams
|
||||
{
|
||||
public class DummyPam
|
||||
{
|
||||
public static implicit operator byte[](DummyPam dummyPam) => new byte[0];
|
||||
}
|
||||
}
|
||||
+17
-5
@@ -1,11 +1,11 @@
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.RFTelegrams
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.RFTelegrams.Pams
|
||||
{
|
||||
public class AlarmsMask
|
||||
public class ResetAlarms
|
||||
{
|
||||
protected readonly byte[] bits;
|
||||
private readonly byte[] bits;
|
||||
|
||||
public AlarmsMask(byte value)
|
||||
=> this.bits = value.GetBitsLE();
|
||||
public ResetAlarms(byte _byte = 0xFF)
|
||||
=> this.bits = _byte.GetBitsLE();
|
||||
|
||||
public bool SpecificError
|
||||
{
|
||||
@@ -54,5 +54,17 @@
|
||||
get => this.bits[7] == 1;
|
||||
set => this.bits[7] = (byte)(value ? 1 : 0);
|
||||
}
|
||||
|
||||
public static implicit operator byte[] (ResetAlarms resetAlarms) => new byte[]
|
||||
{
|
||||
0x03,
|
||||
resetAlarms.bits.GetByteLE(),
|
||||
0x43,
|
||||
0x01,
|
||||
0x14,
|
||||
0x30,
|
||||
0x68,
|
||||
0xD0
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.RFTelegrams
|
||||
{
|
||||
using global::Common.Hardware.SIRT;
|
||||
using global::Common.Hardware.SIRT.Tasks;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class RFTask : WritePamTask
|
||||
{
|
||||
private readonly Stack<SIRTMessage> messages = new Stack<SIRTMessage>();
|
||||
|
||||
public SIRTMessage AKN { get; private set; }
|
||||
|
||||
public SIRTMessage BUP { get; private set; }
|
||||
|
||||
public SIRTMessage LAT { get; private set; }
|
||||
|
||||
public SIRTMessage DEBUG { get; private set; }
|
||||
|
||||
public SIRTMessage SEMI { get; private set; }
|
||||
|
||||
public SIRTMessage LastOrDefault()
|
||||
=> this.messages.Count > 0
|
||||
? this.messages.Peek()
|
||||
: new SIRTMessage();
|
||||
|
||||
public override string ToString()
|
||||
=> BitConverter.ToString(this.request.Payload);
|
||||
|
||||
protected override void OnMessageSent(SIRTMessage request)
|
||||
=> this.messages.Push(request);
|
||||
|
||||
protected override void OnUnknownReceived(SIRTMessage unknown)
|
||||
=> this.messages.Push(unknown);
|
||||
|
||||
protected override void OnAKNReceived(SIRTMessage akn)
|
||||
{
|
||||
this.AKN = akn;
|
||||
|
||||
this.messages.Push(akn);
|
||||
}
|
||||
|
||||
protected override void OnBUPReceived(SIRTMessage bup)
|
||||
{
|
||||
this.BUP = bup;
|
||||
|
||||
this.messages.Push(bup);
|
||||
}
|
||||
|
||||
protected override void OnLATReceived(SIRTMessage lat)
|
||||
{
|
||||
this.LAT = lat;
|
||||
|
||||
this.messages.Push(lat);
|
||||
}
|
||||
|
||||
protected override void OnDEBUGReceived(SIRTMessage debug)
|
||||
{
|
||||
this.DEBUG = debug;
|
||||
|
||||
this.messages.Push(debug);
|
||||
}
|
||||
|
||||
protected override void OnSEMIReceived(SIRTMessage semi)
|
||||
{
|
||||
this.SEMI = semi;
|
||||
|
||||
this.messages.Push(semi);
|
||||
|
||||
if (this.LAT != null)
|
||||
{
|
||||
this.SetCompleted();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SetPending();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
{
|
||||
public RSSI(byte value, int mhz)
|
||||
{
|
||||
this.Value = value;
|
||||
|
||||
if (mhz == 433)
|
||||
{
|
||||
this.Dbm = value * 0.5 - 140;
|
||||
@@ -25,12 +27,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
public byte Value { get; }
|
||||
|
||||
public double Dbm { get; }
|
||||
|
||||
public double Percent { get; }
|
||||
|
||||
public override string ToString() => $"{this.Dbm}dBm ({this.Percent:0.0}%)";
|
||||
|
||||
public static implicit operator byte(RSSI rssi) => rssi?.Value ?? 0;
|
||||
|
||||
public static implicit operator string(RSSI rssi) => rssi?.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.RFTelegrams
|
||||
{
|
||||
using Pams;
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
@@ -13,7 +15,7 @@
|
||||
this.Counter = payload[1];
|
||||
this.Address = payload.ToUInt32BE(2);
|
||||
this.Reading = payload.ToInt32BE(6);
|
||||
this.MainAlarmByte = new AlarmsMask(payload[10]);
|
||||
this.MainAlarmByte = new ResetAlarms(payload[10]);
|
||||
this.PAMStatus = new PAMStatus(payload[11]);
|
||||
this.RSSI = new RSSI(payload[12], mhz);
|
||||
this.MeterType = (MeterTypes)payload[13];
|
||||
@@ -24,7 +26,7 @@
|
||||
this.Units = (DisplayUnits)payload[23];
|
||||
this.MBusStatus = payload[24];
|
||||
this.MBusTransmissionInterval = payload.ToUInt16BE(25);
|
||||
this.MainAlarmMask = new AlarmsMask(payload[27]);
|
||||
this.MainAlarmMask = new ResetAlarms(payload[27]);
|
||||
this.LeakageDetectionParameters = payload[28];
|
||||
this.BrokenPipeDetectionParameters = payload[29];
|
||||
this.BatteryRemainingYears = payload.ToUInt16BE(30) / (4D * 365);
|
||||
@@ -32,10 +34,10 @@
|
||||
this.MaximumFlow = payload.ToUInt16BE(33);
|
||||
this.TimeSinceMaximumFlow = payload.ToUInt16BE(35);
|
||||
this.TimeSinceLowBattery = payload.ToUInt16BE(37);
|
||||
this.AlarmLeakageSeconds = new Epoch20000101(payload.ToUInt32BE(39), DateTimeKind.Local);
|
||||
this.AlarmAirInPipeSeconds = new Epoch20000101(payload.ToUInt32BE(43), DateTimeKind.Local);
|
||||
this.AlarmReverseFlowSeconds = new Epoch20000101(payload.ToUInt32BE(47), DateTimeKind.Local);
|
||||
this.AlarmBrokenPipeSeconds = new Epoch20000101(payload.ToUInt32BE(51), DateTimeKind.Local);
|
||||
this.AlarmLeakage = new Epoch20000101(payload.ToUInt32BE(39), DateTimeKind.Local);
|
||||
this.AlarmAirInPipe = new Epoch20000101(payload.ToUInt32BE(43), DateTimeKind.Local);
|
||||
this.AlarmReverseFlow = new Epoch20000101(payload.ToUInt32BE(47), DateTimeKind.Local);
|
||||
this.AlarmBrokenPipe = new Epoch20000101(payload.ToUInt32BE(51), DateTimeKind.Local);
|
||||
this.DataLogContent = payload.ToUInt16BE(55);
|
||||
this.DataLoggingInterval = payload.ToUInt16BE(57);
|
||||
this.FDRContent = payload.ToUInt16BE(59);
|
||||
@@ -58,7 +60,7 @@
|
||||
|
||||
public int Reading { get; }
|
||||
|
||||
public AlarmsMask MainAlarmByte { get; }
|
||||
public ResetAlarms MainAlarmByte { get; }
|
||||
|
||||
public PAMStatus PAMStatus { get; }
|
||||
|
||||
@@ -80,7 +82,7 @@
|
||||
|
||||
public ushort MBusTransmissionInterval { get; }
|
||||
|
||||
public AlarmsMask MainAlarmMask { get; }
|
||||
public ResetAlarms MainAlarmMask { get; }
|
||||
|
||||
public byte LeakageDetectionParameters { get; }
|
||||
|
||||
@@ -96,13 +98,13 @@
|
||||
|
||||
public ushort TimeSinceLowBattery { get; }
|
||||
|
||||
public DateTime AlarmLeakageSeconds { get; }
|
||||
public DateTime AlarmLeakage { get; }
|
||||
|
||||
public DateTime AlarmAirInPipeSeconds { get; }
|
||||
public DateTime AlarmAirInPipe { get; }
|
||||
|
||||
public DateTime AlarmReverseFlowSeconds { get; }
|
||||
public DateTime AlarmReverseFlow { get; }
|
||||
|
||||
public DateTime AlarmBrokenPipeSeconds { get; }
|
||||
public DateTime AlarmBrokenPipe { get; }
|
||||
|
||||
public LogContent DataLogContent { get; }
|
||||
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
namespace Xylem.Common.Production.ProductionUiCordonel.ProductionProcesses.RFTelegrams
|
||||
{
|
||||
using global::Common.Hardware.SIRT;
|
||||
using global::Common.Hardware.SIRT.Tasks;
|
||||
|
||||
using Pams;
|
||||
|
||||
using System;
|
||||
|
||||
internal class SIRTServer
|
||||
{
|
||||
private static Action<string> messageCallback;
|
||||
private static Action<string> errorMessageCallback;
|
||||
private static readonly SIRTHub sirtHub = new SIRTHub();
|
||||
|
||||
public static bool StartServer(Action<string> messageHandler, Action<string> errorMessageHandler, params int[] comPorts)
|
||||
{
|
||||
string sirtId;
|
||||
int frequency;
|
||||
bool succeeded = true;
|
||||
|
||||
messageHandler?.Invoke(new string('-', 100));
|
||||
|
||||
foreach (var comport in comPorts)
|
||||
{
|
||||
succeeded = ConnectSIRT(comport, out sirtId, out frequency);
|
||||
|
||||
if (succeeded)
|
||||
{
|
||||
messageHandler?.Invoke($"COM{comport}|{sirtId}|{frequency}MHz - connected");
|
||||
messageHandler?.Invoke(new string('-', 100));
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessageHandler?.Invoke($"SIRT at COM{comport} not connected!");
|
||||
errorMessageHandler?.Invoke(new string('-', 100));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (succeeded)
|
||||
{
|
||||
messageCallback = messageHandler;
|
||||
errorMessageCallback = errorMessageHandler;
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
public static bool StartProgramming(int frequency, uint address, string encryptionKey, int repeatsCount = 3)
|
||||
{
|
||||
var succeeded = true;
|
||||
|
||||
if (succeeded)
|
||||
{
|
||||
succeeded = SendPAM(task =>
|
||||
{
|
||||
task.WakeUpCmd = true;
|
||||
task.DelPamSemi = true;
|
||||
task.WakeUpModul = true;
|
||||
task.Frequency = frequency;
|
||||
task.RequestAddress = address;
|
||||
task.EncryptionKey = encryptionKey.GetEncryptionKey();
|
||||
task.Data = new DummyPam();
|
||||
}
|
||||
, repeatsCount);
|
||||
}
|
||||
|
||||
if (succeeded)
|
||||
{
|
||||
succeeded = SendPAM(task =>
|
||||
{
|
||||
task.DelPamSemi = true;
|
||||
task.Frequency = frequency;
|
||||
task.RequestAddress = address;
|
||||
task.EncryptionKey = encryptionKey.GetEncryptionKey();
|
||||
task.Data = new ResetAlarms(0xFF)
|
||||
{
|
||||
MediumAbsent = false
|
||||
};
|
||||
}
|
||||
, repeatsCount);
|
||||
}
|
||||
|
||||
if (succeeded)
|
||||
{
|
||||
succeeded = SendPAM(task =>
|
||||
{
|
||||
task.DelPamSemi = true;
|
||||
task.Frequency = frequency;
|
||||
task.RequestAddress = address;
|
||||
task.EncryptionKey = encryptionKey.GetEncryptionKey();
|
||||
task.Data = new ResetAlarms(0xFE);
|
||||
}
|
||||
, repeatsCount);
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
private static bool ConnectSIRT(int portno, out string sirtId, out int frequency)
|
||||
=> sirtHub.TryOpen($"COM{portno}", out sirtId, out frequency);
|
||||
|
||||
private static bool SendPAM(Action<RFTask> taskOpetions, int repeatsCount = 3)
|
||||
{
|
||||
void LogMessage(SIRTMessage message) => messageCallback?.Invoke(message.ToString());
|
||||
|
||||
var cordonelTask = new RFTask();
|
||||
var succeeded = false;
|
||||
|
||||
taskOpetions(cordonelTask);
|
||||
|
||||
cordonelTask.MessageSent += LogMessage;
|
||||
cordonelTask.MessageReceived += LogMessage;
|
||||
|
||||
for (var i = 1; i <= repeatsCount && cordonelTask.State != SIRTTaskState.Completed && cordonelTask.State != SIRTTaskState.Cancelled; i++)
|
||||
{
|
||||
if (sirtHub.Start(cordonelTask))
|
||||
{
|
||||
cordonelTask.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
cordonelTask.MessageReceived -= LogMessage;
|
||||
cordonelTask.MessageSent -= LogMessage;
|
||||
|
||||
if (cordonelTask.State == SIRTTaskState.Completed)
|
||||
{
|
||||
succeeded = true;
|
||||
|
||||
messageCallback?.Invoke($"{cordonelTask.State} - CMD|{cordonelTask}");
|
||||
messageCallback?.Invoke(new string('-', 100));
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMessageCallback?.Invoke($"{cordonelTask.State} - CMD|{cordonelTask}");
|
||||
errorMessageCallback?.Invoke(new string('-', 100));
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,13 +200,16 @@
|
||||
<Compile Include="ProductionProcesses\EventArgs\ProcessStateArgs.cs" />
|
||||
<Compile Include="ProductionProcesses\EventArgs\ProcessLogArgs.cs" />
|
||||
<Compile Include="ProductionProcesses\EventArgs\ProcessProgressArgs.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\AlarmsMask.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\AppCode.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\RFTask.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\DisplayUnits.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\Epoch20000101.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\LogContent.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\MeterTypes.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\PAMStatus.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\Pams\DummyPam.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\Pams\ResetAlarms.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\SIRTServer.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\RSSI.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\SEMI.cs" />
|
||||
<Compile Include="ProductionProcesses\RFTelegrams\Extensions.cs" />
|
||||
@@ -358,6 +361,10 @@
|
||||
<Project>{1B02C79E-0B19-43E2-8F6B-71EF0C786C97}</Project>
|
||||
<Name>CommonCore</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Hardware\Common.Hardware.SIRT\Common.Hardware.SIRT.csproj">
|
||||
<Project>{8DE8E742-EE0A-4004-AA49-3D08D748E5AC}</Project>
|
||||
<Name>Common.Hardware.SIRT</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Hardware\Interfaces\Ports\PortCore\PortCore.csproj">
|
||||
<Project>{2E139F63-B6FE-4EA9-A098-85364FE9B26C}</Project>
|
||||
<Name>PortCore</Name>
|
||||
|
||||
Reference in New Issue
Block a user