TBF : KPackE.Radio, KPackE.DataEntryForRadio, KPackE.RegisterReader and IReceivesDataFromRadio added, ver. 2.18.1115
This commit is contained in:
parent
1eebb3b4a1
commit
772cfc8e29
12
TBF/BenchControl/GenericDevices/IReceivesDataFromRadio.cs
Normal file
12
TBF/BenchControl/GenericDevices/IReceivesDataFromRadio.cs
Normal file
@ -0,0 +1,12 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
|
||||
namespace TBF.BenchControl.GenericDevices
|
||||
{
|
||||
public interface IReceivesDataFromRadio
|
||||
{
|
||||
void WMStateReceived(string serialNr, double wmState);
|
||||
}
|
||||
}
|
||||
1489
TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/CycleBeginningForm.Designer.cs
generated
Normal file
1489
TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/CycleBeginningForm.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,739 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.DataEntryForRadio
|
||||
{
|
||||
public partial class CycleBeginningForm : Form, GenericDevices.IHasCompleted
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(CycleBeginningForm));
|
||||
|
||||
/// <summary> Number of water meters </summary>
|
||||
public readonly int WaterMetersCount;
|
||||
|
||||
/// To be retrieved after the form is closed
|
||||
public string PurchaseOrder;
|
||||
public string[] SNText;
|
||||
public bool[] Disabled;
|
||||
|
||||
/// Set to 'true' when the form closes
|
||||
public bool Completed { get { return completed; } }
|
||||
bool completed;
|
||||
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
int textBoxesCount;
|
||||
Label[] labels;
|
||||
ComboBox[] comboBoxes;
|
||||
CheckBox[] checkBoxes;
|
||||
IList<ComboBox> enabledComboBoxes;
|
||||
|
||||
|
||||
/// <summary> Parameterless constructor for common functionality </summary>
|
||||
public CycleBeginningForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
ControlBox = false;
|
||||
|
||||
textBoxesCount = 48;
|
||||
labels = new Label[]
|
||||
{
|
||||
label1, label2, label3, label4, label5, label6, label7, label8, label9, label10,
|
||||
label11, label12, label13, label14, label15, label16, label17, label18, label19, label20,
|
||||
label21, label22, label23, label24, label25, label26, label27, label28, label29, label30,
|
||||
label31, label32, label33, label34, label35, label36, label37, label38, label39, label40,
|
||||
label41, label42, label43, label44, label45, label46, label47, label48,
|
||||
};
|
||||
comboBoxes = new ComboBox[]
|
||||
{
|
||||
comboBox1, comboBox2, comboBox3, comboBox4, comboBox5, comboBox6, comboBox7, comboBox8, comboBox9, comboBox10,
|
||||
comboBox11, comboBox12, comboBox13, comboBox14, comboBox15, comboBox16, comboBox17, comboBox18, comboBox19, comboBox20,
|
||||
comboBox21, comboBox22, comboBox23, comboBox24, comboBox25, comboBox26, comboBox27, comboBox28, comboBox29, comboBox30,
|
||||
comboBox31, comboBox32, comboBox33, comboBox34, comboBox35, comboBox36, comboBox37, comboBox38, comboBox39, comboBox40,
|
||||
comboBox41, comboBox42, comboBox43, comboBox44, comboBox45, comboBox46, comboBox47, comboBox48,
|
||||
};
|
||||
checkBoxes = new CheckBox[]
|
||||
{
|
||||
checkBox1, checkBox2, checkBox3, checkBox4, checkBox5, checkBox6, checkBox7, checkBox8, checkBox9, checkBox10,
|
||||
checkBox11, checkBox12, checkBox13, checkBox14, checkBox15, checkBox16, checkBox17, checkBox18, checkBox19, checkBox20,
|
||||
checkBox21, checkBox22, checkBox23, checkBox24, checkBox25, checkBox26, checkBox27, checkBox28, checkBox29, checkBox30,
|
||||
checkBox31, checkBox32, checkBox33, checkBox34, checkBox35, checkBox36, checkBox37, checkBox38, checkBox39, checkBox40,
|
||||
checkBox41, checkBox42, checkBox43, checkBox44, checkBox45, checkBox46, checkBox47, checkBox48,
|
||||
};
|
||||
enabledComboBoxes = new List<ComboBox>();
|
||||
|
||||
completed = false;
|
||||
StartForceCloseHandler();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="waterMetersCount">Number of text boxes for serial numbers</param>
|
||||
public CycleBeginningForm(int waterMetersCount)
|
||||
: this()
|
||||
{
|
||||
this.WaterMetersCount = waterMetersCount;
|
||||
SNText = new string[WaterMetersCount];
|
||||
Disabled = new bool[WaterMetersCount];
|
||||
|
||||
ShuffleTextBoxes(Config.Data.WMsCount, Config.Data.LineSize);
|
||||
|
||||
//Height = 147 + WaterMetersCount * 90;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make sure the layout of labels/text boxes on the screen
|
||||
/// corresponds to the layout of watermeters of the test bench.
|
||||
/// </summary>
|
||||
/// <param name="wmsCount">Number of watermeters</param>
|
||||
/// <param name="lineSize">Number of watermeters in one line</param>
|
||||
void ShuffleTextBoxes(int wmsCount, int lineSize)
|
||||
{
|
||||
if (wmsCount < textBoxesCount && lineSize > 0)
|
||||
{
|
||||
int nrLines = (wmsCount + lineSize - 1) / lineSize;
|
||||
int gap = (textBoxesCount - wmsCount) / nrLines;
|
||||
|
||||
int dest = 0;
|
||||
for (int l = 0; l < nrLines; l++)
|
||||
{
|
||||
for (int i = 0; i < lineSize; i++)
|
||||
{
|
||||
labels[dest] = labels[l * lineSize + l * gap + i];
|
||||
comboBoxes[dest] = comboBoxes[l * lineSize + l * gap + i];
|
||||
checkBoxes[dest] = checkBoxes[l * lineSize + l * gap + i];
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
textBoxesCount = wmsCount;
|
||||
}
|
||||
}
|
||||
|
||||
private void CycleBeginningForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
Localize();
|
||||
|
||||
PrepareOrderCombo(orderComboBox);
|
||||
|
||||
for (int i = 0; i < textBoxesCount; i++)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == textBoxesCount)
|
||||
{
|
||||
comboBoxes[i].Items.Add((Program.LocalSettings.LastSNTexts[i] == null) ? string.Empty : Program.LocalSettings.LastSNTexts[i]);
|
||||
}
|
||||
labels[i].Visible = comboBoxes[i].Visible = checkBoxes[i].Visible = true;
|
||||
enabledComboBoxes.Add(comboBoxes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Localize()
|
||||
{
|
||||
Text = Strings.Data;
|
||||
orderGroupBox.Text = Strings.Purchase_order;
|
||||
for (int i = 0; i < textBoxesCount; i++)
|
||||
{
|
||||
labels[i].Text = Strings.Serial_Number + " " + (i + 1).ToString();
|
||||
}
|
||||
okButton.Text = Strings.OkBtnText;
|
||||
clearButton.Text = Strings.ClearBtnText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load Purchase order combo box items from the LocalSettings PurchaseOrderHistory array
|
||||
/// </summary>
|
||||
/// <param name="orderComboBox">Puchase order ComboBox</param>
|
||||
void PrepareOrderCombo(ComboBox orderComboBox)
|
||||
{
|
||||
for (int i = 0; i < Program.LocalSettings.PurchaseOrderHistoryCount; i++)
|
||||
{
|
||||
orderComboBox.Items.Add(Program.LocalSettings.PurchaseOrderHistory[i]);
|
||||
}
|
||||
|
||||
if (orderComboBox.Items.Count > 0)
|
||||
{
|
||||
orderComboBox.Text = orderComboBox.Items[0].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
PurchaseOrder = orderComboBox.Text;
|
||||
Program.LocalSettings.UpdateHistory(orderComboBox.Text,
|
||||
ref Program.LocalSettings.PurchaseOrderHistory
|
||||
#if FUZHOU_150 || FUZHOU_300
|
||||
, 20
|
||||
#endif
|
||||
);
|
||||
|
||||
Program.LocalSettings.LastSNTexts = SNText;
|
||||
|
||||
for (int i = 0; i < Math.Min(WaterMetersCount, textBoxesCount); i++)
|
||||
{
|
||||
SNText[i] = comboBoxes[i].Text;
|
||||
Disabled[i] = !checkBoxes[i].Checked;
|
||||
}
|
||||
|
||||
completed = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When one combo box is updated using drop-down menu, all combo boxes
|
||||
/// are updated by this function.
|
||||
/// </summary>
|
||||
private void UpdateAllCombos()
|
||||
{
|
||||
for (int i = 0; i < Math.Min(WaterMetersCount, textBoxesCount); i++)
|
||||
{
|
||||
comboBoxes[i].Text = Program.LocalSettings.LastSNTexts[i];
|
||||
checkBoxes[i].Checked = !string.IsNullOrEmpty(comboBoxes[i].Text);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
for (int i = 0; i < Math.Min(WaterMetersCount, textBoxesCount); i++)
|
||||
{
|
||||
comboBoxes[i].Text = string.Empty;
|
||||
checkBoxes[i].Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void comboBox1_TextChanged(object sender, EventArgs e) { checkBox1.Checked = true; }
|
||||
private void comboBox2_TextChanged(object sender, EventArgs e) { checkBox2.Checked = true; }
|
||||
private void comboBox3_TextChanged(object sender, EventArgs e) { checkBox3.Checked = true; }
|
||||
private void comboBox4_TextChanged(object sender, EventArgs e) { checkBox4.Checked = true; }
|
||||
private void comboBox5_TextChanged(object sender, EventArgs e) { checkBox5.Checked = true; }
|
||||
private void comboBox6_TextChanged(object sender, EventArgs e) { checkBox6.Checked = true; }
|
||||
private void comboBox7_TextChanged(object sender, EventArgs e) { checkBox7.Checked = true; }
|
||||
private void comboBox8_TextChanged(object sender, EventArgs e) { checkBox8.Checked = true; }
|
||||
private void comboBox9_TextChanged(object sender, EventArgs e) { checkBox9.Checked = true; }
|
||||
private void comboBox10_TextChanged(object sender, EventArgs e) { checkBox10.Checked = true; }
|
||||
private void comboBox11_TextChanged(object sender, EventArgs e) { checkBox11.Checked = true; }
|
||||
private void comboBox12_TextChanged(object sender, EventArgs e) { checkBox12.Checked = true; }
|
||||
private void comboBox13_TextChanged(object sender, EventArgs e) { checkBox13.Checked = true; }
|
||||
private void comboBox14_TextChanged(object sender, EventArgs e) { checkBox14.Checked = true; }
|
||||
private void comboBox15_TextChanged(object sender, EventArgs e) { checkBox15.Checked = true; }
|
||||
private void comboBox16_TextChanged(object sender, EventArgs e) { checkBox16.Checked = true; }
|
||||
private void comboBox17_TextChanged(object sender, EventArgs e) { checkBox17.Checked = true; }
|
||||
private void comboBox18_TextChanged(object sender, EventArgs e) { checkBox18.Checked = true; }
|
||||
private void comboBox19_TextChanged(object sender, EventArgs e) { checkBox19.Checked = true; }
|
||||
private void comboBox20_TextChanged(object sender, EventArgs e) { checkBox20.Checked = true; }
|
||||
private void comboBox21_TextChanged(object sender, EventArgs e) { checkBox21.Checked = true; }
|
||||
private void comboBox22_TextChanged(object sender, EventArgs e) { checkBox22.Checked = true; }
|
||||
private void comboBox23_TextChanged(object sender, EventArgs e) { checkBox23.Checked = true; }
|
||||
private void comboBox24_TextChanged(object sender, EventArgs e) { checkBox24.Checked = true; }
|
||||
private void comboBox25_TextChanged(object sender, EventArgs e) { checkBox25.Checked = true; }
|
||||
private void comboBox26_TextChanged(object sender, EventArgs e) { checkBox26.Checked = true; }
|
||||
private void comboBox27_TextChanged(object sender, EventArgs e) { checkBox27.Checked = true; }
|
||||
private void comboBox28_TextChanged(object sender, EventArgs e) { checkBox28.Checked = true; }
|
||||
private void comboBox29_TextChanged(object sender, EventArgs e) { checkBox29.Checked = true; }
|
||||
private void comboBox30_TextChanged(object sender, EventArgs e) { checkBox30.Checked = true; }
|
||||
private void comboBox31_TextChanged(object sender, EventArgs e) { checkBox31.Checked = true; }
|
||||
private void comboBox32_TextChanged(object sender, EventArgs e) { checkBox32.Checked = true; }
|
||||
private void comboBox33_TextChanged(object sender, EventArgs e) { checkBox33.Checked = true; }
|
||||
private void comboBox34_TextChanged(object sender, EventArgs e) { checkBox34.Checked = true; }
|
||||
private void comboBox35_TextChanged(object sender, EventArgs e) { checkBox35.Checked = true; }
|
||||
private void comboBox36_TextChanged(object sender, EventArgs e) { checkBox36.Checked = true; }
|
||||
private void comboBox37_TextChanged(object sender, EventArgs e) { checkBox37.Checked = true; }
|
||||
private void comboBox38_TextChanged(object sender, EventArgs e) { checkBox38.Checked = true; }
|
||||
private void comboBox39_TextChanged(object sender, EventArgs e) { checkBox39.Checked = true; }
|
||||
private void comboBox40_TextChanged(object sender, EventArgs e) { checkBox40.Checked = true; }
|
||||
private void comboBox41_TextChanged(object sender, EventArgs e) { checkBox41.Checked = true; }
|
||||
private void comboBox42_TextChanged(object sender, EventArgs e) { checkBox42.Checked = true; }
|
||||
private void comboBox43_TextChanged(object sender, EventArgs e) { checkBox43.Checked = true; }
|
||||
private void comboBox44_TextChanged(object sender, EventArgs e) { checkBox44.Checked = true; }
|
||||
private void comboBox45_TextChanged(object sender, EventArgs e) { checkBox45.Checked = true; }
|
||||
private void comboBox46_TextChanged(object sender, EventArgs e) { checkBox46.Checked = true; }
|
||||
private void comboBox47_TextChanged(object sender, EventArgs e) { checkBox47.Checked = true; }
|
||||
private void comboBox48_TextChanged(object sender, EventArgs e) { checkBox48.Checked = true; }
|
||||
|
||||
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox1.Text.Equals(comboBox1.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox2.Text.Equals(comboBox2.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox3.Text.Equals(comboBox3.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox4.Text.Equals(comboBox4.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox5_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox5.Text.Equals(comboBox5.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox6_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox6.Text.Equals(comboBox6.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox7_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox7.Text.Equals(comboBox7.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox8_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox8.Text.Equals(comboBox8.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox9_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox9.Text.Equals(comboBox9.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox10_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox10.Text.Equals(comboBox10.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox11_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox11.Text.Equals(comboBox11.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox12_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox12.Text.Equals(comboBox12.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox13_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox13.Text.Equals(comboBox13.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox14_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox14.Text.Equals(comboBox14.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox15_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox15.Text.Equals(comboBox15.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox16_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox16.Text.Equals(comboBox16.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox17_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox17.Text.Equals(comboBox17.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox18_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox18.Text.Equals(comboBox18.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox19_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox19.Text.Equals(comboBox19.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox20_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox20.Text.Equals(comboBox20.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox21_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox21.Text.Equals(comboBox21.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox22_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox22.Text.Equals(comboBox22.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox23_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox23.Text.Equals(comboBox23.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox24_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox24.Text.Equals(comboBox24.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox25_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox25.Text.Equals(comboBox25.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox26_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox26.Text.Equals(comboBox26.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox27_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox27.Text.Equals(comboBox27.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox28_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox28.Text.Equals(comboBox28.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox29_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox29.Text.Equals(comboBox29.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox30_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox30.Text.Equals(comboBox30.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox31_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox31.Text.Equals(comboBox31.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox32_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox32.Text.Equals(comboBox32.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox33_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox33.Text.Equals(comboBox33.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox34_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox34.Text.Equals(comboBox34.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox35_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox35.Text.Equals(comboBox35.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox36_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox36.Text.Equals(comboBox36.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox37_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox37.Text.Equals(comboBox37.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox38_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox38.Text.Equals(comboBox38.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox39_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox39.Text.Equals(comboBox39.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox40_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox40.Text.Equals(comboBox40.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox41_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox41.Text.Equals(comboBox41.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox42_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox42.Text.Equals(comboBox42.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox43_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox43.Text.Equals(comboBox43.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox44_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox44.Text.Equals(comboBox44.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox45_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox45.Text.Equals(comboBox45.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox46_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox46.Text.Equals(comboBox46.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox47_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox47.Text.Equals(comboBox47.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox48_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Program.LocalSettings.LastSNTextsCount == WaterMetersCount)
|
||||
{
|
||||
if (comboBox48.Text.Equals(comboBox48.Items[0])) UpdateAllCombos();
|
||||
}
|
||||
}
|
||||
|
||||
#region Forced close handling
|
||||
|
||||
public void StartForceCloseHandler()
|
||||
{
|
||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
||||
else OnForceClose(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
private void OnForceClose(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Process a key press within any enabled text boxe
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="currentFocusOwner">TextBox control which received the event</param>
|
||||
private void ProcKeyPress(object sender, KeyPressEventArgs e, ComboBox currentFocusOwner)
|
||||
{
|
||||
if (e.KeyChar == '+')
|
||||
{
|
||||
/// Process '+' key ..... Form completed
|
||||
okButton_Click(sender, e);
|
||||
}
|
||||
if (e.KeyChar == '\r')
|
||||
{
|
||||
/// Process <enter> key ..... Next text field
|
||||
if (enabledComboBoxes.Count < 2) return; /// There is just one enabled textbox
|
||||
|
||||
for (int i = 0; i < enabledComboBoxes.Count; i++)
|
||||
{
|
||||
if (enabledComboBoxes[i] == currentFocusOwner)
|
||||
{
|
||||
/// Change focus to the next enabled text box
|
||||
enabledComboBoxes[(i + 1) % enabledComboBoxes.Count].Focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBox1_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox1); }
|
||||
private void comboBox2_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox2); }
|
||||
private void comboBox3_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox3); }
|
||||
private void comboBox4_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox4); }
|
||||
private void comboBox5_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox5); }
|
||||
private void comboBox6_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox6); }
|
||||
private void comboBox7_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox7); }
|
||||
private void comboBox8_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox8); }
|
||||
private void comboBox9_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox9); }
|
||||
private void comboBox10_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox10); }
|
||||
private void comboBox11_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox11); }
|
||||
private void comboBox12_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox12); }
|
||||
private void comboBox13_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox13); }
|
||||
private void comboBox14_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox14); }
|
||||
private void comboBox15_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox15); }
|
||||
private void comboBox16_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox16); }
|
||||
private void comboBox17_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox17); }
|
||||
private void comboBox18_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox18); }
|
||||
private void comboBox19_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox19); }
|
||||
private void comboBox20_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox20); }
|
||||
private void comboBox21_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox21); }
|
||||
private void comboBox22_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox22); }
|
||||
private void comboBox23_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox23); }
|
||||
private void comboBox24_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox24); }
|
||||
private void comboBox25_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox25); }
|
||||
private void comboBox26_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox26); }
|
||||
private void comboBox27_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox27); }
|
||||
private void comboBox28_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox28); }
|
||||
private void comboBox29_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox29); }
|
||||
private void comboBox30_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox30); }
|
||||
private void comboBox31_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox31); }
|
||||
private void comboBox32_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox32); }
|
||||
private void comboBox33_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox33); }
|
||||
private void comboBox34_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox34); }
|
||||
private void comboBox35_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox35); }
|
||||
private void comboBox36_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox36); }
|
||||
private void comboBox37_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox37); }
|
||||
private void comboBox38_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox38); }
|
||||
private void comboBox39_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox39); }
|
||||
private void comboBox40_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox40); }
|
||||
private void comboBox41_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox41); }
|
||||
private void comboBox42_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox42); }
|
||||
private void comboBox43_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox43); }
|
||||
private void comboBox44_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox44); }
|
||||
private void comboBox45_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox45); }
|
||||
private void comboBox46_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox46); }
|
||||
private void comboBox47_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox47); }
|
||||
private void comboBox48_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, comboBox48); }
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,284 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl;
|
||||
using TBF.BenchControl.GenericDevices;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.DataEntryForRadio
|
||||
{
|
||||
public class EntryForm : ComponentBase, IOperation, IDataEntry, IHasCycleBeginForm, IHasWMStatesForm, IReceivesDataFromRadio
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(EntryForm));
|
||||
public override string ToString() { return string.Format("DataEntry.Standard48({0})", Cfg.ToString(1)); }
|
||||
|
||||
public bool UsesCameras() { return false; }
|
||||
|
||||
readonly EntryFormCfg entryFormCfg;
|
||||
|
||||
KPackE.Radio.Radio radio; /// Reference to KPackE.Radio component
|
||||
|
||||
IRegisterReader[] regReaders;
|
||||
|
||||
/// <summary>
|
||||
/// Properties set by the Begin, End and WMStates form
|
||||
/// </summary>
|
||||
string purchaseOrder;
|
||||
public string PurchaseOrder { get { return purchaseOrder; } }
|
||||
|
||||
bool[] disabled; /// This array is shared between forms
|
||||
|
||||
string[] wmCycleEndState;
|
||||
public string WMCycleEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmCycleEndState.Length) ? wmCycleEndState[wmNr] : string.Empty; }
|
||||
|
||||
double[] wmStartState;
|
||||
public double WMStartState(int wmNr) { return (wmNr >= 0 && wmNr < wmStartState.Length) ? wmStartState[wmNr] : 0; }
|
||||
|
||||
double[] wmEndState;
|
||||
public double WMEndState(int wmNr) { return (wmNr >= 0 && wmNr < wmEndState.Length) ? wmEndState[wmNr] : 0; }
|
||||
|
||||
string[] wmStartStateStr;
|
||||
|
||||
|
||||
System.Windows.Forms.Form modelessDlg;
|
||||
|
||||
double refVolume;
|
||||
double errLimLo;
|
||||
double errLimHi;
|
||||
|
||||
bool resultSaved; /// Set in Run() when results are saved
|
||||
|
||||
Results.Entities.WaterMeter[] waterMeters; /// Reference to ...ProcessData.BatchRslts.WaterMeters[]
|
||||
|
||||
public enum CurrentOp
|
||||
{
|
||||
None,
|
||||
ShowFormAtCycleBeginning,
|
||||
EnterTestStartStates,
|
||||
EnterTestEndStates,
|
||||
}
|
||||
|
||||
CurrentOp currentOp;
|
||||
|
||||
|
||||
public EntryForm()
|
||||
{
|
||||
}
|
||||
|
||||
public EntryForm(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
entryFormCfg = cfg as EntryFormCfg;
|
||||
|
||||
radio = (KPackE.Radio.Radio)TbfComponents.FindComponent(entryFormCfg.Radio, components);
|
||||
if (radio == null) throw new Exception("Cannot find Radio");
|
||||
radio.EntryForm = this;
|
||||
|
||||
disabled = new bool[Config.Data.WMsCount];
|
||||
wmStartState = new double[Config.Data.WMsCount];
|
||||
wmStartStateStr = new string[Config.Data.WMsCount];
|
||||
wmEndState = new double[Config.Data.WMsCount];
|
||||
wmCycleEndState = new string[Config.Data.WMsCount];
|
||||
|
||||
currentOp = CurrentOp.None;
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation ShowCycleBeginFormOp()
|
||||
{
|
||||
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
|
||||
currentOp = CurrentOp.ShowFormAtCycleBeginning;
|
||||
this.waterMeters = TBF.BenchControl.Sequences.ProcessData.BatchRslts.WaterMeters;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation ShowTestStartFormOp(IRegisterReader[] regReaders)
|
||||
{
|
||||
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
|
||||
currentOp = CurrentOp.EnterTestStartStates;
|
||||
this.regReaders = regReaders;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <returns>Reference to the operation</returns>
|
||||
public IOperation ShowTestEndFormOp(IRegisterReader[] regReaders, double refVolume, double errLimLo, double errLimHi)
|
||||
{
|
||||
if (currentOp != CurrentOp.None) throw new Exception("Sequence error");
|
||||
currentOp = CurrentOp.EnterTestEndStates;
|
||||
this.regReaders = regReaders;
|
||||
this.refVolume = refVolume;
|
||||
this.errLimLo = errLimLo;
|
||||
this.errLimHi = errLimHi;
|
||||
return this;
|
||||
}
|
||||
|
||||
delegate void EntryFormDlgt(EntryForm myRef);
|
||||
///
|
||||
void OpenBeginningDlg(EntryForm myRef)
|
||||
{
|
||||
myRef.modelessDlg = new CycleBeginningForm(Config.Data.WMsCount);
|
||||
modelessDlg.Show();
|
||||
}
|
||||
///
|
||||
void OpenTestStartStatesDlg(EntryForm myRef)
|
||||
{
|
||||
myRef.modelessDlg = new TestStartEndForm(myRef.waterMeters, myRef.regReaders, disabled);
|
||||
modelessDlg.Show();
|
||||
}
|
||||
///
|
||||
void OpenTestEndStatesDlg(EntryForm myRef)
|
||||
{
|
||||
myRef.modelessDlg = new TestStartEndForm(myRef.waterMeters, myRef.regReaders, wmStartStateStr, disabled, refVolume, errLimLo, errLimHi);
|
||||
modelessDlg.Show();
|
||||
}
|
||||
|
||||
|
||||
public void WMStateReceived(string serialNr, double wmState)
|
||||
{
|
||||
if (modelessDlg is IReceivesDataFromRadio)
|
||||
{
|
||||
(modelessDlg as IReceivesDataFromRadio).WMStateReceived(serialNr, wmState);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
resultSaved = false;
|
||||
switch (currentOp)
|
||||
{
|
||||
case CurrentOp.ShowFormAtCycleBeginning:
|
||||
Program.MainWnd.Invoke(new EntryFormDlgt(OpenBeginningDlg), this);
|
||||
break;
|
||||
|
||||
case CurrentOp.EnterTestStartStates:
|
||||
BindRegisterReadersToRadio(waterMeters, regReaders, false);
|
||||
Program.MainWnd.Invoke(new EntryFormDlgt(OpenTestStartStatesDlg), this);
|
||||
break;
|
||||
|
||||
case CurrentOp.EnterTestEndStates:
|
||||
BindRegisterReadersToRadio(waterMeters, regReaders, true);
|
||||
Program.MainWnd.Invoke(new EntryFormDlgt(OpenTestEndStatesDlg), this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>Event.ResultsPrinted</returns>
|
||||
public Event Run()
|
||||
{
|
||||
if ((modelessDlg is IHasCompleted) && !(modelessDlg as IHasCompleted).Completed)
|
||||
{
|
||||
return Event.ModelessFormIsOpen;
|
||||
}
|
||||
|
||||
if (!resultSaved) /// This is to save the result only once
|
||||
{
|
||||
if (currentOp == CurrentOp.ShowFormAtCycleBeginning)
|
||||
{
|
||||
CycleBeginningForm dlg = (modelessDlg as CycleBeginningForm);
|
||||
if (dlg != null)
|
||||
{
|
||||
purchaseOrder = dlg.PurchaseOrder;
|
||||
|
||||
for (int i = 0; i < Math.Min(dlg.WaterMetersCount, waterMeters.Length); i++)
|
||||
{
|
||||
if (waterMeters[i] != null)
|
||||
{
|
||||
waterMeters[i].SerialNr = dlg.SNText[i];
|
||||
disabled[i] = waterMeters[i].Disabled = dlg.Disabled[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((modelessDlg is TestStartEndForm) && (currentOp == CurrentOp.EnterTestStartStates))
|
||||
{
|
||||
/// Fixed start test - start
|
||||
TestStartEndForm dlg = (modelessDlg as TestStartEndForm);
|
||||
if (dlg != null)
|
||||
{
|
||||
for (int i = 0; i < dlg.WaterMetersCount; i++)
|
||||
{
|
||||
if (!(((i < disabled.Length) && disabled[i]) || ((i < regReaders.Length) && (regReaders[i] == null))))
|
||||
{
|
||||
wmStartState[i] = dlg.WMStartState[i];
|
||||
wmStartStateStr[i] = dlg.WMStartStateStr[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((modelessDlg is TestStartEndForm) && (currentOp == CurrentOp.EnterTestEndStates))
|
||||
{
|
||||
/// Fixed start test - end
|
||||
TestStartEndForm dlg = (modelessDlg as TestStartEndForm);
|
||||
if (dlg != null)
|
||||
{
|
||||
for (int i = 0; i < dlg.WaterMetersCount; i++)
|
||||
{
|
||||
if (!(((i < disabled.Length) && disabled[i]) || ((i < regReaders.Length) && (regReaders[i] == null))))
|
||||
{
|
||||
wmEndState[i] = dlg.WMEndState[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resultSaved = true;
|
||||
modelessDlg = null;
|
||||
}
|
||||
|
||||
return Event.ModelessFormClosed; /// Form closed
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
if (modelessDlg is IHasCompleted)
|
||||
{
|
||||
UiBridge.Bridge.OnCloseModelessForm(this, null);
|
||||
modelessDlg = null;
|
||||
}
|
||||
currentOp = CurrentOp.None;
|
||||
}
|
||||
|
||||
|
||||
void BindRegisterReadersToRadio(Results.Entities.WaterMeter[] wMeters, IRegisterReader[] rReaders, bool isEndOfTest)
|
||||
{
|
||||
radio.RegReaders.Clear();
|
||||
|
||||
for (int i = 0; i < Math.Min(wMeters.Length, rReaders.Length); i++)
|
||||
{
|
||||
RegisterReader.RegisterReader regReader = rReaders[i] as RegisterReader.RegisterReader;
|
||||
if (regReader != null)
|
||||
{
|
||||
if ((wMeters[i] != null) && !string.IsNullOrEmpty(wMeters[i].SerialNr))
|
||||
{
|
||||
regReader.SerialNr = wMeters[i].SerialNr;
|
||||
regReader.IsEndOfTest = isEndOfTest;
|
||||
radio.RegReaders.Add(regReader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates test results with the information collected in watermeters.
|
||||
/// </summary>
|
||||
/// <param name="batchResults">Test results to be updated with the information</param>
|
||||
public void UpdateTestResults(Results.BatchResults batchResults)
|
||||
{
|
||||
foreach (var wm in batchResults.WaterMeters)
|
||||
{
|
||||
if ((wm != null) && !wm.Disabled && (PurchaseOrder != null))
|
||||
{
|
||||
wm.PurchaseOrder = PurchaseOrder; /// PurchaseOrder == null if form button OK has not been used => no update
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.DataEntryForRadio
|
||||
{
|
||||
public class EntryFormCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(EntryFormCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new EntryFormCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public string Radio; /// Name of a radio component
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
EntryFormCfg()
|
||||
{
|
||||
Name = "DataEntryForRadio";
|
||||
Radio = "KPackE.Radio";
|
||||
ParentName = string.Empty;
|
||||
}
|
||||
|
||||
public EntryFormCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Radio={1}", Name, Radio);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.DataEntryForRadio
|
||||
{
|
||||
public partial class EntryFormCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
EntryFormCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as EntryFormCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public EntryFormCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void EntryFormCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
Localize();
|
||||
|
||||
parent = ParentForm as ComponentParametersDlg;
|
||||
if (parent == null) return;
|
||||
|
||||
if (parent.TbfComponents != null)
|
||||
{
|
||||
foreach (var cmpnt in parent.TbfComponents)
|
||||
{
|
||||
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Radio.Factory)
|
||||
{
|
||||
radioComboBox.Items.Add(cmpnt.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Redraw();
|
||||
}
|
||||
|
||||
void Localize()
|
||||
{
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
radioComboBox.Text = config.Radio;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
radioComboBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
if (!radioComboBox.Items.Contains(radioComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Radio'";
|
||||
}
|
||||
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;
|
||||
config.Radio = radioComboBox.Text;
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
110
TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/EntryFormCfgCtrl.designer.cs
generated
Normal file
110
TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/EntryFormCfgCtrl.designer.cs
generated
Normal file
@ -0,0 +1,110 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.DataEntryForRadio
|
||||
{
|
||||
partial class EntryFormCfgCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.radioLabel = new System.Windows.Forms.Label();
|
||||
this.radioComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(99, 57);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(164, 20);
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(35, 60);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 1;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(96, 33);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
this.classNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// radioLabel
|
||||
//
|
||||
this.radioLabel.AutoSize = true;
|
||||
this.radioLabel.Location = new System.Drawing.Point(35, 86);
|
||||
this.radioLabel.Name = "radioLabel";
|
||||
this.radioLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.radioLabel.TabIndex = 3;
|
||||
this.radioLabel.Text = "Radio";
|
||||
//
|
||||
// radioComboBox
|
||||
//
|
||||
this.radioComboBox.Enabled = false;
|
||||
this.radioComboBox.FormattingEnabled = true;
|
||||
this.radioComboBox.Location = new System.Drawing.Point(99, 83);
|
||||
this.radioComboBox.Name = "radioComboBox";
|
||||
this.radioComboBox.Size = new System.Drawing.Size(164, 21);
|
||||
this.radioComboBox.TabIndex = 4;
|
||||
//
|
||||
// EntryFormCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.radioComboBox);
|
||||
this.Controls.Add(this.radioLabel);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Name = "EntryFormCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.EntryFormCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.Label radioLabel;
|
||||
private System.Windows.Forms.ComboBox radioComboBox;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -0,0 +1,26 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.DataEntryForRadio
|
||||
{
|
||||
public class Factory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return "DataEntry-KPackE-Radio"; } }
|
||||
|
||||
public void ResetStaticProperties() { EntryForm.ResetStaticProperties(); }
|
||||
|
||||
public IComponent DummyComponent() { return new EntryForm(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new EntryForm(cfg, components); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new EntryFormCfg(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(EntryFormCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,707 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using TBF.BenchControl.GenericDevices;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.DataEntryForRadio
|
||||
{
|
||||
public partial class TestStartEndForm : Form, GenericDevices.IHasCompleted, GenericDevices.IReceivesDataFromRadio
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(TestStartEndForm));
|
||||
|
||||
// Set to 'true' when the form closes
|
||||
public bool Completed { get { return completed; } }
|
||||
bool completed;
|
||||
|
||||
/// <summary> Number of text boxes for serial numbers </summary>
|
||||
public readonly int WaterMetersCount;
|
||||
readonly Results.Entities.WaterMeter[] waterMeters;
|
||||
readonly IRegisterReader[] regReaders;
|
||||
readonly bool[] disabled;
|
||||
|
||||
// To be retrieved after the form closes
|
||||
public double[] WMStartState;
|
||||
|
||||
// To be retrieved after the form closes
|
||||
public readonly string[] WMStartStateStr;
|
||||
|
||||
// To be retrieved after the form closes
|
||||
public double[] WMEndState;
|
||||
|
||||
bool endStates; /// false=start states, true=end states
|
||||
double refVolume;
|
||||
double warningLimLo; /// limit to display exclamation mark, typically 2x errLimLo
|
||||
double warningLimHi; /// limit to display exclamation mark, typically 2x errLimHi
|
||||
bool fixedErrorLimits; /// false in case of calculated error limits
|
||||
|
||||
int TextBoxesCount;
|
||||
///
|
||||
Label[] labels;
|
||||
TextBox[] startTextBoxes;
|
||||
TextBox[] endTextBoxes;
|
||||
Label[] exclamations;
|
||||
///
|
||||
IList<TextBox> activeTextBoxes;
|
||||
IList<int> activeWmNrs;
|
||||
|
||||
/// <summary>
|
||||
/// Parameterless constructor initializing common part for start and endstate form
|
||||
/// </summary>
|
||||
public TestStartEndForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
ControlBox = false;
|
||||
|
||||
TextBoxesCount = 48;
|
||||
|
||||
labels = new Label[]
|
||||
{
|
||||
label1, label2, label3, label4, label5, label6, label7, label8, label9, label10,
|
||||
label11, label12, label13, label14, label15, label16, label17, label18, label19, label20,
|
||||
label21, label22, label23, label24, label25, label26, label27, label28, label29, label30,
|
||||
label31, label32, label33, label34, label35, label36, label37, label38, label39, label40,
|
||||
label41, label42, label43, label44, label45, label46, label47, label48,
|
||||
};
|
||||
startTextBoxes = new TextBox[]
|
||||
{
|
||||
startTextBox1, startTextBox2, startTextBox3, startTextBox4, startTextBox5, startTextBox6, startTextBox7, startTextBox8, startTextBox9, startTextBox10,
|
||||
startTextBox11, startTextBox12, startTextBox13, startTextBox14, startTextBox15, startTextBox16, startTextBox17, startTextBox18, startTextBox19, startTextBox20,
|
||||
startTextBox21, startTextBox22, startTextBox23, startTextBox24, startTextBox25, startTextBox26, startTextBox27, startTextBox28, startTextBox29, startTextBox30,
|
||||
startTextBox31, startTextBox32, startTextBox33, startTextBox34, startTextBox35, startTextBox36, startTextBox37, startTextBox38, startTextBox39, startTextBox40,
|
||||
startTextBox41, startTextBox42, startTextBox43, startTextBox44, startTextBox45, startTextBox46, startTextBox47, startTextBox48,
|
||||
};
|
||||
endTextBoxes = new TextBox[]
|
||||
{
|
||||
endTextBox1, endTextBox2, endTextBox3, endTextBox4, endTextBox5, endTextBox6, endTextBox7, endTextBox8, endTextBox9, endTextBox10,
|
||||
endTextBox11, endTextBox12, endTextBox13, endTextBox14, endTextBox15, endTextBox16, endTextBox17, endTextBox18, endTextBox19, endTextBox20,
|
||||
endTextBox21, endTextBox22, endTextBox23, endTextBox24, endTextBox25, endTextBox26, endTextBox27, endTextBox28, endTextBox29, endTextBox30,
|
||||
endTextBox31, endTextBox32, endTextBox33, endTextBox34, endTextBox35, endTextBox36, endTextBox37, endTextBox38, endTextBox39, endTextBox40,
|
||||
endTextBox41, endTextBox42, endTextBox43, endTextBox44, endTextBox45, endTextBox46, endTextBox47, endTextBox48,
|
||||
};
|
||||
exclamations = new Label[]
|
||||
{
|
||||
exclamation1, exclamation2, exclamation3, exclamation4, exclamation5, exclamation6,
|
||||
exclamation7, exclamation8, exclamation9, exclamation10, exclamation11, exclamation12,
|
||||
exclamation13, exclamation14, exclamation15, exclamation16, exclamation17, exclamation18,
|
||||
exclamation19, exclamation20, exclamation21, exclamation22, exclamation23, exclamation24,
|
||||
exclamation25, exclamation26, exclamation27, exclamation28, exclamation29, exclamation30,
|
||||
exclamation31, exclamation32, exclamation33, exclamation34, exclamation35, exclamation36,
|
||||
exclamation37, exclamation38, exclamation39, exclamation40, exclamation41, exclamation42,
|
||||
exclamation43, exclamation44, exclamation45, exclamation46, exclamation47, exclamation48,
|
||||
};
|
||||
|
||||
activeTextBoxes = new List<TextBox>();
|
||||
activeWmNrs = new List<int>();
|
||||
|
||||
completed = false;
|
||||
StartForceCloseHandler();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor to fill in start states
|
||||
/// </summary>
|
||||
/// <param name="waterMetersCount">Number of water meters</param>
|
||||
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
|
||||
public TestStartEndForm(Results.Entities.WaterMeter[] waterMeters, IRegisterReader[] regReaders, bool[] disabled)
|
||||
: this()
|
||||
{
|
||||
endStates = false;
|
||||
|
||||
this.WaterMetersCount = waterMeters.Length;
|
||||
this.waterMeters = waterMeters;
|
||||
this.regReaders = regReaders;
|
||||
this.disabled = disabled;
|
||||
|
||||
ShuffleTextBoxes();
|
||||
|
||||
WMStartState = new double[WaterMetersCount];
|
||||
WMStartStateStr = new string[WaterMetersCount];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor to fill in end states
|
||||
/// </summary>
|
||||
/// <param name="waterMetersCount">Number of water meters</param>
|
||||
/// <param name="wmStartStateStr">Information entered on test start</param>
|
||||
/// <param name="disabled">Information from CycleBeginningForm about availability of water meters</param>
|
||||
/// <param name="refVolume">Reference volume, it is used to verify the end state, show/hide exclamation if necessary</param>
|
||||
/// <param name="errLimLo">Error limit low, it is used to verify the end state, show/hide exclamation if necessary</param>
|
||||
/// <param name="errLimHi">Error limit high, it is used to verify the end state, show/hide exclamation if necessary</param>
|
||||
public TestStartEndForm(Results.Entities.WaterMeter[] waterMeters, IRegisterReader[] regReaders, string[] wmStartStateStr, bool[] disabled,
|
||||
double refVolume, double errLimLo, double errLimHi)
|
||||
: this()
|
||||
{
|
||||
endStates = true;
|
||||
|
||||
this.WaterMetersCount = waterMeters.Length;
|
||||
this.waterMeters = waterMeters;
|
||||
this.regReaders = regReaders;
|
||||
if (wmStartStateStr == null || wmStartStateStr.Length != WaterMetersCount)
|
||||
throw (new Exception("Invalid 'wmStartStateStr' argument"));
|
||||
this.WMStartStateStr = wmStartStateStr;
|
||||
this.disabled = disabled;
|
||||
this.refVolume = refVolume;
|
||||
this.warningLimLo = 2 * errLimLo;
|
||||
this.warningLimHi = 2 * errLimHi;
|
||||
this.fixedErrorLimits = (errLimHi > errLimLo);
|
||||
|
||||
ShuffleTextBoxes();
|
||||
|
||||
WMEndState = new double[WaterMetersCount];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Make sure the layout of labels/text boxes on the screen
|
||||
/// corresponds to the layout of watermeters of the test bench.
|
||||
/// </summary>
|
||||
void ShuffleTextBoxes()
|
||||
{
|
||||
if (TextBoxesCount > WaterMetersCount)
|
||||
{
|
||||
int nrLines = WaterMetersCount / Config.Data.LineSize;
|
||||
int gap = (TextBoxesCount - WaterMetersCount) / nrLines;
|
||||
|
||||
int dest = 0;
|
||||
for (int l = 0; l < nrLines; l++)
|
||||
{
|
||||
for (int i = 0; i < Config.Data.LineSize; i++)
|
||||
{
|
||||
labels[dest] = labels[l * Config.Data.LineSize + l * gap + i];
|
||||
startTextBoxes[dest] = startTextBoxes[l * Config.Data.LineSize + l * gap + i];
|
||||
endTextBoxes[dest] = endTextBoxes[l * Config.Data.LineSize + l * gap + i];
|
||||
exclamations[dest] = exclamations[l * Config.Data.LineSize + l * gap + i];
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
TextBoxesCount = WaterMetersCount;
|
||||
}
|
||||
}
|
||||
|
||||
private void CycleEndForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
Localize();
|
||||
|
||||
//Height = 115 + 90 * WaterMetersCount;
|
||||
|
||||
for (int i = 0; i < TextBoxesCount; i++)
|
||||
{
|
||||
if (i < WaterMetersCount)
|
||||
{
|
||||
labels[i].Visible = startTextBoxes[i].Visible = endTextBoxes[i].Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (endStates)
|
||||
{
|
||||
/// End of test
|
||||
for (int i = 0; i < TextBoxesCount; i++)
|
||||
{
|
||||
if (WMStartStateStr != null && i < WMStartStateStr.Length)
|
||||
{
|
||||
startTextBoxes[i].Text = WMStartStateStr[i];
|
||||
}
|
||||
|
||||
if (((i < disabled.Length) && disabled[i]) || ((i < regReaders.Length) && (regReaders[i] == null)))
|
||||
{
|
||||
endTextBoxes[i].Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
endTextBoxes[i].Enabled = true;
|
||||
activeTextBoxes.Add(endTextBoxes[i]);
|
||||
activeWmNrs.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/// Start of test
|
||||
for (int i = 0; i < TextBoxesCount; i++)
|
||||
{
|
||||
if (((i < disabled.Length) && disabled[i]) || ((i < regReaders.Length) && (regReaders[i] == null)))
|
||||
{
|
||||
startTextBoxes[i].Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
startTextBoxes[i].Enabled = true;
|
||||
activeTextBoxes.Add(startTextBoxes[i]);
|
||||
activeWmNrs.Add(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((activeTextBoxes.Count > 0) && (activeWmNrs.Count > 0))
|
||||
{
|
||||
activeTextBoxes[0].Focus();
|
||||
}
|
||||
}
|
||||
|
||||
void Localize()
|
||||
{
|
||||
Text = Strings.Water_Meter_States;
|
||||
for (int i = 0; i < TextBoxesCount; i++)
|
||||
{
|
||||
labels[i].Text = string.Format("{0} {1}", Strings.Water_Meter, i + 1);
|
||||
}
|
||||
startLabel.Text = start2Label.Text = Strings.Start;
|
||||
endLabel.Text = end2Label.Text = Strings.End;
|
||||
okButton.Text = Strings.OkBtnText;
|
||||
}
|
||||
|
||||
|
||||
delegate void StateReceivedDlgt(string serialNr, double wmState);
|
||||
///
|
||||
public void WMStateReceived(string serialNr, double wmState)
|
||||
{
|
||||
StateReceivedDlgt dlgt = OnWMStateReceived;
|
||||
Invoke(dlgt, new object[] { serialNr, wmState });
|
||||
}
|
||||
///
|
||||
void OnWMStateReceived(string serialNr, double wmState)
|
||||
{
|
||||
int count = Math.Min(WaterMetersCount, Math.Min(startTextBoxes.Length, endTextBoxes.Length));
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if ((waterMeters[i] != null) && (waterMeters[i].SerialNr == serialNr))
|
||||
{
|
||||
(endStates ? endTextBoxes[i] : startTextBoxes[i]).Text = wmState.ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void okButton_Click(object sender, EventArgs eArgs)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (endStates)
|
||||
{
|
||||
for (int i = 0; i < Math.Min(WaterMetersCount, TextBoxesCount); i++)
|
||||
{
|
||||
if (endTextBoxes[i].Visible && endTextBoxes[i].Enabled)
|
||||
{
|
||||
WMEndState[i] = Utils.ParseUDouble(endTextBoxes[i].Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < Math.Min(WaterMetersCount, TextBoxesCount); i++)
|
||||
{
|
||||
if (startTextBoxes[i].Visible && startTextBoxes[i].Enabled)
|
||||
{
|
||||
WMStartStateStr[i] = startTextBoxes[i].Text;
|
||||
WMStartState[i] = Utils.ParseUDouble(startTextBoxes[i].Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.ErrorFormat("Exception: {0}", e.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
completed = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
#region Forced close handling
|
||||
|
||||
public void StartForceCloseHandler()
|
||||
{
|
||||
UiBridge.Bridge.CloseModelessFormHandler += delegate(object sender, EventArgs args)
|
||||
{
|
||||
if (InvokeRequired) { Invoke(new EventHandler<EventArgs>(OnForceClose), sender, args); }
|
||||
else OnForceClose(sender, args);
|
||||
};
|
||||
}
|
||||
|
||||
void OnForceClose(object sender, EventArgs args)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the approximate error and verify whether it is within limits.
|
||||
/// Make an exclamation mark visible if out of range.
|
||||
/// Similar event handler is implemented for all endTextBoxes (1..24).
|
||||
/// </summary>
|
||||
private void ProcEndTextChanged(object sender, EventArgs e, TextBox endTBox)
|
||||
{
|
||||
int wmIx = -1;
|
||||
for (int i = 0; i < endTextBoxes.Length; i++)
|
||||
{
|
||||
if (endTextBoxes[i] == endTBox)
|
||||
{
|
||||
wmIx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double err = 0;
|
||||
try
|
||||
{
|
||||
double endState = Utils.ParseUDouble(endTextBoxes[wmIx].Text);
|
||||
double startState = Utils.ParseUDouble(startTextBoxes[wmIx].Text);
|
||||
err = 100.0 * (endState - startState - refVolume) / refVolume;
|
||||
}
|
||||
catch { err = 1000.0f; };
|
||||
|
||||
bool errorOoR = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
|
||||
exclamations[wmIx].Visible = errorOoR;
|
||||
}
|
||||
|
||||
private void endTextBox1_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox1); }
|
||||
private void endTextBox2_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox2); }
|
||||
private void endTextBox3_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox3); }
|
||||
private void endTextBox4_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox4); }
|
||||
private void endTextBox5_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox5); }
|
||||
private void endTextBox6_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox6); }
|
||||
private void endTextBox7_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox7); }
|
||||
private void endTextBox8_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox8); }
|
||||
private void endTextBox9_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox9); }
|
||||
private void endTextBox10_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox10); }
|
||||
private void endTextBox11_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox11); }
|
||||
private void endTextBox12_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox12); }
|
||||
private void endTextBox13_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox13); }
|
||||
private void endTextBox14_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox14); }
|
||||
private void endTextBox15_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox15); }
|
||||
private void endTextBox16_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox16); }
|
||||
private void endTextBox17_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox17); }
|
||||
private void endTextBox18_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox18); }
|
||||
private void endTextBox19_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox19); }
|
||||
private void endTextBox20_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox20); }
|
||||
private void endTextBox21_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox21); }
|
||||
private void endTextBox22_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox22); }
|
||||
private void endTextBox23_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox23); }
|
||||
private void endTextBox24_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox24); }
|
||||
private void endTextBox25_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox25); }
|
||||
private void endTextBox26_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox26); }
|
||||
private void endTextBox27_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox27); }
|
||||
private void endTextBox28_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox28); }
|
||||
private void endTextBox29_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox29); }
|
||||
private void endTextBox30_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox30); }
|
||||
private void endTextBox31_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox31); }
|
||||
private void endTextBox32_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox32); }
|
||||
private void endTextBox33_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox33); }
|
||||
private void endTextBox34_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox34); }
|
||||
private void endTextBox35_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox35); }
|
||||
private void endTextBox36_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox36); }
|
||||
private void endTextBox37_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox37); }
|
||||
private void endTextBox38_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox38); }
|
||||
private void endTextBox39_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox39); }
|
||||
private void endTextBox40_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox40); }
|
||||
private void endTextBox41_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox41); }
|
||||
private void endTextBox42_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox42); }
|
||||
private void endTextBox43_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox43); }
|
||||
private void endTextBox44_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox44); }
|
||||
private void endTextBox45_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox45); }
|
||||
private void endTextBox46_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox46); }
|
||||
private void endTextBox47_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox47); }
|
||||
private void endTextBox48_TextChanged(object sndr, EventArgs e) { ProcEndTextChanged(sndr, e, endTextBox48); }
|
||||
|
||||
private void endTextBox1_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox1); }
|
||||
private void endTextBox2_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox2); }
|
||||
private void endTextBox3_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox3); }
|
||||
private void endTextBox4_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox4); }
|
||||
private void endTextBox5_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox5); }
|
||||
private void endTextBox6_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox6); }
|
||||
private void endTextBox7_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox7); }
|
||||
private void endTextBox8_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox8); }
|
||||
private void endTextBox9_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox9); }
|
||||
private void endTextBox10_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox10); }
|
||||
private void endTextBox11_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox11); }
|
||||
private void endTextBox12_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox12); }
|
||||
private void endTextBox13_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox13); }
|
||||
private void endTextBox14_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox14); }
|
||||
private void endTextBox15_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox15); }
|
||||
private void endTextBox16_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox16); }
|
||||
private void endTextBox17_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox17); }
|
||||
private void endTextBox18_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox18); }
|
||||
private void endTextBox19_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox19); }
|
||||
private void endTextBox20_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox20); }
|
||||
private void endTextBox21_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox21); }
|
||||
private void endTextBox22_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox22); }
|
||||
private void endTextBox23_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox23); }
|
||||
private void endTextBox24_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox24); }
|
||||
private void endTextBox25_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox25); }
|
||||
private void endTextBox26_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox26); }
|
||||
private void endTextBox27_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox27); }
|
||||
private void endTextBox28_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox28); }
|
||||
private void endTextBox29_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox29); }
|
||||
private void endTextBox30_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox30); }
|
||||
private void endTextBox31_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox31); }
|
||||
private void endTextBox32_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox32); }
|
||||
private void endTextBox33_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox33); }
|
||||
private void endTextBox34_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox34); }
|
||||
private void endTextBox35_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox35); }
|
||||
private void endTextBox36_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox36); }
|
||||
private void endTextBox37_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox37); }
|
||||
private void endTextBox38_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox38); }
|
||||
private void endTextBox39_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox39); }
|
||||
private void endTextBox40_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox40); }
|
||||
private void endTextBox41_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox41); }
|
||||
private void endTextBox42_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox42); }
|
||||
private void endTextBox43_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox43); }
|
||||
private void endTextBox44_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox44); }
|
||||
private void endTextBox45_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox45); }
|
||||
private void endTextBox46_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox46); }
|
||||
private void endTextBox47_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox47); }
|
||||
private void endTextBox48_MouseClick(object sndr, MouseEventArgs e) { ProcEndTextChanged(sndr, e, endTextBox48); }
|
||||
|
||||
/// <summary>
|
||||
/// Process a key press within any enabled text boxe
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/// <param name="currentFocusOwner">TextBox control which received the event</param>
|
||||
private void ProcKeyPress(object sender, KeyPressEventArgs e, TextBox currentFocusOwner)
|
||||
{
|
||||
if (e.KeyChar == '+')
|
||||
{
|
||||
/// Process '+' key ..... Form completed
|
||||
okButton_Click(sender, e);
|
||||
}
|
||||
|
||||
if (e.KeyChar == '\r')
|
||||
{
|
||||
/// Process <enter> key ..... Next text field
|
||||
if (activeTextBoxes.Count < 2) return; /// There is just one enabled textbox
|
||||
|
||||
for (int i = 0; i < activeTextBoxes.Count; i++)
|
||||
{
|
||||
if (activeTextBoxes[i] == currentFocusOwner)
|
||||
{
|
||||
/// Index of the next active text box
|
||||
int newTBIdx = (i + 1) % activeTextBoxes.Count;
|
||||
|
||||
/// Change focus to the next active text box
|
||||
activeTextBoxes[newTBIdx].Focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startTextBox1_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox1); }
|
||||
private void startTextBox2_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox2); }
|
||||
private void startTextBox3_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox3); }
|
||||
private void startTextBox4_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox4); }
|
||||
private void startTextBox5_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox5); }
|
||||
private void startTextBox6_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox6); }
|
||||
private void startTextBox7_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox7); }
|
||||
private void startTextBox8_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox8); }
|
||||
private void startTextBox9_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox9); }
|
||||
private void startTextBox10_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox10); }
|
||||
private void startTextBox11_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox11); }
|
||||
private void startTextBox12_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox12); }
|
||||
private void startTextBox13_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox13); }
|
||||
private void startTextBox14_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox14); }
|
||||
private void startTextBox15_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox15); }
|
||||
private void startTextBox16_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox16); }
|
||||
private void startTextBox17_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox17); }
|
||||
private void startTextBox18_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox18); }
|
||||
private void startTextBox19_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox19); }
|
||||
private void startTextBox20_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox20); }
|
||||
private void startTextBox21_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox21); }
|
||||
private void startTextBox22_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox22); }
|
||||
private void startTextBox23_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox23); }
|
||||
private void startTextBox24_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox24); }
|
||||
private void startTextBox25_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox25); }
|
||||
private void startTextBox26_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox26); }
|
||||
private void startTextBox27_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox27); }
|
||||
private void startTextBox28_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox28); }
|
||||
private void startTextBox29_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox29); }
|
||||
private void startTextBox30_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox30); }
|
||||
private void startTextBox31_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox31); }
|
||||
private void startTextBox32_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox32); }
|
||||
private void startTextBox33_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox33); }
|
||||
private void startTextBox34_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox34); }
|
||||
private void startTextBox35_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox35); }
|
||||
private void startTextBox36_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox36); }
|
||||
private void startTextBox37_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox37); }
|
||||
private void startTextBox38_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox38); }
|
||||
private void startTextBox39_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox39); }
|
||||
private void startTextBox40_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox40); }
|
||||
private void startTextBox41_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox41); }
|
||||
private void startTextBox42_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox42); }
|
||||
private void startTextBox43_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox43); }
|
||||
private void startTextBox44_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox44); }
|
||||
private void startTextBox45_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox45); }
|
||||
private void startTextBox46_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox46); }
|
||||
private void startTextBox47_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox47); }
|
||||
private void startTextBox48_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, startTextBox48); }
|
||||
|
||||
private void endTextBox1_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox1); }
|
||||
private void endTextBox2_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox2); }
|
||||
private void endTextBox3_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox3); }
|
||||
private void endTextBox4_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox4); }
|
||||
private void endTextBox5_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox5); }
|
||||
private void endTextBox6_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox6); }
|
||||
private void endTextBox7_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox7); }
|
||||
private void endTextBox8_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox8); }
|
||||
private void endTextBox9_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox9); }
|
||||
private void endTextBox10_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox10); }
|
||||
private void endTextBox11_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox11); }
|
||||
private void endTextBox12_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox12); }
|
||||
private void endTextBox13_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox13); }
|
||||
private void endTextBox14_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox14); }
|
||||
private void endTextBox15_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox15); }
|
||||
private void endTextBox16_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox16); }
|
||||
private void endTextBox17_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox17); }
|
||||
private void endTextBox18_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox18); }
|
||||
private void endTextBox19_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox19); }
|
||||
private void endTextBox20_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox20); }
|
||||
private void endTextBox21_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox21); }
|
||||
private void endTextBox22_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox22); }
|
||||
private void endTextBox23_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox23); }
|
||||
private void endTextBox24_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox24); }
|
||||
private void endTextBox25_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox25); }
|
||||
private void endTextBox26_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox26); }
|
||||
private void endTextBox27_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox27); }
|
||||
private void endTextBox28_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox28); }
|
||||
private void endTextBox29_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox29); }
|
||||
private void endTextBox30_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox30); }
|
||||
private void endTextBox31_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox31); }
|
||||
private void endTextBox32_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox32); }
|
||||
private void endTextBox33_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox33); }
|
||||
private void endTextBox34_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox34); }
|
||||
private void endTextBox35_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox35); }
|
||||
private void endTextBox36_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox36); }
|
||||
private void endTextBox37_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox37); }
|
||||
private void endTextBox38_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox38); }
|
||||
private void endTextBox39_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox39); }
|
||||
private void endTextBox40_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox40); }
|
||||
private void endTextBox41_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox41); }
|
||||
private void endTextBox42_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox42); }
|
||||
private void endTextBox43_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox43); }
|
||||
private void endTextBox44_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox44); }
|
||||
private void endTextBox45_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox45); }
|
||||
private void endTextBox46_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox46); }
|
||||
private void endTextBox47_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox47); }
|
||||
private void endTextBox48_KeyPress(object sndr, KeyPressEventArgs e) { ProcKeyPress(sndr, e, endTextBox48); }
|
||||
|
||||
|
||||
private void ProcStartTextChanged(object sender, EventArgs e, TextBox startTBox)
|
||||
{
|
||||
for (int i = 0; i < startTextBoxes.Length; i++)
|
||||
{
|
||||
if (startTextBoxes[i] == startTBox)
|
||||
{
|
||||
/// wmIx == i
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startTextBox1_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox1); }
|
||||
private void startTextBox2_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox2); }
|
||||
private void startTextBox3_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox3); }
|
||||
private void startTextBox4_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox4); }
|
||||
private void startTextBox5_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox5); }
|
||||
private void startTextBox6_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox6); }
|
||||
private void startTextBox7_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox7); }
|
||||
private void startTextBox8_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox8); }
|
||||
private void startTextBox9_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox9); }
|
||||
private void startTextBox10_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox10); }
|
||||
private void startTextBox11_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox11); }
|
||||
private void startTextBox12_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox12); }
|
||||
private void startTextBox13_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox13); }
|
||||
private void startTextBox14_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox14); }
|
||||
private void startTextBox15_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox15); }
|
||||
private void startTextBox16_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox16); }
|
||||
private void startTextBox17_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox17); }
|
||||
private void startTextBox18_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox18); }
|
||||
private void startTextBox19_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox19); }
|
||||
private void startTextBox20_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox20); }
|
||||
private void startTextBox21_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox21); }
|
||||
private void startTextBox22_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox22); }
|
||||
private void startTextBox23_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox23); }
|
||||
private void startTextBox24_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox24); }
|
||||
private void startTextBox25_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox25); }
|
||||
private void startTextBox26_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox26); }
|
||||
private void startTextBox27_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox27); }
|
||||
private void startTextBox28_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox28); }
|
||||
private void startTextBox29_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox29); }
|
||||
private void startTextBox30_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox30); }
|
||||
private void startTextBox31_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox31); }
|
||||
private void startTextBox32_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox32); }
|
||||
private void startTextBox33_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox33); }
|
||||
private void startTextBox34_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox34); }
|
||||
private void startTextBox35_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox35); }
|
||||
private void startTextBox36_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox36); }
|
||||
private void startTextBox37_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox37); }
|
||||
private void startTextBox38_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox38); }
|
||||
private void startTextBox39_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox39); }
|
||||
private void startTextBox40_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox40); }
|
||||
private void startTextBox41_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox41); }
|
||||
private void startTextBox42_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox42); }
|
||||
private void startTextBox43_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox43); }
|
||||
private void startTextBox44_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox44); }
|
||||
private void startTextBox45_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox45); }
|
||||
private void startTextBox46_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox46); }
|
||||
private void startTextBox47_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox47); }
|
||||
private void startTextBox48_TextChanged(object sender, EventArgs e) { ProcStartTextChanged(sender, e, startTextBox48); }
|
||||
|
||||
private void startTextBox1_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox1); }
|
||||
private void startTextBox2_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox2); }
|
||||
private void startTextBox3_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox3); }
|
||||
private void startTextBox4_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox4); }
|
||||
private void startTextBox5_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox5); }
|
||||
private void startTextBox6_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox6); }
|
||||
private void startTextBox7_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox7); }
|
||||
private void startTextBox8_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox8); }
|
||||
private void startTextBox9_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox9); }
|
||||
private void startTextBox10_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox10); }
|
||||
private void startTextBox11_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox11); }
|
||||
private void startTextBox12_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox12); }
|
||||
private void startTextBox13_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox13); }
|
||||
private void startTextBox14_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox14); }
|
||||
private void startTextBox15_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox15); }
|
||||
private void startTextBox16_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox16); }
|
||||
private void startTextBox17_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox17); }
|
||||
private void startTextBox18_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox18); }
|
||||
private void startTextBox19_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox19); }
|
||||
private void startTextBox20_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox20); }
|
||||
private void startTextBox21_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox21); }
|
||||
private void startTextBox22_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox22); }
|
||||
private void startTextBox23_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox23); }
|
||||
private void startTextBox24_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox24); }
|
||||
private void startTextBox25_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox25); }
|
||||
private void startTextBox26_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox26); }
|
||||
private void startTextBox27_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox27); }
|
||||
private void startTextBox28_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox28); }
|
||||
private void startTextBox29_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox29); }
|
||||
private void startTextBox30_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox30); }
|
||||
private void startTextBox31_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox31); }
|
||||
private void startTextBox32_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox32); }
|
||||
private void startTextBox33_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox33); }
|
||||
private void startTextBox34_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox34); }
|
||||
private void startTextBox35_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox35); }
|
||||
private void startTextBox36_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox36); }
|
||||
private void startTextBox37_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox37); }
|
||||
private void startTextBox38_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox38); }
|
||||
private void startTextBox39_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox39); }
|
||||
private void startTextBox40_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox40); }
|
||||
private void startTextBox41_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox41); }
|
||||
private void startTextBox42_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox42); }
|
||||
private void startTextBox43_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox43); }
|
||||
private void startTextBox44_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox44); }
|
||||
private void startTextBox45_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox45); }
|
||||
private void startTextBox46_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox46); }
|
||||
private void startTextBox47_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox47); }
|
||||
private void startTextBox48_MouseClick(object sender, MouseEventArgs e) { ProcStartTextChanged(sender, e, startTextBox48); }
|
||||
}
|
||||
}
|
||||
3052
TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/TestStartEndForm.designer.cs
generated
Normal file
3052
TBF/BenchControl/RegisterReaders/KPackE/DataEntryForRadio/TestStartEndForm.designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
26
TBF/BenchControl/RegisterReaders/KPackE/Radio/Factory.cs
Normal file
26
TBF/BenchControl/RegisterReaders/KPackE/Radio/Factory.cs
Normal file
@ -0,0 +1,26 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.Radio
|
||||
{
|
||||
public class Factory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
|
||||
|
||||
public void ResetStaticProperties() { Radio.ResetStaticProperties(); }
|
||||
|
||||
public IComponent DummyComponent() { return new Radio(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new Radio(cfg); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new RadioCfg(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(RadioCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
288
TBF/BenchControl/RegisterReaders/KPackE/Radio/Radio.cs
Normal file
288
TBF/BenchControl/RegisterReaders/KPackE/Radio/Radio.cs
Normal file
@ -0,0 +1,288 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO.Ports;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Config.Entities;
|
||||
using log4net;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Boxes;
|
||||
using TBF.BenchControl.GenericDevices;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.Radio
|
||||
{
|
||||
/// <summary>
|
||||
/// Root component for Modbus communication via serial port (RS485)
|
||||
/// </summary>
|
||||
public class Radio : ComponentBase, IDevice
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Radio));
|
||||
public override string ToString() { return string.Format("Radio({0})", Cfg.ToString(1)); }
|
||||
|
||||
enum KPackE_Type
|
||||
{
|
||||
Reading = 0,
|
||||
RSSI = 1,
|
||||
Delta = 2,
|
||||
SmartMeterEvent = 5,
|
||||
Event = 7,
|
||||
}
|
||||
|
||||
enum KPackE_Original
|
||||
{
|
||||
Repeated = 0,
|
||||
Original = 1,
|
||||
}
|
||||
|
||||
///
|
||||
/// Definition of telegrams and telegram frames
|
||||
///
|
||||
static readonly byte[] Ack = new byte[] { 0x06 };
|
||||
static readonly byte[] HartBeatTelegram = new byte[] { 0x0A, 0x30, 0x30, 0x20, 0x4F, 0x4B, 0x41, 0x59, 0x20, 0x40, 0x0D }; // <LF>00 OKAY @<CR> (11 bytes)
|
||||
static readonly byte[] KPackETelegramFrame = new byte[] { 0x02, 0x0F, 0x4D, 0x45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x03, 0, 0x0A, 0x0D };
|
||||
static readonly int MinRcvdTlgrmLen = Math.Min(HartBeatTelegram.Length, KPackETelegramFrame.Length);
|
||||
static readonly int MaxRcvdTlgrmLen = Math.Max(HartBeatTelegram.Length, KPackETelegramFrame.Length);
|
||||
|
||||
///
|
||||
/// Private fields
|
||||
///
|
||||
private readonly RadioCfg radioCfg;
|
||||
|
||||
SerialPort serialPort;
|
||||
DateTime lastSerialPortWrite;
|
||||
DateTime lastTelegramReceived;
|
||||
IList<byte> data; /// Received and not yet processed data
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the last telegram is not older then 60 seconds
|
||||
/// </summary>
|
||||
public bool IsRadioOn()
|
||||
{
|
||||
return (DateTime.Now - lastTelegramReceived) < new TimeSpan(0, 0, 60);
|
||||
}
|
||||
|
||||
|
||||
public IList<RegisterReader.RegisterReader> RegReaders;
|
||||
public IReceivesDataFromRadio EntryForm;
|
||||
|
||||
|
||||
public Radio()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ambient temperature / humidity / pressure meter 'Greco' connected via serial interface (RS232)
|
||||
/// Connection settings: 19200 Bd 8-bits No-parity 1-stop-bit Flow control: none or hardware.
|
||||
/// </summary>
|
||||
public Radio(Generic.IComponentCfg cfg)
|
||||
: base(cfg)
|
||||
{
|
||||
RegReaders = new List<RegisterReader.RegisterReader>();
|
||||
|
||||
serialPort = null;
|
||||
radioCfg = cfg as RadioCfg;
|
||||
data = new List<byte>();
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
~Radio()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (radioCfg.DebugLevel == DebugMode.Simulate)
|
||||
{
|
||||
serialPort = null;
|
||||
log.FatalFormat("{0} - Device simulated", Name);
|
||||
return;
|
||||
}
|
||||
|
||||
lastTelegramReceived = DateTime.MinValue;
|
||||
|
||||
string comPortName = "COM" + radioCfg.ComPortNr.ToString();
|
||||
serialPort = new SerialPort(comPortName, radioCfg.BaudRate, radioCfg.Parity, radioCfg.DataBits, radioCfg.StopBits);
|
||||
serialPort.Handshake = radioCfg.Handshake;
|
||||
serialPort.Open();
|
||||
|
||||
//stopWorkerThread = false;
|
||||
//workerThread = new Thread(Worker);
|
||||
//workerThread.Start();
|
||||
|
||||
log.FatalFormat("{0} - Device successfully initialized", Name);
|
||||
}
|
||||
|
||||
|
||||
public void SendAcknowledgeNow()
|
||||
{
|
||||
serialPort.Write(Ack, 0, Ack.Length);
|
||||
lastSerialPortWrite = DateTime.Now;
|
||||
|
||||
string s = Telegram.LogTelegram(string.Format("{0} - Sending message ", Name), Ack);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceBefore()
|
||||
{
|
||||
if (serialPort != null) ReadDataFromSerialPort();
|
||||
}
|
||||
|
||||
/// <summary>Run this device</summary>
|
||||
public void RunDeviceAfter()
|
||||
{
|
||||
if (serialPort != null) ReadDataFromSerialPort();
|
||||
}
|
||||
|
||||
void ReadDataFromSerialPort()
|
||||
{
|
||||
/// Append any new data to the data buffer
|
||||
int receivedBytesCount = serialPort.BytesToRead;
|
||||
if (receivedBytesCount > 0)
|
||||
{
|
||||
byte[] receivedData = new byte[receivedBytesCount];
|
||||
serialPort.Read(receivedData, 0, receivedBytesCount);
|
||||
{
|
||||
string s = Telegram.LogTelegram(string.Format("{0} received ", Name), receivedData);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
}
|
||||
foreach (var b in receivedData) data.Add(b);
|
||||
}
|
||||
|
||||
if (data.Count >= MinRcvdTlgrmLen)
|
||||
{
|
||||
for (int offset = 0; offset <= (data.Count - MinRcvdTlgrmLen); offset++)
|
||||
{
|
||||
if (DataFitFrame(data, offset, KPackETelegramFrame) &&
|
||||
(data[offset + 14] == Telegram.ClaculateTelegramChecksum(SubArray(data, offset + 2, 12))))
|
||||
{
|
||||
/// Read the telegram
|
||||
KPackE_Type type = (KPackE_Type)((data[offset + 4] >> 5) & 0x07);
|
||||
KPackE_Original original = ((data[offset + 4] & 0x10) != 0) ? KPackE_Original.Original : KPackE_Original.Repeated;
|
||||
int slotNumber = (data[offset + 4] & 0x0F);
|
||||
long reading = (((data[offset + 5] * 256 + data[offset + 6]) * 256 + data[offset + 7]) * 256 + data[offset + 8]) * 16 + ((data[offset + 9] >> 4) & 0x0F);
|
||||
int account = ((data[offset + 9] & 0x0F) * 256 + data[offset + 10]) * 256 + data[offset + 11];
|
||||
int rssi = data[offset + 12];
|
||||
|
||||
if (type == KPackE_Type.Reading)
|
||||
{
|
||||
string serialNr = account.ToString();
|
||||
foreach (var rr in RegReaders)
|
||||
{
|
||||
if (rr.SerialNr == serialNr)
|
||||
{
|
||||
double wmState = (double)reading;
|
||||
rr.WMStateReceived(wmState);
|
||||
EntryForm.WMStateReceived(serialNr, wmState);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastTelegramReceived = DateTime.Now;
|
||||
SendAcknowledgeNow();
|
||||
|
||||
/// Remove processed data from the buffer
|
||||
for (int i = 0; i < offset + KPackETelegramFrame.Length; i++) data.RemoveAt(0);
|
||||
|
||||
string s;
|
||||
if (type == KPackE_Type.Reading)
|
||||
{
|
||||
s = string.Format("{0} processed KPackE telegram: s/n = {1} reading = {2}", Name, account, reading);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = string.Format("{0} processed KPackE telegram: s/n = {1} {2}", Name, account, type);
|
||||
}
|
||||
Debug.WriteLine(s);
|
||||
log.Info(s);
|
||||
|
||||
break;
|
||||
}
|
||||
else if (DataFitFrame(data, offset, HartBeatTelegram))
|
||||
{
|
||||
/// acknowledge hart beat telegram
|
||||
lastTelegramReceived = DateTime.Now;
|
||||
SendAcknowledgeNow();
|
||||
|
||||
/// Remove processed data from the buffer
|
||||
for (int i = 0; i < offset + HartBeatTelegram.Length; i++) data.RemoveAt(0);
|
||||
|
||||
string s = string.Format("{0} processed HartBeat telegram", Name);
|
||||
Debug.WriteLine(s);
|
||||
log.Debug(s);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string ss = string.Format("{0}: {1} unprocessed bytes in the data buffer", Name, data.Count);
|
||||
Debug.WriteLine(ss);
|
||||
log.Debug(ss);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares received data bytes with a telegram frame.
|
||||
/// Zero bytes in the telegram frame are ignored, nonzero bytes must fit.
|
||||
/// </summary>
|
||||
/// <param name="data">Data bytes</param>
|
||||
/// <param name="offset">Offset of the fitted frame within data</param>
|
||||
/// <param name="telegramFrame">Telegram frame</param>
|
||||
/// <returns>true when data fit the frame</returns>
|
||||
bool DataFitFrame(IList<byte> data, int offset, byte[] telegramFrame)
|
||||
{
|
||||
if ((data.Count - offset) < telegramFrame.Length)
|
||||
{
|
||||
return false; /// Not enough data
|
||||
}
|
||||
|
||||
for (int i = 0; i < telegramFrame.Length; i++)
|
||||
{
|
||||
if ((telegramFrame[i] != 0) && (telegramFrame[i] != data[i + offset]))
|
||||
{
|
||||
return false; /// Data do not fit nonzero frame bytes (zero frame bytes are ignored)
|
||||
}
|
||||
}
|
||||
|
||||
return true; /// Data fit the telegram frame
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a sub-array
|
||||
/// </summary>
|
||||
public static byte[] SubArray(IList<byte> data, int index, int length)
|
||||
{
|
||||
if (data.Count < index + length) return new byte[1] { 0 };
|
||||
|
||||
byte[] result = new byte[length];
|
||||
for (int i = 0; i < length; i++) result[i] = data[index + i];
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Stop this device</summary>
|
||||
public void StopDevice()
|
||||
{
|
||||
if (serialPort != null)
|
||||
{
|
||||
//stopWorkerThread = true;
|
||||
//workerThread.Join(2000);
|
||||
serialPort.Close();
|
||||
serialPort = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopDevice2() { }
|
||||
}
|
||||
}
|
||||
53
TBF/BenchControl/RegisterReaders/KPackE/Radio/RadioCfg.cs
Normal file
53
TBF/BenchControl/RegisterReaders/KPackE/Radio/RadioCfg.cs
Normal file
@ -0,0 +1,53 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO.Ports;
|
||||
using System.Xml.Serialization;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.Radio
|
||||
{
|
||||
public class RadioCfg : ComponentCfgBase, Generic.IComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RadioCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new RadioCfgCtrl(); }
|
||||
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int ComPortNr;
|
||||
public int BaudRate;
|
||||
public Parity Parity;
|
||||
public int DataBits;
|
||||
public StopBits StopBits;
|
||||
public Handshake Handshake;
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
RadioCfg()
|
||||
{
|
||||
Name = "KPackE.Radio";
|
||||
ParentName = string.Empty;
|
||||
ComPortNr = 3;
|
||||
BaudRate = 38400;
|
||||
Parity = System.IO.Ports.Parity.None;
|
||||
DataBits = 8;
|
||||
StopBits = System.IO.Ports.StopBits.One;
|
||||
Handshake = System.IO.Ports.Handshake.None;
|
||||
}
|
||||
|
||||
public RadioCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Com{1}, {2}Bd, {3}-bits, parity={4}, stopBits={5}, {6}",
|
||||
Name, ComPortNr, BaudRate, DataBits, Parity, StopBits, Handshake);
|
||||
}
|
||||
}
|
||||
}
|
||||
171
TBF/BenchControl/RegisterReaders/KPackE/Radio/RadioCfgCtrl.cs
Normal file
171
TBF/BenchControl/RegisterReaders/KPackE/Radio/RadioCfgCtrl.cs
Normal file
@ -0,0 +1,171 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.IO.Ports;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.Radio
|
||||
{
|
||||
public partial class RadioCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
RadioCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as RadioCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public RadioCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
parityComboBox.Items.Add(Parity.None.ToString());
|
||||
parityComboBox.Items.Add(Parity.Even.ToString());
|
||||
parityComboBox.Items.Add(Parity.Odd.ToString());
|
||||
|
||||
stopBitsComboBox.Items.Add(StopBits.None.ToString());
|
||||
stopBitsComboBox.Items.Add(StopBits.One.ToString());
|
||||
stopBitsComboBox.Items.Add(StopBits.OnePointFive.ToString());
|
||||
stopBitsComboBox.Items.Add(StopBits.Two.ToString());
|
||||
|
||||
handshakeComboBox.Items.Add(Handshake.None.ToString());
|
||||
handshakeComboBox.Items.Add(Handshake.RequestToSend.ToString());
|
||||
handshakeComboBox.Items.Add(Handshake.XOnXOff.ToString());
|
||||
}
|
||||
|
||||
int GetParityIx(Parity par)
|
||||
{
|
||||
if (par == Parity.None) return 0;
|
||||
if (par == Parity.Even) return 0;
|
||||
if (par == Parity.Odd) return 0;
|
||||
return -1;
|
||||
}
|
||||
Parity GetParity(string str)
|
||||
{
|
||||
if (str.Equals(Parity.None.ToString())) return Parity.None;
|
||||
if (str.Equals(Parity.Even.ToString())) return Parity.Even;
|
||||
if (str.Equals(Parity.Odd.ToString())) return Parity.Odd;
|
||||
return (Parity)(-1);
|
||||
}
|
||||
|
||||
int GetStopBitsIx(StopBits sb)
|
||||
{
|
||||
if (sb == StopBits.None) return 0;
|
||||
if (sb == StopBits.One) return 1;
|
||||
if (sb == StopBits.OnePointFive) return 2;
|
||||
if (sb == StopBits.Two) return 3;
|
||||
return -1;
|
||||
}
|
||||
StopBits GetStopBits(string str)
|
||||
{
|
||||
if (str.Equals(StopBits.None.ToString())) return StopBits.None;
|
||||
if (str.Equals(StopBits.One.ToString())) return StopBits.One;
|
||||
if (str.Equals(StopBits.OnePointFive.ToString())) return StopBits.OnePointFive;
|
||||
if (str.Equals(StopBits.Two.ToString())) return StopBits.Two;
|
||||
return (StopBits)(-1);
|
||||
}
|
||||
|
||||
int GetHandshakeIx(Handshake par)
|
||||
{
|
||||
if (par == Handshake.None) return 0;
|
||||
if (par == Handshake.RequestToSend) return 0;
|
||||
if (par == Handshake.XOnXOff) return 0;
|
||||
return -1;
|
||||
}
|
||||
Handshake GetHandshake(string str)
|
||||
{
|
||||
if (str.Equals(Handshake.None.ToString())) return Handshake.None;
|
||||
if (str.Equals(Handshake.RequestToSend.ToString())) return Handshake.RequestToSend;
|
||||
if (str.Equals(Handshake.XOnXOff.ToString())) return Handshake.XOnXOff;
|
||||
return (Handshake)(-1);
|
||||
}
|
||||
|
||||
private void ModbusCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
nameLabel.Text = Strings.Name;
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
comPortNrTextBox.Text = config.ComPortNr.ToString();
|
||||
baudRateTextBox.Text = config.BaudRate.ToString();
|
||||
parityComboBox.Text = config.Parity.ToString();
|
||||
dataBitsTextBox.Text = config.DataBits.ToString();
|
||||
stopBitsComboBox.Text = config.StopBits.ToString();
|
||||
handshakeComboBox.Text = config.Handshake.ToString();
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
comPortNrTextBox.Enabled = true;
|
||||
baudRateTextBox.Enabled = true;
|
||||
parityComboBox.Enabled = true;
|
||||
dataBitsTextBox.Enabled = true;
|
||||
stopBitsComboBox.Enabled = true;
|
||||
handshakeComboBox.Enabled = true;
|
||||
}
|
||||
|
||||
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;
|
||||
config.ComPortNr = int.Parse(comPortNrTextBox.Text);
|
||||
config.BaudRate = int.Parse(baudRateTextBox.Text);
|
||||
config.Parity = GetParity(parityComboBox.SelectedItem.ToString());
|
||||
config.DataBits = int.Parse(dataBitsTextBox.Text);
|
||||
config.StopBits = GetStopBits(stopBitsComboBox.SelectedItem.ToString());
|
||||
config.Handshake = GetHandshake(handshakeComboBox.SelectedItem.ToString());
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
int dummy;
|
||||
if (!int.TryParse(comPortNrTextBox.Text, out dummy) || dummy < 1 || dummy > 999)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Serial Port Number' is not valid";
|
||||
}
|
||||
|
||||
if (!int.TryParse(baudRateTextBox.Text, out dummy) || dummy < 150 || dummy > 115200)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Baud Rate' is not valid";
|
||||
}
|
||||
|
||||
if (!int.TryParse(dataBitsTextBox.Text, out dummy) || dummy < 7 || dummy > 8)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Data Bits' is not valid";
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
229
TBF/BenchControl/RegisterReaders/KPackE/Radio/RadioCfgCtrl.designer.cs
generated
Normal file
229
TBF/BenchControl/RegisterReaders/KPackE/Radio/RadioCfgCtrl.designer.cs
generated
Normal file
@ -0,0 +1,229 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.Radio
|
||||
{
|
||||
partial class RadioCfgCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.comPortNrTextBox = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.baudRateLabel = new System.Windows.Forms.Label();
|
||||
this.baudRateTextBox = new System.Windows.Forms.TextBox();
|
||||
this.partityLabel = new System.Windows.Forms.Label();
|
||||
this.dataBitsLabel = new System.Windows.Forms.Label();
|
||||
this.dataBitsTextBox = new System.Windows.Forms.TextBox();
|
||||
this.stopBitsLabel = new System.Windows.Forms.Label();
|
||||
this.handshakeLabel = new System.Windows.Forms.Label();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.classNameLabel = new System.Windows.Forms.Label();
|
||||
this.parityComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.stopBitsComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.handshakeComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comPortNrTextBox
|
||||
//
|
||||
this.comPortNrTextBox.Enabled = false;
|
||||
this.comPortNrTextBox.Location = new System.Drawing.Point(140, 52);
|
||||
this.comPortNrTextBox.Name = "comPortNrTextBox";
|
||||
this.comPortNrTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.comPortNrTextBox.TabIndex = 4;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(29, 55);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(98, 13);
|
||||
this.label1.TabIndex = 3;
|
||||
this.label1.Text = "Serial Port Number:";
|
||||
//
|
||||
// baudRateLabel
|
||||
//
|
||||
this.baudRateLabel.AutoSize = true;
|
||||
this.baudRateLabel.Location = new System.Drawing.Point(29, 79);
|
||||
this.baudRateLabel.Name = "baudRateLabel";
|
||||
this.baudRateLabel.Size = new System.Drawing.Size(58, 13);
|
||||
this.baudRateLabel.TabIndex = 5;
|
||||
this.baudRateLabel.Text = "Baud Rate";
|
||||
//
|
||||
// baudRateTextBox
|
||||
//
|
||||
this.baudRateTextBox.Enabled = false;
|
||||
this.baudRateTextBox.Location = new System.Drawing.Point(140, 76);
|
||||
this.baudRateTextBox.Name = "baudRateTextBox";
|
||||
this.baudRateTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.baudRateTextBox.TabIndex = 6;
|
||||
//
|
||||
// partityLabel
|
||||
//
|
||||
this.partityLabel.AutoSize = true;
|
||||
this.partityLabel.Location = new System.Drawing.Point(29, 103);
|
||||
this.partityLabel.Name = "partityLabel";
|
||||
this.partityLabel.Size = new System.Drawing.Size(33, 13);
|
||||
this.partityLabel.TabIndex = 7;
|
||||
this.partityLabel.Text = "Parity";
|
||||
//
|
||||
// dataBitsLabel
|
||||
//
|
||||
this.dataBitsLabel.AutoSize = true;
|
||||
this.dataBitsLabel.Location = new System.Drawing.Point(29, 127);
|
||||
this.dataBitsLabel.Name = "dataBitsLabel";
|
||||
this.dataBitsLabel.Size = new System.Drawing.Size(50, 13);
|
||||
this.dataBitsLabel.TabIndex = 9;
|
||||
this.dataBitsLabel.Text = "Data Bits";
|
||||
//
|
||||
// dataBitsTextBox
|
||||
//
|
||||
this.dataBitsTextBox.Enabled = false;
|
||||
this.dataBitsTextBox.Location = new System.Drawing.Point(140, 124);
|
||||
this.dataBitsTextBox.Name = "dataBitsTextBox";
|
||||
this.dataBitsTextBox.Size = new System.Drawing.Size(34, 20);
|
||||
this.dataBitsTextBox.TabIndex = 10;
|
||||
//
|
||||
// stopBitsLabel
|
||||
//
|
||||
this.stopBitsLabel.AutoSize = true;
|
||||
this.stopBitsLabel.Location = new System.Drawing.Point(29, 151);
|
||||
this.stopBitsLabel.Name = "stopBitsLabel";
|
||||
this.stopBitsLabel.Size = new System.Drawing.Size(49, 13);
|
||||
this.stopBitsLabel.TabIndex = 11;
|
||||
this.stopBitsLabel.Text = "Stop Bits";
|
||||
//
|
||||
// handshakeLabel
|
||||
//
|
||||
this.handshakeLabel.AutoSize = true;
|
||||
this.handshakeLabel.Location = new System.Drawing.Point(29, 175);
|
||||
this.handshakeLabel.Name = "handshakeLabel";
|
||||
this.handshakeLabel.Size = new System.Drawing.Size(62, 13);
|
||||
this.handshakeLabel.TabIndex = 13;
|
||||
this.handshakeLabel.Text = "Handshake";
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(140, 28);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(30, 31);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 1;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(137, 7);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
this.classNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// parityComboBox
|
||||
//
|
||||
this.parityComboBox.Enabled = false;
|
||||
this.parityComboBox.FormattingEnabled = true;
|
||||
this.parityComboBox.Location = new System.Drawing.Point(140, 100);
|
||||
this.parityComboBox.Name = "parityComboBox";
|
||||
this.parityComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.parityComboBox.TabIndex = 8;
|
||||
//
|
||||
// stopBitsComboBox
|
||||
//
|
||||
this.stopBitsComboBox.Enabled = false;
|
||||
this.stopBitsComboBox.FormattingEnabled = true;
|
||||
this.stopBitsComboBox.Location = new System.Drawing.Point(140, 148);
|
||||
this.stopBitsComboBox.Name = "stopBitsComboBox";
|
||||
this.stopBitsComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.stopBitsComboBox.TabIndex = 12;
|
||||
//
|
||||
// handshakeComboBox
|
||||
//
|
||||
this.handshakeComboBox.Enabled = false;
|
||||
this.handshakeComboBox.FormattingEnabled = true;
|
||||
this.handshakeComboBox.Location = new System.Drawing.Point(140, 172);
|
||||
this.handshakeComboBox.Name = "handshakeComboBox";
|
||||
this.handshakeComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.handshakeComboBox.TabIndex = 14;
|
||||
//
|
||||
// AmbientCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.Controls.Add(this.handshakeComboBox);
|
||||
this.Controls.Add(this.stopBitsComboBox);
|
||||
this.Controls.Add(this.parityComboBox);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Controls.Add(this.handshakeLabel);
|
||||
this.Controls.Add(this.stopBitsLabel);
|
||||
this.Controls.Add(this.dataBitsTextBox);
|
||||
this.Controls.Add(this.dataBitsLabel);
|
||||
this.Controls.Add(this.partityLabel);
|
||||
this.Controls.Add(this.baudRateTextBox);
|
||||
this.Controls.Add(this.baudRateLabel);
|
||||
this.Controls.Add(this.comPortNrTextBox);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "AmbientCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 240);
|
||||
this.Load += new System.EventHandler(this.ModbusCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox comPortNrTextBox;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label baudRateLabel;
|
||||
private System.Windows.Forms.TextBox baudRateTextBox;
|
||||
private System.Windows.Forms.Label partityLabel;
|
||||
private System.Windows.Forms.Label dataBitsLabel;
|
||||
private System.Windows.Forms.TextBox dataBitsTextBox;
|
||||
private System.Windows.Forms.Label stopBitsLabel;
|
||||
private System.Windows.Forms.Label handshakeLabel;
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label classNameLabel;
|
||||
private System.Windows.Forms.ComboBox parityComboBox;
|
||||
private System.Windows.Forms.ComboBox stopBitsComboBox;
|
||||
private System.Windows.Forms.ComboBox handshakeComboBox;
|
||||
|
||||
}
|
||||
}
|
||||
120
TBF/BenchControl/RegisterReaders/KPackE/Radio/RadioCfgCtrl.resx
Normal file
120
TBF/BenchControl/RegisterReaders/KPackE/Radio/RadioCfgCtrl.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -0,0 +1,26 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System.Collections.Generic;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader
|
||||
{
|
||||
public class Factory : IComponentFactory
|
||||
{
|
||||
public string ClassName { get { return this.GetType().Namespace.Substring(17); } }
|
||||
|
||||
public void ResetStaticProperties() { RegisterReader.ResetStaticProperties(); }
|
||||
|
||||
public IComponent DummyComponent() { return new RegisterReader(); }
|
||||
|
||||
public IComponent GetComponent(IComponentCfg cfg, IList<IComponent> components) { return new RegisterReader(cfg, components); }
|
||||
|
||||
public IComponentCfg DefaultConfig() { return new RegisterReaderCfg(this); }
|
||||
|
||||
public IComponentCfg CmpntCfgFromCmpntEntity(Config.Entities.Component component)
|
||||
{
|
||||
return ComponentCfgBase.CreateFromDbEntity(RegisterReaderCfg.Serializer, component, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml.Serialization;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
using TBF.Resources;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader
|
||||
{
|
||||
public class ProcedureParams : ProcedureParamsBase, IParamsProvider, IProcedureParams
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(ProcedureParams) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public double PulsesPerLtr; /// Target low limit of the flow increase or decrease
|
||||
|
||||
public override void InitializeAll()
|
||||
{
|
||||
PulsesPerLtr = 1.0;
|
||||
}
|
||||
|
||||
string[] paramNames = new string[]
|
||||
{
|
||||
Strings.PulsesPerLtr,
|
||||
};
|
||||
public override string ParamName(int i) { return paramNames[i]; }
|
||||
public override int ParamsCount() { return paramNames.Length; }
|
||||
|
||||
public override string ToString(int i)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: return PulsesPerLtr.ToString();
|
||||
default: return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieves parameters from UI controls
|
||||
public CfgUpdateFlags UpdateParam(int i, string strValue)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: PulsesPerLtr = Utils.ParseUDouble(strValue); return CfgUpdateFlags.None;
|
||||
default: return CfgUpdateFlags.None;
|
||||
}
|
||||
}
|
||||
|
||||
/// Verifies whether strings in UI controls represent valid parameters
|
||||
public bool ValidateParam(int i, string strValue, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
|
||||
double dummy;
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
if (Utils.TryParseUDouble(strValue, out dummy)) return true;
|
||||
break;
|
||||
default:
|
||||
message = "Invalid index";
|
||||
return false;
|
||||
}
|
||||
|
||||
message = ParamName(i) + " is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
void CopyContentTo(ProcedureParams prms)
|
||||
{
|
||||
prms.PulsesPerLtr = this.PulsesPerLtr;
|
||||
}
|
||||
|
||||
public IParamsProvider Clone()
|
||||
{
|
||||
ProcedureParams pars = new ProcedureParams();
|
||||
CopyContentTo(pars);
|
||||
return pars;
|
||||
}
|
||||
|
||||
public override void UpdateFromDbEntity(ComponentProcedure dbEntity)
|
||||
{
|
||||
if (dbEntity == null) return;
|
||||
try
|
||||
{
|
||||
ProcedureParams tmp = Serializer.Deserialize(new StringReader(dbEntity.Parameters)) as ProcedureParams;
|
||||
|
||||
procedureParamsEntity = dbEntity;
|
||||
componentName = dbEntity.CmpntName;
|
||||
procedure = dbEntity.Procedure;
|
||||
|
||||
if (tmp != null) tmp.CopyContentTo(this);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ProcedureParams()
|
||||
{
|
||||
}
|
||||
|
||||
public ProcedureParams(bool initialize)
|
||||
{
|
||||
if (initialize) InitializeAll();
|
||||
}
|
||||
|
||||
public ProcedureParams(ComponentProcedure procedureParamsEntity, string componentName, Procedure procedure)
|
||||
{
|
||||
this.procedureParamsEntity = procedureParamsEntity;
|
||||
this.componentName = componentName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,139 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using TBF.Boxes;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader
|
||||
{
|
||||
public class RegisterReader : ComponentBase, GenericDevices.IRegisterReader, IOperation
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(RegisterReader));
|
||||
public override string ToString() { return string.Format("KPackE.RegisterReader({0})", Cfg.ToString(1)); }
|
||||
|
||||
readonly RegisterReaderCfg registerReaderCfg;
|
||||
readonly Radio.Radio radio;
|
||||
readonly TBF.BenchControl.Elde.ControlBoardDev controlBoard;
|
||||
|
||||
|
||||
public Config.Entities.RegisterReaderType RegisterReaderType { get { return Config.Entities.RegisterReaderType.Manual; } }
|
||||
public double PulsesPerLtr { get { return registerReaderCfg.ProcParams.PulsesPerLtr; } }
|
||||
public double LtrsPerPulse { get { return (PulsesPerLtr <= float.Epsilon) ? 1.0 : (1 / PulsesPerLtr); } }
|
||||
|
||||
/// <summary>
|
||||
/// Writen to by DataEntryForRadio component
|
||||
/// </summary>
|
||||
public string SerialNr; /// Serial number of the respective water meter
|
||||
public bool IsEndOfTest; /// false at the beginning oftest, true at the end of test
|
||||
|
||||
/// <summary>
|
||||
/// Called by Radio when data for SerialNr were received
|
||||
/// </summary>
|
||||
/// <param name="wmState"></param>
|
||||
public void WMStateReceived(double wmState)
|
||||
{
|
||||
if (IsEndOfTest)
|
||||
{
|
||||
endWMState = wmState;
|
||||
}
|
||||
else
|
||||
{
|
||||
beginWMState = wmState;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double beginWMState;
|
||||
public double BeginWMState
|
||||
{
|
||||
get { return beginWMState; }
|
||||
set { beginWMState = value; }
|
||||
}
|
||||
|
||||
double endWMState;
|
||||
public double EndWMState
|
||||
{
|
||||
get { return endWMState; }
|
||||
set { endWMState = value; }
|
||||
}
|
||||
|
||||
public double WMVolume { get { return endWMState - beginWMState; } }
|
||||
|
||||
public int WMPulses { get { return (int)(WMVolume / LtrsPerPulse); } }
|
||||
|
||||
int wmRefPulses;
|
||||
public int WMRefPulses { get { return wmRefPulses; } }
|
||||
|
||||
|
||||
|
||||
public RegisterReader()
|
||||
{
|
||||
}
|
||||
|
||||
public RegisterReader(Generic.IComponentCfg cfg, IList<Generic.IComponent> components)
|
||||
: base(cfg)
|
||||
{
|
||||
registerReaderCfg = cfg as RegisterReaderCfg;
|
||||
|
||||
/// Control board is used to read reference flowmeter pulses
|
||||
radio = (Radio.Radio)TbfComponents.FindComponent(cfg.ParentName, components);
|
||||
if (radio == null) throw new Exception(string.Format("Cannot find a parent of {0}", Name));
|
||||
|
||||
controlBoard = StateMachine.ControlBoard;
|
||||
|
||||
Clear();
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
log.DebugFormat("{0}:Clear()", Name);
|
||||
beginWMState = 0;
|
||||
endWMState = 0;
|
||||
wmRefPulses = 0;
|
||||
}
|
||||
|
||||
|
||||
public void TestCompleted()
|
||||
{
|
||||
log.DebugFormat("{0}:TestCompleted()", Name);
|
||||
ReadPulses();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events: Event.ReadRegisterDone
|
||||
/// </summary>
|
||||
/// <returns>ReadWaterMeter instance reference casted to IOperaton</returns>
|
||||
public IOperation ReadRegisterOp()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
private void ReadPulses()
|
||||
{
|
||||
wmRefPulses = (controlBoard != null) ? controlBoard.EtPulses(0) : 0;
|
||||
}
|
||||
|
||||
/// <summary>Start this operation</summary>
|
||||
public void Start()
|
||||
{
|
||||
ReadPulses();
|
||||
}
|
||||
|
||||
/// <summary>Run this operation</summary>
|
||||
/// <returns>eventDone</returns>
|
||||
public Event Run()
|
||||
{
|
||||
ReadPulses();
|
||||
return Event.ReadRegisterDone;
|
||||
}
|
||||
|
||||
/// <summary>Stop this operation</summary>
|
||||
public void Stop()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader
|
||||
{
|
||||
public class RegisterReaderCfg : ComponentCfgBase, Generic.IChildComponentCfg
|
||||
{
|
||||
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(RegisterReaderCfg) })[0];
|
||||
public override XmlSerializer GetSerializer() { return Serializer; }
|
||||
|
||||
public IComponentCfgCtrl GetControl() { return new RegisterReaderCfgCtrl(); }
|
||||
|
||||
/// <summary> Procedure parameters </summary>
|
||||
[XmlIgnore]
|
||||
public ProcedureParams ProcParams;
|
||||
public override IParamsProvider GetRuntimeProcParamsProvider() { return ProcParams; }
|
||||
public override IParamsProvider CreateProcParamsProvider() { return new ProcedureParams(true); }
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
RegisterReaderCfg()
|
||||
{
|
||||
Name = "RF-Register";
|
||||
ParentName = "Radio";
|
||||
ProcParams = new ProcedureParams(true);
|
||||
}
|
||||
|
||||
public RegisterReaderCfg(IComponentFactory factory)
|
||||
: this()
|
||||
{
|
||||
this.Factory = factory;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, Parent={1}",
|
||||
Name,
|
||||
(string.IsNullOrEmpty(ParentName) ? "-" : ParentName));
|
||||
}
|
||||
}
|
||||
}
|
||||
110
TBF/BenchControl/RegisterReaders/KPackE/RegisterReader/RegisterReaderCfgCtrl.Designer.cs
generated
Normal file
110
TBF/BenchControl/RegisterReaders/KPackE/RegisterReader/RegisterReaderCfgCtrl.Designer.cs
generated
Normal file
@ -0,0 +1,110 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader
|
||||
{
|
||||
partial class RegisterReaderCfgCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.parentNameLabel = new System.Windows.Forms.Label();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.componentNameLabel = new System.Windows.Forms.Label();
|
||||
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// parentNameLabel
|
||||
//
|
||||
this.parentNameLabel.AutoSize = true;
|
||||
this.parentNameLabel.Location = new System.Drawing.Point(26, 96);
|
||||
this.parentNameLabel.Name = "parentNameLabel";
|
||||
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
|
||||
this.parentNameLabel.TabIndex = 3;
|
||||
this.parentNameLabel.Text = "Parent Name";
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(136, 67);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(26, 70);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 1;
|
||||
this.nameLabel.Text = "Name";
|
||||
//
|
||||
// componentNameLabel
|
||||
//
|
||||
this.componentNameLabel.AutoSize = true;
|
||||
this.componentNameLabel.Location = new System.Drawing.Point(133, 43);
|
||||
this.componentNameLabel.Name = "componentNameLabel";
|
||||
this.componentNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.componentNameLabel.TabIndex = 0;
|
||||
this.componentNameLabel.Text = "ComonentName";
|
||||
//
|
||||
// parentNameComboBox
|
||||
//
|
||||
this.parentNameComboBox.Enabled = false;
|
||||
this.parentNameComboBox.FormattingEnabled = true;
|
||||
this.parentNameComboBox.Location = new System.Drawing.Point(136, 93);
|
||||
this.parentNameComboBox.Name = "parentNameComboBox";
|
||||
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.parentNameComboBox.TabIndex = 4;
|
||||
//
|
||||
// RegisterReaderCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.parentNameComboBox);
|
||||
this.Controls.Add(this.parentNameLabel);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.componentNameLabel);
|
||||
this.Name = "RegisterReaderCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Load += new System.EventHandler(this.RegisterReaderCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label parentNameLabel;
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.Label componentNameLabel;
|
||||
private System.Windows.Forms.ComboBox parentNameComboBox;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
///
|
||||
/// Copyright (c) 2018 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Config.Entities;
|
||||
using TBF.BenchControl.Generic;
|
||||
|
||||
namespace TBF.BenchControl.RegisterReaders.KPackE.RegisterReader
|
||||
{
|
||||
public partial class RegisterReaderCfgCtrl : UserControl, IComponentCfgCtrl
|
||||
{
|
||||
ComponentParametersDlg parent;
|
||||
|
||||
public bool ShowMore { get { return false; } }
|
||||
|
||||
RegisterReaderCfg config;
|
||||
public IComponentCfg Config
|
||||
{
|
||||
get { return config as IComponentCfg; }
|
||||
set
|
||||
{
|
||||
config = value as RegisterReaderCfg;
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
|
||||
public RegisterReaderCfgCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void RegisterReaderCfgCtrl_Load(object sender, EventArgs e)
|
||||
{
|
||||
parent = ParentForm as ComponentParametersDlg;
|
||||
if (parent == null) return;
|
||||
|
||||
if (parent.TbfComponents != null)
|
||||
{
|
||||
foreach (var cmpnt in parent.TbfComponents)
|
||||
{
|
||||
if (TbfComponents.CmpntFactoryFromClassName(cmpnt.ClassName) is Radio.Factory)
|
||||
{
|
||||
parentNameComboBox.Items.Add(cmpnt.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Redraw();
|
||||
}
|
||||
|
||||
public void Closing()
|
||||
{
|
||||
}
|
||||
|
||||
void Redraw()
|
||||
{
|
||||
if (config == null) return; /// Control was not loaded, settings were not changed
|
||||
|
||||
componentNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
parentNameComboBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
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;
|
||||
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@ -37,7 +37,8 @@ namespace TBF.BenchControl
|
||||
Factories.Add(new DataEntry.Standard48.Factory());
|
||||
Factories.Add(new DataEntry.Standard48.FactoryNoStartEnd());
|
||||
Factories.Add(new DataEntry.StandardCamera.Factory());
|
||||
Factories.Add(new Dummy.Balance.Factory());
|
||||
Factories.Add(new RegisterReaders.KPackE.DataEntryForRadio.Factory()); /// DataEntry for KPackE radio
|
||||
Factories.Add(new Dummy.Balance.Factory());
|
||||
Factories.Add(new Dummy.Diverter.Factory());
|
||||
Factories.Add(new Dummy.FlowMeter.Factory());
|
||||
Factories.Add(new Dummy.RegulValve.Factory());
|
||||
@ -153,6 +154,8 @@ namespace TBF.BenchControl
|
||||
Factories.Add(new Elde.FixedStartRegisterReader.RegisterReaderFactory()); /// 'RegisterReader for standing start/stop'
|
||||
Factories.Add(new TestMethods.iPerlCommunication.iPerlHead.Factory()); /// 'RegisterReader for iPerl'
|
||||
Factories.Add(new RegisterReaders.SerialStream.Factory()); /// 'RegisterReader for generic serial stream'
|
||||
Factories.Add(new RegisterReaders.KPackE.RegisterReader.Factory()); /// KPackE register reader
|
||||
Factories.Add(new RegisterReaders.KPackE.Radio.Factory()); /// Radio for KPackE register readers
|
||||
Factories.Add(new Elde.RegulValve.RegulValveFactory());
|
||||
Factories.Add(new Elde.RegulValveCoax.Factory());
|
||||
Factories.Add(new Elde.RegulValveTandem.RegulValveTandemFactory());
|
||||
|
||||
@ -664,6 +664,11 @@ namespace TBF
|
||||
(cfg as IChildComponentCfg).ParentName = "CB";
|
||||
return true;
|
||||
}
|
||||
else if (cfg is BenchControl.RegisterReaders.KPackE.RegisterReader.RegisterReaderCfg)
|
||||
{
|
||||
(cfg as IChildComponentCfg).ParentName = "KPackE.Radio";
|
||||
return true;
|
||||
}
|
||||
else if (cfg is BenchControl.TestMethods.iPerlCommunication.iPerlHead.IperlHeadCfg)
|
||||
{
|
||||
return true;
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.1114.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1114.0")]
|
||||
[assembly: AssemblyVersion("2.18.1115.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1115.0")]
|
||||
|
||||
@ -549,6 +549,7 @@
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Elde\ValveEx\ValveFactory.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\ICalibInfoCfg.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IReceivesDataFromRadio.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IStartInfoReader.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IHart.cs" />
|
||||
<Compile Include="BenchControl\GenericDevices\IHasTestName.cs" />
|
||||
@ -946,6 +947,46 @@
|
||||
<DependentUpon>WriterCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Output\SensusTestInfo.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\CycleBeginningForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\CycleBeginningForm.designer.cs">
|
||||
<DependentUpon>CycleBeginningForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\EntryFormCfg.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\EntryFormCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\EntryFormCfgCtrl.designer.cs">
|
||||
<DependentUpon>EntryFormCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\EntryForm.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\Factory.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\TestStartEndForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\TestStartEndForm.designer.cs">
|
||||
<DependentUpon>TestStartEndForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\Radio\Factory.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\Radio\Radio.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\Radio\RadioCfg.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\Radio\RadioCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\Radio\RadioCfgCtrl.designer.cs">
|
||||
<DependentUpon>RadioCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\RegisterReader\Factory.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\RegisterReader\ProcedureParams.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\RegisterReader\RegisterReader.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\RegisterReader\RegisterReaderCfg.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\RegisterReader\RegisterReaderCfgCtrl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\KPackE\RegisterReader\RegisterReaderCfgCtrl.designer.cs">
|
||||
<DependentUpon>RegisterReaderCfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\RegisterReaders\SerialStream\Enums.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\SerialStream\Factory.cs" />
|
||||
<Compile Include="BenchControl\RegisterReaders\SerialStream\FrameFormat.cs" />
|
||||
@ -2605,6 +2646,21 @@
|
||||
<EmbeddedResource Include="BenchControl\Output\FileWriters\Basic\WriterCfgCtrl.resx">
|
||||
<DependentUpon>WriterCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\CycleBeginningForm.resx">
|
||||
<DependentUpon>CycleBeginningForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\EntryFormCfgCtrl.resx">
|
||||
<DependentUpon>EntryFormCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\RegisterReaders\KPackE\DataEntryForRadio\TestStartEndForm.resx">
|
||||
<DependentUpon>TestStartEndForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\RegisterReaders\KPackE\Radio\RadioCfgCtrl.resx">
|
||||
<DependentUpon>RadioCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\RegisterReaders\KPackE\RegisterReader\RegisterReaderCfgCtrl.resx">
|
||||
<DependentUpon>RegisterReaderCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="BenchControl\RegisterReaders\SerialStream\SerialStreamCfgCtrl.resx">
|
||||
<DependentUpon>SerialStreamCfgCtrl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
||||
@ -87,7 +87,7 @@ namespace TBF
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the checksum from a data telegram (an array of bytes).
|
||||
/// A complete telegram including one bytes reserved for the checksum
|
||||
/// A complete telegram including one byte reserved for the checksum
|
||||
/// must be supplied as an argument.
|
||||
/// </summary>
|
||||
/// <param name="data">Data telegram</param>
|
||||
@ -175,22 +175,46 @@ namespace TBF
|
||||
|
||||
|
||||
|
||||
public static string LogTelegram(string intro, byte[] data)
|
||||
public static string LogTelegram(string intro, byte[] data, int from = 0, int len = -1)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder(80);
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder(256);
|
||||
|
||||
sb.Append(intro);
|
||||
sb.Append(data.Length.ToString());
|
||||
int length = (len >= 0) ? len : (data.Length - from);
|
||||
|
||||
sb.Append(intro);
|
||||
sb.Append(length.ToString());
|
||||
sb.Append(" bytes:");
|
||||
foreach (var d in data)
|
||||
|
||||
for (int i = from; i < from + length; i++)
|
||||
{
|
||||
byte b = data[i];
|
||||
sb.Append(" ");
|
||||
sb.Append(((int)d).ToString("X2"));
|
||||
sb.Append(((int)b).ToString("X2"));
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string LogTelegram(string intro, IList<byte> data, int from = 0, int len = -1)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder(256);
|
||||
|
||||
int length = (len >= 0) ? len : (data.Count - from);
|
||||
|
||||
sb.Append(intro);
|
||||
sb.Append(length.ToString());
|
||||
sb.Append(" bytes:");
|
||||
|
||||
for (int i = from; i < from + length; i++)
|
||||
{
|
||||
byte b = data[i];
|
||||
sb.Append(" ");
|
||||
sb.Append(((int)b).ToString("X2"));
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static string LogTelegram(string intro, string data)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user