IPerlHead : more logging when saving opto data, ver. 2.18.1103
This commit is contained in:
parent
97c041801f
commit
2f3f67c82e
@ -573,22 +573,21 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
if (wmPosition.Length == 1) wmPosition = "0" + wmPosition;
|
||||
|
||||
SensusTestInfo[] testInfos = SensusTestInfo.GetTestInfos(LogType);
|
||||
string flowNr = null;
|
||||
|
||||
optoDataLogFileName = null;
|
||||
///
|
||||
foreach (var ti in testInfos)
|
||||
{
|
||||
if ((testName != null) && (testName == ti.TestName))
|
||||
{
|
||||
flowNr = ti.PruefungsNrStr;
|
||||
optoDataLogFileName = string.Format("{0}_{1}_{2}_{3}.txt",
|
||||
(ConfigStruct != null) ? ConfigStruct.GetPcbNrString() : "UnknownPcbNr",
|
||||
wmPosition,
|
||||
ti.PruefungsNrStr,
|
||||
StateMachine.CycleStartTimeStamp.ToString("HH_mm_ss"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flowNr == null) flowNr = "99";
|
||||
|
||||
optoDataLogFileName = string.Format("{0}_{1}_{2}_{3}.txt",
|
||||
(ConfigStruct != null) ? ConfigStruct.GetPcbNrString() : "UnknownPcbNr",
|
||||
wmPosition,
|
||||
flowNr,
|
||||
StateMachine.CycleStartTimeStamp.ToString("HH_mm_ss"));
|
||||
|
||||
StartParsingOptoSerialPort();
|
||||
}
|
||||
@ -660,57 +659,64 @@ namespace TBF.BenchControl.TestMethods.iPerlCommunication.iPerlHead
|
||||
/// </summary>
|
||||
void SaveOptoData()
|
||||
{
|
||||
string directory = string.Format("C:\\TBF\\ProcessData\\{0}\\{1}\\{2}\\",
|
||||
StateMachine.CycleStartTimeStamp.ToString("yy"),
|
||||
StateMachine.CycleStartTimeStamp.ToString("MM"),
|
||||
StateMachine.CycleStartTimeStamp.ToString("dd"));
|
||||
string fullFileName = directory + optoDataLogFileName;
|
||||
try
|
||||
if (optoDataLogFileName != null)
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
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);
|
||||
|
||||
double scalFact = ScalingFactor();
|
||||
log.WarnFormat("Saving {0} opto data to {1}", Name, fullFileName);
|
||||
|
||||
using (TextWriter optoLogFile = new StreamWriter(fullFileName))
|
||||
{
|
||||
if (optoDataCount <= MaxOptoDataCount)
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
double scalFact = ScalingFactor();
|
||||
|
||||
using (TextWriter optoLogFile = new StreamWriter(fullFileName))
|
||||
{
|
||||
/// Telegrams are stored continuously, save them.
|
||||
optoLogFile.WriteLine(optoData[0].ToString(scalFact, null));
|
||||
for (int i = 1; i < optoDataCount; i++)
|
||||
if (optoDataCount <= MaxOptoDataCount)
|
||||
{
|
||||
optoLogFile.WriteLine(optoData[i].ToString(scalFact, optoData[i - 1]));
|
||||
/// Telegrams are stored continuously, save them.
|
||||
optoLogFile.WriteLine(optoData[0].ToString(scalFact, null));
|
||||
for (int i = 1; i < optoDataCount; i++)
|
||||
{
|
||||
optoLogFile.WriteLine(optoData[i].ToString(scalFact, optoData[i - 1]));
|
||||
}
|
||||
}
|
||||
else /// if (optoDataCount > MaxOptoDataCount)
|
||||
{
|
||||
/// Buffer overflow
|
||||
/// First part of the buffer is saved as is
|
||||
optoLogFile.WriteLine(optoData[0].ToString(scalFact, null));
|
||||
for (int i = 1; i < StartOptoDataCount; i++)
|
||||
{
|
||||
optoLogFile.WriteLine(optoData[i].ToString(scalFact, optoData[i - 1]));
|
||||
}
|
||||
|
||||
optoLogFile.WriteLine(" ...");
|
||||
|
||||
/// Second part of the buffer is an overflowed circular buffer
|
||||
optoLogFile.WriteLine(optoData[(optoDataCount - MaxOptoDataCount) % EndOptoDataCount + StartOptoDataCount].ToString(scalFact, null));
|
||||
for (int i = optoDataCount - EndOptoDataCount + 1; i < optoDataCount; i++)
|
||||
{
|
||||
optoLogFile.WriteLine(optoData[(i - StartOptoDataCount) % EndOptoDataCount + StartOptoDataCount]
|
||||
.ToString(scalFact, optoData[(i - 1 - StartOptoDataCount) % EndOptoDataCount + StartOptoDataCount]));
|
||||
}
|
||||
}
|
||||
|
||||
log.WarnFormat("{0} opto data successfully saved: {1} lines", Name, optoDataCount);
|
||||
|
||||
optoLogFile.Close();
|
||||
}
|
||||
else /// if (optoDataCount > MaxOptoDataCount)
|
||||
{
|
||||
/// Buffer overflow
|
||||
/// First part of the buffer is saved as is
|
||||
optoLogFile.WriteLine(optoData[0].ToString(scalFact, null));
|
||||
for (int i = 1; i < StartOptoDataCount; i++)
|
||||
{
|
||||
optoLogFile.WriteLine(optoData[i].ToString(scalFact, optoData[i - 1]));
|
||||
}
|
||||
|
||||
optoLogFile.WriteLine(" ...");
|
||||
|
||||
/// Second part of the buffer is an overflowed circular buffer
|
||||
optoLogFile.WriteLine(optoData[(optoDataCount - MaxOptoDataCount) % EndOptoDataCount + StartOptoDataCount].ToString(scalFact, null));
|
||||
for (int i = optoDataCount - EndOptoDataCount + 1; i < optoDataCount; i++)
|
||||
{
|
||||
optoLogFile.WriteLine(optoData[(i - StartOptoDataCount) % EndOptoDataCount + StartOptoDataCount]
|
||||
.ToString(scalFact, optoData[(i - 1 - StartOptoDataCount) % EndOptoDataCount + StartOptoDataCount]));
|
||||
}
|
||||
}
|
||||
|
||||
optoLogFile.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
File.Delete(fullFileName);
|
||||
log.ErrorFormat(string.Format("Error writing into file {0}", fullFileName));
|
||||
log.ErrorFormat(string.Format("Exception message: {0}", exc.Message));
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
File.Delete(fullFileName);
|
||||
log.ErrorFormat(string.Format("Error writing into file {0}", fullFileName));
|
||||
log.ErrorFormat(string.Format("Exception message: {0}", exc.Message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.18.1102.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1102.0")]
|
||||
[assembly: AssemblyVersion("2.18.1103.0")]
|
||||
[assembly: AssemblyFileVersion("2.18.1103.0")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user