e-register for test on the test benches
This commit is contained in:
parent
beae7b7787
commit
fd535d2903
@ -14,51 +14,49 @@
|
||||
|
||||
public class PAM03
|
||||
{
|
||||
/// <summary>
|
||||
/// Process.ExitCode:
|
||||
/// 0 - OK
|
||||
/// 1 - Execution Error
|
||||
/// 2 - Connection Error
|
||||
/// 3 - Invalid Arguments
|
||||
/// </summary>
|
||||
private int exitCode;
|
||||
private string portName;
|
||||
private uint address;
|
||||
private byte[] key;
|
||||
|
||||
public int Run(params string[] args)
|
||||
{
|
||||
this.exitCode = this.ParseArguments(args);
|
||||
/// <summary>
|
||||
/// Process.ExitCode:
|
||||
/// 0 - OK
|
||||
/// 1 - Execution Error
|
||||
/// 2 - Connection Error
|
||||
/// 3 - Invalid Arguments
|
||||
/// </summary>
|
||||
var exitCode = this.ParseArguments(args);
|
||||
|
||||
if (this.exitCode == 0)
|
||||
if (exitCode == 0)
|
||||
{
|
||||
this.exitCode = 2;
|
||||
|
||||
var processAwaiter = new ManualResetEventSlim();
|
||||
var sirtBroadcaster = new SIRTBroadcaster(this.portName);
|
||||
var pinI = new ProvidePin { AuthLevel = AuthLevel.I };
|
||||
|
||||
void SIRTBroadcaster_Connected(SIRTBroadcaster sirt)
|
||||
{
|
||||
var auth = new ProvidePin
|
||||
{
|
||||
AuthLevel = AuthLevel.I
|
||||
};
|
||||
var task = new CordonelTask(sirt.Frequency)
|
||||
{
|
||||
Timeout = 60_000,
|
||||
DelPamSemi = true,
|
||||
WakeUpCmd = true,
|
||||
WakeUpModul = true,
|
||||
RequestAddress = address,
|
||||
EncryptionKey = key,
|
||||
WakeUpModul = true,
|
||||
WakeUpCmd = true,
|
||||
IsEncrypted = true
|
||||
};
|
||||
|
||||
this.exitCode = 1;
|
||||
|
||||
int ResetAlarms(byte alarmMask)
|
||||
void ResetAlarms(byte alarmMask)
|
||||
{
|
||||
task.Data = new ResetAlarms(0xFF).Append(auth);
|
||||
if (exitCode != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
task.WakeUpCmd = false;
|
||||
task.WakeUpModul = false;
|
||||
task.Data = new ResetAlarms(alarmMask).Append(pinI);
|
||||
task.SetPending();
|
||||
sirt.Start(task);
|
||||
task.Wait();
|
||||
@ -67,37 +65,32 @@
|
||||
{
|
||||
Console.WriteLine($"{nameof(SIRTTaskState)}.{task.State}");
|
||||
|
||||
return 1;
|
||||
exitCode = 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
exitCode = 0;
|
||||
}
|
||||
|
||||
this.exitCode = ResetAlarms(0xFF);
|
||||
task.SetPending();
|
||||
sirt.Start(task);
|
||||
task.Wait();
|
||||
|
||||
if (this.exitCode != 0)
|
||||
if (task.State != SIRTTaskState.Completed)
|
||||
{
|
||||
processAwaiter.Set();
|
||||
|
||||
return;
|
||||
exitCode = 1;
|
||||
}
|
||||
|
||||
this.exitCode = ResetAlarms(0xFE);
|
||||
|
||||
if (this.exitCode != 0)
|
||||
ResetAlarms(new AlarmsMask(0xFF)
|
||||
{
|
||||
processAwaiter.Set();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MediumAbsent = false
|
||||
});
|
||||
ResetAlarms(0xFE);
|
||||
processAwaiter.Set();
|
||||
}
|
||||
|
||||
void SIRTBroadcaster_Disconnected(SIRTBroadcaster _)
|
||||
=> processAwaiter.Set();
|
||||
|
||||
|
||||
sirtBroadcaster.Connected += SIRTBroadcaster_Connected;
|
||||
sirtBroadcaster.Disconnected += SIRTBroadcaster_Disconnected;
|
||||
|
||||
@ -109,7 +102,7 @@
|
||||
sirtBroadcaster.Connected -= SIRTBroadcaster_Connected;
|
||||
}
|
||||
|
||||
return this.exitCode;
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
public int ParseArguments(string[] args)
|
||||
|
||||
@ -6,9 +6,17 @@
|
||||
{
|
||||
var pam03 = new PAM03();
|
||||
|
||||
return pam03.Run("COM17", "412004190", "0E9FACC6A0E1EF1C3B27A49BAC216535");
|
||||
return pam03.Run(args);
|
||||
}
|
||||
//return pam03.Run("COM7", "412004190", "0E9FACC6A0E1EF1C3B27A49BAC216535");
|
||||
|
||||
try
|
||||
{
|
||||
return pam03.Run("COM10", "402009768", "3CB64CBCB71F8D0F9F69FF18DF5D24D3");
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
//public static void Main()
|
||||
//{
|
||||
|
||||
@ -118,11 +118,13 @@
|
||||
if (task.ErrorMessage != null)
|
||||
{
|
||||
var error = task.ErrorMessage;
|
||||
var result = MessageBox.Show(error.Text + $"{Environment.NewLine}{Environment.NewLine}Möchten Sie fortfahren?", error.Title, MessageBoxButtons.YesNo);
|
||||
var message = $"{error.Text}{Environment.NewLine}{Environment.NewLine}Möchten Sie fortfahren?";
|
||||
var result = MessageBox.Show(message, error.Title, MessageBoxButtons.YesNo);
|
||||
|
||||
if (result == DialogResult.No)
|
||||
{
|
||||
task.SetCancelled();
|
||||
|
||||
stopProgramming = true;
|
||||
|
||||
break;
|
||||
@ -132,18 +134,18 @@
|
||||
|
||||
task.MessageReceived -= this.history.Push;
|
||||
|
||||
if (task.FactoryState == FactoryState.Shipment)
|
||||
{
|
||||
task.Label = "GESCHLOSSEN";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (stopProgramming)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//if (task.FactoryState == FactoryState.Shipment && !this.runningTasks.IsEmpty)
|
||||
//{
|
||||
// task.Label = "GESCHLOSSEN";
|
||||
|
||||
// break;
|
||||
//}
|
||||
|
||||
this.UpdateTasksStateInTheQueue(task);
|
||||
|
||||
if (task.State == SIRTTaskState.Completed)
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
if (this.State == SIRTTaskState.Completed)
|
||||
{
|
||||
this.ErrorMessage = default(ErrorMessage);
|
||||
var hasValidConfiguration = true;
|
||||
var message = new StringBuilder();
|
||||
message.AppendLine();
|
||||
message.AppendLine();
|
||||
@ -47,12 +48,14 @@
|
||||
|
||||
message.AppendLine();
|
||||
message.AppendLine($"- Das Rechenwerk ist um {over:0.0000} Tage älter als erlaubt. Bitte informieren Sie die Linienleitung und QS.");
|
||||
hasValidConfiguration = false;
|
||||
}
|
||||
|
||||
if (this.SEMIMessage.BatteryRemainingYears <= this.parameters.MinBatteryRemainingYears)
|
||||
{
|
||||
message.AppendLine();
|
||||
message.AppendLine($"- Die Batterielaufzeit ({this.SEMIMessage.BatteryRemainingYears}) liegt unter dem angegebenen Minimum von ({this.parameters.MinBatteryRemainingYears}). ");
|
||||
message.AppendLine($"- Die Batterielaufzeit ({this.SEMIMessage.BatteryRemainingYears}) liegt unter dem angegebenen Minimum von ({this.parameters.MinBatteryRemainingYears}).");
|
||||
hasValidConfiguration = false;
|
||||
}
|
||||
|
||||
// Min metrology FW version (>= 1108) CSD dependent
|
||||
@ -67,6 +70,7 @@
|
||||
{
|
||||
message.AppendLine();
|
||||
message.AppendLine($"- Die Metrologische FW Version ({curFW}) liegt unter dem angegebenen Minimum von ({minFW}).");
|
||||
hasValidConfiguration = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,12 +81,14 @@
|
||||
{
|
||||
message.AppendLine();
|
||||
message.AppendLine($"- Die Metrologische FW Version ({this.DEBUGMessage.MetrologyFWVersion}) ist nicht für Produktion freigegeben. ");
|
||||
hasValidConfiguration = false;
|
||||
}
|
||||
|
||||
if (!this.parameters.FWVersionsList.Contains(this.DEBUGMessage.RadioFWVersion))
|
||||
{
|
||||
message.AppendLine();
|
||||
message.AppendLine($"- Die Radio FW Version ({this.DEBUGMessage.RadioFWVersion}) ist nicht für Produktion freigegeben. ");
|
||||
hasValidConfiguration = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,16 +96,17 @@
|
||||
{
|
||||
message.AppendLine();
|
||||
message.AppendLine($"- Der rechenwerk wurde mehr als {this.parameters.MaxRebootCount} mal rebooted.");
|
||||
hasValidConfiguration = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (message.Length > 10)
|
||||
if (!hasValidConfiguration)
|
||||
{
|
||||
message.Insert(0, $"Am Einbauplatz: {this.SlotNr}, "
|
||||
+ $"eingebaute E-Register mit Funkadressen: {this.RequestAddress} | {this.ResponseAddress}, "
|
||||
+ $"sind folgenden Fehler sind aufgetreten:");
|
||||
+ $"sind folgenden Fehler aufgetreten:");
|
||||
message.AppendLine();
|
||||
message.AppendLine("Linienleitung informieren!");
|
||||
message.AppendLine("Linienleitung und QS informieren!");
|
||||
|
||||
this.ErrorMessage = new ErrorMessage
|
||||
{
|
||||
|
||||
@ -198,14 +198,14 @@
|
||||
|
||||
if (pamStatus == PAMStatus.OK)
|
||||
{
|
||||
if (this.request.Length > 0 && this.request.Payload[0] == Pam.GetDebug && this.DEBUGMessage == null)
|
||||
{
|
||||
this.Label = "!DEBUG";
|
||||
}
|
||||
else if (this.LATMessage is null)
|
||||
if (this.LATMessage is null)
|
||||
{
|
||||
this.Label = "!LAT";
|
||||
}
|
||||
else if (this.request.Length > 0 && this.request.Payload[0] == Pam.GetDebug && this.DEBUGMessage == null)
|
||||
{
|
||||
this.Label = "!DEBUG";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SetCompleted();
|
||||
|
||||
@ -83,5 +83,7 @@
|
||||
|
||||
return alarmMaskBuilder.ToString().Trim();
|
||||
}
|
||||
|
||||
public static implicit operator byte(AlarmsMask alarmMask) => alarmMask.bits.GetByteLE();
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
while (bytesLength > cmdIX)
|
||||
{
|
||||
cmd = bytes[cmdIX];
|
||||
_ = cmdLengths.TryGetValue(cmd, out cmdLength);
|
||||
available = !cmdUnavailableAfterSeal.ContainsKey(cmd);
|
||||
|
||||
if (cmd == Pam.SetPowerLevel && bytes[cmdIX + 1] > 127)
|
||||
@ -25,14 +26,12 @@
|
||||
available = false;
|
||||
}
|
||||
|
||||
if (available)
|
||||
if (cmd == Pam.ProvidePin || available)
|
||||
{
|
||||
index = cmdIX + 1;
|
||||
|
||||
this.Add(cmd);
|
||||
|
||||
_ = cmdLengths.TryGetValue(cmd, out cmdLength);
|
||||
|
||||
for (var i = 0; i < cmdLength; i++)
|
||||
{
|
||||
this.Add(bytes[index++]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user