2015-08-01 20:21:43 +00:00
|
|
|
|
///
|
|
|
|
|
|
/// Copyright (c) 2015 Sensus Metering Systems
|
|
|
|
|
|
/// Author: Milan Hanajík
|
|
|
|
|
|
///
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using log4net;
|
|
|
|
|
|
using TBF.BenchControl.Generic;
|
|
|
|
|
|
using TBF.Resources;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBF.BenchControl.BenchInfo.Polska
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class ComponentCfgCtrl : UserControl, IComponentCfgCtrl
|
|
|
|
|
|
{
|
|
|
|
|
|
static readonly ILog log = LogManager.GetLogger(typeof(ComponentCfgCtrl));
|
|
|
|
|
|
|
|
|
|
|
|
public bool ShowMore { get { return false; } }
|
|
|
|
|
|
|
|
|
|
|
|
ComponentCfg config;
|
|
|
|
|
|
public IComponentCfg Config
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return config as IComponentCfg; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
config = value as ComponentCfg;
|
|
|
|
|
|
Redraw();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ComponentCfgCtrl()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
nameLabel.Text = Strings.Name;
|
2016-01-02 16:53:57 +00:00
|
|
|
|
benchNameLabel.Text = Strings.Test_bench_name;
|
2015-08-01 20:21:43 +00:00
|
|
|
|
benchIdLabel.Text = Strings.Test_bench_number;
|
|
|
|
|
|
|
|
|
|
|
|
address1Label.Text = Strings.Address + " 1";
|
|
|
|
|
|
address2Label.Text = Strings.Address + " 2";
|
|
|
|
|
|
address3Label.Text = Strings.Address + " 3";
|
|
|
|
|
|
address4Label.Text = Strings.Address + " 4";
|
|
|
|
|
|
address5Label.Text = Strings.Address + " 5";
|
|
|
|
|
|
|
|
|
|
|
|
approvalIdLabel.Text = Strings.Approval_ID;
|
|
|
|
|
|
approvalDateLabel.Text = Strings.Approval_date;
|
|
|
|
|
|
approvedByLabel.Text = Strings.Approved_by;
|
|
|
|
|
|
Redraw();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Closing()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Redraw()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (config == null) return; /// Control was not loaded, settings were not changed
|
2016-01-02 16:53:57 +00:00
|
|
|
|
|
2015-08-01 20:21:43 +00:00
|
|
|
|
classNameLabel.Text = config.Factory.ClassName;
|
|
|
|
|
|
nameTextBox.Text = config.Name;
|
2016-01-02 16:53:57 +00:00
|
|
|
|
benchNameTextBox.Text = config.TestBenchName;
|
|
|
|
|
|
benchIdTextBox.Text = config.TestBenchId.ToString();
|
2015-08-01 20:21:43 +00:00
|
|
|
|
|
|
|
|
|
|
address1TextBox.Text = config.Address1;
|
|
|
|
|
|
address2TextBox.Text = config.Address2;
|
|
|
|
|
|
address3TextBox.Text = config.Address3;
|
|
|
|
|
|
address4TextBox.Text = config.Address4;
|
|
|
|
|
|
address5TextBox.Text = config.Address5;
|
|
|
|
|
|
|
|
|
|
|
|
approvalIdTextBox.Text = config.ApprovalId;
|
|
|
|
|
|
approvalDateTextBox.Text = config.ApprovalDate;
|
|
|
|
|
|
approvedByTextBox.Text = config.ApprovedBy;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Unlock()
|
|
|
|
|
|
{
|
|
|
|
|
|
nameTextBox.Enabled = true;
|
2016-01-02 16:53:57 +00:00
|
|
|
|
benchNameTextBox.Enabled = true;
|
2015-08-01 20:21:43 +00:00
|
|
|
|
benchIdTextBox.Enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
address1TextBox.Enabled = true;
|
|
|
|
|
|
address2TextBox.Enabled = true;
|
|
|
|
|
|
address3TextBox.Enabled = true;
|
|
|
|
|
|
address4TextBox.Enabled = true;
|
|
|
|
|
|
address5TextBox.Enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
approvalIdTextBox.Enabled = true;
|
|
|
|
|
|
approvalDateTextBox.Enabled = true;
|
|
|
|
|
|
approvedByTextBox.Enabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CfgUpdateFlags VerifyCfg(ref string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
2016-01-02 16:53:57 +00:00
|
|
|
|
|
|
|
|
|
|
int dummy;
|
|
|
|
|
|
if (!int.TryParse(benchIdTextBox.Text, out dummy) || dummy < 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
flags = CfgUpdateFlags.Error;
|
|
|
|
|
|
message = string.Format("Invalid {0} parameter", Strings.Test_bench_number);
|
|
|
|
|
|
}
|
2015-08-01 20:21:43 +00:00
|
|
|
|
return flags;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CfgUpdateFlags UpdateCfg()
|
|
|
|
|
|
{
|
|
|
|
|
|
CfgUpdateFlags flags = CfgUpdateFlags.RestartRqrd;
|
|
|
|
|
|
|
|
|
|
|
|
if (config == null) return CfgUpdateFlags.Error; /// Control was not loaded, settings were not changed
|
|
|
|
|
|
///
|
|
|
|
|
|
config.Name = nameTextBox.Text;
|
2016-01-02 16:53:57 +00:00
|
|
|
|
config.TestBenchName = benchNameTextBox.Text;
|
|
|
|
|
|
config.TestBenchId = int.Parse(benchIdTextBox.Text);
|
2015-08-01 20:21:43 +00:00
|
|
|
|
|
|
|
|
|
|
config.Address1 = address1TextBox.Text;
|
|
|
|
|
|
config.Address2 = address2TextBox.Text;
|
|
|
|
|
|
config.Address3 = address3TextBox.Text;
|
|
|
|
|
|
config.Address4 = address4TextBox.Text;
|
|
|
|
|
|
config.Address5 = address5TextBox.Text;
|
|
|
|
|
|
|
|
|
|
|
|
config.ApprovalId = approvalIdTextBox.Text;
|
|
|
|
|
|
config.ApprovalDate = approvalDateTextBox.Text;
|
|
|
|
|
|
config.ApprovedBy = approvedByTextBox.Text;
|
|
|
|
|
|
|
|
|
|
|
|
return flags;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|