Major upgrade
This commit is contained in:
128
Source/Program/Actions/UutPowerOffAction.cs
Normal file
128
Source/Program/Actions/UutPowerOffAction.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
// UNCLASSIFIED
|
||||
/*-------------------------------------------------------------------------
|
||||
RAYTHEON PROPRIETARY: THIS DOCUMENT CONTAINS DATA OR INFORMATION
|
||||
PROPRIETARY TO RAYTHEON COMPANY AND IS RESTRICTED TO USE ONLY BY PERSONS
|
||||
AUTHORIZED BY RAYTHEON COMPANY IN WRITING TO USE IT. DISCLOSURE TO
|
||||
UNAUTHORIZED PERSONS WOULD LIKELY CAUSE SUBSTANTIAL COMPETITIVE HARM TO
|
||||
RAYTHEON COMPANY'S BUSINESS POSITION. NEITHER SAID DOCUMENT NOR ITS
|
||||
CONTENTS SHALL BE FURNISHED OR DISCLOSED TO OR COPIED OR USED BY PERSONS
|
||||
OUTSIDE RAYTHEON COMPANY WITHOUT THE EXPRESS WRITTEN APPROVAL OF RAYTHEON
|
||||
COMPANY.
|
||||
|
||||
THIS PROPRIETARY NOTICE IS NOT APPLICABLE IF DELIVERED TO THE U.S.
|
||||
GOVERNMENT.
|
||||
|
||||
UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
||||
-------------------------------------------------------------------------*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using NLog;
|
||||
|
||||
namespace ProgramLib
|
||||
{
|
||||
/// <summary>
|
||||
/// Power off UUT
|
||||
/// </summary>
|
||||
internal class UutPowerOffAction : BasicAction
|
||||
{
|
||||
#region PrivateClassMembers
|
||||
private static NLog.ILogger _logger;
|
||||
|
||||
private static object _syncObj = new object();
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public UutPowerOffAction()
|
||||
{
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run the action
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_syncObj)
|
||||
{
|
||||
if (Program.Instance().IsUutPwrOn)
|
||||
{
|
||||
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() method...");
|
||||
|
||||
foreach (var item in ProgramLib.Program.Instance().PowerModulesToBePowered)
|
||||
Program.Instance().MalMeasurementLibManager.PowerSupplyMeasurementManager.OutputDisable(item);
|
||||
|
||||
RecordPowerOffTimeToFile();
|
||||
|
||||
// enable front panel
|
||||
//Program.Instance().MalMeasurementLibManager.PowerSupplyMeasurementManager.DisplayEnable("STE_POWER_SUPPLY_SYSTEM");
|
||||
|
||||
Program.Instance().EventManager[EventManager.Events.UUT_POWER_ON].Reset();
|
||||
Program.Instance().EventManager[EventManager.Events.UUT_POWER_OFF].Set();
|
||||
|
||||
Program.Instance().IsUutPwrOn = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse ini file for modules to be powered on
|
||||
/// </summary>
|
||||
public void ParseProgramSpecificConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<string> keys = Program.Instance().ProgramSpecificConfig.ReadAllKeys(ProgramSpecificConfigIni.POWER_MODULES_TO_BE_POWERED.ToString());
|
||||
foreach (string key in keys)
|
||||
{
|
||||
string powerSupplyModule = Program.Instance().ProgramSpecificConfig.ReadValue(ProgramSpecificConfigIni.POWER_MODULES_TO_BE_POWERED.ToString(), key);
|
||||
|
||||
if (!Program.Instance().PowerModulesToBePowered.Contains(powerSupplyModule, StringComparer.OrdinalIgnoreCase))
|
||||
Program.Instance().PowerModulesToBePowered.Add(powerSupplyModule);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Record power off time
|
||||
/// </summary>
|
||||
private void RecordPowerOffTimeToFile()
|
||||
{
|
||||
XmlDocumentWrapper doc = new XmlDocumentWrapper(Program.Instance().FileAndFolderManager.GetFile(FileAndFolderManager.Files.TEST_RUN_LOG));
|
||||
|
||||
XmlNode node = doc.GetNode(TestRunConfigXml.TestRunPowerPath);
|
||||
|
||||
XmlAttribute onDateAttr = node.Attributes[TestRunConfigXml.TestRunPowerOnDateAttributeName];
|
||||
XmlAttribute onTimeAttr = node.Attributes[TestRunConfigXml.TestRunPowerOnTimeAttributeName];
|
||||
DateTime powerOnDateTime = DateTime.Parse($"{onDateAttr.Value} {onTimeAttr.Value}");
|
||||
|
||||
DateTime dt = DateTime.Now;
|
||||
int duration = (int)dt.Subtract(powerOnDateTime).TotalSeconds;
|
||||
Dictionary<string, string> attributesDict = new Dictionary<string, string>();
|
||||
attributesDict[TestRunConfigXml.TestRunPowerOffDateAttributeName] = dt.ToString("MM/dd/yyyy");
|
||||
attributesDict[TestRunConfigXml.TestRunPowerOffTimeAttributeName] = dt.ToString("HH:mm:ss");
|
||||
attributesDict[TestRunConfigXml.TestRunPowerOnDurationAttributeName] = duration.ToString();
|
||||
|
||||
doc.ChangeNode(node, attributesDict);
|
||||
|
||||
doc.SaveToFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user