GTB: - refactoring
This commit is contained in:
parent
bc63ced264
commit
4f04ed0f49
@ -34,7 +34,7 @@
|
||||
|
||||
|
||||
<appSettings>
|
||||
<add key="Mode" value="1" /> <!--1 = EOL ; 2 = Picking-->
|
||||
<add key="Mode" value="2" /> <!--1 = EOL ; 2 = Picking-->
|
||||
<!--add key="SirtComport433" value="14" /--> <!--Thomas 14; Roland ; Stoyan ; VFM1 9; VFM4 7-->
|
||||
<!--add key="SirtComport868" value="15" /--> <!--Thomas 15; Roland ; Stoyan ; VFM1 10; VFM4 8-->
|
||||
<!--add key="SirtBoxNr" value="2" /--> <!--Thomas 2; Roland 2; Stoyan 2; VFM1 1; VFM4 3-->
|
||||
|
||||
@ -1131,6 +1131,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
_meterFile = new MeterFile(_currentGenesis);
|
||||
}
|
||||
|
||||
LowLevelActionControl(true);
|
||||
_currentGenesis.ReLogin();
|
||||
var sbMSG = new StringBuilder();
|
||||
|
||||
@ -1159,9 +1160,13 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentGenesis.Logout();
|
||||
LowLevelActionControl(false);
|
||||
return false;
|
||||
}
|
||||
_currentGenesis.Logout();
|
||||
LowLevelActionControl(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
@ -1324,6 +1329,11 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
/// <remarks date="2022-Dec-20" author="Roland Drabesch">
|
||||
/// - Initial
|
||||
/// </remarks>
|
||||
/// <remarks date="2025-Oct-15" author="Thomas Wiedebusch">
|
||||
/// - WarnFromClamp from 20 to 22 years (based on CSD value with 365,00 days a year
|
||||
/// and not a more accurate 365,25 days/year),
|
||||
/// - StoreConfiguration.
|
||||
/// </remarks>
|
||||
private void btnFixBattery_Click(Object sender, EventArgs e)
|
||||
{
|
||||
if (_currentGenesis == null)
|
||||
@ -1347,12 +1357,15 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
SetActualProcessAndLog("Reset alarms in meter");
|
||||
_currentGenesis.ResetAlarm(Alarm.ALL);
|
||||
|
||||
SetActualProcessAndLog("Set project end time to meter");
|
||||
_currentGenesis.WriteRegister("POWERMON_WarnFromClamp", (UInt32)630720000); // 20 years in seconds
|
||||
SetActualProcessAndLog("Set meter lifetime before empty warning");
|
||||
_currentGenesis.WriteRegister("POWERMON_WarnFromClamp", (UInt32)693792000); // 22 years in seconds
|
||||
|
||||
SetActualProcessAndLog("Set meter battery quantity to 2");
|
||||
_currentGenesis.WriteRegister("POWERMON_BatteryQuantity", (UInt32)2);
|
||||
|
||||
SetActualProcessAndLog("Store settings");
|
||||
_currentGenesis.WriteRegister("POWERMON_StoreConfiguration", (UInt32)1);
|
||||
|
||||
SetActualProcessAndLog("Trigger idle to release function to normal operation");
|
||||
_currentGenesis.WriteRegister("GENESISFLOW_TriggerIdle", (UInt32)0);
|
||||
|
||||
|
||||
@ -20,8 +20,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
public partial class FrmQsTool : Form
|
||||
{
|
||||
private GenesisMeter _currentGenesis;
|
||||
private String _currentPcbId;
|
||||
private MeterBatch _meterBatch = new MeterBatch();
|
||||
private readonly MeterBatch _meterBatch;
|
||||
private readonly ILogger logger = NLogHelper.CreateOrGetLogger("GenesisConfigurator");
|
||||
|
||||
public FrmQsTool()
|
||||
@ -31,20 +30,21 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
_meterBatch = new MeterBatch();
|
||||
|
||||
var configfile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(Xylem.Common.Hardware.WaterMeter.Genesis), ProgramConfig.SerialConfigFileName);
|
||||
var configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
nameof(Hardware.WaterMeter.Genesis), ProgramConfig.SerialConfigFileName);
|
||||
|
||||
if (!File.Exists(configfile))
|
||||
if (!File.Exists(configFile))
|
||||
{
|
||||
throw new ApplicationException($"Configuration file {configfile} not found ");
|
||||
throw new ApplicationException($"Configuration file {configFile} not found ");
|
||||
}
|
||||
var tr = new StreamReader(configfile);
|
||||
var tr = new StreamReader(configFile);
|
||||
var meterConfigList = JsonConvert.DeserializeObject<SlotConfig[]>(tr.ReadToEnd());
|
||||
cbComSlot.Items.Clear();
|
||||
var listSlots = new List<Int32>();
|
||||
// var listSlots = new List<Int32>();
|
||||
foreach (var item in meterConfigList)
|
||||
{
|
||||
cbComSlot.Items.Add(item.Slot);
|
||||
listSlots.Add(item.Slot);
|
||||
//listSlots.Add(item.Slot);
|
||||
}
|
||||
if (cbComSlot.Items.Count >= 1)
|
||||
{
|
||||
@ -63,9 +63,6 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
{
|
||||
_currentGenesis.Logout();
|
||||
}
|
||||
|
||||
_currentPcbId = "";
|
||||
|
||||
}
|
||||
|
||||
private void btnConnect_Click(Object sender, EventArgs e)
|
||||
@ -76,7 +73,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
if (!string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) &&
|
||||
int.TryParse(cbComSlot.SelectedItem.ToString(), out slotNR))
|
||||
{
|
||||
conntect(slotNR);
|
||||
Connect(slotNR);
|
||||
|
||||
}
|
||||
}
|
||||
@ -388,13 +385,13 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
|
||||
|
||||
private void conntect(Int32 slotNR)
|
||||
private void Connect(Int32 slotNR)
|
||||
{
|
||||
try
|
||||
{
|
||||
_meterBatch.RemoveAllMeters();
|
||||
_currentGenesis = new GenesisMeter();
|
||||
btnSwichtPressure.Text = "Drucksensor";
|
||||
btnSwichtPressure.Text = @"Drucksensor";
|
||||
//_currentGenesis.IsDevelopmentUsage = true; //Make sure to set this before login
|
||||
try
|
||||
{
|
||||
@ -405,10 +402,9 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, $"Slot #{slotNR} failed: {ex.Message}");
|
||||
lblState.Text = "Failed";
|
||||
lblState.Text = @"Failed";
|
||||
}
|
||||
_currentGenesis.Login();
|
||||
_currentPcbId = _currentGenesis.PcbId;
|
||||
|
||||
if (_currentGenesis.IsLoggedOn)
|
||||
{
|
||||
@ -416,18 +412,18 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
var pressureReadOut = RegisterConverter.ByteArrayToValue<Boolean>(_currentGenesis.ReadRegister("METROLOGYASST_PressurePresent"));
|
||||
if (pressureReadOut)
|
||||
{
|
||||
btnSwichtPressure.Text = "Drucksensor ist vorhanden. Ändern?";
|
||||
btnSwichtPressure.Text = @"Drucksensor ist vorhanden. Ändern?";
|
||||
}
|
||||
else
|
||||
{
|
||||
btnSwichtPressure.Text = "Drucksensor ist NICHT vorhanden. Ändern?";
|
||||
btnSwichtPressure.Text = @"Drucksensor ist NICHT vorhanden. Ändern?";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
lblState.Text = "Failed";
|
||||
lblState.Text = @"Failed";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -229,6 +229,7 @@
|
||||
this.button1.TabIndex = 60;
|
||||
this.button1.Text = "Battery Idle";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
this.button1.Visible = false;
|
||||
this.button1.Click += new System.EventHandler(this.button1_Click_4);
|
||||
//
|
||||
// button2
|
||||
|
||||
@ -7,14 +7,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -30,12 +27,8 @@ using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisStatus;
|
||||
using Xylem.Common.Hardware.WaterMeter.Genesis.Registers;
|
||||
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
|
||||
using Xylem.Common.Logic.ProductionOrderCore.TestResults;
|
||||
using Xylem.Common.Logic.ServiceCore;
|
||||
using Xylem.Common.Logic.SoftwareAccessHelper;
|
||||
using Xylem.Common.Utils.Logging;
|
||||
using XylemCommonUiLegacyGenCtl;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using static Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.GenesisMeter;
|
||||
using Access = Xylem.Common.Hardware.WaterMeter.Genesis.Registers.Access;
|
||||
|
||||
namespace Xylem.Common.Ui.GenesisToolBox
|
||||
@ -103,8 +96,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
else
|
||||
{
|
||||
ProgreessTotal = null;
|
||||
ProgreessCurrent = null;
|
||||
ProgressTotal = null;
|
||||
ProgressCurrent = null;
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
pnlBussy.Visible = false;
|
||||
@ -115,27 +108,27 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
}
|
||||
|
||||
private void SetProgreess(String text, Int32 total = 0, Int32 current = 0)
|
||||
private void SetProgress(String text, Int32 total = 0, Int32 current = 0)
|
||||
{
|
||||
ProgreessTotal = total;
|
||||
ProgreessCurrent = current;
|
||||
Invoke(new Action(() => { lblProgress.Text = $"{text} ({current}/{total})"; }));
|
||||
ProgressTotal = total;
|
||||
ProgressCurrent = current;
|
||||
Invoke(new Action(() => { lblProgress.Text = $@"{text} ({current}/{total})"; }));
|
||||
}
|
||||
|
||||
private Int32? ProgreessTotal;
|
||||
private Int32? ProgreessCurrent;
|
||||
private Int32? ProgressTotal;
|
||||
private Int32? ProgressCurrent;
|
||||
|
||||
private void TimeProgress_tick(Object sender, EventArgs e)
|
||||
{
|
||||
if (IsBusy)
|
||||
{
|
||||
if (ProgreessTotal.HasValue && ProgreessCurrent.HasValue && !ProgreessTotal.Value.Equals(0) &&
|
||||
!ProgreessCurrent.Value.Equals(0))
|
||||
if (ProgressTotal.HasValue && ProgressCurrent.HasValue && !ProgressTotal.Value.Equals(0) &&
|
||||
!ProgressCurrent.Value.Equals(0))
|
||||
{
|
||||
try
|
||||
{
|
||||
probarBussy.Value =
|
||||
(Int32)Math.Round(((Double)ProgreessCurrent.Value / (Double)ProgreessTotal.Value) * 100,
|
||||
(Int32)Math.Round(((Double)ProgressCurrent.Value / (Double)ProgressTotal.Value) * 100,
|
||||
0);
|
||||
}
|
||||
catch (Exception exception)
|
||||
@ -162,11 +155,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
{
|
||||
if (cbComSlot.SelectedItem != null) // && cbComSlot.SelectedValue is ListBoxItem)
|
||||
{
|
||||
Int32 slotNR = 0;
|
||||
if (!string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) &&
|
||||
int.TryParse(cbComSlot.SelectedItem.ToString(), out slotNR))
|
||||
int.TryParse(cbComSlot.SelectedItem.ToString(), out var slotNR))
|
||||
{
|
||||
SetBusy(true, "Connect");
|
||||
//SetBusy(true, "Connect");
|
||||
if (Connect(slotNR))
|
||||
{
|
||||
Task.Factory.StartNew(() =>
|
||||
@ -284,19 +276,19 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
})
|
||||
|
||||
);
|
||||
SetBusy(false);
|
||||
//SetBusy(false);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
SetBusy(false);
|
||||
//SetBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnRead_Click(Object sender, EventArgs e)
|
||||
{
|
||||
SetBusy(true, "read Registers");
|
||||
SetBusy(true, "Read Registers");
|
||||
|
||||
String hex = "4F793AF100000002";
|
||||
UInt64 value = ulong.Parse(hex, System.Globalization.NumberStyles.HexNumber);
|
||||
@ -304,7 +296,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
Console.WriteLine(value);
|
||||
|
||||
|
||||
Task.Factory.StartNew(() => { read(); }).ContinueWith(delegate
|
||||
Task.Factory.StartNew(() => { ReadRegisters(); }).ContinueWith(delegate
|
||||
{
|
||||
SetBusy(false);
|
||||
});
|
||||
@ -424,10 +416,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
}
|
||||
|
||||
private void button1_Click(Object sender, EventArgs e)
|
||||
{
|
||||
_currentGenesis.Logout();
|
||||
}
|
||||
//private void button1_Click(Object sender, EventArgs e)
|
||||
//{
|
||||
// _currentGenesis.Logout();
|
||||
//}
|
||||
|
||||
private void frmRegisterStore_Load(Object sender, EventArgs e)
|
||||
{
|
||||
@ -479,8 +471,6 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
_meterBatch.AddMeter(_currentGenesis);
|
||||
_currentGenesis.Login();
|
||||
_currentPcbId = _currentGenesis.PcbId;
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -492,11 +482,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
_currentGenesis?.DisposeMeter();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void getPcbId(Int32 slotNR)
|
||||
private void GetPcbId(Int32 slotNR)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -521,7 +510,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
}
|
||||
|
||||
private void selectPreset(String content)
|
||||
private void SelectPreset(String content)
|
||||
{
|
||||
foreach (var rowItem in _dataTable.Rows)
|
||||
{
|
||||
@ -689,7 +678,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
}
|
||||
|
||||
private RegisterRestoreData read()
|
||||
private RegisterRestoreData ReadRegisters()
|
||||
{
|
||||
|
||||
regsToStore = new regStore()
|
||||
@ -726,7 +715,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
var meterRegisters = _currentGenesis.GetConfigRegistersDefinitions();
|
||||
var regDef = meterRegisters.GetRegisterDefinitionByName(reg);
|
||||
SetProgreess($"Read Register {regDef.RegisterName}", total, done + 1);
|
||||
SetProgress($"Read Register {regDef.RegisterName}", total, done + 1);
|
||||
if (regDef.RegisterDetail != null && (
|
||||
regDef.RegisterDetail.Privilege.Lvl8 == Access.RO ||
|
||||
regDef.RegisterDetail.Privilege.Lvl8 == Access.RW))
|
||||
@ -796,7 +785,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
|
||||
|
||||
SetProgreess($"Read File {filename}");
|
||||
SetProgress($"Read File {filename}");
|
||||
var text = File.ReadAllText(filename);
|
||||
var loadedRegStore = JsonConvert.DeserializeObject<regStore>(text);
|
||||
|
||||
@ -808,7 +797,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
if (rowItem is DataRow)
|
||||
{
|
||||
|
||||
SetProgreess($"Read file", loadedRegStore.keyValues.Count, done);
|
||||
SetProgress($"Read file", loadedRegStore.keyValues.Count, done);
|
||||
|
||||
var reg = ((DataRow)rowItem)["Name"].ToString();
|
||||
var meterRegisters = _currentGenesis.GetConfigRegistersDefinitions();
|
||||
@ -893,10 +882,10 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
}
|
||||
|
||||
private void showFile(String filename)
|
||||
private void ShowFile(String filename)
|
||||
{
|
||||
|
||||
SetProgreess($"Read File {filename}");
|
||||
SetProgress($"Read File {filename}");
|
||||
var text = File.ReadAllText(filename);
|
||||
var loadedRegStore = JsonConvert.DeserializeObject<regStore>(text);
|
||||
|
||||
@ -908,7 +897,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
if (rowItem is DataRow)
|
||||
{
|
||||
|
||||
SetProgreess($"Compare file", loadedRegStore.keyValues.Count, done);
|
||||
SetProgress($"Compare file", loadedRegStore.keyValues.Count, done);
|
||||
var regDef = (RegisterDefinition)((DataRow)rowItem)["regDef"];
|
||||
var keyValue =
|
||||
loadedRegStore.keyValues.FirstOrDefault(f => f.def.RegisterName.Equals(regDef.RegisterName));
|
||||
@ -987,7 +976,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
private void storeCsv()
|
||||
{
|
||||
read();
|
||||
ReadRegisters();
|
||||
|
||||
var csv = new StringBuilder();
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
@ -1105,18 +1094,17 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
{
|
||||
if (cbComSlot.SelectedItem != null) // && cbComSlot.SelectedValue is ListBoxItem)
|
||||
{
|
||||
Int32 slotNR = 0;
|
||||
_currentPcbId = "";
|
||||
if (!string.IsNullOrEmpty(cbComSlot.SelectedItem.ToString()) &&
|
||||
int.TryParse(cbComSlot.SelectedItem.ToString(), out slotNR))
|
||||
int.TryParse(cbComSlot.SelectedItem.ToString(), out var slotNR))
|
||||
{
|
||||
SetBusy(true, "GetPcbId");
|
||||
Task.Factory.StartNew(() => { getPcbId(slotNR); }).ContinueWith(delegate
|
||||
Task.Factory.StartNew(() => { GetPcbId(slotNR); }).ContinueWith(delegate
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
MessageBox.Show(_currentPcbId);
|
||||
SetBusy(false);
|
||||
MessageBox.Show(_currentPcbId);
|
||||
}));
|
||||
});
|
||||
|
||||
@ -1124,22 +1112,22 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
}
|
||||
}
|
||||
|
||||
private void button1_Click_1(Object sender, EventArgs e)
|
||||
{
|
||||
if (_currentGenesis != null)
|
||||
{
|
||||
_currentGenesis.ResetAlarm(Alarm.EMPTY_PIPE);
|
||||
}
|
||||
}
|
||||
//private void button1_Click_1(Object sender, EventArgs e)
|
||||
//{
|
||||
// if (_currentGenesis != null)
|
||||
// {
|
||||
// _currentGenesis.ResetAlarm(Alarm.EMPTY_PIPE);
|
||||
// }
|
||||
//}
|
||||
|
||||
private void button2_Click(Object sender, EventArgs e)
|
||||
{
|
||||
if (_currentGenesis != null)
|
||||
{
|
||||
MessageBox.Show(
|
||||
$@"Check alarm EMPTY_PIPE = {_currentGenesis.HasAlarms(Alarm.EMPTY_PIPE)}");
|
||||
}
|
||||
}
|
||||
//private void button2_Click(Object sender, EventArgs e)
|
||||
//{
|
||||
// if (_currentGenesis != null)
|
||||
// {
|
||||
// MessageBox.Show(
|
||||
// $@"Check alarm EMPTY_PIPE = {_currentGenesis.HasAlarms(Alarm.EMPTY_PIPE)}");
|
||||
// }
|
||||
//}
|
||||
|
||||
private void btnReadFwVersions_Click(Object sender, EventArgs e)
|
||||
{
|
||||
@ -1657,12 +1645,12 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
if (_preSelectReminder.Contains("None"))
|
||||
{
|
||||
_preSelectReminder = "All";
|
||||
selectPreset("All");
|
||||
SelectPreset("All");
|
||||
}
|
||||
else
|
||||
{
|
||||
_preSelectReminder = "None";
|
||||
selectPreset("None");
|
||||
SelectPreset("None");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1966,7 +1954,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
SetBusy(true, "GetPcbId");
|
||||
Task.Factory.StartNew((Action)(() =>
|
||||
{
|
||||
getPcbId(slotNR);
|
||||
GetPcbId(slotNR);
|
||||
|
||||
var str = LocalWebRequest.GetRequest($"{ServiceUrls.GenesisFinalCheckServiceUrl()}GetPossibleRadioLengths?CheckPcbId={_currentPcbId}", 15000);
|
||||
MessageBox.Show(str);
|
||||
@ -2859,8 +2847,8 @@ namespace Xylem.Common.Ui.GenesisToolBox
|
||||
|
||||
private void btnRegisterToFile_Click(Object sender, EventArgs e)
|
||||
{
|
||||
selectPreset("All");
|
||||
var j = read();
|
||||
SelectPreset("All");
|
||||
var j = ReadRegisters();
|
||||
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
|
||||
saveFileDialog1.Filter = "Register Back Up files (*.rbu)|*.rbu";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user