Diverter.Resolution 1, 2, 4, and 8 ms implemented, ver. 3.7.2092
This commit is contained in:
parent
900a2d660c
commit
1691c634c6
@ -653,7 +653,16 @@ namespace Common
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum ImageRotation
|
||||
public enum DivResolution : int
|
||||
{
|
||||
[Description("1 ms (0.25 s)")] _1ms = 0,
|
||||
[Description("2 ms (0.5 s)")] _2ms = 1,
|
||||
[Description("4 ms (1 s)")] _4ms = 2,
|
||||
[Description("8 ms (2 s)")] _8ms = 3,
|
||||
Count,
|
||||
}
|
||||
|
||||
public enum ImageRotation
|
||||
{
|
||||
[Description("0 deg")] None,
|
||||
[Description("90 deg")] Deg90,
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("3.7.2088.0")]
|
||||
[assembly: AssemblyFileVersion("3.7.2088.0")]
|
||||
[assembly: AssemblyVersion("3.7.2092.0")]
|
||||
[assembly: AssemblyFileVersion("3.7.2092.0")]
|
||||
|
||||
@ -29,10 +29,10 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
|
||||
const int SamplesCount = 247;
|
||||
|
||||
DivTransitionData()
|
||||
DivTransitionData(int divResolutionMs)
|
||||
{
|
||||
Samples = new byte[SamplesCount];
|
||||
Resolution_ms = Const.DivTimeResolution;
|
||||
Resolution_ms = divResolutionMs;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -62,12 +62,12 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// </summary>
|
||||
/// <param name="rcvdData">Received data</param>
|
||||
/// <param name="offset">Offset of the message</param>
|
||||
public static DivTransitionData GetData(byte[] rcvdData, int offset)
|
||||
public static DivTransitionData GetData(byte[] rcvdData, int offset, int divResolutionMs)
|
||||
{
|
||||
log.DebugFormat("DivTransitionDataGetData() ... Diverter = {0}, DiverterAssociationValidUntil-StateMachine.Time = {1}s left",
|
||||
(Diverter != null) ? Diverter.Name : "none", DiverterAssociationValidUntil - StateMachine.Time);
|
||||
|
||||
var data = new DivTransitionData();
|
||||
var data = new DivTransitionData(divResolutionMs);
|
||||
for (int i = 0; i < SamplesCount; i++)
|
||||
{
|
||||
data.Samples[i] = rcvdData[offset + 6 + i];
|
||||
@ -75,7 +75,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
|
||||
if (Diverter != null && StateMachine.Time <= DiverterAssociationValidUntil)
|
||||
{
|
||||
data.TransitionTime_ms = Const.DivTimeResolution * CalculateDivTransitionTime(data.Samples, Diverter.ThresholdLo, Diverter.ThresholdHi);
|
||||
data.TransitionTime_ms = divResolutionMs * CalculateDivTransitionTime(data.Samples, Diverter.ThresholdLo, Diverter.ThresholdHi);
|
||||
log.InfoFormat("{0} transition time = {1} ms", Diverter.Name, data.TransitionTime_ms);
|
||||
if (ToTank)
|
||||
{
|
||||
|
||||
@ -11,7 +11,6 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
public const int RVsCount = 8; /// 0..7
|
||||
public const int FlowmtrsCount = 7; /// ID=1..7, ID=0 ... flowmeters 1,2,3 parallel
|
||||
public const int DivertersCount = 5; /// 1..5
|
||||
public const int DivTimeResolution = 2; /// [ms]
|
||||
public const double TimeResolution = 0.0002; /// [s]
|
||||
}
|
||||
|
||||
|
||||
@ -96,6 +96,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
regV.Idx1, flowMeter.Idx1, (diverter != null) ? diverter.DiverterNr : 0, qFrom, qTo);
|
||||
|
||||
/// Start the test (and the flow measurement)
|
||||
if (withDiverter) { uniCB.DivResolution = diverter.Resolution; }
|
||||
uniCB.SetActivity((diverter != null) ? Activity.FlyingStartStopTestWithDiverter : Activity.FlyingStartStopTest);
|
||||
uniCB.StartTest(false, flowMeter.Idx1, (diverter != null) ? diverter.DiverterNr : 0, (diverter != null) ? diverter.StartThreshold : 0,
|
||||
true, withDiverter, false, isProlonged, pulsesCount, massPulsesCount);
|
||||
|
||||
@ -86,7 +86,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// </summary>
|
||||
/// <param name="data">Received data</param>
|
||||
/// <param name="offs">Offset of the message</param>
|
||||
public void UpdateData(byte[] data, int offs)
|
||||
public void UpdateData(byte[] data, int offs, int divResolutionMs)
|
||||
{
|
||||
State = GetUInt40(data, offs + (int)Poz.State) | /// Byte 5,6,7,8,9,80,81
|
||||
((ulong)data[offs + (int)Poz.Stat5] << 40) |
|
||||
@ -188,7 +188,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
ReferenceFreq[0] = ReferenceFreq[1] + ReferenceFreq[2] + ReferenceFreq[3];
|
||||
}
|
||||
|
||||
DivTime = Const.DivTimeResolution * data[offs + (int)Poz.CasKl]; /// Byte 271
|
||||
DivTime = divResolutionMs * data[offs + (int)Poz.CasKl]; /// Byte 271
|
||||
byte spare4 = data[offs + (int)Poz.spare4]; /// Byte 272
|
||||
Chyby485 = GetUInt16(data, offs + (int)Poz.Chyb485); /// Byte 273, 274 !!!!!!!!!!!!!!!
|
||||
uint timeRefRaw = GetUInt24(data, offs + (int)Poz.Tim2); /// Byte 274,275,276 !!!!!!!!!!!!!!!
|
||||
@ -203,7 +203,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
EtPulses3 = Convert.ToInt32(GetUInt24(data, offs + (int)Poz.ETX3)); /// Byte 297,298.299 !!!!!!!!!!!!!!!
|
||||
|
||||
log.InfoFormat("Et={0} State={1:X14} Route={2} Freq={3} EtPulses={4} TTime={5} WMPulses[3]={6} WMRefPulses[3]={7}, Time[3]={8}",
|
||||
(State & 7), State, Utils.ToBin40(((UInt64)Vystupy) >> 8), ReferenceFreq[0], EtPulses[0], Ttime, WMeterPuls[3], EtPulses[3], ImpulseTime[3]);
|
||||
State & 7, State, Utils.ToBin40(Vystupy >> 8), ReferenceFreq[0], EtPulses[0], Ttime, WMeterPuls[3], EtPulses[3], ImpulseTime[3]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -74,6 +74,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
log.InfoFormat("Start() Et#={0} pulses={1} withDiverter={2}", flowMeter.Idx1, pulsesCount, withDiverter);
|
||||
|
||||
/// Start the test (and the flow measurement)
|
||||
if (withDiverter) { uniCB.DivResolution = diverter.Resolution; }
|
||||
uniCB.SetActivity(Activity.StandingStartStopTest);
|
||||
uniCB.StartTest(false, flowMeter.Idx1, (withDiverter ? diverter.DiverterNr : 0), 0,
|
||||
false, withDiverter, true, false, pulsesCount);
|
||||
|
||||
@ -28,7 +28,24 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
/// TBF component configuration and useful wrappers
|
||||
readonly UniCBCfg cbCfg;
|
||||
string comPort { get { return string.Format("COM{0}", cbCfg.ComPortNr); } }
|
||||
short config { get { return (short)((cbCfg.DrainValvesCount << 8) + ((cbCfg.DivertersCount - 1) << 3) + cbCfg.RegValvesCount - 4); } }
|
||||
|
||||
public DivResolution DivResolution { get; set; }
|
||||
public int DivResolutionMs
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (DivResolution)
|
||||
{
|
||||
case DivResolution._1ms: return 1;
|
||||
default:
|
||||
case DivResolution._2ms: return 2;
|
||||
case DivResolution._4ms: return 4;
|
||||
case DivResolution._8ms: return 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
short config { get { return (short)((cbCfg.DrainValvesCount << 8) + ((int)DivResolution << 6) + ((cbCfg.DivertersCount - 1) << 3) + cbCfg.RegValvesCount - 4); } }
|
||||
|
||||
/// IDrawingItCmpnt interface implementation
|
||||
public SchematicDrawing.IDrawingItem DrawingItem { get { return cbCfg as SchematicDrawing.IDrawingItem; } }
|
||||
@ -382,7 +399,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
{
|
||||
/// Regular data received
|
||||
generalDataReceived = true;
|
||||
Data.UpdateData(rcvdData, offset);
|
||||
Data.UpdateData(rcvdData, offset, DivResolutionMs);
|
||||
caption.Append(GeneralData.Caption());
|
||||
offset += GeneralData.MessageLen;
|
||||
anyProcessed = true;
|
||||
@ -398,7 +415,7 @@ namespace TBF.Rig.ControlBoard.Uni
|
||||
else if (DivTransitionData.FrameFitsData(rcvdData, cumulativeSums, rcvdBytesCount, offset))
|
||||
{
|
||||
/// Diverter transition data received
|
||||
divTransitionData = DivTransitionData.GetData(rcvdData, offset);
|
||||
divTransitionData = DivTransitionData.GetData(rcvdData, offset, DivResolutionMs);
|
||||
caption.Append(DivTransitionData.Caption());
|
||||
offset += DivTransitionData.MessageLen;
|
||||
anyProcessed = true;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -16,8 +16,8 @@ using TBF.Resources;
|
||||
namespace TBF.Rig.Uni.Diverter
|
||||
{
|
||||
public class Diverter : ComponentBase, IDevice, GenericDevices.IDiverter, GenericDevices.ISequenceCondition, GenericDevices.IHasCalendarEvents, IDrawingItCmpnt
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Diverter));
|
||||
{
|
||||
private static readonly ILog log = LogManager.GetLogger(typeof(Diverter));
|
||||
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
|
||||
|
||||
/// Configuration and wrappers
|
||||
@ -27,6 +27,7 @@ namespace TBF.Rig.Uni.Diverter
|
||||
public int AdcNr { get { return divCfg.AdcNr; } }
|
||||
public int AdcValueToSink { get { return divCfg.AdcValueToSink; } }
|
||||
public int AdcValueToTank { get { return divCfg.AdcValueToTank; } }
|
||||
public DivResolution Resolution { get { return divCfg.Resolution; } }
|
||||
public IDrawingItem DrawingItem { get { return divCfg as IDrawingItem; } }
|
||||
///
|
||||
public int StartThreshold
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Slovensko a.s.
|
||||
/// Copyright (c) 2021-2023 Sensus Slovensko a.s.
|
||||
///
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Serialization;
|
||||
using Common;
|
||||
using Config.Entities;
|
||||
using SchematicDrawing;
|
||||
using TBF.Rig.Generic;
|
||||
@ -34,6 +35,7 @@ namespace TBF.Rig.Uni.Diverter
|
||||
public int ThresholdHiPct; /// 0..100 in %, threshold for high level when diverter transition time is measured
|
||||
public int DfltSwithTimeStartMs; /// Default diverter transition time 'start' or 'to tank' in ms
|
||||
public int DfltSwithTimeEndMs; /// Default diverter transition time 'end' or 'to sink' in ms
|
||||
public DivResolution Resolution;
|
||||
|
||||
/// Calibration info serialized parameters displayed in Metrology tab page
|
||||
public string CalibCertificateNr { get; set; }
|
||||
@ -82,6 +84,7 @@ namespace TBF.Rig.Uni.Diverter
|
||||
ThresholdHiPct = 90;
|
||||
DfltSwithTimeStartMs = 1;
|
||||
DfltSwithTimeEndMs = 1;
|
||||
Resolution = DivResolution._2ms;
|
||||
CalibCertificateNr = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
26
TBF/Rig/Uni/Diverter/DiverterCfgCtrl.Designer.cs
generated
26
TBF/Rig/Uni/Diverter/DiverterCfgCtrl.Designer.cs
generated
@ -81,6 +81,8 @@ namespace TBF.Rig.Uni.Diverter
|
||||
this.label10 = new System.Windows.Forms.Label();
|
||||
this.divNr1TextBox = new System.Windows.Forms.TextBox();
|
||||
this.divIx1Label = new System.Windows.Forms.Label();
|
||||
this.resolutionComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.resolutionLabel = new System.Windows.Forms.Label();
|
||||
this.groupBox4.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
@ -536,10 +538,30 @@ namespace TBF.Rig.Uni.Diverter
|
||||
this.divIx1Label.TabIndex = 36;
|
||||
this.divIx1Label.Text = "Diverter nr. (1 .. 5)";
|
||||
//
|
||||
// resolutionComboBox
|
||||
//
|
||||
this.resolutionComboBox.Enabled = false;
|
||||
this.resolutionComboBox.FormattingEnabled = true;
|
||||
this.resolutionComboBox.Location = new System.Drawing.Point(144, 318);
|
||||
this.resolutionComboBox.Name = "resolutionComboBox";
|
||||
this.resolutionComboBox.Size = new System.Drawing.Size(68, 21);
|
||||
this.resolutionComboBox.TabIndex = 39;
|
||||
//
|
||||
// resolutionLabel
|
||||
//
|
||||
this.resolutionLabel.AutoSize = true;
|
||||
this.resolutionLabel.Location = new System.Drawing.Point(21, 321);
|
||||
this.resolutionLabel.Name = "resolutionLabel";
|
||||
this.resolutionLabel.Size = new System.Drawing.Size(57, 13);
|
||||
this.resolutionLabel.TabIndex = 38;
|
||||
this.resolutionLabel.Text = "Resolution";
|
||||
//
|
||||
// DiverterCfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.resolutionComboBox);
|
||||
this.Controls.Add(this.resolutionLabel);
|
||||
this.Controls.Add(this.divNr1TextBox);
|
||||
this.Controls.Add(this.divIx1Label);
|
||||
this.Controls.Add(this.label10);
|
||||
@ -642,5 +664,7 @@ namespace TBF.Rig.Uni.Diverter
|
||||
private System.Windows.Forms.Label label10;
|
||||
private System.Windows.Forms.TextBox divNr1TextBox;
|
||||
private System.Windows.Forms.Label divIx1Label;
|
||||
}
|
||||
private System.Windows.Forms.ComboBox resolutionComboBox;
|
||||
private System.Windows.Forms.Label resolutionLabel;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
///
|
||||
/// Copyright (c) 2021 Sensus Metering Systems
|
||||
/// Copyright (c) 2021-2023 Sensus Metering Systems
|
||||
///
|
||||
using System;
|
||||
using System.Linq;
|
||||
@ -49,7 +49,12 @@ namespace TBF.Rig.Uni.Diverter
|
||||
}
|
||||
}
|
||||
|
||||
if (config != null)
|
||||
for (DivResolution res = 0; res < DivResolution.Count; res++)
|
||||
{
|
||||
resolutionComboBox.Items.Add(res.ToDescription());
|
||||
}
|
||||
|
||||
if (config != null)
|
||||
{
|
||||
adc1 = config.AdcValueToSink;
|
||||
pct1 = 0;
|
||||
@ -83,6 +88,7 @@ namespace TBF.Rig.Uni.Diverter
|
||||
thresholdHiTextBox.Text = config.ThresholdHiPct.ToString();
|
||||
dfltSwitchTimeStartTextBox.Text = config.DfltSwithTimeStartMs.ToString();
|
||||
dfltSwitchTimeEndTextBox.Text = config.DfltSwithTimeEndMs.ToString();
|
||||
resolutionComboBox.Text = config.Resolution.ToDescription();
|
||||
|
||||
adcTextBox1.Text = adc1.ToString();
|
||||
adcTextBox2.Text = adc2.ToString();
|
||||
@ -104,6 +110,7 @@ namespace TBF.Rig.Uni.Diverter
|
||||
thresholdHiTextBox.Enabled = true;
|
||||
dfltSwitchTimeStartTextBox.Enabled = true;
|
||||
dfltSwitchTimeEndTextBox.Enabled = true;
|
||||
resolutionComboBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags VerifyCfg(ref string message)
|
||||
@ -182,6 +189,22 @@ namespace TBF.Rig.Uni.Diverter
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Default switch time end' should be positive integer";
|
||||
}
|
||||
|
||||
bool isValidRes = false;
|
||||
for (DivResolution res = 0; res < DivResolution.Count; res++)
|
||||
{
|
||||
if (resolutionComboBox.Text == res.ToDescription())
|
||||
{
|
||||
isValidRes = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isValidRes)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'Resolution' is invalid";
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
@ -275,6 +298,19 @@ namespace TBF.Rig.Uni.Diverter
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
|
||||
for (DivResolution res = 0; res < DivResolution.Count; res++)
|
||||
{
|
||||
if (resolutionComboBox.Text == res.ToDescription())
|
||||
{
|
||||
if (config.Resolution != res)
|
||||
{
|
||||
config.Resolution = res;
|
||||
flags |= CfgUpdateFlags.RestartRqrd;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user