DataEntry.Uni : Compound meters support.
This commit is contained in:
parent
eaf60f3292
commit
900a2d660c
@ -29,7 +29,9 @@ namespace TBF.Rig.DataEntry
|
||||
[Description("Radio address")] RadioAddress,
|
||||
[Description("Year of calibration")] YearOfCalibration,
|
||||
[Description("Start state")] StartState,
|
||||
[Description("Start state aux")] StartStateAux,
|
||||
[Description("End state")] EndState,
|
||||
[Description("End state aux")] EndStateAux,
|
||||
[Description("Archive path")] ArchivePath,
|
||||
[Description("WM Order")] WmOrder,
|
||||
[Description("Batch order")] BatchOrder,
|
||||
|
||||
@ -15,18 +15,20 @@ namespace TBF.Rig.DataEntry
|
||||
switch (content)
|
||||
{
|
||||
default:
|
||||
case Ct.None: return string.Empty;
|
||||
case Ct.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty;
|
||||
case Ct.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty;
|
||||
case Ct.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty;
|
||||
case Ct.None: return string.Empty;
|
||||
case Ct.SerialNr: return (!wm.Disabled && wm.SerialNr != null) ? wm.SerialNr : string.Empty;
|
||||
case Ct.SerialNrAux: return (!wm.Disabled && wm.SerialNrAux != null) ? wm.SerialNrAux : string.Empty;
|
||||
case Ct.RadioAddress: return (!wm.Disabled && wm.RadioAddress != null) ? wm.RadioAddress : string.Empty;
|
||||
case Ct.YearOfCalibration: return (!wm.Disabled) ? wm.YearOfProduction.ToString() : string.Empty;
|
||||
case Ct.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
|
||||
case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
|
||||
case Ct.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty;
|
||||
case Ct.StartState: return (!wm.Disabled && wm.GetStartState() != null) ? wm.GetStartState() : string.Empty;
|
||||
case Ct.StartStateAux: return string.Empty;
|
||||
case Ct.EndState: return (!wm.Disabled && wm.EndState != null) ? wm.EndState : string.Empty;
|
||||
case Ct.EndStateAux: return (!wm.Disabled && wm.GetEndStateAux() != null) ? wm.GetEndStateAux() : string.Empty;
|
||||
case Ct.ArchivePath: return (!wm.Disabled && wm.ArchivePath != null) ? wm.ArchivePath : string.Empty;
|
||||
|
||||
case Ct.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty;
|
||||
case Ct.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
|
||||
case Ct.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
|
||||
case Ct.WmOrder: return (!wm.Disabled && wm.PurchaseOrder != null) ? wm.PurchaseOrder : string.Empty;
|
||||
case Ct.BatchOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
|
||||
case Ct.BatchAndWmOrder: return (wm.Batch != null && wm.Batch.PurchaseOrder != null) ? wm.Batch.PurchaseOrder : string.Empty;
|
||||
|
||||
case Ct.WmRemark: return (!wm.Disabled && wm.Remark != null) ? wm.Remark : string.Empty;
|
||||
case Ct.BatchRemark: return (wm.Batch != null && wm.Batch.Remark != null) ? wm.Batch.Remark : string.Empty;
|
||||
@ -53,7 +55,9 @@ namespace TBF.Rig.DataEntry
|
||||
case Ct.RadioAddress: wm.RadioAddress = value; return;
|
||||
case Ct.YearOfCalibration: if (int.TryParse(value, out year)) wm.YearOfProduction = year; return;
|
||||
case Ct.StartState: wm.SetStartState(value); return;
|
||||
case Ct.StartStateAux: return;
|
||||
case Ct.EndState: wm.EndState = value; return;
|
||||
case Ct.EndStateAux: wm.SetEndStateAux(value); return;
|
||||
case Ct.ArchivePath: wm.ArchivePath = value; return;
|
||||
|
||||
case Ct.WmOrder:
|
||||
|
||||
@ -82,13 +82,13 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
/// <param name="commonItems">Common items displayed in the upper part of the form</param>
|
||||
/// <param name="colItems">Water meter items displayed in columns (in the matrix in the main part of the form)</param>
|
||||
/// <param name="isEnd">true = This form is displayed at the end of cycle</param>
|
||||
public CycleBgEnForm(IList<WaterMeter> waterMeters, int lineSize, string title, FontSz sz, bool isLrOrder, bool isCameraPicture,
|
||||
public CycleBgEnForm(IList<WaterMeter> waterMeters, int _lineSize, string title, FontSz sz, bool isLrOrder, bool isCameraPicture,
|
||||
string formCloseKeys, IList<DEItem> commonItems, IList<DEItem> colItems, bool isEnd = false)
|
||||
: this()
|
||||
{
|
||||
/// Arguments
|
||||
this.WaterMeters = waterMeters;
|
||||
this.lineSize = lineSize;
|
||||
this.lineSize = Math.Min(waterMeters.Count, _lineSize);
|
||||
this.Text = !string.IsNullOrEmpty(title) ? title : string.Empty;
|
||||
this.sz = sz;
|
||||
this.isLrOrder = isLrOrder;
|
||||
|
||||
@ -557,7 +557,9 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
Ct.RadioAddress.ToDescription(),
|
||||
Ct.YearOfCalibration.ToDescription(),
|
||||
Ct.StartState.ToDescription(),
|
||||
Ct.StartStateAux.ToDescription(),
|
||||
Ct.EndState.ToDescription(),
|
||||
Ct.EndStateAux.ToDescription(),
|
||||
Ct.ArchivePath.ToDescription(),
|
||||
Ct.WmOrder.ToDescription(),
|
||||
Ct.WmRemark.ToDescription(),
|
||||
|
||||
@ -281,9 +281,10 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
}
|
||||
}
|
||||
|
||||
bool isCompound = waterMeters[0].Batch.Compound;
|
||||
modelessDlg = new TestStartEndForm(waterMeters, myRef.regReaders, TBF.Data.LineSize, myCfg.TestTitle, myCfg.TestSize,
|
||||
myCfg.TestStartBoxAlwaysEn, myCfg.TestIsLrOrder, myCfg.TestFormCloseKeys,
|
||||
DEItem.GetColumns(), volumeUnit, myCfg.TestIsCameraPicture,
|
||||
DEItem.GetColumns(), isCompound, volumeUnit, myCfg.TestIsCameraPicture,
|
||||
startImages, endImages, ocr, ocrMessage, myRef.OcrStream);
|
||||
modelessDlg.Show();
|
||||
}
|
||||
@ -302,9 +303,10 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
}
|
||||
}
|
||||
|
||||
bool isCompound = waterMeters[0].Batch.Compound;
|
||||
modelessDlg = new TestStartEndForm(waterMeters, myRef.regReaders, TBF.Data.LineSize, myCfg.TestTitle, myCfg.TestSize,
|
||||
myCfg.TestStartBoxAlwaysEn, myCfg.TestIsLrOrder, myCfg.TestFormCloseKeys, DEItem.GetColumns(),
|
||||
volumeUnit, myCfg.TestIsCameraPicture, startImages, endImages,
|
||||
isCompound, volumeUnit, myCfg.TestIsCameraPicture, startImages, endImages,
|
||||
ocr, ocrMessage, myRef.OcrStream, wmStartStateStr, refVolume, errLimLo, errLimHi);
|
||||
modelessDlg.Show();
|
||||
}
|
||||
@ -323,9 +325,10 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
}
|
||||
}
|
||||
|
||||
bool isCompound = waterMeters[0].Batch.Compound;
|
||||
modelessDlg = new TestStartEndForm(waterMeters, myRef.regReaders, TBF.Data.LineSize, myCfg.TestTitle, myCfg.TestSize,
|
||||
myCfg.TestStartBoxAlwaysEn, myCfg.TestIsLrOrder, myCfg.TestFormCloseKeys, DEItem.GetColumns(),
|
||||
volumeUnit, myCfg.TestIsCameraPicture, startImages, endImages,
|
||||
isCompound, volumeUnit, myCfg.TestIsCameraPicture, startImages, endImages,
|
||||
ocr, ocrMessage, myRef.OcrStream, wmStartStateStr, refVolume, errLimLo, errLimHi);
|
||||
modelessDlg.Show();
|
||||
}
|
||||
@ -432,9 +435,9 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
if (!((i < waterMeters.Count && waterMeters[i].Disabled) || (i < regReaders.Length && regReaders[i] == null)))
|
||||
{
|
||||
wmStartState[i] = dlg.WMStartState[i];
|
||||
wmStartStateStr[i] = dlg.WMStartStateStr[i];
|
||||
}
|
||||
}
|
||||
wmStartStateStr = dlg.WMStartStateStr;
|
||||
}
|
||||
}
|
||||
else if (modelessDlg is TestStartEndForm && currentOp == CurrentOp.TestEndStates)
|
||||
|
||||
@ -13,6 +13,7 @@ using TBF.Rig.GenericDevices;
|
||||
using TBF.Resources;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace TBF.Rig.DataEntry.Uni
|
||||
{
|
||||
@ -47,6 +48,7 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
readonly bool isStartBoxAlwaysEn;
|
||||
readonly bool isLrOrder; /// true = controls obtain focus after ENTER key in left-right order, false = top-down order
|
||||
readonly IList<DEItem> colItems;
|
||||
readonly bool isCompound;
|
||||
readonly string formCloseKeys;
|
||||
public readonly string[] WMStartStateStr;
|
||||
readonly bool isCameraPicture; /// true = camera picture displayed on the left side
|
||||
@ -72,7 +74,9 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
public double[] WMEndState;
|
||||
public Unit VolumeUnit;
|
||||
int startStateColumn;
|
||||
int startStateColumnAux;
|
||||
int endStateColumn;
|
||||
int endStateColumnAux;
|
||||
|
||||
/// Size and layout related values
|
||||
readonly int meterHeight;
|
||||
@ -131,30 +135,39 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
/// <param name="lineSize">Number of water meters in one (test bencch) line</param>
|
||||
/// <param name="title">Form title</param>
|
||||
/// <param name="sz">Font size</param>
|
||||
/// <param name="isStartBoxAlwaysEn">true = start box enabled at the end of a test</param>
|
||||
/// <param name="isLrOrder">true = controls obtain focus in left-right order, forls = top-down order</param>
|
||||
/// <param name="formCloseKeys">String containing keys to close this form</param>
|
||||
/// <param name="colItems">Water meter items displayed in columns (in the matrix in the main part of the form)</param>
|
||||
/// <param name="isCompound">true = Compound meters: StartStateAux and EndStateAux columns displayed</param>
|
||||
/// <param name="initialVolumeUnit">Volume unit preset initially</param>
|
||||
/// <param name="isCameraPicture">true = display camera pictures in this form</param>
|
||||
/// <param name="startImages">Images before a standing start/stop test</param>
|
||||
/// <param name="endImages">Images after a standing start/stop test</param>
|
||||
/// <param name="ocrVidi">Reference to OCR objejct</param>
|
||||
/// <param name="ocrMessage">Message to be displayed when OCR was not initialized properly</param>
|
||||
/// <param name="streamName">OCR stream selection</param>
|
||||
/// <param name="wmStartStateStr">Information entered on test start</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(IList<WaterMeter> waterMeters, IRegReader[] regReaders, int lineSize, string title, FontSz sz,
|
||||
bool isStartBoxAlwaysEn, bool isLrOrder, string formCloseKeys, IList<DEItem> colItems,
|
||||
public TestStartEndForm(IList<WaterMeter> waterMeters, IRegReader[] regReaders, int _lineSize, string title, FontSz sz,
|
||||
bool isStartBoxAlwaysEn, bool isLrOrder, string formCloseKeys, IList<DEItem> colItems, bool isCompound,
|
||||
Unit initialVolumeUnit, bool isCameraPicture, string[] startImages, string[] endImages,
|
||||
OcrVidi ocrVidi, string ocrMessage, string streamName,
|
||||
string[] wmStartStateStr = null, double refVolume = 0, double errLimLo = 0, double errLimHi = 0)
|
||||
OcrVidi ocrVidi, string ocrMessage, string streamName, string[] wmStartStateStr = null,
|
||||
double refVolume = 0, double errLimLo = 0, double errLimHi = 0)
|
||||
: this()
|
||||
{
|
||||
this.waterMeters = waterMeters;
|
||||
this.regReaders = regReaders;
|
||||
this.lineSize = lineSize;
|
||||
this.lineSize = Math.Min(waterMeters.Count, _lineSize);
|
||||
this.Text = !string.IsNullOrEmpty(title) ? title : string.Empty;
|
||||
this.sz = sz;
|
||||
this.isStartBoxAlwaysEn = isStartBoxAlwaysEn;
|
||||
this.isLrOrder = isLrOrder;
|
||||
this.formCloseKeys = !string.IsNullOrEmpty(formCloseKeys) ? formCloseKeys : string.Empty;
|
||||
this.colItems = colItems;
|
||||
this.isCompound = isCompound;
|
||||
this.VolumeUnit = initialVolumeUnit;
|
||||
this.isCameraPicture = isCameraPicture;
|
||||
this.startImages = startImages;
|
||||
@ -168,7 +181,7 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
this.warningLimHi = 2 * errLimHi;
|
||||
|
||||
if (waterMeters == null || regReaders == null ||
|
||||
(wmStartStateStr != null && wmStartStateStr.Length != waterMeters.Count))
|
||||
(wmStartStateStr != null && wmStartStateStr.Length != (isCompound ? 2 : 1) * waterMeters.Count))
|
||||
{
|
||||
throw new Exception("Invalid argument");
|
||||
}
|
||||
@ -179,12 +192,12 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
isEnd = (wmStartStateStr != null);
|
||||
mode = isEnd ? Tst.End : Tst.Start;
|
||||
wmsCount = waterMeters.Count;
|
||||
if (WMStartStateStr == null) WMStartStateStr = new string[wmsCount];
|
||||
if (WMStartStateStr == null) WMStartStateStr = new string[(isCompound ? 2 : 1) * wmsCount];
|
||||
fixedErrorLimits = (errLimHi > errLimLo);
|
||||
linesCount = (wmsCount + Math.Max(1, lineSize) - 1) / Math.Max(1, lineSize);
|
||||
firstValidWM = waterMeters.FirstOrDefault(x => (x != null && !x.Disabled));
|
||||
WMStartState = new double[wmsCount];
|
||||
WMEndState = new double[wmsCount];
|
||||
WMStartState = new double[(isCompound ? 2 : 1) * wmsCount];
|
||||
WMEndState = new double[(isCompound ? 2 : 1) * wmsCount];
|
||||
///
|
||||
unitComboBox.Text = VolumeUnit.ToDescription();
|
||||
for (Unit u = 0; u < Unit.Count; u++)
|
||||
@ -460,7 +473,9 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
|
||||
/// Table
|
||||
startStateColumn = -1;
|
||||
startStateColumnAux = -1;
|
||||
endStateColumn = -1;
|
||||
endStateColumnAux = -1;
|
||||
for (int k = 0; k < colItems.Count; k++)
|
||||
{
|
||||
if (colItems[k].Content == Ct.StartState)
|
||||
@ -468,14 +483,32 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
startStateColumn = k;
|
||||
for (int i = 0; i < wmsCount; i++)
|
||||
{
|
||||
int rrIx = (isCompound ? 2 : 1) * i;
|
||||
textBoxes[k, i].Text = (!isEnd || waterMeters[i] == null
|
||||
|| waterMeters[i].Disabled
|
||||
|| i >= regReaders.Length
|
||||
|| regReaders[i] == null
|
||||
|| string.IsNullOrEmpty(WMStartStateStr[i])) ? string.Empty : WMStartStateStr[i];
|
||||
|| string.IsNullOrEmpty(WMStartStateStr[i])) ? string.Empty : WMStartStateStr[rrIx];
|
||||
|
||||
textBoxes[k, i].Enabled = (isStartBoxAlwaysEn || !isEnd) && waterMeters[i] != null && !waterMeters[i].Disabled
|
||||
&& i < regReaders.Length && regReaders[i] != null;
|
||||
&& rrIx < regReaders.Length && regReaders[rrIx] != null;
|
||||
}
|
||||
}
|
||||
else if (colItems[k].Content == Ct.StartStateAux)
|
||||
{
|
||||
startStateColumnAux = k;
|
||||
for (int i = 0; i < wmsCount; i++)
|
||||
{
|
||||
int rrIx = 2 * i + 1;
|
||||
textBoxes[k, i].Text = (!isEnd || !isCompound
|
||||
|| waterMeters[i] == null
|
||||
|| waterMeters[i].Disabled
|
||||
|| i >= regReaders.Length
|
||||
|| regReaders[i] == null
|
||||
|| string.IsNullOrEmpty(WMStartStateStr[i])) ? string.Empty : WMStartStateStr[rrIx];
|
||||
|
||||
textBoxes[k, i].Enabled = isCompound && (isStartBoxAlwaysEn || !isEnd) && waterMeters[i] != null && !waterMeters[i].Disabled
|
||||
&& rrIx < regReaders.Length && regReaders[rrIx] != null;
|
||||
}
|
||||
}
|
||||
else if (colItems[k].Content == Ct.EndState)
|
||||
@ -483,9 +516,21 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
endStateColumn = k;
|
||||
for (int i = 0; i < wmsCount; i++)
|
||||
{
|
||||
int rrIx = (isCompound ? 2 : 1) * i;
|
||||
textBoxes[k, i].Text = string.Empty;
|
||||
textBoxes[k, i].Enabled = isEnd && waterMeters[i] != null && !waterMeters[i].Disabled
|
||||
&& i < regReaders.Length && regReaders[i] != null;
|
||||
&& rrIx < regReaders.Length && regReaders[rrIx] != null;
|
||||
}
|
||||
}
|
||||
else if (colItems[k].Content == Ct.EndStateAux)
|
||||
{
|
||||
endStateColumn = k;
|
||||
for (int i = 0; i < wmsCount; i++)
|
||||
{
|
||||
int rrIx = 2 * i + 1;
|
||||
textBoxes[k, i].Text = string.Empty;
|
||||
textBoxes[k, i].Enabled = isEnd && isCompound && waterMeters[i] != null && !waterMeters[i].Disabled
|
||||
&& rrIx < regReaders.Length && regReaders[rrIx] != null;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -533,23 +578,37 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
{
|
||||
for (int i = 0; i < wmsCount; i++)
|
||||
{
|
||||
int rrIx = (isCompound ? 2 : 1) * i;
|
||||
double volume;
|
||||
|
||||
if (colItems[k].Content == Ct.StartState)
|
||||
{
|
||||
/// Water meter start state
|
||||
double startVol;
|
||||
if (textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out startVol))
|
||||
if (textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out volume))
|
||||
{
|
||||
WMStartStateStr[i] = textBoxes[k, i].Text;
|
||||
WMStartState[i] = Units.ConvertFrom(VolumeUnit, startVol);
|
||||
WMStartStateStr[rrIx] = textBoxes[k, i].Text;
|
||||
WMStartState[rrIx] = Units.ConvertFrom(VolumeUnit, volume);
|
||||
}
|
||||
}
|
||||
else if (colItems[k].Content == Ct.StartStateAux)
|
||||
{
|
||||
if (isCompound && textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out volume))
|
||||
{
|
||||
WMStartStateStr[rrIx + 1] = textBoxes[k, i].Text;
|
||||
WMStartState[rrIx + 1] = Units.ConvertFrom(VolumeUnit, volume);
|
||||
}
|
||||
}
|
||||
else if (colItems[k].Content == Ct.EndState)
|
||||
{
|
||||
/// Water meter end state
|
||||
double endVol;
|
||||
if (textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out endVol))
|
||||
if (textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out volume))
|
||||
{
|
||||
WMEndState[i] = Units.ConvertFrom(VolumeUnit, endVol);
|
||||
WMEndState[rrIx] = Units.ConvertFrom(VolumeUnit, volume);
|
||||
}
|
||||
}
|
||||
else if (colItems[k].Content == Ct.EndStateAux)
|
||||
{
|
||||
if (isCompound && textBoxes[k, i].Enabled && Utils.TryParseUDouble(textBoxes[k, i].Text, out volume))
|
||||
{
|
||||
WMEndState[rrIx + 1] = Units.ConvertFrom(VolumeUnit, volume);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -565,21 +624,39 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
/// Count the images
|
||||
/// Count images
|
||||
for (int i = 0; i < wmsCount; i++)
|
||||
{
|
||||
if ((mode == Tst.Start || mode == Tst.Both) &&
|
||||
startStateColumn >= 0 && textBoxes[startStateColumn, i].Enabled &&
|
||||
startImages != null && startImages.Length > i && !string.IsNullOrEmpty(startImages[i]))
|
||||
int rrIx = (isCompound ? 2 : 1) * i;
|
||||
|
||||
if (mode == Tst.Start || mode == Tst.Both)
|
||||
{
|
||||
count++;
|
||||
if (startStateColumn >= 0 && textBoxes[startStateColumn, i].Enabled &&
|
||||
startImages != null && startImages.Length > rrIx && !string.IsNullOrEmpty(startImages[rrIx]))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
if (startStateColumnAux >= 0 && textBoxes[startStateColumnAux, i].Enabled &&
|
||||
startImages != null && startImages.Length > rrIx + 1 && !string.IsNullOrEmpty(startImages[rrIx + 1]))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((mode == Tst.End || mode == Tst.Both) &&
|
||||
endStateColumn >= 0 && textBoxes[endStateColumn, i].Enabled &&
|
||||
endImages != null && endImages.Length > i && !string.IsNullOrEmpty(endImages[i]))
|
||||
|
||||
if (mode == Tst.End || mode == Tst.Both)
|
||||
{
|
||||
count++;
|
||||
if (endStateColumn >= 0 && textBoxes[endStateColumn, i].Enabled &&
|
||||
endImages != null && endImages.Length > rrIx && !string.IsNullOrEmpty(endImages[rrIx]))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
|
||||
if (endStateColumnAux >= 0 && textBoxes[endStateColumnAux, i].Enabled &&
|
||||
endImages != null && endImages.Length > rrIx + 1 && !string.IsNullOrEmpty(endImages[rrIx + 1]))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -593,50 +670,87 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
|
||||
Thread.Sleep(2000);
|
||||
|
||||
bool[] startImgProcessed = new bool[wmsCount];
|
||||
bool[] endImgProcessed = new bool[wmsCount];
|
||||
bool[] startImgProcessed = new bool[(isCompound ? 2 : 1) * wmsCount];
|
||||
bool[] endImgProcessed = new bool[(isCompound ? 2 : 1) * wmsCount];
|
||||
|
||||
for (int attempt = 1; attempt <= 3; attempt++)
|
||||
{
|
||||
for (int i = 0; i < wmsCount; i++)
|
||||
{
|
||||
double pulsesPerLtr = (regReaders != null && regReaders.Length > i && regReaders[i] != null) ? regReaders[i].PulsesPerLtr : 1;
|
||||
GetOcrParameters(pulsesPerLtr, out denominator, out format);
|
||||
|
||||
if ((mode == Tst.Start || mode == Tst.Both) &&
|
||||
startStateColumn >= 0 && textBoxes[startStateColumn, i].Enabled &&
|
||||
startImages != null && startImages.Length > i && !string.IsNullOrEmpty(startImages[i]))
|
||||
int rrIx = (isCompound ? 2 : 1) * i;
|
||||
double pulsesPerLtr = (regReaders != null && regReaders.Length > rrIx && regReaders[rrIx] != null) ? regReaders[rrIx].PulsesPerLtr : 1;
|
||||
double pulsesPerLtrAux = (regReaders != null && regReaders.Length > rrIx + 1 && regReaders[rrIx + 1] != null) ? regReaders[rrIx + 1].PulsesPerLtr : 1;
|
||||
|
||||
if (mode == Tst.Start || mode == Tst.Both)
|
||||
{
|
||||
if (!startImgProcessed[i])
|
||||
if (startStateColumn >= 0 && textBoxes[startStateColumn, i].Enabled &&
|
||||
startImages != null && startImages.Length > rrIx && !string.IsNullOrEmpty(startImages[rrIx]))
|
||||
{
|
||||
try
|
||||
if (!startImgProcessed[rrIx])
|
||||
{
|
||||
/// Process a start image
|
||||
var text = ocrVidi.Recognize(streamName, startImages[i], denominator, format); /// OCR
|
||||
this.Invoke(ocrTextObtained, new object[] { i, false, text });
|
||||
startImgProcessed[i] = true;
|
||||
try
|
||||
{
|
||||
/// Process a start image
|
||||
GetOcrParameters(pulsesPerLtr, out denominator, out format);
|
||||
var text = ocrVidi.Recognize(streamName, startImages[rrIx], denominator, format); /// OCR
|
||||
this.Invoke(ocrTextObtained, new object[] { rrIx, false, text });
|
||||
startImgProcessed[rrIx] = true;
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
catch (Exception)
|
||||
}
|
||||
|
||||
if (startStateColumnAux >= 0 && textBoxes[startStateColumnAux, i].Enabled &&
|
||||
startImages != null && startImages.Length > rrIx + 1 && !string.IsNullOrEmpty(startImages[rrIx + 1]))
|
||||
{
|
||||
if (!startImgProcessed[rrIx + 1])
|
||||
{
|
||||
try
|
||||
{
|
||||
/// Process a start image
|
||||
GetOcrParameters(pulsesPerLtrAux, out denominator, out format);
|
||||
var text = ocrVidi.Recognize(streamName, startImages[rrIx + 1], denominator, format); /// OCR
|
||||
this.Invoke(ocrTextObtained, new object[] { rrIx + 1, false, text });
|
||||
startImgProcessed[rrIx + 1] = true;
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((mode == Tst.End || mode == Tst.Both) &&
|
||||
endStateColumn >= 0 && textBoxes[endStateColumn, i].Enabled &&
|
||||
endImages != null && endImages.Length > i && !string.IsNullOrEmpty(endImages[i]))
|
||||
if (mode == Tst.End || mode == Tst.Both)
|
||||
{
|
||||
if (!endImgProcessed[i])
|
||||
if (endStateColumn >= 0 && textBoxes[endStateColumn, i].Enabled &&
|
||||
endImages != null && endImages.Length > rrIx && !string.IsNullOrEmpty(endImages[rrIx]))
|
||||
{
|
||||
try
|
||||
if (!endImgProcessed[rrIx])
|
||||
{
|
||||
/// Process an end image
|
||||
var text = ocrVidi.Recognize(streamName, endImages[i], denominator, format); /// OCR
|
||||
this.Invoke(ocrTextObtained, new object[] { i, true, text });
|
||||
endImgProcessed[i] = true;
|
||||
try
|
||||
{
|
||||
/// Process an end image
|
||||
GetOcrParameters(pulsesPerLtr, out denominator, out format);
|
||||
var text = ocrVidi.Recognize(streamName, endImages[rrIx], denominator, format); /// OCR
|
||||
this.Invoke(ocrTextObtained, new object[] { rrIx, true, text });
|
||||
endImgProcessed[rrIx] = true;
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
catch (Exception)
|
||||
}
|
||||
|
||||
if (endStateColumnAux >= 0 && textBoxes[endStateColumnAux, i].Enabled &&
|
||||
endImages != null && endImages.Length > rrIx + 1 && !string.IsNullOrEmpty(endImages[rrIx + 1]))
|
||||
{
|
||||
if (!endImgProcessed[rrIx + 1])
|
||||
{
|
||||
try
|
||||
{
|
||||
/// Process an end image
|
||||
GetOcrParameters(pulsesPerLtrAux, out denominator, out format);
|
||||
var text = ocrVidi.Recognize(streamName, endImages[rrIx + 1], denominator, format); /// OCR
|
||||
this.Invoke(ocrTextObtained, new object[] { rrIx + 1, true, text });
|
||||
endImgProcessed[rrIx + 1] = true;
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -668,24 +782,24 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
}
|
||||
}
|
||||
|
||||
public void OnOcrTextObtained(int ix, bool _isEnd, string text)
|
||||
public void OnOcrTextObtained(int rrIx, bool _isEnd, string text)
|
||||
{
|
||||
if (!isCameraPicture) return;
|
||||
|
||||
if (_isEnd)
|
||||
{
|
||||
if (endStateColumn>= 0 && textBoxes[endStateColumn, ix].Enabled)
|
||||
if (endStateColumn>= 0 && textBoxes[endStateColumn, rrIx].Enabled)
|
||||
{
|
||||
textBoxes[endStateColumn, ix].Text = text;
|
||||
LoadImage(null, Tst.End, ix);
|
||||
textBoxes[endStateColumn, rrIx].Text = text;
|
||||
LoadImage(null, Tst.End, rrIx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startStateColumn >= 0 && textBoxes[startStateColumn, ix].Enabled)
|
||||
if (startStateColumn >= 0 && textBoxes[startStateColumn, rrIx].Enabled)
|
||||
{
|
||||
textBoxes[endStateColumn, ix].Text = text;
|
||||
LoadImage(null, Tst.Start, ix);
|
||||
textBoxes[endStateColumn, rrIx].Text = text;
|
||||
LoadImage(null, Tst.Start, rrIx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -720,19 +834,41 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
{
|
||||
for (int i = 0; i < wmsCount; i++)
|
||||
{
|
||||
double startVol, endVol;
|
||||
double startVol, endVol, startVolAux, endVolAux;
|
||||
|
||||
if (Utils.TryParseUDouble(textBoxes[startStateColumn, i].Text, out startVol) &&
|
||||
Utils.TryParseUDouble(textBoxes[endStateColumn, i].Text, out endVol))
|
||||
if (isCompound && startStateColumnAux >= 0 && endStateColumnAux >= 0)
|
||||
{
|
||||
double startState = Units.ConvertFrom(VolumeUnit, startVol);
|
||||
double endState = Units.ConvertFrom(VolumeUnit, endVol);
|
||||
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
|
||||
exclamations[i].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
|
||||
/// Compound
|
||||
if (Utils.TryParseUDouble(textBoxes[startStateColumn, i].Text, out startVol) &&
|
||||
Utils.TryParseUDouble(textBoxes[startStateColumnAux, i].Text, out startVolAux) &&
|
||||
Utils.TryParseUDouble(textBoxes[endStateColumn, i].Text, out endVol) &&
|
||||
Utils.TryParseUDouble(textBoxes[endStateColumnAux, i].Text, out endVolAux))
|
||||
{
|
||||
double startState = Units.ConvertFrom(VolumeUnit, startVol + startVolAux);
|
||||
double endState = Units.ConvertFrom(VolumeUnit, endVol + endVolAux);
|
||||
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
|
||||
exclamations[i].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
|
||||
}
|
||||
else
|
||||
{
|
||||
exclamations[i].Visible = !string.IsNullOrEmpty(textBoxes[endStateColumn, i].Text);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
exclamations[i].Visible = !string.IsNullOrEmpty(textBoxes[endStateColumn, i].Text);
|
||||
/// Single
|
||||
if (Utils.TryParseUDouble(textBoxes[startStateColumn, i].Text, out startVol) &&
|
||||
Utils.TryParseUDouble(textBoxes[endStateColumn, i].Text, out endVol))
|
||||
{
|
||||
double startState = Units.ConvertFrom(VolumeUnit, startVol);
|
||||
double endState = Units.ConvertFrom(VolumeUnit, endVol);
|
||||
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
|
||||
exclamations[i].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
|
||||
}
|
||||
else
|
||||
{
|
||||
exclamations[i].Visible = !string.IsNullOrEmpty(textBoxes[endStateColumn, i].Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -776,9 +912,11 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
largeTextBox.Text = string.Format("{0}: {1}", j + 1, textBoxes[k, j].Text);
|
||||
largeExclamationLabel.Visible = false;
|
||||
|
||||
if (isCameraPicture && (k == startStateColumn || k == endStateColumn))
|
||||
if (isCameraPicture && (k == startStateColumn || k == startStateColumnAux ||
|
||||
k == endStateColumn || k == endStateColumnAux))
|
||||
{
|
||||
LoadImage(sender, (k == startStateColumn) ? Tst.Start : Tst.End, j);
|
||||
int rrIx = (isCompound ? 2 : 1) * j + ((k == startStateColumnAux || k == endStateColumnAux) ? 1 : 0);
|
||||
LoadImage(sender, (k == startStateColumn || k == startStateColumnAux) ? Tst.Start : Tst.End, rrIx);
|
||||
}
|
||||
|
||||
textBoxes[k, j].Focus();
|
||||
@ -802,24 +940,9 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
|
||||
largeTextBox.Text = string.Format("{0}: {1}", j + 1, textBoxes[k, j].Text);
|
||||
|
||||
if (isEnd && (k == startStateColumn || k == endStateColumn))
|
||||
if (isEnd && (k == startStateColumn || k == startStateColumnAux || k == endStateColumn || k == endStateColumnAux))
|
||||
{
|
||||
double startVol, endVol;
|
||||
|
||||
if (startStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[startStateColumn, j].Text, out startVol) &&
|
||||
endStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[endStateColumn, j].Text, out endVol))
|
||||
{
|
||||
double startState = Units.ConvertFrom(VolumeUnit, startVol);
|
||||
double endState = Units.ConvertFrom(VolumeUnit, endVol);
|
||||
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
|
||||
largeExclamationLabel.Visible =
|
||||
exclamations[j].Visible = fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
|
||||
}
|
||||
else
|
||||
{
|
||||
largeExclamationLabel.Visible =
|
||||
exclamations[j].Visible = !string.IsNullOrEmpty(textBoxes[endStateColumn, j].Text);
|
||||
}
|
||||
UpdateExclamation(j);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -827,6 +950,36 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateExclamation(int j)
|
||||
{
|
||||
double startVol, startVolAux, endVol, endVolAux;
|
||||
|
||||
if (isCompound && startStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[startStateColumn, j].Text, out startVol) &&
|
||||
startStateColumnAux >= 0 && Utils.TryParseUDouble(textBoxes[startStateColumnAux, j].Text, out startVolAux) &&
|
||||
endStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[endStateColumn, j].Text, out endVol) &&
|
||||
endStateColumnAux >= 0 && Utils.TryParseUDouble(textBoxes[endStateColumnAux, j].Text, out endVolAux))
|
||||
{
|
||||
double startState = Units.ConvertFrom(VolumeUnit, startVol + startVolAux);
|
||||
double endState = Units.ConvertFrom(VolumeUnit, endVol + endVolAux);
|
||||
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
|
||||
largeExclamationLabel.Visible = exclamations[j].Visible =
|
||||
fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
|
||||
}
|
||||
else if (startStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[startStateColumn, j].Text, out startVol) &&
|
||||
endStateColumn >= 0 && Utils.TryParseUDouble(textBoxes[endStateColumn, j].Text, out endVol))
|
||||
{
|
||||
double startState = Units.ConvertFrom(VolumeUnit, startVol);
|
||||
double endState = Units.ConvertFrom(VolumeUnit, endVol);
|
||||
double err = (refVolume != 0) ? 100.0 * (endState - startState - refVolume) / refVolume : 1000.0;
|
||||
largeExclamationLabel.Visible = exclamations[j].Visible =
|
||||
fixedErrorLimits ? ((err < warningLimLo) || (warningLimHi < err)) : ((err < -6) || (+6 < err));
|
||||
}
|
||||
else
|
||||
{
|
||||
largeExclamationLabel.Visible = exclamations[j].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
textBox_AcceptsTabChanged(sender, e);
|
||||
@ -898,14 +1051,14 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
/// Handles mouse clicks and Tab-changes inside text boxes.
|
||||
/// </summary>
|
||||
/// <param name="startOrEnd">Tst.Start or Tst.End</param>
|
||||
/// <param name="wmNr0">0-based WM position</param>
|
||||
void LoadImage(object sender, Tst startOrEnd, int wmNr0)
|
||||
/// <param name="rrIx">0-based WM position</param>
|
||||
void LoadImage(object sender, Tst startOrEnd, int rrIx)
|
||||
{
|
||||
string imageFileName;
|
||||
if (startOrEnd == Tst.Start && startImages[wmNr0] != null)
|
||||
imageFileName = startImages[wmNr0];
|
||||
else if (startOrEnd == Tst.End && endImages[wmNr0] != null)
|
||||
imageFileName = endImages[wmNr0];
|
||||
if (startOrEnd == Tst.Start && startImages[rrIx] != null)
|
||||
imageFileName = startImages[rrIx];
|
||||
else if (startOrEnd == Tst.End && endImages[rrIx] != null)
|
||||
imageFileName = endImages[rrIx];
|
||||
else
|
||||
imageFileName = string.Empty;
|
||||
|
||||
@ -915,7 +1068,7 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
}
|
||||
|
||||
lastImageName = imageFileName;
|
||||
lastWmNr1 = wmNr0 + 1;
|
||||
lastWmNr1 = rrIx + 1;
|
||||
|
||||
if (string.IsNullOrEmpty(imageFileName) || !File.Exists(imageFileName))
|
||||
{
|
||||
@ -923,7 +1076,7 @@ namespace TBF.Rig.DataEntry.Uni
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Bitmap tempBmp = Image.FromFile(imageFileName) as Bitmap)
|
||||
using (Bitmap tempBmp = System.Drawing.Image.FromFile(imageFileName) as Bitmap)
|
||||
{
|
||||
Rectangle rect;
|
||||
if (tempBmp.Height < tempBmp.Width)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user