IperlHead as in 2.26, MeterTestRslt.ExtraDataPath and related changes, set in FlyingStart, FlStMassCollection and FlStMassCollProlonged.
This commit is contained in:
@@ -26,6 +26,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
#else
|
||||
public const int MaxOptoDataCount = 40000;
|
||||
#endif
|
||||
public const string OptoDataDirectory = "C:\\TBF\\ProcessData";
|
||||
public const int StartOptoDataCount = MaxOptoDataCount / 2;
|
||||
public const int EndOptoDataCount = MaxOptoDataCount - StartOptoDataCount;
|
||||
public const int StartEndFilterSamplesCount2 = 20; /// StartEndFilterSamplesCount = 2 * StartEndFilterSamplesCount2 + 1
|
||||
@@ -65,31 +66,19 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ConfigStruct != null) return configStruct.GetPcbNrString();
|
||||
if (ConfigStruct != null) return ConfigStruct.GetPcbNrString();
|
||||
else return string.Empty;
|
||||
}
|
||||
set { }
|
||||
}
|
||||
|
||||
public bool Disabled
|
||||
{
|
||||
get { return disabled; }
|
||||
set { disabled = value; }
|
||||
}
|
||||
bool disabled;
|
||||
public bool Disabled;
|
||||
public bool CommFailed;
|
||||
public int ResultCode;
|
||||
|
||||
public bool CommFailed
|
||||
{
|
||||
get { return commFailed; }
|
||||
set { commFailed = value; }
|
||||
}
|
||||
bool commFailed;
|
||||
|
||||
public int ResultCode
|
||||
{
|
||||
get { return resultCode; }
|
||||
}
|
||||
int resultCode;
|
||||
string extraDataPath;
|
||||
public string ExtraDataPath { get { return extraDataPath; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -103,29 +92,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
public bool PositiveCounting;
|
||||
|
||||
|
||||
/// <summary> ConfigStruct of the water meter obtained or updated by iPerlCommunication </summary>
|
||||
public ConfigStruct ConfigStruct
|
||||
{
|
||||
get { return configStruct; }
|
||||
set { configStruct = value; }
|
||||
}
|
||||
ConfigStruct configStruct;
|
||||
|
||||
/// <summary> CalibrationStruct of the water meter obtained or updated by iPerlCommunication </summary>
|
||||
public CalibrationStruct CalibrationStruct
|
||||
{
|
||||
get { return calibrationStruct; }
|
||||
set { calibrationStruct = value; }
|
||||
}
|
||||
CalibrationStruct calibrationStruct;
|
||||
|
||||
/// <summary> CalibrationStruct of the water meter obtained or updated by iPerlCommunication </summary>
|
||||
public CalibrationStructV4 CalibrationStructV4
|
||||
{
|
||||
get { return calibrationStructV4; }
|
||||
set { calibrationStructV4 = value; }
|
||||
}
|
||||
CalibrationStructV4 calibrationStructV4;
|
||||
public ConfigStruct ConfigStruct; /// ConfigStruct of WM obtained or updated by iPerlCommunication
|
||||
public CalibrationStruct CalibrationStruct; /// CalibrationStruct of WM obtained or updated by iPerlCommunication
|
||||
public CalibrationStructV4 CalibrationStructV4; /// CalibrationStruct of WM obtained or updated by iPerlCommunication
|
||||
|
||||
public ushort OrigCalibFactor;
|
||||
public ushort CalibFactor
|
||||
@@ -171,16 +140,16 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
///
|
||||
public int WMPulses { get { return wmPulses; } }
|
||||
public int WMRefPulses { get { return wmRefPulses; } }
|
||||
public double WMVolume { get { return wmVolume; } }
|
||||
public double BeginWMState { get { return beginWMState; } }
|
||||
public double EndWMState { get { return endWMState; } }
|
||||
public double WMTestTime { get { return wmTestTime; } }
|
||||
public double WMVolume { get { return wmVolume; } }
|
||||
public double WMTestTime { get { return wmTestTime; } }
|
||||
|
||||
double beginWMState;
|
||||
int wmPulses;
|
||||
int wmRefPulses;
|
||||
double beginWMState;
|
||||
double endWMState;
|
||||
double wmVolume;
|
||||
int wmPulses;
|
||||
int wmRefPulses;
|
||||
double wmTestTime;
|
||||
|
||||
|
||||
@@ -312,31 +281,6 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
/// <summary> Name set by the test, to be used as a part of the opto-data log file name </summary>
|
||||
public string BenchName;
|
||||
|
||||
///
|
||||
/// Volume of water from the opto telegram
|
||||
///
|
||||
private Int64 lastVolumeRaw; /// Last read raw volume
|
||||
private double volumeLtr;
|
||||
private double volumeLtr0;
|
||||
|
||||
/// Test start volume for metrology in liters
|
||||
public double VolumeLtrStart { get { return VolumeFromSamples(optoData, optoDataCount, TestStartTelegramIx, ScalingFactor(), StartEndFilterSamplesCount2); } }
|
||||
/// Test end volume for metrology in liters
|
||||
public double VolumeLtrEnd { get { return VolumeFromSamples(optoData, optoDataCount, TestEndTelegramIx, ScalingFactor(), StartEndFilterSamplesCount2); } }
|
||||
|
||||
///
|
||||
/// Timestamp from the opto telegram
|
||||
///
|
||||
private Int64 lastTimestamp;
|
||||
private double timestampSec;
|
||||
private double timestampSec0;
|
||||
|
||||
public bool NoSamples { get { return (TimestampSecEnd - TimestampSecStart) < float.Epsilon; } }
|
||||
|
||||
/// Test start volume for metrology in seconds
|
||||
public double TimestampSecStart { get { return TimeFromSamples(optoData, optoDataCount, TestStartTelegramIx, StartEndFilterSamplesCount2); } }
|
||||
/// Test end time for metrology in seconds
|
||||
public double TimestampSecEnd { get { return TimeFromSamples(optoData, optoDataCount, TestEndTelegramIx, StartEndFilterSamplesCount2); } }
|
||||
|
||||
///
|
||||
/// Indices to determine centers of start / end samples
|
||||
@@ -350,6 +294,47 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
int currentTelegramIx;
|
||||
bool startSampleAcquired;
|
||||
|
||||
///
|
||||
/// Timestamp from the opto telegram
|
||||
///
|
||||
private Int64 lastTimestamp;
|
||||
private double timestampSec;
|
||||
private double timestampSec0;
|
||||
|
||||
/// Test start volume for metrology in seconds
|
||||
public double TimestampSecStart
|
||||
{
|
||||
get { return TimeFromSamples(optoData, optoDataCount, TestStartTelegramIx, StartEndFilterSamplesCount2); }
|
||||
}
|
||||
/// Test end time for metrology in seconds
|
||||
public double TimestampSecEnd
|
||||
{
|
||||
get { return TimeFromSamples(optoData, optoDataCount, TestEndTelegramIx, StartEndFilterSamplesCount2); }
|
||||
}
|
||||
///
|
||||
public bool NoSamples
|
||||
{
|
||||
get { return TimestampSecStart == 0 || TimestampSecEnd == 0 || (TimestampSecEnd - TimestampSecStart) < float.Epsilon; }
|
||||
}
|
||||
|
||||
///
|
||||
/// Volume of water from the opto telegram
|
||||
///
|
||||
private Int64 lastVolumeRaw; /// Last read raw volume
|
||||
private double volumeLtr;
|
||||
private double volumeLtr0;
|
||||
|
||||
/// Test start volume for metrology in liters
|
||||
public double VolumeLtrStart
|
||||
{
|
||||
get { return NoSamples ? 0 : VolumeFromSamples(optoData, optoDataCount, TestStartTelegramIx, ScalingFactor(), StartEndFilterSamplesCount2); }
|
||||
}
|
||||
/// Test end volume for metrology in liters
|
||||
public double VolumeLtrEnd
|
||||
{
|
||||
get { return NoSamples ? 0 : VolumeFromSamples(optoData, optoDataCount, TestEndTelegramIx, ScalingFactor(), StartEndFilterSamplesCount2); }
|
||||
}
|
||||
|
||||
|
||||
OptoTelegramRaw[] optoData;
|
||||
int optoDataCount;
|
||||
@@ -369,22 +354,23 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
: base(cfg)
|
||||
{
|
||||
iperlHeadCfg = cfg as IperlHeadCfg;
|
||||
log.Warn(this.ToString());
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
ClearSessionData();
|
||||
optoSerialPortParsingEnabled = false;
|
||||
|
||||
flowDirectionDetection = new FlowDirectionDetection();
|
||||
|
||||
/// Allocate memory for opto-data from iPerl
|
||||
optoData = new OptoTelegramRaw[MaxOptoDataCount];
|
||||
for (int i = 0; i < MaxOptoDataCount; i++) optoData[i] = new OptoTelegramRaw();
|
||||
for (int i = 0; i < MaxOptoDataCount; i++)
|
||||
{
|
||||
optoData[i] = new OptoTelegramRaw();
|
||||
}
|
||||
|
||||
toBeFlushed = new OptoTelegramRaw();
|
||||
|
||||
optoSerialPortParsingEnabled = false;
|
||||
synchronized = false;
|
||||
synchronized2 = false;
|
||||
partOfTelegram = string.Empty;
|
||||
@@ -396,12 +382,12 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
optoSerialPort = new SerialPort(portName, 9600, Parity.None, 8, StopBits.One);
|
||||
optoSerialPort.Handshake = Handshake.None;
|
||||
optoSerialPort.Open();
|
||||
log.FatalFormat("{0} - Device successfully initialized", Name);
|
||||
log.FatalFormat("{0} initialized: {1}", Name, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
optoSerialPort = null;
|
||||
log.FatalFormat("{0} - Device simulated", Name);
|
||||
log.FatalFormat("{0} simulated: {1}", Name, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,14 +396,14 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
/// </summary>
|
||||
public void ClearSessionData()
|
||||
{
|
||||
resultCode = 0;
|
||||
ResultCode = 0;
|
||||
|
||||
disabled = false;
|
||||
commFailed = false;
|
||||
Disabled = false;
|
||||
CommFailed = false;
|
||||
|
||||
configStruct = null;
|
||||
calibrationStruct = null;
|
||||
calibrationStructV4 = null;
|
||||
ConfigStruct = null;
|
||||
CalibrationStruct = null;
|
||||
CalibrationStructV4 = null;
|
||||
|
||||
LastTestResult = null;
|
||||
LastTestResult2 = null;
|
||||
@@ -521,7 +507,7 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
resultCode = 0;
|
||||
ResultCode = 0;
|
||||
|
||||
volumeLtr = 0;
|
||||
volumeLtr0 = 0;
|
||||
@@ -550,34 +536,42 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
endTelegramIdx3 = 0;
|
||||
TestEndTelegramIx = 0;
|
||||
|
||||
/// File name is: PCB_AA_BB_HH_MI_SS..txt
|
||||
string wmPosition = Name.Substring(5); /// WMPosition is extracted from a component name in form 'iPerl#'
|
||||
if (wmPosition.Length == 1) wmPosition = "0" + wmPosition;
|
||||
|
||||
if (StateMachine.Procedure != null && Sequences.ProcessData.CompleteTestInfos == null)
|
||||
{
|
||||
Sequences.ProcessData.CompleteTestInfos = Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure);
|
||||
}
|
||||
|
||||
Results.Output.SensusTestInfo[] testInfos = Sequences.ProcessData.CompleteTestInfos;
|
||||
optoDataLogFileName = null;
|
||||
///
|
||||
if (testInfos != null)
|
||||
/// Determine opto data file name: PCB_AA_BB_HH_MI_SS..txt
|
||||
///
|
||||
Results.Output.SensusTestInfo[] localTestInfos = Sequences.ProcessData.CompleteTestInfos;
|
||||
if (localTestInfos == null && StateMachine.Procedure != null)
|
||||
{
|
||||
string fullTestName = Results.Utils.GetTestName(testName, testRepeats, repetitionNr);
|
||||
foreach (var ti in testInfos)
|
||||
localTestInfos = Results.Output.SensusTestInfo.CreateFromProcedure(StateMachine.Procedure);
|
||||
}
|
||||
///
|
||||
string fullTestName = Results.Utils.GetTestName(testName, testRepeats, repetitionNr);
|
||||
string qBezeichnungOpto = null; /// To be determined from TestInfo-s (if there are any)
|
||||
if (localTestInfos != null)
|
||||
{
|
||||
foreach (var ti in localTestInfos)
|
||||
{
|
||||
if ((ti.PruefungsNrOpto != 0) && (ti.TestName == fullTestName))
|
||||
{
|
||||
optoDataLogFileName = string.Format("{0}_{1}_{2}_{3}.txt",
|
||||
(ConfigStruct != null) ? ConfigStruct.GetPcbNrString() : "UnknownPcbNr",
|
||||
wmPosition,
|
||||
string.IsNullOrEmpty(ti.QBezeichnungOpto) ? ti.PruefungsNrOpto.ToString("D2") : ti.QBezeichnungOpto,
|
||||
StateMachine.CycleStartTimeStamp.ToString("HH_mm_ss"));
|
||||
qBezeichnungOpto = string.IsNullOrEmpty(ti.QBezeichnungOpto) ? ti.PruefungsNrOpto.ToString("D2") : ti.QBezeichnungOpto;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (qBezeichnungOpto == null)
|
||||
{
|
||||
qBezeichnungOpto = fullTestName; /// No appropriate TestInfo found => set default opto data file name
|
||||
}
|
||||
///
|
||||
string pcbNr = (ConfigStruct != null) ? ConfigStruct.GetPcbNrString() : "UnknownPcbNr";
|
||||
string wmPosition = Name.Substring(5); /// WMPosition is extracted from a component name in form 'iPerl#'
|
||||
if (wmPosition.Length == 1) wmPosition = "0" + wmPosition;
|
||||
string cycleStartTime = StateMachine.CycleStartTimeStamp.ToString("HH_mm_ss");
|
||||
///
|
||||
optoDataLogFileName = string.Format("{0}_{1}_{2}_{3}.txt", pcbNr, wmPosition, qBezeichnungOpto, cycleStartTime);
|
||||
|
||||
extraDataPath = null;
|
||||
|
||||
StartParsingOptoSerialPort();
|
||||
}
|
||||
@@ -636,35 +630,36 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
OptoTelegramRaw.FIRFilterFlow(optoData, 0, StartOptoDataCount - 1);
|
||||
OptoTelegramRaw.FIRFilterFlow(optoData, (optoDataCount - EndOptoDataCount), optoDataCount - 1);
|
||||
}
|
||||
SaveOptoData();
|
||||
|
||||
extraDataPath = SaveOptoData();
|
||||
|
||||
if (TestStartTelegramIx == 0 || optoDataCount < 100)
|
||||
{
|
||||
resultCode |= (int)Results.Entities.ResultCode.MissingOptoData;
|
||||
ResultCode |= (int)Results.Entities.ResultCode.MissingOptoData;
|
||||
}
|
||||
else if (VolumeLtrEnd == VolumeLtrStart)
|
||||
{
|
||||
resultCode |= (int)Results.Entities.ResultCode.OptoDataWithZeroFlow;
|
||||
ResultCode |= (int)Results.Entities.ResultCode.OptoDataWithZeroFlow;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save opto data to a file.
|
||||
/// </summary>
|
||||
void SaveOptoData()
|
||||
string SaveOptoData()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(optoDataLogFileName))
|
||||
{
|
||||
string directory = Path.Combine("C:\\TBF\\ProcessData", StateMachine.CycleStartTimeStamp.ToString("yy"),
|
||||
StateMachine.CycleStartTimeStamp.ToString("MM"),
|
||||
StateMachine.CycleStartTimeStamp.ToString("dd"));
|
||||
string fullFileName = Path.Combine(directory, optoDataLogFileName);
|
||||
string relativeDirectory = Path.Combine(StateMachine.CycleStartTimeStamp.ToString("yy"),
|
||||
StateMachine.CycleStartTimeStamp.ToString("MM"),
|
||||
StateMachine.CycleStartTimeStamp.ToString("dd"));
|
||||
string fullFileName = Path.Combine(OptoDataDirectory, relativeDirectory, optoDataLogFileName);
|
||||
|
||||
log.WarnFormat("Saving {0} opto data to {1}", Name, fullFileName);
|
||||
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
Directory.CreateDirectory(Path.Combine(OptoDataDirectory, relativeDirectory));
|
||||
|
||||
double scalFact = ScalingFactor();
|
||||
|
||||
@@ -704,6 +699,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
|
||||
optoLogFile.Close();
|
||||
}
|
||||
|
||||
return Path.Combine(relativeDirectory, optoDataLogFileName);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -712,7 +709,9 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
log.ErrorFormat(string.Format("Exception message: {0}", exc.Message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void ReadPulses()
|
||||
{
|
||||
@@ -913,8 +912,8 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
{
|
||||
default:
|
||||
case VolumeUnits.m3: return Common.Units.ConvertFrom(Common.Unit.m3, 1.0); /// liter
|
||||
case VolumeUnits.UK_gallon: return Common.Units.ConvertFrom(Common.Unit.UKgal, 1.0); /// liter
|
||||
case VolumeUnits.US_gallon: return Common.Units.ConvertFrom(Common.Unit.USgal, 1.0); /// liter
|
||||
case VolumeUnits.UK_gallon: return Common.Units.ConvertFrom(Common.Unit.UKgal, 1.0); /// liter
|
||||
case VolumeUnits.US_gallon: return Common.Units.ConvertFrom(Common.Unit.USgal, 1.0); /// liter
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1019,29 +1018,29 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
|
||||
public void WriteBinary(BinaryWriter writer)
|
||||
{
|
||||
writer.Write(disabled);
|
||||
writer.Write(commFailed);
|
||||
writer.Write(resultCode);
|
||||
writer.Write(Disabled);
|
||||
writer.Write(CommFailed);
|
||||
writer.Write(ResultCode);
|
||||
writer.Write(PositiveCounting);
|
||||
|
||||
if (configStruct != null)
|
||||
if (ConfigStruct != null)
|
||||
{
|
||||
writer.Write(true);
|
||||
configStruct.WriteBinary(writer);
|
||||
ConfigStruct.WriteBinary(writer);
|
||||
}
|
||||
else writer.Write(false);
|
||||
|
||||
if (calibrationStruct != null)
|
||||
if (CalibrationStruct != null)
|
||||
{
|
||||
writer.Write(true);
|
||||
calibrationStruct.WriteBinary(writer);
|
||||
CalibrationStruct.WriteBinary(writer);
|
||||
}
|
||||
else writer.Write(false);
|
||||
|
||||
if (calibrationStructV4 != null)
|
||||
if (CalibrationStructV4 != null)
|
||||
{
|
||||
writer.Write(true);
|
||||
calibrationStructV4.WriteBinary(writer);
|
||||
CalibrationStructV4.WriteBinary(writer);
|
||||
}
|
||||
else writer.Write(false);
|
||||
|
||||
@@ -1071,14 +1070,14 @@ namespace TBF.Rig.TestMethods.iPerlCommunication.iPerlHead
|
||||
|
||||
public void ReadBinary(BinaryReader reader)
|
||||
{
|
||||
disabled = reader.ReadBoolean();
|
||||
commFailed = reader.ReadBoolean();
|
||||
resultCode = reader.ReadInt32();
|
||||
Disabled = reader.ReadBoolean();
|
||||
CommFailed = reader.ReadBoolean();
|
||||
ResultCode = reader.ReadInt32();
|
||||
PositiveCounting = reader.ReadBoolean();
|
||||
|
||||
if (reader.ReadBoolean()) (configStruct = new ConfigStruct()).ReadBinary(reader);
|
||||
if (reader.ReadBoolean()) (calibrationStruct = new CalibrationStruct()).ReadBinary(reader);
|
||||
if (reader.ReadBoolean()) (calibrationStructV4 = new CalibrationStructV4()).ReadBinary(reader);
|
||||
if (reader.ReadBoolean()) (ConfigStruct = new ConfigStruct()).ReadBinary(reader);
|
||||
if (reader.ReadBoolean()) (CalibrationStruct = new CalibrationStruct()).ReadBinary(reader);
|
||||
if (reader.ReadBoolean()) (CalibrationStructV4 = new CalibrationStructV4()).ReadBinary(reader);
|
||||
|
||||
OrigCalibFactor = reader.ReadUInt16();
|
||||
OrigCalibFactorLNA = reader.ReadUInt16();
|
||||
|
||||
Reference in New Issue
Block a user