This commit is contained in:
Roland Drabesch
2023-01-24 10:12:01 +01:00
80 changed files with 2162 additions and 1674 deletions
@@ -1,9 +1,10 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System;
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Threading;
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Logic.SoftwareAccessHelper;
@@ -28,7 +29,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -42,26 +43,25 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private void doStartProcessLoop()
{
var reTrysLeft = 1;
while (reTrysLeft >= 0)
var retriesRemaining = 1;
while (retriesRemaining >= 0)
{
try
{
base.Progress = 0;
Progress = 0;
//var url = $"http://localhost:56011/api/FinalCheck/GetProgrammingParameters?PcbID={Meter.PcbId}";
var url = $"{ServiceUrls.MeterInfoForTestBench()}{Meter.PcbId}";
var csdRet = LocalWebRequest.GetRequest(url);
var res = Newtonsoft.Json.JsonConvert.DeserializeObject<string[]>(csdRet);
var res = JsonConvert.DeserializeObject<String[]>(csdRet);
var CalibrationRun = res[4];
var LastTestBechState = 0;
bool? HyState = null;
bool? preState = null;
Boolean? HyState;
Boolean? preState = null;
if (!string.IsNullOrEmpty(res[5]))
{
var tmp = 0;
int.TryParse(res[5], out tmp);
int.TryParse(res[5], out var tmp);
LastTestBechState = tmp;
}
@@ -89,24 +89,24 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send,
new Action(() =>
{
UserControl.lblText.Content = $"Zähler nicht erfolgreich geprüft";
UserControl.lblText.Content = "Zähler nicht erfolgreich geprüft";
}
));
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
if (!preState.HasValue || !preState.Value)
{
UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send,
new Action(() =>
{
UserControl.lblText.Content = $"Zähler nicht erfolgreich vorbehandelt";
UserControl.lblText.Content = "Zähler nicht erfolgreich vorbehandelt";
}
));
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
base.Progress = 50;
Progress = 50;
var nowSeconds = Meter.ReadRegister("POWERMON_TotalUsedSeconds");
var nowCharge = Meter.ReadRegister("POWERMON_TotalUsedCharge", 8);
@@ -116,10 +116,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send,
new Action(() =>
{
UserControl.lblText.Content = $"Batterie nicht lesbar";
UserControl.lblText.Content = "Batterie nicht lesbar";
}
));
Meter.WriteLog($"Batterie nicht lesbar");
Meter.WriteLog("Batterie nicht lesbar");
break;
}
var nowChargeV = BitConverter.ToUInt64(nowCharge.ToArray(), 0);
@@ -129,8 +129,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//// Time Span in h in mAhr In % with one battery is 100%
////(((total used change difference / (Time span / 3600) ) / 3600000) / 19000)*100
var loadAtH = ((((double)nowChargeV / ((double)nowSecondsV / 3600)) / 3600000) / (19000 * 2)) * 100;
var totalUsed = (((double)nowChargeV / 1000000 / 3.6) / ((19000 * 2))) * 100;
// ReSharper disable once UnusedVariable used for debug purposes
var loadAtH = nowChargeV / ((Double)nowSecondsV / 3600) / 3600000 / (19000 * 2) * 100;
var totalUsed = (Double)nowChargeV / 1000000 / 3.6 / (19000 * 2) * 100;
//lastFrame
Meter.WriteLog($"totalUsed at EOL {totalUsed}");
@@ -138,9 +139,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
if (totalUsed > 10)
{
base.currentProcessState = ProductionProcessState.Error;
UserControl.lblText.Content = $"Batterie über 15% entladen";
Meter.WriteLog($"Batterie über 15% entladen");
currentProcessState = ProductionProcessState.Error;
UserControl.lblText.Content = "Batterie über 15% entladen";
Meter.WriteLog("Batterie über 15% entladen");
}
if (currentProcessState != ProductionProcessState.Error)
@@ -148,20 +149,20 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
currentProcessState = ProductionProcessState.Done;
return;
}
reTrysLeft = reTrysLeft - 1;
retriesRemaining = retriesRemaining - 1;
currentProcessState = ProductionProcessState.Error;
}
catch (Exception ex)
{
Meter.WriteLog($"{ex}");
base.currentProcessState = ProductionProcessState.Error;
reTrysLeft = reTrysLeft - 1;
currentProcessState = ProductionProcessState.Error;
retriesRemaining = retriesRemaining - 1;
}
}
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
public override void StartProcess()
@@ -1,17 +1,12 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System.Threading;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Logic.SoftwareAccessHelper;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Logic.ProductionOrderCore.Vako;
using Xylem.Common.Logic.SoftwareAccessHelper;
namespace ProductionUiCordonel.ProductionProcesses.Actions
{
@@ -25,9 +20,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Error,
Acknowledge
}
public bool DialogIsDone { get; private set; }
public int OrderNumber { get; set; }
public ProductionProcessCheckAttachment(int orderNumber)
public Boolean DialogIsDone { get; }
public Int32 OrderNumber { get; set; }
public ProductionProcessCheckAttachment(Int32 orderNumber)
{
OrderNumber = orderNumber;
DialogIsDone = false;
@@ -43,7 +38,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -56,23 +51,23 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private void StepDone()
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
isDone?.Invoke(null, EventArgs.Empty);
}
private void StepError()
{
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
isDone?.Invoke(null, EventArgs.Empty);
}
public override async void StartProcess()
public override void StartProcess()
{
try
{
var a = LocalWebRequest.GetRequest($"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetSingleVakoKey?ProductionOrderNumber={OrderNumber}&KeyName=C_GEN_PULS");
var myJsonResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<VakoKeyValue>(a);
var myJsonResponse = JsonConvert.DeserializeObject<VakoKeyValue>(a);
if (myJsonResponse.Value.ToLower() == "q" || myJsonResponse.Value.ToLower() == "k")
{
UserControl.SetDesc("Pulse Module anbauen!");
@@ -1,17 +1,10 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ProductionUiCordonel.UserControls.FinalTest;
using System.Threading;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using System;
using System.IO;
using System.Net;
using System.Windows.Controls;
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
namespace ProductionUiCordonel.ProductionProcesses.Actions
@@ -28,14 +21,13 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Print,
Abort
}
public bool DialogIsDone { get; private set; }
public int SerialNumber { get; private set; }
public int Ordernumber { get; private set; }
public Boolean DialogIsDone { get; }
public Int32 SerialNumber { get; private set; }
public Int32 Ordernumber { get; private set; }
private int? OldOrderNumber { get; set; }
private bool Error = false;
public ProductionProcessCheckOrderNumber(int? oldOrderNumber = null)
private Int32? OldOrderNumber { get; }
public ProductionProcessCheckOrderNumber(Int32? oldOrderNumber = null)
{
OldOrderNumber = oldOrderNumber;
@@ -53,7 +45,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -66,23 +58,23 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private void StepDone()
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
isDone?.Invoke(this, EventArgs.Empty);
}
private void StepMismatch(string msg)
private void StepMismatch(String msg)
{
UserControl.SetDesc(msg);
UserControl.SetFocusMe();
//UserControl.Focus();
base.NewStatus(msg);
NewStatus(msg);
UserControl.BarcodeInput += UserControl_KeyDown;
}
private void UserControl_KeyDown(object sender, string input)
private void UserControl_KeyDown(Object sender, String input)
{
var a = input;
@@ -101,7 +93,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//StepDone();
}
public override async void StartProcess()
public override void StartProcess()
{
//get order number
@@ -120,7 +112,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
private void GetPcbMapping(string pcbID)
private void GetPcbMapping(String pcbID)
{
if (string.IsNullOrEmpty(pcbID))
{
@@ -132,7 +124,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
try
{
var http = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = null;
HttpWebResponse response;
try
{
response = (HttpWebResponse)http.GetResponse();
@@ -145,15 +137,16 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
if (response != null && response.StatusCode == HttpStatusCode.OK)
{
var responseStream = response.GetResponseStream();
using (var sr = new StreamReader(responseStream))
{
var responseJson = sr.ReadToEnd();
var a = JsonConvert.DeserializeObject<string[]>(responseJson);
SerialNumber = Convert.ToInt32(a[0]);
Ordernumber = Convert.ToInt32(a[1]);
if (responseStream != null)
using (var sr = new StreamReader(responseStream))
{
var responseJson = sr.ReadToEnd();
var a = JsonConvert.DeserializeObject<String[]>(responseJson);
SerialNumber = Convert.ToInt32(a[0]);
Ordernumber = Convert.ToInt32(a[1]);
Meter.SerialNumber = SerialNumber.ToString();
}
Meter.SerialNumber = SerialNumber.ToString();
}
}
else
{
@@ -1,18 +1,7 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using System.Windows.Controls;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System.Threading;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using System.IO;
using System.Net;
using Newtonsoft.Json;
using Xylem.Common.CommonCore.Configuration;
namespace ProductionUiCordonel.ProductionProcesses.Actions
{
@@ -28,13 +17,12 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Print,
Abort
}
public bool DialogIsDone { get; private set; }
public string PcbSerialNumber { get; private set; }
public Boolean DialogIsDone { get; }
public String PcbSerialNumber { get; private set; }
public string AltRadio { get; private set; }
public String AltRadio { get; }
private bool Error = false;
public ProductionProcessCheckSerialNumber(String pcbSerialNumber, string altRadio = null)
public ProductionProcessCheckSerialNumber(String pcbSerialNumber, String altRadio = null)
{
PcbSerialNumber = pcbSerialNumber;
@@ -52,7 +40,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -65,21 +53,21 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private void StepDone()
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
isDone?.Invoke(this, EventArgs.Empty);
}
private void StepMismatch(string msg)
private void StepMismatch(String msg)
{
base.currentProcessState = ProductionProcessState.Error;
base.NewStatus(msg);
currentProcessState = ProductionProcessState.Error;
NewStatus(msg);
isDone?.Invoke(this, EventArgs.Empty);
}
private void UserControl_KeyDown(object sender, string input)
private void UserControl_KeyDown(Object sender, String input)
{
var a = input;
PcbSerialNumber = Meter.SerialNumber;
@@ -114,7 +102,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//StepDone();
}
public override async void StartProcess()
public override void StartProcess()
{
PcbSerialNumber = Meter.SerialNumber;
UserControl.SetDesc($"Bitte den Deckel des Zählers Scannern{Environment.NewLine} Die Seriennummer muss abgeglichen werden.");
@@ -1,9 +1,10 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows.Controls;
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Logic.ProductionOrderCore;
@@ -13,27 +14,34 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
public class ProductionProcessConnect : BaseProductionProcess
{
public Task<IList<ProgrammingParameters>> asyncprogrammingParametersTask;
public Task<IList<ProgrammingParameters>> asyncProgrammingParametersTask;
private UcPlain UserControl;
private GenesisMeter Meter;
public ProductionProcessConnect()
public ProductionProcessConnect(GenesisMeter meter)
{
Meter = meter;
name = "Connect";
currentProcessState = ProductionProcessState.Waiting;
}
public override void InitUserControl()
{
UserControl = new UcPlain();
UserControl.lblHl.Content = name;
UserControl.lblText.Content = "";
UserControl = new UcPlain
{
lblHl =
{
Content = name
},
lblText =
{
Content = ""
}
};
}
public override UserControl GetControl()
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -46,49 +54,47 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
public override void StartProcess()
{
base.NewStatus($"Prüfe Verbindung");
base.Progress = 0;
if (!base.Meter.IsLoggedOn)
NewStatus("Prüfe Verbindung");
Progress = 0;
if (!Meter.IsLoggedOn)
{
base.NewStatus($"Login wird gestartet");
base.Meter.Login();
NewStatus("Login wird gestartet");
Meter.Login();
}
//Check access in
base.Progress = 50;
base.NewStatus($"Zugang wird überprüft");
Progress = 50;
NewStatus("Zugang wird überprüft");
//var res = base.Meter.ReadRegister(Register.Genesisflow.LedMode);
//if (res != null && res.Length > 0)
//{
base.Progress = 100;
base.NewStatus($"Zugang verifiziert");
Progress = 100;
NewStatus("Zugang verifiziert");
currentProcessState = ProductionProcessState.Done;
asyncprogrammingParametersTask = new Task<IList<ProgrammingParameters>>(() =>
asyncProgrammingParametersTask = new Task<IList<ProgrammingParameters>>(() =>
{
try
{
//var url = $"http://localhost:56011/api/FinalCheck/GetProgrammingParameters?PcbID={base.Meter.PcbId}";
var url = $"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetProgrammingParameters?PcbID={base.Meter.PcbId}";
var url = $"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetProgrammingParameters?PcbID={Meter.PcbId}";
var csdRet = LocalWebRequest.GetRequest(url, 80000);
return Newtonsoft.Json.JsonConvert.DeserializeObject<IList<ProgrammingParameters>>(csdRet);
return JsonConvert.DeserializeObject<IList<ProgrammingParameters>>(csdRet);
}
catch (Exception ex)
catch (Exception )
{
return new List<ProgrammingParameters>() { };
return new List<ProgrammingParameters>
{
Capacity = 0
};
}
});
asyncprogrammingParametersTask.Start();
asyncProgrammingParametersTask.Start();
return;
//}
currentProcessState = ProductionProcessState.Error;
// throw new Exception($"Not able to login");
}
}
}
@@ -1,20 +1,14 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System.Threading;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
namespace ProductionUiCordonel.ProductionProcesses.Actions
{
public class ProductionProcessDone : BaseProductionProcess
{
public event EventHandler<Tuple<bool,bool, bool>> isDone;
public event EventHandler<Tuple<Boolean,Boolean, Boolean>> isDone;
private UcDialog UserControl;
public DialogResult Result = DialogResult.None;
public enum DialogResult
@@ -24,9 +18,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Print,
Abort
}
public bool DialogIsDone { get; private set; }
private bool Error = false;
public ProductionProcessDone(bool error = false)
public Boolean DialogIsDone { get; }
private Boolean Error;
public ProductionProcessDone(Boolean error = false)
{
Error = error;
DialogIsDone = false;
@@ -42,7 +36,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -55,7 +49,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private void StepDone()
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
var retry = false;
var abort = false;
var print = false;
@@ -74,14 +68,12 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
case DialogResult.Abort:
abort = true;
break;
default:
break;
}
}
isDone?.Invoke(null, new Tuple<bool, bool,bool>(retry, abort, print));
isDone?.Invoke(null, new Tuple<Boolean, Boolean,Boolean>(retry, abort, print));
}
private void StepError(string ErrorText = "Ein Fehler ist aufgetreten")
private void StepError(String ErrorText = "Ein Fehler ist aufgetreten")
{
UserControl.SetDesc(ErrorText);
@@ -132,7 +124,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
UserControl.SetDialogOptions(OptionList);
}
public override async void StartProcess()
public override void StartProcess()
{
if (Error)
{
@@ -1,25 +1,24 @@
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows.Controls;
using Xylem.Common.CommonCore.Configuration;
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.Hardware.WaterMeter.Genesis.DataPackages;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
namespace ProductionUiCordonel.ProductionProcesses.Actions
{
public class ProductionProcessFinalParameterizationFix : BaseProductionProcess
public class ProductionProcessFinalParametrizationFix : BaseProductionProcess
{
private UcPlain UserControl;
public ProductionProcessFinalParameterizationFix()
public ProductionProcessFinalParametrizationFix()
{
name = "Final Parameterization";
name = "Final Parametrization";
currentProcessState = ProductionProcessState.Waiting;
}
public override void InitUserControl()
@@ -31,7 +30,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -59,7 +58,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
public Task<Tuple<String, Boolean>> wirteRegisterInBetweenCheck(String reg, Int32 value, Boolean waitForResult = true,
Boolean checkRegister = false, int addToCheck = 10, int addFromCheck = 0)
Boolean checkRegister = false, Int32 addToCheck = 10, Int32 addFromCheck = 0)
{
return new Task<Tuple<String, Boolean>>(() =>
{
@@ -77,21 +76,12 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
public override void StartProcess()
{
Progress = 0;
base.Progress = 0;
var useRadio = true;
var radioParams = new RadioConfigurationParams();
if (useRadio)
RadioConfigurationParams radioParams;
{
var url = ServiceUrls.GenesisFinalCheckServiceUrl();
url = "http://localhost:56011/api/FinalCheck/";
url = url + $"GetRadioConfiguration?PcbId={Meter.PcbId}&withPressure=false";
var url = "http://localhost:56011/api/FinalCheck/";
url += $"GetRadioConfiguration?PcbId={Meter.PcbId}&withPressure=false";
var http = (HttpWebRequest)WebRequest.Create(url);
http.Method = "GET";
@@ -108,7 +98,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
radioParams = JsonConvert.DeserializeObject<RadioConfigurationParams>(responseJson);
}
}
base.Progress = 20;
Progress = 20;
@@ -169,11 +159,8 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
(new Byte[] { 0x00, 0x00, 0x00, 0xFD }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_DisplayUnits",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true));
if (useRadio)
{
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_ForwardArrow",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true));
}
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_ForwardArrow",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_HardErrorLimit",
(new Byte[] { 0x00, 0x00, 0x00, 0x04 }).Reverse().ToArray(), true, true));
@@ -189,7 +176,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_PipeFillingDelay",
(new Byte[] { 0x00, 0x00, 0x00, 0x1E }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_ResetAccumulators",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, false));
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_SampleRate",
(new Byte[] { 0x00, 0x00, 0x00, 0x02 }).Reverse().ToArray(), true, true));
@@ -226,26 +213,18 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
(new Byte[] { 0x00, 0x00, 0x27, 0x10 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("METROLOGYASST_TemperatureUnits",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("POWERMON_BatterySelection",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, false));
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("POWERMON_WarnFromClamp",
(new Byte[] { 0x25, 0x89, 0x06, 0x00 }).Reverse().ToArray(), true, true));
//// just read later //overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_FrequencyIndicator}).Reverse(), true, true);
//Original
//0x11, 0x12, 0x13, 0x14, 0x21, 0x22, 0x23, 0x24, 0x31, 0x32, 0x33, 0x34, 0x41, 0x42, 0x43, 0x44
//Write to register
//0x14, 0x13, 0x12, 0x11, 0x24, 0x23, 0x22, 0x21, 0x34, 0x33, 0x32, 0x31, 0x44, 0x43, 0x42, 0x41
//good one
//E6-C8-88-00-DE-B8-68-C0-D6-A8-48-80-CE-98-28-40
//0E-05-04-04-00-14-30-68-D0-14-0E-80-40-63-93-73-22
@@ -253,85 +232,74 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//&bad one
//0E-05-04-05-00-00-88-C8-E6-C0-68-B8-DE-80-48-A8-D6-40-28-98-CE
//0E-05-04-04-00-22-73-93-63-40-80-0E-14-D0-68-30-14
if (useRadio)
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_WakeupInterval",
(new Byte[] { 0x00, 0x00, 0x00, 0x03 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_MbusState",
(new Byte[] { 0x00, 0x00, 0x00, 0x07 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_UtcTimeOffset",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_HistoricalAlarmsDays",
(new Byte[] { 0x00, 0x00, 0x00, 0x1D }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_AverageFlowPeriod",
(new Byte[] { 0x00, 0x00, 0x00, 0x05 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_DataLogContents",
(new Byte[] { 0x0C, 0x00, 0x24, 0x03 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_DataLogPeriod",
(new Byte[] { 0x00, 0x00, 0x00, 0x3C }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_FixedDateDayOfMonth",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_FixedDateReadingContents",
(new Byte[] { 0x0C, 0x00, 0x24, 0x03 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_PeriodicLogLifeTimeCounter",
(new Byte[] { 0x00, 0x00, 0x00, 0x0 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_ResetCounter",
(new Byte[] { 0x00, 0x00, 0x00, 0x0 }).Reverse().ToArray(), true, true));
//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());
//overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_EncryptionKey", funkadresse.ToArray(),
// true, true));
//overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_EncryptionKey",
// (new Byte[]
// {
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
// }).ToArray(), true, true));
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());
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_EncryptionKey", funkadresse.ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_RadioAddress", radioParams.RadioAddress, true, true));
if (radioParams.PowerLevel > 0 && radioParams.PowerLevelOption > 0 && radioParams.ImpedanceCodeNew > 0 && radioParams.ImpedanceCodeOption > 0)
{
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_PowerLevel", radioParams.PowerLevel, true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_PowerLevelOption", radioParams.PowerLevelOption, true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_ImpedanceCodeNew", radioParams.ImpedanceCodeNew, true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_ImpedanceCodeOption", radioParams.ImpedanceCodeOption, true, true));
}
else
{
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_WakeupInterval",
(new Byte[] { 0x00, 0x00, 0x00, 0x03 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_MbusState",
(new Byte[] { 0x00, 0x00, 0x00, 0x07 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_UtcTimeOffset",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_HistoricalAlarmsDays",
(new Byte[] { 0x00, 0x00, 0x00, 0x1D }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_AverageFlowPeriod",
(new Byte[] { 0x00, 0x00, 0x00, 0x05 }).Reverse().ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_DataLogContents",
(new Byte[] { 0x0C, 0x00, 0x24, 0x03 }).Reverse().ToArray(), true, false));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_DataLogPeriod",
(new Byte[] { 0x00, 0x00, 0x00, 0x3C }).Reverse().ToArray(), true, false));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_FixedDateDayOfMonth",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, false));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_FixedDateReadingContents",
(new Byte[] { 0x0C, 0x00, 0x24, 0x03 }).Reverse().ToArray(), true, false));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_PeriodicLogLifeTimeCounter",
(new Byte[] { 0x00, 0x00, 0x00, 0x0 }).Reverse().ToArray(), true, false));
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_ResetCounter",
(new Byte[] { 0x00, 0x00, 0x00, 0x0 }).Reverse().ToArray(), true, true));
//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());
//overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_EncryptionKey", funkadresse.ToArray(),
// true, true));
//overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_EncryptionKey",
// (new Byte[]
// {
// 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
// }).ToArray(), true, true));
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());
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_EncryptionKey", funkadresse.ToArray(), true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_RadioAddress", radioParams.RadioAddress, true, true));
if (radioParams.PowerLevel > 0 && radioParams.PowerLevelOption > 0 && radioParams.ImpedanceCodeNew > 0 && radioParams.ImpedanceCodeOption > 0)
{
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_PowerLevel", radioParams.PowerLevel, true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_PowerLevelOption", radioParams.PowerLevelOption, true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_ImpedanceCodeNew", radioParams.ImpedanceCodeNew, true, true));
overAllResult.Add(_currentGenesis_WriteRegister("SENSUSRADIO_ImpedanceCodeOption", radioParams.ImpedanceCodeOption, true, true));
}
else
{
base.currentProcessState = ProductionProcessState.Error;
return;
}
//_currentGenesis_WriteRegister("SENSUSRADIO_CustomerText",
// (new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, false);
currentProcessState = ProductionProcessState.Error;
return;
}
//_currentGenesis_WriteRegister("SENSUSRADIO_CustomerText",
// (new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, false);
var ts = DateTimeOffset.UtcNow - new DateTimeOffset(2000, 1, 1, 0, 0, 0, new TimeSpan(0));
overAllResult.Add(wirteRegisterInBetweenCheck("SYSTEM_CalendarSeconds", Convert.ToInt32(ts.TotalSeconds)));
@@ -349,30 +317,30 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
var ret = true;
int done = 0;
Int32 done = 0;
foreach (var cTask in overAllResult)
{
cTask.RunSynchronously();
if (cTask.Result.Item2)
{
base.NewStatus($"set Parameter {cTask.Result.Item1} succeed");
NewStatus($"set Parameter {cTask.Result.Item1} succeed");
}
else
{
base.NewStatus($"set Parameter {cTask.Result.Item1} failed");
NewStatus($"set Parameter {cTask.Result.Item1} failed");
ret = false;
break;
}
base.Progress = 20 + ((Int32)Math.Round(((Double)done / (Double)overAllResult.Count) * 80, 0));
done = done + 1;
Progress = 20 + ((Int32)Math.Round((done / (Double)overAllResult.Count) * 80, 0));
done += 1;
}
if (!ret)
{
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
else
{
@@ -1,23 +1,23 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Logic.ProductionOrderCore;
namespace ProductionUiCordonel.ProductionProcesses.Actions
{
public class ProductionProcessFinalParameterizationVakoCsd : BaseProductionProcess
public class ProductionProcessFinalParametrizationVakoCsd : BaseProductionProcess
{
private UcPlain UserControl;
private ProductionProcessConnect connectProcess;
private bool hasRadio;
private Boolean hasRadio;
public ProductionProcessFinalParameterizationVakoCsd(ProductionProcessConnect connectProcess, bool registerHasRadio = true)
public ProductionProcessFinalParametrizationVakoCsd(ProductionProcessConnect connectProcess, Boolean registerHasRadio = true)
{
this.connectProcess = connectProcess;
name = "Kunden Parametrierung";
@@ -27,16 +27,24 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
public override void InitUserControl()
{
UserControl = new UcPlain();
UserControl.lblHl.Content = name;
UserControl.lblText.Content = "Kann bis zu 1 Minute dauern!";
UserControl = new UcPlain
{
lblHl =
{
Content = name
},
lblText =
{
Content = "Dieser Vorgang kann bis zu 1 Minute dauern!"
}
};
}
public override UserControl GetControl()
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -52,8 +60,6 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
return new Task<Tuple<String, Boolean>>(() =>
{
Task.Delay(10).Wait();
var ret = Meter.WriteRegister(reg, value, waitForResult, checkRegister);
if (!ret)
@@ -65,15 +71,15 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
public Task<Tuple<String, Boolean>> wirteRegisterInBetweenCheck(String reg, Int32 value, Boolean waitForResult = true,
Boolean checkRegister = false, int addToCheck = 10, int addFromCheck = 0)
public Task<Tuple<String, Boolean>> wirteRegisterInBetweenCheck(String reg, Int32 value, Boolean waitForResult = true,
Int32 addToCheck = 10, Int32 addFromCheck = 0)
{
return new Task<Tuple<String, Boolean>>(() =>
{
Meter.WriteRegister(reg, value, waitForResult);
var accucalValue = RegisterConverter.ConvertTo<Int32>(Meter.ReadRegister(reg));
if (accucalValue >= (value + addFromCheck) && value <= accucalValue + (addToCheck))
var actualValue = RegisterConverter.ConvertTo<Int32>(Meter.ReadRegister(reg));
if (actualValue >= (value + addFromCheck) && value <= actualValue + (addToCheck))
{
return new Tuple<String, Boolean>(reg, true);
}
@@ -83,23 +89,23 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private void doStartProcessLoop()
{
var reTrysLeft = 4;
while (reTrysLeft >= 0)
var remainingRetries = 4;
while (remainingRetries >= 0)
{
try
{
while (connectProcess.asyncprogrammingParametersTask.Status == TaskStatus.Running)
while (connectProcess.asyncProgrammingParametersTask.Status == TaskStatus.Running)
{
Thread.Sleep(500);
}
if (connectProcess.asyncprogrammingParametersTask.Status == TaskStatus.RanToCompletion
&& connectProcess.asyncprogrammingParametersTask.Result != null
&& connectProcess.asyncprogrammingParametersTask.Result.Any())
if (connectProcess.asyncProgrammingParametersTask.Status == TaskStatus.RanToCompletion
&& connectProcess.asyncProgrammingParametersTask.Result != null
&& connectProcess.asyncProgrammingParametersTask.Result.Any())
{
var myJsonResponse = connectProcess.asyncprogrammingParametersTask.Result;
var myJsonResponse = connectProcess.asyncProgrammingParametersTask.Result;
base.Progress = 15;
Progress = 15;
//fix
// CUSTOMER_LeakFlowThreshold
@@ -110,11 +116,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//
var ts = DateTimeOffset.UtcNow - new DateTimeOffset(2000, 1, 1, 0, 0, 0, new TimeSpan(0));
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_SealDisplay",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, true));
foreach (var item in myJsonResponse.Where(m => m.Source == ProgrammingSource.Vako))
{
@@ -126,7 +130,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//SENSUSRADIO_EncryptionKey dont reserve SENSUSRADIO_EncryptionKey!
if (item.RegisterName.ToLower().Contains("displaypow".ToLower()) || item.RegisterName.ToLower().Contains("METROLOGYASST_FlowPoint".ToLower()))
{
overAllResult.Add(_currentGenesis_WriteRegister(item.RegisterName, new byte[] { item.RegisterValue.ToArray()[0] }, true, true));
overAllResult.Add(_currentGenesis_WriteRegister(item.RegisterName, new[] { item.RegisterValue.ToArray()[0] }, true, true));
}
else if (item.RegisterName.ToLower().Contains("SENSUSRADIO_EncryptionKey".ToLower()))
{
@@ -138,18 +142,15 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
//else if (!item.RegisterName.ToLower().Contains("apparrangement"))
//{
// overAllResult.Add(_currentGenesis_WriteRegister(item.RegisterName, item.RegisterValue.Reverse().ToArray(), true, true));
//}
}
overAllResult.Add(_currentGenesis_WriteRegister("CUSTOMER_AlarmEnableMask", new byte[] { 0x00, 0x00, 0x80, 0x53 }.Reverse().ToArray(), true, false)); ;
overAllResult.Add(_currentGenesis_WriteRegister("CUSTOMER_AlarmBroadcastMask", new byte[] { 0x00, 0x00, 0x1f, 0xdc }.Reverse().ToArray(), true, false));
overAllResult.Add(_currentGenesis_WriteRegister("CUSTOMER_AlarmVisualMask", new byte[] { 0x00, 0x00, 0x1f, 0xdc }.Reverse().ToArray(), true, false));
overAllResult.Add(_currentGenesis_WriteRegister("CUSTOMER_AlarmEnableMask", new Byte[] { 0x00, 0x00, 0x80, 0x53 }.Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("CUSTOMER_AlarmBroadcastMask", new Byte[] { 0x00, 0x00, 0x1f, 0xdc }.Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("CUSTOMER_AlarmVisualMask", new Byte[] { 0x00, 0x00, 0x1f, 0xdc }.Reverse().ToArray()));
foreach (var item in myJsonResponse.Where(m => m.Source == ProgrammingSource.Csd))
{
@@ -166,35 +167,27 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_ResetAccumulators",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, false));
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray()));
overAllResult.Add(wirteRegisterInBetweenCheck("SYSTEM_CalendarSeconds", Convert.ToInt32(ts.TotalSeconds)));
overAllResult.Add(wirteRegisterInBetweenCheck("IRDA_MfgDate", Convert.ToInt32(ts.TotalSeconds)));
overAllResult.Add(_currentGenesis_WriteRegister("LOGGER_TriggerLogFlush",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, false));
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("NFC_EraseRMA",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, false));
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray()));
if (hasRadio)
{
overAllResult.Add(_currentGenesis_WriteRegister("PERIODICLOG_ResetCounter",
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray(), true, false));
(new Byte[] { 0x00, 0x00, 0x00, 0x00 }).Reverse().ToArray()));
overAllResult.Add(_currentGenesis_WriteRegister("GENESISFLOW_SealDisplay",
(new Byte[] { 0x00, 0x00, 0x00, 0x01 }).Reverse().ToArray(), true, true));
}
var ret = true;
int done = 0;
Int32 done = 0;
foreach (var cTask in overAllResult)
{
@@ -204,39 +197,34 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
cTask.RunSynchronously();
if (cTask.Result.Item2)
{
base.NewStatus($"Schreiben des Parameter {cTask.Result.Item1} war erfolgreich");
NewStatus($"Schreiben des Parameter {cTask.Result.Item1} war erfolgreich");
}
else
{
if (cTask.Result.Item1.ToLower().Contains("Metersize".ToLower()) || cTask.Result.Item1.ToLower().Contains("NFC_EraseRMA".ToLower()) || cTask.Result.Item1.ToLower().Contains("CUSTOMER_ExcessFlowVolumeThreshold".ToLower()) || cTask.Result.Item1.ToLower().Contains("CUSTOMER_LeakFlowThreshold".ToLower()) || cTask.Result.Item1.ToLower() == "SENSUSRADIO_MetroRadioLifeTimeCounter".ToLower())
if (cTask.Result.Item1.ToLower().Contains("Metersize".ToLower()) || cTask.Result.Item1.ToLower().Contains("NFC_EraseRMA".ToLower()) || cTask.Result.Item1.ToLower().Contains("CUSTOMER_ExcessFlowVolumeThreshold".ToLower()) || cTask.Result.Item1.ToLower().Contains("CUSTOMER_LeakFlowThreshold".ToLower()) || cTask.Result.Item1.ToLower() == "SENSUSRADIO_MetroRadioLifeTimeCounter".ToLower())
{
base.NewStatus($"Warnung!Schreiben des Parameter {cTask.Result.Item1} war nicht erfolgreich");
NewStatus($"Warnung! Fehler beim Schreiben des Parameters {cTask.Result.Item1}");
}
else
{
base.NewStatus($"Warnung!Schreiben des Parameter {cTask.Result.Item1} war nicht erfolgreich");
NewStatus($"Warnung! Fehler beim Schreiben des Parameters {cTask.Result.Item1}");
ret = false;
break;
}
}
}
catch (Exception ex)
catch (Exception)
{
if (cTask.Result.Item1 != "GENESISFLOW_MaxDeltaToFRange")
{
throw;
}
}
base.Progress = 15 + ((Int32)Math.Round(((Double)done / (Double)overAllResult.Count) * 85, 0));
done = done + 1;
Progress = 15 + ((Int32)Math.Round((done / (Double)overAllResult.Count) * 85, 0));
done += 1;
}
if (!ret)
{
@@ -246,35 +234,28 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
currentProcessState = ProductionProcessState.Done;
return;
}
reTrysLeft = reTrysLeft - 1;
remainingRetries -= 1;
}
else
{
base.currentProcessState = ProductionProcessState.Error;
reTrysLeft = -1;
base.NewStatus($"Warnung!Fehler beim laden des Parametersatzes");
currentProcessState = ProductionProcessState.Error;
remainingRetries = -1;
NewStatus("Warnung! Fehler beim Laden des Parametersatzes");
}
}
catch (Exception ex)
{
base.currentProcessState = ProductionProcessState.Error;
base.NewStatus($"Warnung!Fehler bei behandeln {ex.Message}");
reTrysLeft = reTrysLeft - 1;
currentProcessState = ProductionProcessState.Error;
NewStatus($"Warnung! Fehler beim Behandeln von {ex.Message}");
remainingRetries = remainingRetries - 1;
}
}
}
public override void StartProcess()
{
doStartProcessLoop();
}
}
}
@@ -1,9 +1,9 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System;
using System;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Threading;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
namespace ProductionUiCordonel.ProductionProcesses.Actions
@@ -26,7 +26,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -55,10 +55,11 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
try
{
var done1 = done;
UserControl.lblText.Dispatcher.Invoke(DispatcherPriority.Send,
new Action(() =>
{
UserControl.lblText.Content = $"Read {dic.GetIdent()}({done}/{total.Count})";
UserControl.lblText.Content = $"Read {dic.GetIdent()}({done1}/{total.Count})";
}
));
if (dic.RegisterName.ToLower() != "password" && dic.RegisterDetail.Privilege.Lvl8 != Access.Wo)
@@ -82,14 +83,14 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
}
base.Progress = (Int32)Math.Round(((Double)done / (Double)total.Count) * 100, 0);
Progress = (Int32)Math.Round(((Double)done / total.Count) * 100, 0);
}
catch (Exception e)
catch (Exception )
{
//todo: error logger
}
done = done + 1;
done += 1;
}
Meter.StoreCurrentRegisterDic();
@@ -97,13 +98,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
currentProcessState = ProductionProcessState.Done;
}
catch (Exception e)
catch (Exception )
{
currentProcessState = ProductionProcessState.Error;
}
}
}
}
@@ -1,23 +1,21 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using Xylem.Common.Logic.ProductionOrderCore;
using Xylem.Common.Logic.SoftwareAccessHelper;
namespace ProductionUiCordonel.ProductionProcesses.Actions
{
public class ProductionProcessGetFinalParameterizationVakoCsd : BaseProductionProcess
public class ProductionProcessGetFinalParametrizationVakoCsd : BaseProductionProcess
{
public IList<ProgrammingParameters> Result = new List<ProgrammingParameters>();
private UcPlain UserControl;
public ProductionProcessGetFinalParameterizationVakoCsd()
public ProductionProcessGetFinalParametrizationVakoCsd()
{
name = "Hole Kunden Parametrierung";
currentProcessState = ProductionProcessState.Waiting;
@@ -33,7 +31,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -47,47 +45,42 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private void doStartProcessLoop()
{
var reTrysLeft = 2;
while (reTrysLeft >= 0)
var retriesRemaining = 2;
while (retriesRemaining >= 0)
{
try
{
base.Progress = 0;
Progress = 0;
//var url = $"http://localhost:56011/api/FinalCheck/GetProgrammingParameters?PcbID={Meter.PcbId}";
var url = $"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetProgrammingParameters?PcbID={Meter.PcbId}";
var csdRet = LocalWebRequest.GetRequest(url, 60000);
Result = Newtonsoft.Json.JsonConvert.DeserializeObject<IList<ProgrammingParameters>>(csdRet);
Result = JsonConvert.DeserializeObject<IList<ProgrammingParameters>>(csdRet);
base.Progress = 100;
Progress = 100;
if (!Result.Any())
{
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
else
{
currentProcessState = ProductionProcessState.Done;
return;
}
reTrysLeft = reTrysLeft - 1;
retriesRemaining -= 1;
}
catch (Exception ex)
catch (Exception )
{
base.currentProcessState = ProductionProcessState.Error;
reTrysLeft = reTrysLeft - 1;
currentProcessState = ProductionProcessState.Error;
retriesRemaining -= 1;
}
}
}
public override void StartProcess()
{
doStartProcessLoop();
}
}
}
@@ -1,10 +1,10 @@
using Logic.ProductionToProductMapper.Cordonel;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Windows.Controls;
using Logic.ProductionToProductMapper.Cordonel;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Logic.SoftwareAccessHelper;
@@ -30,7 +30,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -1,13 +1,12 @@
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Controls;
using Newtonsoft.Json;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
using Xylem.Common.Logic.SoftwareAccessHelper;
@@ -33,41 +32,32 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
private void updateImage(Image ctlImage, bool? success = null)
private void updateImage(Image ctlImage, Boolean? success = null)
{
string path = "/Resources/iconWating.png";
if (success.HasValue)
{
if (success.Value)
{
path = "/Resources/iconCheck.png";
}
else
{
path = "/Resources/iconWarn.png";
}
}
}
public override void StartProcess()
{
bool ret = RequestPassword();
Boolean ret = RequestPassword();
updateImage(UserControl.RequestPassword, ret);
base.Progress = base.Progress + 16;
Progress += 16;
if (Encoding.UTF8.GetString(pwContainer.listOfPasswords.Last()) == pwContainer.Skeleton)//pwContainer.Skeleton )
{
NewStatus("Passwörter schon geschrieben. Prozess wird übersprungen");
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
return;
}
@@ -80,15 +70,15 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
updateImage(UserControl.CreateFile, ret);
base.Progress = base.Progress + 16;
Progress += 16;
if (ret)
{
ret = WritePasswordFileToMeter();
}
updateImage(UserControl.WriteToMeter, ret);
base.Progress = base.Progress + 16;
//Check if new password is in the meter ... even the file wirte wasnt succesfull
Progress += 16;
//Check if new password is in the meter ... even the file write wasn't successful
if (!ret)
{
Meter.Logout();
@@ -100,14 +90,14 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
ret = UpdatePasswordinDb();
}
updateImage(UserControl.UpdatePassword, ret);
base.Progress = base.Progress + 16;
Progress += 16;
if (ret)
{
ret = Meter.Logout();
}
updateImage(UserControl.Logout, ret);
base.Progress = base.Progress + 16;
Progress += 16;
if (ret)
@@ -115,15 +105,15 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
ret = Meter.Login();
}
updateImage(UserControl.CheckNewPassword, ret);
base.Progress = 100;
Progress = 100;
if (!ret)
{
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
else
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
}
}
public override void ProcessDone()
@@ -136,42 +126,43 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
public Int64? orderNumber = null;
public Int64? radioAdress = null;
public string Skeleton = "";
public List<byte[]> listOfHashes = new List<byte[]>();
public List<byte[]> listOfPasswords = new List<byte[]>();
public String Skeleton = "";
public List<Byte[]> listOfHashes = new List<Byte[]>();
public List<Byte[]> listOfPasswords = new List<Byte[]>();
}
private MeterPasswordContainer pwContainer = new MeterPasswordContainer();
private MeterPwdFile meterPwdFile;
public bool RequestPassword()
public Boolean RequestPassword()
{
base.NewStatus($"Request Passwords");
NewStatus("Request Passwords");
var url = ServiceUrls.GenesisGetPasswordContainerServiceUrl();
//url = "http://localhost:56011/api/Password/GetPasswordHashFileContent?PcbId=";
url = ($"{url}{Meter.PcbId}");
var errorCode = 0;
var header = new Dictionary<string, string>();
header.Add("Cache-Control", "no-cache");
header.Add("X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616");
var resp = LocalWebRequest.GetRequestWithError(url, out errorCode, 20000, header,true);
var header = new Dictionary<String, String>
{
{ "Cache-Control", "no-cache" },
{ "X-Node-Token", "d5b8c0b2-81f6-4421-80d0-44eb2093e616" }
};
var resp = LocalWebRequest.GetRequestWithError(url, out var errorCode, 20000, header,true);
if (errorCode == HttpStatusCode.OK.GetHashCode())
{
pwContainer = JsonConvert.DeserializeObject<MeterPasswordContainer>(resp);
base.NewStatus($"Passwörter verfügbar");
NewStatus("Passwörter verfügbar");
return true;
}
return false;
}
public bool CreatePasswordFile()
public Boolean CreatePasswordFile()
{
meterPwdFile = new MeterPwdFile(Meter);
return meterPwdFile.BuildPwdFile(pwContainer.listOfPasswords, 1, pwContainer.Skeleton);
}
public bool WritePasswordFileToMeter()
public Boolean WritePasswordFileToMeter()
{
if (meterPwdFile.UnlockEraseWriteMeterPwdFile())
{
@@ -179,7 +170,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
return false;
}
public bool UpdatePasswordinDb()
public Boolean UpdatePasswordinDb()
{
var newPs = Encoding.UTF8.GetString(pwContainer.listOfPasswords.Last());
@@ -1,23 +1,23 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using System;
using System.Collections.Generic;
using System;
using System.Configuration;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ProductionUiCordonel.UserControls.FinalTest;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using SIRTCOM;
using Xylem.Common.CommonCore.Configuration;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
using System.Net;
using System.IO;
using Newtonsoft.Json;
using Xylem.Common.CommonCore.Configuration;
using System.Configuration;
using System.Net.Http;
using System.Windows.Threading;
using Newtonsoft.Json.Linq;
using Xylem.Common.Logic.SoftwareAccessHelper;
using Button = System.Windows.Controls.Button;
using UserControl = System.Windows.Controls.UserControl;
namespace ProductionUiCordonel.ProductionProcesses.Actions
{
@@ -36,12 +36,12 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
UserControl = new UcRadioCheck();
UserControl.OnRetryRequested += delegate (Object sender, EventArgs args) { GetRssi(); };
UserControl.OnRetryRequested += delegate { GetRssi(); };
UserControl.OnResetRequested += delegate (Object sender, EventArgs args) { Reset(); };
UserControl.OnForceAPam += delegate (Object sender, EventArgs args) { forcePush(); };
UserControl.OnDoneRequested += delegate (Object sender, EventArgs args)
UserControl.OnResetRequested += delegate { Reset(); };
UserControl.OnForceAPam += delegate { forcePush(); };
UserControl.OnDoneRequested += delegate
{
currentProcessState = ProductionProcessState.Done;
@@ -52,7 +52,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -66,13 +66,13 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
if (!ret)
{
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
}
//clear
}
private Byte[] SENSUSRADIO_WakeupInterval = null;
private Byte[] SENSUSRADIO_WakeupInterval;
public override void StartProcess()
{
@@ -89,7 +89,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
EncyptionKey = LocalWebRequest.GetRequest($"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetEncryptionKey?PcbID={Meter.PcbId}", 80000).ToUpper().Trim('\"');
if (!EncyptionKey.Equals(BitConverter.ToString(enc.ToArray()).Replace("-", "")))
{
System.Windows.Forms.MessageBox.Show("Funkschlüssel überprüfen!");
MessageBox.Show("Funkschlüssel überprüfen!");
}
EncyptionKey = BitConverter.ToString(enc.ToArray()).Replace("-", "");
@@ -102,9 +102,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
//{
// Comport = 7;
//}
BoxNr = Convert.ToByte(ConfigurationManager.AppSettings[$"SirtBoxNr"]);
BoxNr = Convert.ToByte(ConfigurationManager.AppSettings["SirtBoxNr"]);
DebugMessage($"Start RadioCheck Comport:{Comport} ,BoxNr:{BoxNr}, freq: {freq}, RadioAdress:{RadioAdress}s\r\n", false);
DebugMessage($"Start RadioCheck Comport:{Comport} ,BoxNr:{BoxNr}, freq: {freq}, RadioAddress:{RadioAdress}s\r\n");
Meter.WriteRegister("SENSUSRADIO_IrDAModulePresent", 1, true, true);
@@ -119,27 +119,27 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
#region FormerForm
private SaveData saveData;
private SIRTCOM.Statemashine stm;
private Statemashine stm;
private static HttpClient httpclient;
private byte? RSSI_PAM_Min;
private byte? RSSI_PAM_Max;
private byte? RSSI_PAM;
private byte? RSSI_SEMI_Min;
private byte? RSSI_SEMI_Max;
private byte? RSSI_SEMI;
private Byte? RSSI_PAM_Min;
private Byte? RSSI_PAM_Max;
private Byte? RSSI_PAM;
private Byte? RSSI_SEMI_Min;
private Byte? RSSI_SEMI_Max;
private Byte? RSSI_SEMI;
public byte BoxNr;
public Byte BoxNr;
public int Ordernumber;
public Int32 Ordernumber;
public UInt32 RadioAdress;
public byte Comport;
public Byte Comport;
public string EncyptionKey = "";
public String EncyptionKey = "";
private void enableBtn(Button btn, bool enable)
private void enableBtn(Button btn, Boolean enable)
{
btn.Dispatcher.Invoke(DispatcherPriority.Send,
new Action(() =>
@@ -179,7 +179,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
await GetRssiMinMaxAsync(BoxNr, Ordernumber);
SetUi();
GetRSSI((int)RadioAdress, Comport, EncyptionKey);
GetRSSI((Int32)RadioAdress, Comport, EncyptionKey);
SetUi();
}
catch (Exception ex)
@@ -207,7 +207,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
stm.ClearPam();
stm.Stop();
}
DebugMessage("Reset\r\n", false);
DebugMessage("Reset\r\n");
clearRssi();
SetUi();
StartProcess();
@@ -216,10 +216,10 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private class SaveData
{
public Int32 RadioAdress { get; set; }
public byte RSSI_PAM { get; set; }
public byte RSSI_SEMI { get; set; }
public int LimitId { get; set; }
public byte Result { get; set; }
public Byte RSSI_PAM { get; set; }
public Byte RSSI_SEMI { get; set; }
public Int32 LimitId { get; set; }
public Byte Result { get; set; }
}
@@ -231,9 +231,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
DebugMessage("Calling SaveRSSI Webservice...", true);
try
{
saveData.RadioAdress = (int)RadioAdress; // 0-4294967295
string url = $"{ServiceUrls.GenesisRadioCheckServiceUrl()}SaveRSSI";
string body = JsonConvert.SerializeObject(saveData);
saveData.RadioAdress = (Int32)RadioAdress; // 0-4294967295
String url = $"{ServiceUrls.GenesisRadioCheckServiceUrl()}SaveRSSI";
String body = JsonConvert.SerializeObject(saveData);
await PostDataAsync(url, body);
DebugMessage(" Ready\r\n", true);
}
@@ -244,14 +244,14 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
private async Task GetRssiMinMaxAsync(byte BoxNr, Int32 FaNr)
private async Task GetRssiMinMaxAsync(Byte BoxNr, Int32 FaNr)
{
//DebugMessage("Calling GetLimits Webservice...", true);
try
{
// TODO anpassen
string url = $"{ServiceUrls.GenesisRadioCheckServiceUrl()}GetLimits/{BoxNr}/{FaNr}";
string body = await GetResponseAsync(url);
String url = $"{ServiceUrls.GenesisRadioCheckServiceUrl()}GetLimits/{BoxNr}/{FaNr}";
String body = await GetResponseAsync(url);
JObject o = JObject.Parse(body);
saveData.LimitId = Convert.ToInt32(o.SelectToken("LimitId").ToString());
@@ -276,20 +276,20 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
}
private void GetRSSI(Int32 RadioAdress, Int32 ByteCOMPort, string strKey)
private void GetRSSI(Int32 RadioAdress, Int32 ByteCOMPort, String strKey)
{
RSSI_PAM = null;
RSSI_SEMI = null;
stm = new SIRTCOM.Statemashine();
stm = new Statemashine();
byte P81_1 = 0;
Byte P81_1 = 0;
saveData.RadioAdress = RadioAdress;
stm.initialise((byte)ByteCOMPort);
SIRTCOM.Wrapper wrp = new SIRTCOM.Wrapper();
stm.initialise((Byte)ByteCOMPort);
Wrapper wrp = new Wrapper();
stm.StartLoggin("C:\\GenesisLog\\log.txt");
// ist wohl nicht nötig da der SIRT richtig konfiguroert ist:
@@ -313,7 +313,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
stm.OnStateChanged += Stm_OnStateChanged;
stm.Start(); // Start polling
DebugMessage($" OK\r\n", true);
DebugMessage(" OK\r\n", true);
Meter.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE);
Thread.Sleep(5000);
//Meter.WriteRegister("SENSUSRADIO_SYSTEMSTATE", 0x01, true, false);
@@ -327,17 +327,17 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private void forcePush()
{
Meter.WriteRegister("SENSUSRADIO_SYSTEMSTATE", 0x55, true, false);
Meter.WriteRegister("SENSUSRADIO_SYSTEMSTATE", 0x02, true, false);
Meter.WriteRegister("SENSUSRADIO_SYSTEMSTATE", 0x55);
Meter.WriteRegister("SENSUSRADIO_SYSTEMSTATE", 0x02);
}
public void DebugMessage(string value, Boolean Append = false)
public void DebugMessage(String value, Boolean Append = false)
{
NewStatus(value);
}
private void GotRSSICallback(byte Rssi_Semi_Sirt, byte Rssi_Pam_Cord)
private void GotRSSICallback(Byte Rssi_Semi_Sirt, Byte Rssi_Pam_Cord)
{
// RSSI beim Empfangen der PAM gemessen vom Cordonel (Sendestärke des SIRT verpackt in SEMI, byte 20)
DebugMessage($"RSSI Cord of PAM (Sirt => Cord):{Rssi_Pam_Cord}\r\n", true);
@@ -376,21 +376,21 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
SetUi();
if (saveData.Result == 1)
{
UserControl.ViewResult(10);
UserControl.ViewResult();
}
}
private void Stm_OnStateChanged(object sender, SIRTCOM.MyEventArgs e)
private void Stm_OnStateChanged(Object sender, MyEventArgs e)
{
// our Pam
SIRTCOM.PAM Pam = stm.GetPAM(1);
PAM Pam = stm.GetPAM(1);
if (Pam.State == SIRTCOM.PAM.PAMStates.Timeout)
if (Pam.State == PAM.PAMStates.Timeout)
{
DebugMessage($"Timeout nach {Pam.GetTime()} s\r\n", false);
DebugMessage($"Timeout nach {Pam.GetTime()} s\r\n");
}
if (Pam.CountSemi > 0)
@@ -401,20 +401,20 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
stm.Stop();
stm.ClearPam();
string HexbytesSEMI = Pam.Semi.HexData.Replace(" ", "");
byte[] SEMI_bytes = new byte[HexbytesSEMI.Length / 2];
String HexbytesSEMI = Pam.Semi.HexData.Replace(" ", "");
Byte[] SEMI_bytes = new Byte[HexbytesSEMI.Length / 2];
for (int i = 0; i < HexbytesSEMI.Length; i += 2)
for (Int32 i = 0; i < HexbytesSEMI.Length; i += 2)
SEMI_bytes[i / 2] = Convert.ToByte(HexbytesSEMI.Substring(i, 2), 16);
// SEMI Status
if (SEMI_bytes[19] == 0)
{
// RSSI beim Empfangen der SEMI gemessen vom Sirt
byte Semi_Rssi_Sirt = SEMI_bytes[2];
Byte Semi_Rssi_Sirt = SEMI_bytes[2];
// RSSI beim Empfangen der PAM gemessen vom Cordonel
byte Pam_Rssi_Cord = SEMI_bytes[20];
Byte Pam_Rssi_Cord = SEMI_bytes[20];
GotRSSICallback(Semi_Rssi_Sirt, Pam_Rssi_Cord);
}
@@ -431,7 +431,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
}
public static async Task<string> PostDataAsync(string url, string data)
public static async Task<String> PostDataAsync(String url, String data)
{
httpclient = new HttpClient();
// 20 Sekunden Timeout
@@ -441,11 +441,11 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
HttpResponseMessage response = await httpclient.PostAsync(url, queryString);
response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync();
String content = await response.Content.ReadAsStringAsync();
return content;
}
static async Task<string> GetResponseAsync(string url)
static async Task<String> GetResponseAsync(String url)
{
httpclient = new HttpClient();
// 20 Sekunden Timeout
@@ -454,7 +454,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
HttpResponseMessage response = httpclient.GetAsync(url).Result;
response.EnsureSuccessStatusCode();
string content = await response.Content.ReadAsStringAsync();
String content = await response.Content.ReadAsStringAsync();
return content;
}
@@ -1,10 +1,10 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Controls;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
@@ -13,9 +13,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
public class ProductionProcessShippingMode : BaseProductionProcess
{
private UcPlain UserControl;
private bool doRestart = false;
private bool hasRadio = false;
public ProductionProcessShippingMode(bool restart = false, bool registerHasRadio = true)
private Boolean doRestart;
private Boolean hasRadio;
public ProductionProcessShippingMode(Boolean restart = false, Boolean registerHasRadio = true)
{
name = "Versandbereitschaft herstellen";
currentProcessState = ProductionProcessState.Waiting;
@@ -33,7 +33,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -48,7 +48,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
Meter.ResetAlarm(GenesisMeter.Alarm.ALL);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
Meter.SetLcdText(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
Meter.SetLcdText(true, new Byte[] { 0x00, 0x00, 0x00, 0x01 });
Meter.ResetAlarm(GenesisMeter.Alarm.EMPTY_PIPE);//(true, new byte[] { 0x00, 0x00, 0x00, 0x01 });
@@ -58,12 +58,12 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
if (Meter.StoreAllConfigurations())
{
var writeList = new List<bool>();
writeList.Add(Meter.WriteRegister("SENSUSRADIO_SystemState", 1, true, false));
writeList.Add(Meter.WriteRegister("SENSUSRADIO_MainAlarmMask", 0, true, false));
writeList.Add(Meter.WriteRegister("SENSUSRADIO_ExtendedAlarmMask", 0, true, false));
var writeList = new List<Boolean>
{
Meter.WriteRegister("SENSUSRADIO_SystemState", 1),
Meter.WriteRegister("SENSUSRADIO_MainAlarmMask", 0),
Meter.WriteRegister("SENSUSRADIO_ExtendedAlarmMask", 0)
};
Thread.Sleep(15000);
@@ -86,16 +86,20 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
}
}
if (writeList.All(a => a == true))
if (writeList.All(a => a))
{
if (doRestart)
{
var CheckValuesAufterBoot = new List<Tuple<string, byte[]>>();
CheckValuesAufterBoot.Add(new Tuple<string, byte[]>("METROLOGYASST_PulseLength", Meter.ReadRegister("METROLOGYASST_PulseLength")));
CheckValuesAufterBoot.Add(new Tuple<string, byte[]>("POWERMON_BatteryQuantity", Meter.ReadRegister("POWERMON_BatteryQuantity")));
CheckValuesAufterBoot.Add(new Tuple<string, byte[]>("GENESISFLOW_MeterSize", Meter.ReadRegister("GENESISFLOW_MeterSize")));
CheckValuesAufterBoot.Add(new Tuple<string, byte[]>("GENESISFLOW_CalFactor1", Meter.ReadRegister("GENESISFLOW_CalFactor1")));
CheckValuesAufterBoot.Add(new Tuple<string, byte[]>("SENSUSRADIO_RadioAddress", Meter.ReadRegister("SENSUSRADIO_RadioAddress")));
var CheckValuesAfterBoot = new List<Tuple<String, Byte[]>>
{
new Tuple<String, Byte[]>("METROLOGYASST_PulseLength",
Meter.ReadRegister("METROLOGYASST_PulseLength")),
new Tuple<String, Byte[]>("POWERMON_BatteryQuantity",
Meter.ReadRegister("POWERMON_BatteryQuantity")),
new Tuple<String, Byte[]>("GENESISFLOW_MeterSize", Meter.ReadRegister("GENESISFLOW_MeterSize")),
new Tuple<String, Byte[]>("GENESISFLOW_CalFactor1", Meter.ReadRegister("GENESISFLOW_CalFactor1")),
new Tuple<String, Byte[]>("SENSUSRADIO_RadioAddress", Meter.ReadRegister("SENSUSRADIO_RadioAddress"))
};
var _meterResetPsu = new MeterResetPsu(Meter)
{
StoreConfigEnable = true
@@ -106,8 +110,8 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Meter.Login();
bool? hasDiffrences = null;
foreach (var item in CheckValuesAufterBoot)
Boolean? hasDiffrences = null;
foreach (var item in CheckValuesAfterBoot)
{
if (!item.Item2.SequenceEqual(Meter.ReadRegister(item.Item1)))
{
@@ -125,7 +129,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
if (rebootSucceeded && hasDiffrences.HasValue && !hasDiffrences.Value)
{
Meter.WriteRegister("SENSUSRADIO_SystemState", 0xFF, true, false);
Meter.WriteRegister("SENSUSRADIO_SystemState", 0xFF);
Meter.Logout();
Thread.Sleep(5000);
Meter.Login();
@@ -134,12 +138,12 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
var SENSUSRADIO_SystemState = Meter.ReadRegister("SENSUSRADIO_SystemState");
if (SENSUSRADIO_SystemState[0] == 0x02 && SENSUSRADIO_MainAlarmMask[0] != 0)
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
}
else
{
Meter.WriteLog("resetRadio Failed");
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
@@ -148,12 +152,12 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
else
{
Meter.WriteLog("reboot compare failed");
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
}
else
{
Meter.WriteRegister("SENSUSRADIO_SystemState", 0xFF, true, false);
Meter.WriteRegister("SENSUSRADIO_SystemState", 0xFF);
Meter.Logout();
Thread.Sleep(5000);
Meter.Login();
@@ -162,19 +166,19 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
var SENSUSRADIO_SystemState = Meter.ReadRegister("SENSUSRADIO_SystemState");
if (SENSUSRADIO_SystemState[0] == 0x02 && SENSUSRADIO_MainAlarmMask[0] != 0)
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
}
else
{
Meter.WriteLog("resetRadio Failed");
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
}
}
else
{
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
@@ -187,11 +191,11 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (doRestart)
{
var CheckValuesAufterBoot = new List<Tuple<string, byte[]>>();
CheckValuesAufterBoot.Add(new Tuple<string, byte[]>("METROLOGYASST_PulseLength", Meter.ReadRegister("METROLOGYASST_PulseLength")));
CheckValuesAufterBoot.Add(new Tuple<string, byte[]>("POWERMON_BatteryQuantity", Meter.ReadRegister("POWERMON_BatteryQuantity")));
CheckValuesAufterBoot.Add(new Tuple<string, byte[]>("GENESISFLOW_MeterSize", Meter.ReadRegister("GENESISFLOW_MeterSize")));
CheckValuesAufterBoot.Add(new Tuple<string, byte[]>("GENESISFLOW_CalFactor1", Meter.ReadRegister("GENESISFLOW_CalFactor1")));
var CheckValuesAufterBoot = new List<Tuple<String, Byte[]>>();
CheckValuesAufterBoot.Add(new Tuple<String, Byte[]>("METROLOGYASST_PulseLength", Meter.ReadRegister("METROLOGYASST_PulseLength")));
CheckValuesAufterBoot.Add(new Tuple<String, Byte[]>("POWERMON_BatteryQuantity", Meter.ReadRegister("POWERMON_BatteryQuantity")));
CheckValuesAufterBoot.Add(new Tuple<String, Byte[]>("GENESISFLOW_MeterSize", Meter.ReadRegister("GENESISFLOW_MeterSize")));
CheckValuesAufterBoot.Add(new Tuple<String, Byte[]>("GENESISFLOW_CalFactor1", Meter.ReadRegister("GENESISFLOW_CalFactor1")));
var _meterResetPsu = new MeterResetPsu(Meter)
{
@@ -203,7 +207,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
Meter.Login();
bool? hasDiffrences = null;
Boolean? hasDiffrences = null;
foreach (var item in CheckValuesAufterBoot)
{
if (!item.Item2.SequenceEqual(Meter.ReadRegister(item.Item1)))
@@ -221,23 +225,23 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
if (rebootSucceeded && hasDiffrences.HasValue && !hasDiffrences.Value)
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
}
else
{
Meter.WriteLog("reboot compare failed");
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
}
else
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
}
return;
}
}
base.currentProcessState = ProductionProcessState.Error;
currentProcessState = ProductionProcessState.Error;
}
@@ -1,14 +1,9 @@
using ProductionUiCordonel.ProductionProcesses.Enum;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using ProductionUiCordonel.ProductionProcesses.Enum;
using ProductionUiCordonel.UserControls.FinalTest;
using System.Threading;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
namespace ProductionUiCordonel.ProductionProcesses.Actions
{
@@ -16,7 +11,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
private UcDialog UserControl;
public bool DialogIsDone { get; private set; }
public Boolean DialogIsDone { get; }
public ProductionProcessSpecialConfig()
{
@@ -33,7 +28,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
{
if (UserControl == null)
{
throw new Exception($"UserControl {this.GetType()} not Ready");
throw new Exception($"UserControl {GetType()} not Ready");
}
return UserControl;
}
@@ -46,7 +41,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
private void StepDone()
{
base.currentProcessState = ProductionProcessState.Done;
currentProcessState = ProductionProcessState.Done;
}
private void StepRadio()
@@ -57,7 +52,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
var radioDefault = new UcDialog.DialogOption("old default", "same as iperl", () =>
{
var funkadresse = new List<byte>();
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());
@@ -79,7 +74,7 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
var optOneLiter = new UcDialog.DialogOption("new default", "new default key", () =>
{
var funkadresse = new List<byte>();
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());
@@ -158,12 +153,9 @@ namespace ProductionUiCordonel.ProductionProcesses.Actions
UserControl.SetDialogOptions(pulseOptionList);
}
public override async void StartProcess()
public override void StartProcess()
{
StepPulse();
}
}