Diverter.Resolution 1, 2, 4, and 8 ms implemented, ver. 3.7.2092
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user