(1) No MessageBox when writing opto-data fails, (2) Read1, Read2, Read3, Read4 added to CommErr enum, ver. 2.16.650

This commit is contained in:
Milan Hanajik 2017-09-06 10:25:22 +02:00
parent 7ed21ff08c
commit 3c85440d34
3 changed files with 28 additions and 21 deletions

View File

@ -26,15 +26,19 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
CommFailed, /// 1
OpenPort, /// 2
Read, /// 3
Write, /// 4
ReadAfterWrite, /// 5
CmdActive, /// 6
CmdTest, /// 7
Verify, /// 8
WrongIPerlType, /// 9
CalibFactorOoRange, /// A
MissingTest, /// B
RFPowerRecordMissing, /// C
Read1, /// 4
Read2, /// 5
Read3, /// 6
Read4, /// 7
Write, /// 8
ReadAfterWrite, /// 9
CmdActive, /// A = 10
CmdTest, /// B = 11
Verify, /// C = 12
WrongIPerlType, /// D = 13
CalibFactorOoRange, /// E = 14
MissingTest, /// F = 15
RFPowerRecordMissing, /// 10H = 16
}
@ -767,12 +771,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Read;
int readRetVal = 0;
/// Read configuration
byte[] config = null;
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == ReadRequestPort(threadId, ihead, MessageID.Configuration, 0, ConfigStruct.Length, out config, cfg.CommTimeout))
readRetVal = ReadRequestPort(threadId, ihead, MessageID.Configuration, 0, ConfigStruct.Length, out config, cfg.CommTimeout);
if (readRetVal == 0)
{
error = CommErr.None;
ihead.ConfigStruct = ConfigStruct.FromByteArray(config);
@ -783,7 +789,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
ClosePort(threadId, ihead); /// Close RFID port
return error;
return error + Math.Max(0, Math.Min(readRetVal, 4));
}
@ -972,12 +978,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
if (OpenPort(threadId, ihead) != 0) return CommErr.OpenPort; /// Open RFID port
CommErr error = CommErr.Read;
int readRetVal = 0;
/// Read calibration
byte[] calib = null;
for (int j = 0; j < cfg.MaxCommRetries; j++)
{
if (0 == ReadRequestPort(threadId, ihead, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, cfg.CommTimeout))
readRetVal = ReadRequestPort(threadId, ihead, MessageID.Calibration, 0, CalibrationStruct.Length, out calib, cfg.CommTimeout);
if (readRetVal == 0)
{
ihead.CalibrationStruct = CalibrationStruct.FromByteArray(calib);
#if IPERL
@ -995,7 +1003,7 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication
ClosePort(threadId, ihead); /// Close RFID port
return error;
return error + Math.Max(0, Math.Min(readRetVal, 4));
}

View File

@ -591,13 +591,14 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
StateMachine.CycleStartTimeStamp.ToString("yy"),
StateMachine.CycleStartTimeStamp.ToString("MM"),
StateMachine.CycleStartTimeStamp.ToString("dd"));
string fullFileName = directory + optoDataLogFileName;
try
{
Directory.CreateDirectory(directory);
double scalFact = ScalingFactor();
using (TextWriter optoLogFile = new StreamWriter(directory + optoDataLogFileName))
using (TextWriter optoLogFile = new StreamWriter(fullFileName))
{
optoLogFile.WriteLine(optoData[0].ToString(scalFact, null));
for (int i = 1; i < optoDataCount; i++) optoLogFile.WriteLine(optoData[i].ToString(scalFact, optoData[i - 1]));
@ -606,11 +607,9 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
}
catch (Exception exc)
{
MessageBox.Show(Strings.Error_writing_into_file_ + Environment.NewLine +
string.Format("{0}\\{1}\r\n{2}", directory, optoDataLogFileName, exc.Message),
Strings.Error,
MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
File.Delete(fullFileName);
log.ErrorFormat(string.Format("Error writing into file {0}", fullFileName));
log.ErrorFormat(string.Format("Exception message: {0}", exc.Message));
}
}

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("2.16.647.1")]
[assembly: AssemblyFileVersion("2.16.647.1")]
[assembly: AssemblyVersion("2.16.650.1")]
[assembly: AssemblyFileVersion("2.16.650.1")]