common/ProductionUiCordonel/ProductionProcesses/Actions/ProductionProcessSpecialConfig.cs
2026-04-23 17:50:07 +02:00

163 lines
6.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Controls;
using ProductionUiCordonelLegacy.ProductionProcesses.Enum;
using ProductionUiCordonelLegacy.UserControls.FinalTest;
namespace ProductionUiCordonelLegacy.ProductionProcesses.Actions
{
public class ProductionProcessSpecialConfig : BaseProductionProcess
{
private UcDialog UserControl;
public Boolean DialogIsDone { get; }
public ProductionProcessSpecialConfig()
{
DialogIsDone = false;
name = "Customer Parameterization";
currentProcessState = ProductionProcessState.Waiting;
}
public override void InitUserControl()
{
UserControl = new UcDialog();
}
public override UserControl GetControl()
{
if (UserControl == null)
{
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
public override void ProcessDone()
{
//clear
}
private void StepDone()
{
currentProcessState = ProductionProcessState.Done;
}
private void StepRadio()
{
UserControl.SetDesc("Set EncryptionKey");
var radioOptionList = new List<UcDialog.DialogOption>();
var radioDefault = new UcDialog.DialogOption("old default", "same as iperl", () =>
{
var funkadresse = new List<Byte>();
funkadresse.AddRange((new Byte[] { 0xE6, 0xC8, 0x88, 0x00 }).ToArray());
funkadresse.AddRange((new Byte[] { 0xDE, 0xB8, 0x68, 0xC0 }).ToArray());
funkadresse.AddRange((new Byte[] { 0xD6, 0xA8, 0x48, 0x80 }).ToArray());
funkadresse.AddRange((new Byte[] { 0xCE, 0x98, 0x28, 0x40 }).ToArray());
Meter.WriteRegister("SENSUSRADIO_EncryptionKey", funkadresse.ToArray(), true, true);
StepDone();
});
var upRadioOnly = new UcDialog.DialogOption("alpha", "000...", () =>
{
Meter.WriteRegister("SENSUSRADIO_EncryptionKey", (new Byte[]
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}).ToArray(), true, true);
StepDone();
});
var optOneLiter = new UcDialog.DialogOption("new default", "new default key", () =>
{
var funkadresse = new List<Byte>();
funkadresse.AddRange((new Byte[] { 0x0E, 0x9F, 0xAC, 0xC6 }).ToArray());
funkadresse.AddRange((new Byte[] { 0xA0, 0xE1, 0xEF, 0x1C }).ToArray());
funkadresse.AddRange((new Byte[] { 0x3B, 0x27, 0xA4, 0x9B }).ToArray());
funkadresse.AddRange((new Byte[] { 0xAC, 0x21, 0x65, 0x35 }).ToArray());
Meter.WriteRegister("SENSUSRADIO_EncryptionKey", funkadresse.ToArray(), true, true);
StepDone();
});
radioOptionList.Add(radioDefault);
radioOptionList.Add(upRadioOnly);
radioOptionList.Add(optOneLiter);
UserControl.SetDialogOptions(radioOptionList);
}
private void StepWakeUp()
{
UserControl.SetDesc("Set Radio WakeUp");
var wakeupOptionList = new List<UcDialog.DialogOption>();
var wakeUpDefault = new UcDialog.DialogOption("wakeup Water and Radio", "Default for nearly all", () =>
{
Meter.WriteRegister("SENSUSRADIO_WakeupInterval", (new Byte[] { 0x00, 0x00, 0x00, 0x03 }).Reverse().ToArray(), true, true);
StepRadio();
});
var wakeUpRadioOnly = new UcDialog.DialogOption("wakeup only Radio", "WakeupInterval to 6 (only radio)", () =>
{
Meter.WriteRegister("SENSUSRADIO_WakeupInterval", (new Byte[] { 0x00, 0x00, 0x00, 0x06 }).Reverse().ToArray(), true, true);
StepRadio();
});
var pulseOptOneLiter = new UcDialog.DialogOption("wakeup off", "WakeupInterval to 0, no Radio active (e.g. USA))", () =>
{
Meter.WriteRegister("SENSUSRADIO_WakeupInterval", (new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true);
StepRadio();
});
wakeupOptionList.Add(wakeUpDefault);
wakeupOptionList.Add(wakeUpRadioOnly);
wakeupOptionList.Add(pulseOptOneLiter);
UserControl.SetDialogOptions(wakeupOptionList);
}
private void StepPulse()
{
UserControl.SetDesc("Set Pulse Configuration");
var pulseOptionList = new List<UcDialog.DialogOption>();
var pulseOptOff = new UcDialog.DialogOption("Pulse off", "set pulsemode to off", () =>
{
Meter.WriteRegister("METROLOGYASST_PulseLength", (new Byte[] { 0x00, 0x00, 0x00, 0x07 }).Reverse().ToArray(), true, true);
Meter.WriteRegister("METROLOGYASST_PulseMode", (new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true);
Meter.WriteRegister("METROLOGYASST_PulseWeight", (new Byte[] { 0x00, 0x00, 0x27, 0x10 }).Reverse().ToArray(), true, true);
StepWakeUp();
});
var pulseOptDefault = new UcDialog.DialogOption("Pulse Default", "1 pulse per 10 l, pulse mode a4 and 200ms pulse length", () =>
{
Meter.WriteRegister("METROLOGYASST_PulseLength", (new Byte[] { 0x00, 0x00, 0x00, 0x07 }).Reverse().ToArray(), true, true);
Meter.WriteRegister("METROLOGYASST_PulseMode", (new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, true);
Meter.WriteRegister("METROLOGYASST_PulseWeight", (new Byte[] { 0x00, 0x00, 0x27, 0x10 }).Reverse().ToArray(), true, true);
StepWakeUp();
});
var pulseOptOneLiter = new UcDialog.DialogOption("One Liter Pulse", "1 pulse per 1l, pulse mode a4 and 20ms pulse length", () =>
{
Meter.WriteRegister("METROLOGYASST_PulseLength", (new Byte[] { 0x00, 0x00, 0x00, 0x04 }).Reverse().ToArray(), true, true);
Meter.WriteRegister("METROLOGYASST_PulseMode", (new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, true);
Meter.WriteRegister("METROLOGYASST_PulseWeight", (new Byte[] { 0x00, 0x00, 0x03, 0xE8 }).Reverse().ToArray(), true, true);
StepWakeUp();
});
pulseOptionList.Add(pulseOptOff);
pulseOptionList.Add(pulseOptDefault);
pulseOptionList.Add(pulseOptOneLiter);
UserControl.SetDialogOptions(pulseOptionList);
}
public override void StartProcess()
{
StepPulse();
}
}
}