Fix bug where multiple threads modify same variable at the same time. Perform some refactoring
This commit is contained in:
@@ -61,13 +61,13 @@ namespace ProgramLib
|
||||
|
||||
#endregion
|
||||
|
||||
internal SequenceContext _testStandSeqContext;
|
||||
internal UutInfo _uutInfo;
|
||||
internal EventManager _eventManager = new EventManager();
|
||||
internal FileAndFolderManager _fileAndFolderManager;
|
||||
internal IConfigurationFile _programConfig { get; private set; }
|
||||
internal SequenceContext TestStandSeqContext { get; private set; }
|
||||
internal UutInfo UutInfo { get; private set; }
|
||||
internal EventManager EventManager { get; private set; }
|
||||
internal FileAndFolderManager FileAndFolderManager { get; set; }
|
||||
internal IConfigurationFile ProgramConfig { get; private set; }
|
||||
internal MalMeasurementLibManager MalMeasurementLibManager { get; private set; }
|
||||
internal string _testMethodConfigFilePath;
|
||||
internal string TestMethodConfigFilePath { get; private set; }
|
||||
|
||||
internal bool SttoSuccess { get; set; }
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace ProgramLib
|
||||
if (_program != null)
|
||||
{
|
||||
// signal to all running threads to exit
|
||||
_program._eventManager[EventManager.Events.GLOBAL_QUIT].Set();
|
||||
_program.EventManager[EventManager.Events.GLOBAL_QUIT].Set();
|
||||
|
||||
UutPowerAction uutPowerAction = new UutPowerAction();
|
||||
uutPowerAction.UutPowerOff();
|
||||
@@ -133,15 +133,16 @@ namespace ProgramLib
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
_programConfig = new ConfigurationFile(Path.Combine(assemblyFolder, GeneralConstants.ProgramConfigFilename));
|
||||
ProgramConfig = new ConfigurationFile(Path.Combine(assemblyFolder, GeneralConstants.ProgramConfigFilename));
|
||||
|
||||
_testMethodConfigFilePath = Path.Combine(assemblyFolder, GeneralConstants.TestMethodConfigFolderName, GeneralConstants.TestMethodConfigFileName);
|
||||
TestMethodConfigFilePath = Path.Combine(assemblyFolder, GeneralConstants.TestMethodConfigFolderName, GeneralConstants.TestMethodConfigFileName);
|
||||
|
||||
_fileAndFolderManager = new FileAndFolderManager(_programConfig);
|
||||
EventManager = new EventManager();
|
||||
FileAndFolderManager = new FileAndFolderManager(ProgramConfig);
|
||||
|
||||
if (testStandSeqContext != null)
|
||||
{
|
||||
_testStandSeqContext = testStandSeqContext as SequenceContext;
|
||||
TestStandSeqContext = testStandSeqContext as SequenceContext;
|
||||
}
|
||||
|
||||
// make sure PN/SN are valid (TS may not pass in the PN)
|
||||
@@ -162,7 +163,7 @@ namespace ProgramLib
|
||||
SttoSuccess = false;
|
||||
|
||||
// Initialze all other configuration that the program needs
|
||||
_uutInfo = new UutInfo(_partNumber, _serialNumber);
|
||||
UutInfo = new UutInfo(_partNumber, _serialNumber);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -185,19 +186,19 @@ namespace ProgramLib
|
||||
{
|
||||
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() ...");
|
||||
|
||||
if (_testStandSeqContext != null)
|
||||
if (TestStandSeqContext != null)
|
||||
{
|
||||
// clear any setting that we have added for any steps in the Setup Group
|
||||
for (int i = 0; i < _testStandSeqContext.Sequence.GetNumSteps(StepGroups.StepGroup_Setup); i++)
|
||||
for (int i = 0; i < TestStandSeqContext.Sequence.GetNumSteps(StepGroups.StepGroup_Setup); i++)
|
||||
{
|
||||
_testStandSeqContext.Sequence.GetStep(i, StepGroups.StepGroup_Setup).PostExpression = "";
|
||||
TestStandSeqContext.Sequence.GetStep(i, StepGroups.StepGroup_Setup).PostExpression = "";
|
||||
}
|
||||
|
||||
// clear any setting that we have added for any steps in the Main Group
|
||||
for (int i = 0; i < _testStandSeqContext.Sequence.GetNumSteps(StepGroups.StepGroup_Main); i++)
|
||||
for (int i = 0; i < TestStandSeqContext.Sequence.GetNumSteps(StepGroups.StepGroup_Main); i++)
|
||||
{
|
||||
_testStandSeqContext.Sequence.GetStep(i, StepGroups.StepGroup_Main).PostExpression = "";
|
||||
_testStandSeqContext.Sequence.GetStep(i, StepGroups.StepGroup_Main).AdditionalResults.CustomResults.Clear();
|
||||
TestStandSeqContext.Sequence.GetStep(i, StepGroups.StepGroup_Main).PostExpression = "";
|
||||
TestStandSeqContext.Sequence.GetStep(i, StepGroups.StepGroup_Main).AdditionalResults.CustomResults.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,7 +222,7 @@ namespace ProgramLib
|
||||
/// <returns></returns>
|
||||
private void TerminateTestOnMainThreadError(Exception ex)
|
||||
{
|
||||
if (_testStandSeqContext != null)
|
||||
if (TestStandSeqContext != null)
|
||||
{
|
||||
_logger.Error(ex.Message + "\n" + ex.StackTrace);
|
||||
|
||||
@@ -230,13 +231,13 @@ namespace ProgramLib
|
||||
if (!_terminateTestInitiated)
|
||||
{
|
||||
// tells teststand there's a exception occurred and give it the error message
|
||||
_testStandSeqContext.Step.PostExpression = $"Step.Result.Error.Msg=\"{ex.Message} \", Step.Result.Error.Occurred=True";
|
||||
TestStandSeqContext.Step.PostExpression = $"Step.Result.Error.Msg=\"{ex.Message} \", Step.Result.Error.Occurred=True";
|
||||
|
||||
_testStandSeqContext.Step.ResultStatus = "Error";
|
||||
TestStandSeqContext.Step.ResultStatus = "Error";
|
||||
|
||||
// tells TestStand to go to clean up
|
||||
_testStandSeqContext.StepGroup = StepGroups.StepGroup_Cleanup;
|
||||
_testStandSeqContext.NextStepIndex = 0;
|
||||
TestStandSeqContext.StepGroup = StepGroups.StepGroup_Cleanup;
|
||||
TestStandSeqContext.NextStepIndex = 0;
|
||||
|
||||
_terminateTestInitiated = true;
|
||||
}
|
||||
@@ -255,19 +256,19 @@ namespace ProgramLib
|
||||
/// <returns></returns>
|
||||
internal void TerminateTestOnSupportThreadError()
|
||||
{
|
||||
if (_testStandSeqContext != null)
|
||||
if (TestStandSeqContext != null)
|
||||
{
|
||||
lock (_terminateTestSyncObj)
|
||||
{
|
||||
if (!_terminateTestInitiated)
|
||||
{
|
||||
// tells teststand there's a exception occurred and give it the error message
|
||||
_testStandSeqContext.SequenceErrorMessage = _fatalErrorMsgFromSupportThread + " ";
|
||||
_testStandSeqContext.SequenceErrorOccurred = true;
|
||||
TestStandSeqContext.SequenceErrorMessage = _fatalErrorMsgFromSupportThread + " ";
|
||||
TestStandSeqContext.SequenceErrorOccurred = true;
|
||||
|
||||
// tells TestStand to go to clean up
|
||||
_testStandSeqContext.StepGroup = StepGroups.StepGroup_Cleanup;
|
||||
_testStandSeqContext.NextStepIndex = 0;
|
||||
TestStandSeqContext.StepGroup = StepGroups.StepGroup_Cleanup;
|
||||
TestStandSeqContext.NextStepIndex = 0;
|
||||
|
||||
_terminateTestInitiated = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user