Uni.GeneralData : Unused member variables deleted.

This commit is contained in:
Milan Hanajik
2021-02-23 11:35:28 +01:00
parent f54430ccf6
commit 5325d7f6ee
2 changed files with 46 additions and 64 deletions
@@ -10,47 +10,27 @@ namespace TBF.BenchControl.ControlBoard.Uni
public const byte MessageCode = (byte)' ';
/// General data
public byte UnusedCode; /// ???, byte 4
public ulong Status; /// byte 5..9
public uint Status4; /// byte 9
public ulong Status; /// byte 5..9, 5 bytes = 40 bits
public uint Status5;
public uint Status6; /// Parallel flow meters mask: bit0=0x01=Et1, bit1=0x02=Et2, bit2=0x04=Et3
public uint Chyby485;
public bool PosliKohut;
public int TolerRV;
public float[] ZCasPohybu = new float[2];
public ulong Kohuty = 0;
public ulong KohutyH = 0;
public ulong Vystupy;
public uint DajFilt;
public uint[] KFilter = new uint[8];
public uint[] Parametre = new uint[5];
public uint NastavRV;
public uint StabRV;
public uint[] StavDA = new uint[2];
public float ZStavDA2;
public float[] referenceFreq = new float[4];
public uint[] etPulses = new uint[Const.WMsCount + 1]; /// WMsCount = 20
public uint etPulsesK;
public float[] ReferenceFreq = new float[4];
public uint[] EtPulses = new uint[Const.WMsCount + 1]; /// EtPulses[0]=total pulses, EtPulses[1..WMsCount] gated et.pulses for respective WM
public uint EtPulsesK;
public uint EtPulses2;
public uint EtPulses3;
public uint[] wMeterPuls = new uint[Const.WMsCount + 1]; /// WMsCount = 20
public uint[] WMeterPuls = new uint[Const.WMsCount + 1]; /// WMsCount = 20
public double[] ImpulseTime = new double[Const.WMsCount + 1]; /// WMsCount = 20
public uint[] wMeterReference = new uint[Const.WMsCount + 1]; /// WMsCount = 20
public uint[] rValveStatus = new uint[Const.RVsCount + 1 + 1]; /// RVsCount = 8, posledny rValveStatus[9] je prudovy
public float[] ValveMoveTime = new float[Const.RVsCount];
public ulong rRoute;
public ulong rRouteH;
public int[] divTime = new int[3];
public uint[] RegVStatus = new uint[Const.RVsCount + 1 + 1]; /// RVsCount = 8, posledny rValveStatus[9] je prudovy
public float[] RegVMoveTime = new float[Const.RVsCount];
public int DivTime;
public double Ttime; /// s
public double TimeRef; /// s
public uint[] beginSt = new uint[Const.WMsCount + 1]; /// WMsCount = 20
public float referenceFlow;
public float[] RValvePosition = new float[Const.RVsCount + 1 + 1]; /// RVsCount = 8
public ulong Vstupy;
public int[] AnalogyRaw = new int[Const.ADCsCount];
public int[] TemperatureRaw = new int[8];
public float[] ReferenceVolume = new float[2];
public GeneralData()
@@ -101,9 +81,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
/// <param name="offs">Offset of the message</param>
public void UpdateData(byte[] data, int offs)
{
UnusedCode = data[offs + (int)Poz.Start]; /// Byte 4
Status = GetUInt40(data, offs + (int)Poz.Status); /// Byte 5,6,7,8,9
Status4 = data[offs + (int)Poz.Status + 4]; /// Byte 9 (duplicated)
Vystupy = GetUInt64(data, offs + (int)Poz.Vyst); /// Byte 10 .. 17
StavDA[1] = GetUInt16(data, offs + (int)Poz.SDA2); /// Byte 18,19
Vstupy = GetUInt40(data, offs + (int)Poz.Vst); /// Byte 20,21,22,23,24
@@ -120,23 +98,20 @@ namespace TBF.BenchControl.ControlBoard.Uni
TemperatureRaw[i] = GetInt16(data, offs + (int)Poz.Groch + 2 * i);
}
etPulses[0] = GetUInt24(data, offs + (int)Poz.Et1); /// Byte 73,74,75
etPulsesK = GetUInt24(data, offs + (int)Poz.EtK); /// Byte 76,77,78
/// TODO /// byte 79
EtPulses[0] = GetUInt24(data, offs + (int)Poz.Et1); /// Byte 73,74,75
EtPulsesK = GetUInt24(data, offs + (int)Poz.EtK); /// Byte 76,77,78
byte spare1 = data[offs + (int)Poz.spare1]; /// byte 79
Status5 = data[offs + (int)Poz.Stat5]; /// Byte 80
Status6 = data[offs + (int)Poz.Stat6]; /// Byte 81
/// TODO /// byte 82
byte spare2 = data[offs + (int)Poz.spare2]; /// byte 82
for (int i = 0; i < Const.RVsCount; i++) /// Byte 83 .. 90
{
rValveStatus[i + 1] = ((uint)data[offs + (int)Poz.RVs + i] >> 3) & 7;
RegVStatus[i + 1] = ((uint)data[offs + (int)Poz.RVs + i] >> 3) & 7;
}
/// 4-20 mA reg. valve
uint stavRegQ = (uint)((Status >> 16) & 0xFF);
rValveStatus[Const.RVsCount + 1] = (stavRegQ >> 4) & 2;
RegVStatus[Const.RVsCount + 1] = (stavRegQ >> 4) & 2;
/// This must preceed processing bytes 91 .. 250 as Ttime is used there
uint ttimeRaw = GetUInt32(data, offs + (int)Poz.Ttime); /// Byte 251,252,253,254
@@ -151,20 +126,20 @@ namespace TBF.BenchControl.ControlBoard.Uni
if ((Status & (ulong)StatusP.SynchroMethod) != 0)
{
ushort pulses = GetUInt16(data, ix2);
wMeterPuls[wmNr] = pulses;
etPulses[wmNr] = (pulses == 0) ? 0 : GetUInt24(data, ix1);
WMeterPuls[wmNr] = pulses;
EtPulses[wmNr] = (pulses == 0) ? 0 : GetUInt24(data, ix1);
ImpulseTime[wmNr] = (pulses == 0) ? 0 : GetUInt24(data, ix1 + 3) * Const.TimeResolution;
}
else
{
wMeterPuls[wmNr] = GetUInt24(data, ix1);
etPulses[wmNr] = etPulses[0];
WMeterPuls[wmNr] = GetUInt24(data, ix1);
EtPulses[wmNr] = EtPulses[0];
ImpulseTime[wmNr] = Ttime;
}
}
StavDA[0] = GetUInt16(data, offs + (int)Poz.SDA); /// Byte 255,256
byte spare1 = data[offs + (int)Poz.spare1]; /// Byte 257
byte spare3 = data[offs + (int)Poz.spare3]; /// Byte 257
/// Impulzy perioda (???)
uint[] par1 = new uint[3];
@@ -176,31 +151,31 @@ namespace TBF.BenchControl.ControlBoard.Uni
par2[2] = GetUInt16(data, offs + (int)Poz.Per3); /// Byte 266,267
par1[2] = GetUInt16(data, offs + (int)Poz.Per3 + 2); /// Byte 268,269
///
referenceFreq[0] = (par2[0] != 0) ? (5.0f * par1[0] / par2[0]) : 0.0f;
referenceFreq[1] = referenceFreq[2] = referenceFreq[3] = 0;
ReferenceFreq[0] = (par2[0] != 0) ? (5.0f * par1[0] / par2[0]) : 0.0f;
ReferenceFreq[1] = ReferenceFreq[2] = ReferenceFreq[3] = 0;
///
if ((Status & (ulong)StatusP.TestWithRefFlowmtr) != 0 && (Status & (ulong)StatusP.FlowmtrIdMask) == 0)
{
/// Measurement with parallel flowmeters
if ((Status6 & 0x01) != 0)
referenceFreq[1] = referenceFreq[0];
ReferenceFreq[1] = ReferenceFreq[0];
if ((Status6 & 0x02) != 0)
referenceFreq[2] = (par2[1] != 0) ? (5.0f * par1[1] / par2[1]) : 0.0f;
ReferenceFreq[2] = (par2[1] != 0) ? (5.0f * par1[1] / par2[1]) : 0.0f;
if ((Status6 & 0x04) != 0)
referenceFreq[3] = (par2[2] != 0) ? (5.0f * par1[2] / par2[2]) : 0.0f;
ReferenceFreq[3] = (par2[2] != 0) ? (5.0f * par1[2] / par2[2]) : 0.0f;
referenceFreq[0] = referenceFreq[1] + referenceFreq[2] + referenceFreq[3];
ReferenceFreq[0] = ReferenceFreq[1] + ReferenceFreq[2] + ReferenceFreq[3];
}
divTime[0] = Const.DivTimeResolution * data[offs + (int)Poz.CasKl]; /// Byte 271
byte spare2 = data[offs + (int)Poz.spare2]; /// Byte 272
DivTime = Const.DivTimeResolution * 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 !!!!!!!!!!!!!!!
TimeRef = Convert.ToDouble(timeRefRaw) / 1000.0; /// convert to [s]
for (int i = 0; i < Const.RVsCount; i++) /// Byte 278 .. 293
{
ValveMoveTime[i] = 10 * GetUInt16(data, offs + (int)Poz.CasKoh + 2*i);
RegVMoveTime[i] = 10 * GetUInt16(data, offs + (int)Poz.CasKoh + 2*i);
}
EtPulses2 = GetUInt24(data, offs + (int)Poz.ETX2); /// Byte 294,295,296
@@ -213,8 +188,7 @@ namespace TBF.BenchControl.ControlBoard.Uni
/// </summary>
public enum Poz : int
{
Start = 4,
Status = Start + 1, /// 5 .. 9
Status = 5, /// 5 .. 9
Vyst = Status + 5, /// 10 .. 17
SDA2 = Vyst + 8, /// 18,19
Vst = SDA2 + 2, /// 20 .. 24
@@ -222,20 +196,22 @@ namespace TBF.BenchControl.ControlBoard.Uni
Groch = Analogy + 2 * Const.ADCsCount, /// 57 (16 analog inputs)
Et1 = Groch + 16, /// 73,74,75
EtK = Et1 + 3, /// 76,77,78
Stat5 = EtK + 4, /// 80
spare1 = EtK + 3, /// 79
Stat5 = spare1 + 1, /// 80
Stat6 = Stat5 + 1, /// 81
RVs = Stat6 + 2, /// 83
spare2 = Stat6 + 1, /// 82
RVs = spare2 + 1, /// 83
CT1 = RVs + 8, /// 91
CTR1 = CT1 + 6 * Const.WMsCount, /// 211
Ttime = CTR1 + 2 * Const.WMsCount, /// 251
SDA = Ttime + 4, /// 255
spare1 = SDA + 2, /// 257
Per1 = spare1 + 1, /// 258
spare3 = SDA + 2, /// 257
Per1 = spare3 + 1, /// 258
Per2 = Per1 + 4, /// 262
Per3 = Per2 + 4, /// 266
CasKl = Per3 + 5, /// 271
spare2 = CasKl + 1, /// 272
Chyb485 = spare2 + 1, /// 273
spare4 = CasKl + 1, /// 272
Chyb485 = spare4 + 1, /// 273
Tim2 = Chyb485 + 1, /// 274
CasKoh = Tim2 + 4, /// 278
ETX2 = CasKoh + 2 * Const.RVsCount, /// 294