Add LUT management and merge#

This commit is contained in:
Roland Drabesch
2022-08-12 08:55:24 +02:00
8 changed files with 435 additions and 66 deletions
@@ -965,6 +965,29 @@ namespace Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile
// validate the file
return ValidateLutFile();
}
/// <summary>
/// Load file from memory
/// </summary>
/// <param name="Name">origin Name</param>
/// /// <param name="StreamData">list of bytes of the file strean</param>
/// <returns></returns>
/// <remarks date="2022-Feb-15" author="Thomas Wiedebusch">
/// - Initial
/// </remarks>
public Boolean LoadLutFromStream(String Name, List<Byte> StreamData )
{
LutFile = null;
LutFile = new MeterLutFile(Name)
{
BinData = StreamData
};
// validate the file
return ValidateLutFile();
}
#endregion
}
}
@@ -17,5 +17,11 @@ namespace Logic.ProductionToProductMapper.Cordonel
public string Version { get; set; }
public byte[] FileContent { get; set; }
public override string ToString()
{
return FileName;
}
}
}
@@ -252,11 +252,11 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
public async Task<HttpResponseMessage> GetLutFiles(int? Metersize = null, string Region = null, bool? ForProd = null)
{
return await Task.Run(() =>
try
{
try
{
return await Task.Run(() =>
{
using (var dataacces = new SqlDataAccess(GlobalConfig.connectionString.Value))
{
@@ -282,14 +282,15 @@ namespace Xylem.Common.Service.MeterProcessState.Controllers
return Request.CreateResponse(HttpStatusCode.OK, retDT);
}
}
catch (Exception ex)
{
throw new ApplicationException($"file was not uploaded {ex.Message}");
}
throw new ApplicationException("file was not uploaded");
});
}
catch (Exception ex)
{
throw new ApplicationException($"file was not uploaded {ex.Message}");
}
throw new ApplicationException("file was not uploaded");
}
@@ -1 +1 @@
f64d563def603c89cafafa61a3219ba97e1e344c
81d60b90addc793525740e9993e19bf6665bd401
+117 -8
View File
@@ -1,4 +1,6 @@
namespace Xylem.Common.Ui.GenesisToolBox
using Logic.ProductionToProductMapper.Cordonel;
namespace Xylem.Common.Ui.GenesisToolBox
{
partial class FrmLutManagement
{
@@ -45,12 +47,22 @@
this.btnOpenLutFile = new System.Windows.Forms.Button();
this.btnStore = new System.Windows.Forms.Button();
this.dgvLuts = new System.Windows.Forms.DataGridView();
this.cordonelMetrologyLutBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.btnLoad = new System.Windows.Forms.Button();
this.tbxVersion = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.tbxDataLengt = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.cordonelMetrologyLutBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.idDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.fileIdDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.fileNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.meterSizeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.regionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.fileCrcDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.currentVerionForProdDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.dataLengthDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.versionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.fileContentDataGridViewImageColumn = new System.Windows.Forms.DataGridViewImageColumn();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgvLuts)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cordonelMetrologyLutBindingSource)).BeginInit();
@@ -179,6 +191,17 @@
this.dgvLuts.AllowUserToDeleteRows = false;
this.dgvLuts.AutoGenerateColumns = false;
this.dgvLuts.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvLuts.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.idDataGridViewTextBoxColumn,
this.fileIdDataGridViewTextBoxColumn,
this.fileNameDataGridViewTextBoxColumn,
this.meterSizeDataGridViewTextBoxColumn,
this.regionDataGridViewTextBoxColumn,
this.fileCrcDataGridViewTextBoxColumn,
this.currentVerionForProdDataGridViewCheckBoxColumn,
this.dataLengthDataGridViewTextBoxColumn,
this.versionDataGridViewTextBoxColumn,
this.fileContentDataGridViewImageColumn});
this.dgvLuts.DataSource = this.cordonelMetrologyLutBindingSource;
this.dgvLuts.Location = new System.Drawing.Point(3, 378);
this.dgvLuts.Name = "dgvLuts";
@@ -231,6 +254,82 @@
this.label2.TabIndex = 62;
this.label2.Text = "Data Length";
//
// cordonelMetrologyLutBindingSource
//
this.cordonelMetrologyLutBindingSource.DataSource = typeof(CordonelMetrologyLut);
//
// idDataGridViewTextBoxColumn
//
this.idDataGridViewTextBoxColumn.DataPropertyName = "Id";
this.idDataGridViewTextBoxColumn.HeaderText = "Id";
this.idDataGridViewTextBoxColumn.Name = "idDataGridViewTextBoxColumn";
this.idDataGridViewTextBoxColumn.ReadOnly = true;
this.idDataGridViewTextBoxColumn.Visible = false;
//
// fileIdDataGridViewTextBoxColumn
//
this.fileIdDataGridViewTextBoxColumn.DataPropertyName = "FileId";
this.fileIdDataGridViewTextBoxColumn.HeaderText = "FileId";
this.fileIdDataGridViewTextBoxColumn.Name = "fileIdDataGridViewTextBoxColumn";
this.fileIdDataGridViewTextBoxColumn.ReadOnly = true;
//
// fileNameDataGridViewTextBoxColumn
//
this.fileNameDataGridViewTextBoxColumn.DataPropertyName = "FileName";
this.fileNameDataGridViewTextBoxColumn.HeaderText = "FileName";
this.fileNameDataGridViewTextBoxColumn.Name = "fileNameDataGridViewTextBoxColumn";
this.fileNameDataGridViewTextBoxColumn.ReadOnly = true;
//
// meterSizeDataGridViewTextBoxColumn
//
this.meterSizeDataGridViewTextBoxColumn.DataPropertyName = "MeterSize";
this.meterSizeDataGridViewTextBoxColumn.HeaderText = "MeterSize";
this.meterSizeDataGridViewTextBoxColumn.Name = "meterSizeDataGridViewTextBoxColumn";
this.meterSizeDataGridViewTextBoxColumn.ReadOnly = true;
//
// regionDataGridViewTextBoxColumn
//
this.regionDataGridViewTextBoxColumn.DataPropertyName = "Region";
this.regionDataGridViewTextBoxColumn.HeaderText = "Region";
this.regionDataGridViewTextBoxColumn.Name = "regionDataGridViewTextBoxColumn";
this.regionDataGridViewTextBoxColumn.ReadOnly = true;
//
// fileCrcDataGridViewTextBoxColumn
//
this.fileCrcDataGridViewTextBoxColumn.DataPropertyName = "FileCrc";
this.fileCrcDataGridViewTextBoxColumn.HeaderText = "FileCrc";
this.fileCrcDataGridViewTextBoxColumn.Name = "fileCrcDataGridViewTextBoxColumn";
this.fileCrcDataGridViewTextBoxColumn.ReadOnly = true;
//
// currentVerionForProdDataGridViewCheckBoxColumn
//
this.currentVerionForProdDataGridViewCheckBoxColumn.DataPropertyName = "CurrentVerionForProd";
this.currentVerionForProdDataGridViewCheckBoxColumn.HeaderText = "CurrentVerionForProd";
this.currentVerionForProdDataGridViewCheckBoxColumn.Name = "currentVerionForProdDataGridViewCheckBoxColumn";
this.currentVerionForProdDataGridViewCheckBoxColumn.ReadOnly = true;
//
// dataLengthDataGridViewTextBoxColumn
//
this.dataLengthDataGridViewTextBoxColumn.DataPropertyName = "DataLength";
this.dataLengthDataGridViewTextBoxColumn.HeaderText = "DataLength";
this.dataLengthDataGridViewTextBoxColumn.Name = "dataLengthDataGridViewTextBoxColumn";
this.dataLengthDataGridViewTextBoxColumn.ReadOnly = true;
//
// versionDataGridViewTextBoxColumn
//
this.versionDataGridViewTextBoxColumn.DataPropertyName = "Version";
this.versionDataGridViewTextBoxColumn.HeaderText = "Version";
this.versionDataGridViewTextBoxColumn.Name = "versionDataGridViewTextBoxColumn";
this.versionDataGridViewTextBoxColumn.ReadOnly = true;
//
// fileContentDataGridViewImageColumn
//
this.fileContentDataGridViewImageColumn.DataPropertyName = "FileContent";
this.fileContentDataGridViewImageColumn.HeaderText = "FileContent";
this.fileContentDataGridViewImageColumn.Name = "fileContentDataGridViewImageColumn";
this.fileContentDataGridViewImageColumn.ReadOnly = true;
this.fileContentDataGridViewImageColumn.Visible = false;
//
// FrmLutManagement
//
this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound;
@@ -292,21 +391,31 @@
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox tbxDataLengt;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.DataGridViewTextBoxColumn fileIdDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn fileNameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn meterSizeDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn regionDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn cRCDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewCheckBoxColumn forProductionDataGridViewCheckBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;
private System.Windows.Forms.DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn11;
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn12;
private System.Windows.Forms.DataGridViewImageColumn dataGridViewImageColumn1;
private System.Windows.Forms.DataGridViewTextBoxColumn idDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn fileIdDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn fileNameDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn meterSizeDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn regionDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn fileCrcDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewCheckBoxColumn currentVerionForProdDataGridViewCheckBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn dataLengthDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn versionDataGridViewTextBoxColumn;
private System.Windows.Forms.DataGridViewCheckBoxColumn currentVerionForProdDataGridViewCheckBoxColumn;
private System.Windows.Forms.DataGridViewImageColumn fileContentDataGridViewImageColumn;
private System.Windows.Forms.BindingSource cordonelMetrologyLutBindingSource;
}
+13 -9
View File
@@ -90,10 +90,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
public FrmLutManagement()
{
InitializeComponent();
//
// cordonelMetrologyLutBindingSource
//
this.cordonelMetrologyLutBindingSource.DataSource = typeof(CordonelMetrologyLut);
var cultureInfo = new CultureInfo("en-GB");
Thread.CurrentThread.CurrentUICulture = cultureInfo;
@@ -239,13 +236,20 @@ namespace Xylem.Common.Ui.GenesisToolBox
//sbUrl.Append($"&crc={_FileCrc}");
//sbUrl.Append($"&Metersize={_MeterSize.GetHashCode()}");
//sbUrl.Append($"&Region={_StrLutRegion}");
var ret = LocalWebRequest.GetRequest(sbUrl.ToString());
try
{
var ret = LocalWebRequest.GetRequest(sbUrl.ToString(), 80000);
var a = JsonConvert.DeserializeObject<List<CordonelMetrologyLut>>(ret);
dgvLuts.DataSource = a;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
var a = JsonConvert.DeserializeObject<List<CordonelMetrologyLut>>(ret);
dgvLuts.DataSource = a;
}
+132 -34
View File
@@ -56,17 +56,24 @@
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label4 = new System.Windows.Forms.Label();
this.rbtProd = new System.Windows.Forms.RadioButton();
this.cbxDbLuts = new System.Windows.Forms.ComboBox();
this.rbtDb = new System.Windows.Forms.RadioButton();
this.rbtFile = new System.Windows.Forms.RadioButton();
this.lblSelectDb = new System.Windows.Forms.Label();
this.tbxFileMeterSize = new System.Windows.Forms.TextBox();
this.tbxFileCrc = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.lblLutFileLoadedInfo = new System.Windows.Forms.Label();
this.tbxLutFilePathName = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.lvlSelechtFile = new System.Windows.Forms.Label();
this.btnOpenLutFile = new System.Windows.Forms.Button();
this.label9 = new System.Windows.Forms.Label();
this.lblUpdateTime = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.btnLoadfromDb = new System.Windows.Forms.Button();
this.grpSetup.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox1.SuspendLayout();
@@ -87,9 +94,9 @@
this.grpSetup.Controls.Add(this.lblConnectPcb);
this.grpSetup.Controls.Add(this.label2);
this.grpSetup.Controls.Add(this.cbComSlot);
this.grpSetup.Location = new System.Drawing.Point(12, 56);
this.grpSetup.Location = new System.Drawing.Point(12, 69);
this.grpSetup.Name = "grpSetup";
this.grpSetup.Size = new System.Drawing.Size(248, 212);
this.grpSetup.Size = new System.Drawing.Size(248, 250);
this.grpSetup.TabIndex = 24;
this.grpSetup.TabStop = false;
this.grpSetup.Text = "Cordonel";
@@ -233,7 +240,7 @@
//
this.lblWaitingForMeterResponse.AutoSize = true;
this.lblWaitingForMeterResponse.ForeColor = System.Drawing.Color.Red;
this.lblWaitingForMeterResponse.Location = new System.Drawing.Point(532, 280);
this.lblWaitingForMeterResponse.Location = new System.Drawing.Point(529, 331);
this.lblWaitingForMeterResponse.Name = "lblWaitingForMeterResponse";
this.lblWaitingForMeterResponse.Size = new System.Drawing.Size(182, 13);
this.lblWaitingForMeterResponse.TabIndex = 18;
@@ -241,7 +248,7 @@
//
// btnStopFwUpdate
//
this.btnStopFwUpdate.Location = new System.Drawing.Point(310, 181);
this.btnStopFwUpdate.Location = new System.Drawing.Point(310, 219);
this.btnStopFwUpdate.Name = "btnStopFwUpdate";
this.btnStopFwUpdate.Size = new System.Drawing.Size(116, 25);
this.btnStopFwUpdate.TabIndex = 8;
@@ -251,7 +258,7 @@
//
// btnDownloadLutFile
//
this.btnDownloadLutFile.Location = new System.Drawing.Point(310, 147);
this.btnDownloadLutFile.Location = new System.Drawing.Point(310, 188);
this.btnDownloadLutFile.Name = "btnDownloadLutFile";
this.btnDownloadLutFile.Size = new System.Drawing.Size(116, 25);
this.btnDownloadLutFile.TabIndex = 0;
@@ -262,7 +269,7 @@
// lblOverall
//
this.lblOverall.AutoSize = true;
this.lblOverall.Location = new System.Drawing.Point(21, 317);
this.lblOverall.Location = new System.Drawing.Point(18, 368);
this.lblOverall.Name = "lblOverall";
this.lblOverall.Size = new System.Drawing.Size(80, 13);
this.lblOverall.TabIndex = 7;
@@ -270,7 +277,7 @@
//
// barSingleProgressUpdate
//
this.barSingleProgressUpdate.Location = new System.Drawing.Point(12, 296);
this.barSingleProgressUpdate.Location = new System.Drawing.Point(9, 347);
this.barSingleProgressUpdate.Name = "barSingleProgressUpdate";
this.barSingleProgressUpdate.Size = new System.Drawing.Size(702, 18);
this.barSingleProgressUpdate.TabIndex = 6;
@@ -279,7 +286,7 @@
// lblActualProcess
//
this.lblActualProcess.AutoSize = true;
this.lblActualProcess.Location = new System.Drawing.Point(21, 280);
this.lblActualProcess.Location = new System.Drawing.Point(18, 331);
this.lblActualProcess.Name = "lblActualProcess";
this.lblActualProcess.Size = new System.Drawing.Size(76, 13);
this.lblActualProcess.TabIndex = 4;
@@ -287,7 +294,7 @@
//
// barOverallProgressUpdate
//
this.barOverallProgressUpdate.Location = new System.Drawing.Point(12, 333);
this.barOverallProgressUpdate.Location = new System.Drawing.Point(9, 384);
this.barOverallProgressUpdate.Name = "barOverallProgressUpdate";
this.barOverallProgressUpdate.Size = new System.Drawing.Size(702, 18);
this.barOverallProgressUpdate.TabIndex = 3;
@@ -315,7 +322,7 @@
// pictureBox1
//
this.pictureBox1.Image = global::Xylem.Common.Ui.GenesisToolBox.Properties.Resources.SensusLogoXylem;
this.pictureBox1.Location = new System.Drawing.Point(611, 3);
this.pictureBox1.Location = new System.Drawing.Point(609, 9);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(102, 54);
this.pictureBox1.TabIndex = 29;
@@ -327,6 +334,13 @@
//
// groupBox1
//
this.groupBox1.Controls.Add(this.btnLoadfromDb);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.rbtProd);
this.groupBox1.Controls.Add(this.cbxDbLuts);
this.groupBox1.Controls.Add(this.rbtDb);
this.groupBox1.Controls.Add(this.rbtFile);
this.groupBox1.Controls.Add(this.lblSelectDb);
this.groupBox1.Controls.Add(this.tbxFileMeterSize);
this.groupBox1.Controls.Add(this.tbxFileCrc);
this.groupBox1.Controls.Add(this.label3);
@@ -334,19 +348,84 @@
this.groupBox1.Controls.Add(this.lblLutFileLoadedInfo);
this.groupBox1.Controls.Add(this.btnDownloadLutFile);
this.groupBox1.Controls.Add(this.tbxLutFilePathName);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.lvlSelechtFile);
this.groupBox1.Controls.Add(this.btnStopFwUpdate);
this.groupBox1.Controls.Add(this.btnOpenLutFile);
this.groupBox1.Location = new System.Drawing.Point(278, 56);
this.groupBox1.Location = new System.Drawing.Point(275, 69);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(436, 212);
this.groupBox1.Size = new System.Drawing.Size(436, 250);
this.groupBox1.TabIndex = 28;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Lookup Table File";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(12, 28);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(68, 13);
this.label4.TabIndex = 19;
this.label4.Text = "LUT Source:";
//
// rbtProd
//
this.rbtProd.AutoSize = true;
this.rbtProd.Location = new System.Drawing.Point(270, 24);
this.rbtProd.Name = "rbtProd";
this.rbtProd.Size = new System.Drawing.Size(96, 17);
this.rbtProd.TabIndex = 18;
this.rbtProd.TabStop = true;
this.rbtProd.Text = "Prod Database";
this.rbtProd.UseVisualStyleBackColor = true;
this.rbtProd.Click += new System.EventHandler(this.SwitchView);
//
// cbxDbLuts
//
this.cbxDbLuts.FormattingEnabled = true;
this.cbxDbLuts.Location = new System.Drawing.Point(82, 53);
this.cbxDbLuts.Name = "cbxDbLuts";
this.cbxDbLuts.Size = new System.Drawing.Size(333, 21);
this.cbxDbLuts.TabIndex = 17;
this.cbxDbLuts.Visible = false;
this.cbxDbLuts.SelectedIndexChanged += new System.EventHandler(this.cbxDbLuts_SelectedIndexChanged);
//
// rbtDb
//
this.rbtDb.AutoSize = true;
this.rbtDb.Location = new System.Drawing.Point(150, 24);
this.rbtDb.Name = "rbtDb";
this.rbtDb.Size = new System.Drawing.Size(120, 17);
this.rbtDb.TabIndex = 16;
this.rbtDb.TabStop = true;
this.rbtDb.Text = "Research Database";
this.rbtDb.UseVisualStyleBackColor = true;
this.rbtDb.Click += new System.EventHandler(this.SwitchView);
//
// rbtFile
//
this.rbtFile.AutoSize = true;
this.rbtFile.Location = new System.Drawing.Point(103, 24);
this.rbtFile.Name = "rbtFile";
this.rbtFile.Size = new System.Drawing.Size(41, 17);
this.rbtFile.TabIndex = 15;
this.rbtFile.TabStop = true;
this.rbtFile.Text = "File";
this.rbtFile.UseVisualStyleBackColor = true;
this.rbtFile.Click += new System.EventHandler(this.SwitchView);
//
// lblSelectDb
//
this.lblSelectDb.AutoSize = true;
this.lblSelectDb.Location = new System.Drawing.Point(12, 58);
this.lblSelectDb.Name = "lblSelectDb";
this.lblSelectDb.Size = new System.Drawing.Size(64, 13);
this.lblSelectDb.TabIndex = 14;
this.lblSelectDb.Text = "Select LUT:";
this.lblSelectDb.Visible = false;
//
// tbxFileMeterSize
//
this.tbxFileMeterSize.Location = new System.Drawing.Point(104, 148);
this.tbxFileMeterSize.Location = new System.Drawing.Point(104, 223);
this.tbxFileMeterSize.Name = "tbxFileMeterSize";
this.tbxFileMeterSize.ReadOnly = true;
this.tbxFileMeterSize.Size = new System.Drawing.Size(68, 20);
@@ -354,7 +433,7 @@
//
// tbxFileCrc
//
this.tbxFileCrc.Location = new System.Drawing.Point(104, 118);
this.tbxFileCrc.Location = new System.Drawing.Point(104, 193);
this.tbxFileCrc.Name = "tbxFileCrc";
this.tbxFileCrc.ReadOnly = true;
this.tbxFileCrc.Size = new System.Drawing.Size(68, 20);
@@ -363,7 +442,7 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(10, 152);
this.label3.Location = new System.Drawing.Point(10, 227);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(79, 13);
this.label3.TabIndex = 11;
@@ -372,7 +451,7 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(10, 122);
this.label1.Location = new System.Drawing.Point(10, 197);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(75, 13);
this.label1.TabIndex = 10;
@@ -381,7 +460,7 @@
// lblLutFileLoadedInfo
//
this.lblLutFileLoadedInfo.AutoSize = true;
this.lblLutFileLoadedInfo.Location = new System.Drawing.Point(10, 60);
this.lblLutFileLoadedInfo.Location = new System.Drawing.Point(6, 107);
this.lblLutFileLoadedInfo.Name = "lblLutFileLoadedInfo";
this.lblLutFileLoadedInfo.Size = new System.Drawing.Size(97, 13);
this.lblLutFileLoadedInfo.TabIndex = 9;
@@ -389,24 +468,26 @@
//
// tbxLutFilePathName
//
this.tbxLutFilePathName.Location = new System.Drawing.Point(104, 27);
this.tbxLutFilePathName.Location = new System.Drawing.Point(82, 76);
this.tbxLutFilePathName.Name = "tbxLutFilePathName";
this.tbxLutFilePathName.ReadOnly = true;
this.tbxLutFilePathName.Size = new System.Drawing.Size(322, 20);
this.tbxLutFilePathName.Size = new System.Drawing.Size(333, 20);
this.tbxLutFilePathName.TabIndex = 2;
this.tbxLutFilePathName.Visible = false;
//
// label4
// lvlSelechtFile
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(10, 30);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(63, 13);
this.label4.TabIndex = 1;
this.label4.Text = "Path Name:";
this.lvlSelechtFile.AutoSize = true;
this.lvlSelechtFile.Location = new System.Drawing.Point(10, 79);
this.lvlSelechtFile.Name = "lvlSelechtFile";
this.lvlSelechtFile.Size = new System.Drawing.Size(63, 13);
this.lvlSelechtFile.TabIndex = 1;
this.lvlSelechtFile.Text = "Path Name:";
this.lvlSelechtFile.Visible = false;
//
// btnOpenLutFile
//
this.btnOpenLutFile.Location = new System.Drawing.Point(310, 112);
this.btnOpenLutFile.Location = new System.Drawing.Point(310, 156);
this.btnOpenLutFile.Name = "btnOpenLutFile";
this.btnOpenLutFile.Size = new System.Drawing.Size(116, 26);
this.btnOpenLutFile.TabIndex = 0;
@@ -417,7 +498,7 @@
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(250, 280);
this.label9.Location = new System.Drawing.Point(247, 331);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(101, 13);
this.label9.TabIndex = 30;
@@ -426,7 +507,7 @@
// lblUpdateTime
//
this.lblUpdateTime.AutoSize = true;
this.lblUpdateTime.Location = new System.Drawing.Point(357, 280);
this.lblUpdateTime.Location = new System.Drawing.Point(354, 331);
this.lblUpdateTime.Name = "lblUpdateTime";
this.lblUpdateTime.Size = new System.Drawing.Size(28, 13);
this.lblUpdateTime.TabIndex = 31;
@@ -442,12 +523,22 @@
this.label7.TabIndex = 32;
this.label7.Text = "Cordonel LUT Update";
//
// btnLoadfromDb
//
this.btnLoadfromDb.Location = new System.Drawing.Point(310, 124);
this.btnLoadfromDb.Name = "btnLoadfromDb";
this.btnLoadfromDb.Size = new System.Drawing.Size(116, 26);
this.btnLoadfromDb.TabIndex = 20;
this.btnLoadfromDb.Text = "Load from Db";
this.btnLoadfromDb.UseVisualStyleBackColor = true;
this.btnLoadfromDb.Click += new System.EventHandler(this.btnLoadfromDb_Click);
//
// FrmLutUpdate
//
this.AccessibleRole = System.Windows.Forms.AccessibleRole.Sound;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(723, 366);
this.ClientSize = new System.Drawing.Size(723, 461);
this.Controls.Add(this.label7);
this.Controls.Add(this.lblUpdateTime);
this.Controls.Add(this.label9);
@@ -461,7 +552,7 @@
this.Controls.Add(this.grpSetup);
this.Controls.Add(this.barOverallProgressUpdate);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(739, 405);
this.MaximumSize = new System.Drawing.Size(739, 500);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(739, 405);
this.Name = "FrmLutUpdate";
@@ -500,7 +591,7 @@
private System.Windows.Forms.Label lblFwVersion;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox tbxLutFilePathName;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label lvlSelechtFile;
private System.Windows.Forms.Button btnOpenLutFile;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label lblUpdateTime;
@@ -518,5 +609,12 @@
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox tbxRegionRadio;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label lblSelectDb;
private System.Windows.Forms.RadioButton rbtDb;
private System.Windows.Forms.RadioButton rbtFile;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.RadioButton rbtProd;
private System.Windows.Forms.ComboBox cbxDbLuts;
private System.Windows.Forms.Button btnLoadfromDb;
}
}
+132 -4
View File
@@ -1,14 +1,19 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Logic.ProductionToProductMapper.Cordonel;
using Newtonsoft.Json;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore;
using Xylem.Common.Hardware.WaterMeter.Genesis.GenesisFile;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using Xylem.Common.Logic.SoftwareAccessHelper;
using Xylem.Common.Utils.ProcessExec.EventArguments;
@@ -158,7 +163,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
btnStopFwUpdate.Enabled = false;
}
#endregion
#region BoardControls
private void Connect()
{
@@ -463,7 +468,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
}));
}
#endregion
#region Checks
private void CheckUpdateEnabled()
{
@@ -589,7 +594,7 @@ namespace Xylem.Common.Ui.GenesisToolBox
LogText("File Meter Size: " + tbxFileMeterSize.Text);
LogText("File LUT CRC: " + tbxFileCrc.Text);
LogText(StrSeparator);
}
else
{
@@ -681,6 +686,129 @@ namespace Xylem.Common.Ui.GenesisToolBox
}
#endregion
private void SwitchView(object sender, EventArgs e)
{
btnLoadfromDb.Enabled = false;
bool File = rbtFile.Checked;
cbxDbLuts.Visible = !File;
lblSelectDb.Visible = !File;
btnLoadfromDb.Visible = !File;
lvlSelechtFile.Visible = File;
tbxLutFilePathName.Visible = File;
btnOpenLutFile.Visible = File;
if (!File)
{
LoadDbLuts(rbtProd.Checked);
}
}
private void LoadDbLuts(bool Prod)
{
StringBuilder sbUrl = new StringBuilder();
// sbUrl.Append("http://10.49.40.25/MeterProcessState/api/FileUpToDate/GetLutFiles");
sbUrl.Append("http://localhost:56011/api/FileUpToDate/GetLutFiles");
//sbUrl.Append($"?DataLength={_DataLength}");
//sbUrl.Append($"&version={_Version}");
//sbUrl.Append($"&crc={_FileCrc}");
//sbUrl.Append($"&Metersize={_MeterSize.GetHashCode()}");
//sbUrl.Append($"&Region={_StrLutRegion}");
try
{
var ret = LocalWebRequest.GetRequest(sbUrl.ToString(), 80000);
var a = JsonConvert.DeserializeObject<List<CordonelMetrologyLut>>(ret);
cbxDbLuts.Items.Clear();
foreach (var item in a)
{
if (!Prod || item.CurrentVerionForProd)
{
cbxDbLuts.Items.Add(item);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void cbxDbLuts_SelectedIndexChanged(object sender, EventArgs e)
{
if (cbxDbLuts.SelectedItem is CordonelMetrologyLut lut)
{
btnLoadfromDb.Enabled = true;
}
else
{
btnLoadfromDb.Enabled = false;
}
}
private void btnLoadfromDb_Click(object sender, EventArgs e)
{
if (cbxDbLuts.SelectedItem is CordonelMetrologyLut lut)
{
lblLutFileLoadedInfo.Text = "";
tbxLutFilePathName.Text = $"fromDB{lut.FileName}";
if (_meterLutUpdate == null)
{
_meterLutUpdate = new MeterLutUpdate(_currentGenesis);
_meterLutUpdate.OnProcessUpdate += ProcessUpdate_Event;
}
if (_meterLutUpdate == null)
{
return;
}
if (_meterLutUpdate.LoadLutFromStream(lut.FileName, lut.FileContent.ToList()))
{
lblLutFileLoadedInfo.ForeColor = Color.Green;
lblLutFileLoadedInfo.Text = StrLutFileValid;
tbxFileCrc.Text = $@"0x{_meterLutUpdate.LutFile.FileCrc:X4}";
tbxFileMeterSize.Text = MeterSizeConverter.ConvertMeterSizeEnumToSizeName(_meterLutUpdate.LutFile.MeterSize);
_lutFileValid = true;
LogText("File Meter Size: " + tbxFileMeterSize.Text);
LogText("File LUT CRC: " + tbxFileCrc.Text);
LogText(StrSeparator);
}
else
{
var txt = "";
if (!string.IsNullOrEmpty(_meterLutUpdate?.ErrorMessage))
{
txt += _meterLutUpdate?.ErrorMessage;
}
else
{
txt = StrLutFileInvalid;
}
LogErrorText(txt);
lblLutFileLoadedInfo.ForeColor = Color.Red;
lblLutFileLoadedInfo.Text = txt;
tbxFileCrc.Text = @" --- ";
tbxFileMeterSize.Text = @" --- ";
_lutFileValid = false;
}
CheckUpdateEnabled();
_resetTimeMeasurement = true;
}
}
}
}
}