Major upgrade
This commit is contained in:
130
Source/Program/Actions/SendCoeBatteryGoodMsgToUutAction.cs
Normal file
130
Source/Program/Actions/SendCoeBatteryGoodMsgToUutAction.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
// 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.Threading;
|
||||
using NLog;
|
||||
using Raytheon.Common.Coe;
|
||||
using Raytheon.Instruments;
|
||||
|
||||
namespace ProgramLib
|
||||
{
|
||||
/// <summary>
|
||||
/// Send COE Message to UUT
|
||||
/// </summary>
|
||||
internal class SendCoeBatteryGoodMsgToUutAction : BasicAction
|
||||
{
|
||||
#region PrivateClassMembers
|
||||
private static NLog.ILogger _logger;
|
||||
|
||||
private string _coeDeviceName;
|
||||
private string _msgName = "UmbilicalRetractBatteryGoodMsg";
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="coeDeviceName">name of COE device</param>
|
||||
/// <returns></returns>
|
||||
public SendCoeBatteryGoodMsgToUutAction(string coeDeviceName)
|
||||
{
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
_coeDeviceName = coeDeviceName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run the action
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override void Run()
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger?.Debug($"Entering {this.GetType().Name}::{System.Reflection.MethodBase.GetCurrentMethod().Name}() method...");
|
||||
|
||||
if (Program.Instance().IsUutPwrOn)
|
||||
{
|
||||
if (SendCoeUncageMsgToUutAction.mMgrState == Coe.MmgrState.ACQUISITION)
|
||||
{
|
||||
CoeResponseMsgData missionManagerMsg = null;
|
||||
bool firstMissionManagerMsgReceived = false;
|
||||
const int MAX_RETRIES = 5;
|
||||
int retry = 0;
|
||||
CoeFieldData val = null;
|
||||
Coe.MmgrState mMgrState = Coe.MmgrState.NOT_SET;
|
||||
Coe.MmgrState desiredMmgrState = Coe.MmgrState.PRELAUNCH;
|
||||
|
||||
string missionManagerMessageName = "MissionManagerMsgLL";
|
||||
_logger.Info($"Waiting for message {missionManagerMessageName}");
|
||||
do
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
missionManagerMsg = Program.Instance().MalMeasurementLibManager.CoeMeasurementManager.GetNextResponseInQueue(_coeDeviceName, missionManagerMessageName);
|
||||
|
||||
if (missionManagerMsg != null)
|
||||
{
|
||||
if (!firstMissionManagerMsgReceived)
|
||||
firstMissionManagerMsgReceived = true;
|
||||
|
||||
val = missionManagerMsg.GetFieldData("data.mmgrState");
|
||||
|
||||
if (Enum.TryParse(val.FieldValue, out mMgrState))
|
||||
{
|
||||
_logger.Info($"Current mission state: {mMgrState.ToString()}");
|
||||
|
||||
if (mMgrState == desiredMmgrState)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Warn($"Invalid mission state: {val.FieldValue}");
|
||||
}
|
||||
}
|
||||
} while (retry++ < MAX_RETRIES && (missionManagerMsg == null || mMgrState != desiredMmgrState));
|
||||
|
||||
if (!firstMissionManagerMsgReceived)
|
||||
{
|
||||
throw new Exception($"Timed out waiting for Mission Manager's state message");
|
||||
}
|
||||
|
||||
if (mMgrState != desiredMmgrState)
|
||||
{
|
||||
throw new Exception($"Timed out waiting for Mission Manager to transition to {desiredMmgrState}");
|
||||
}
|
||||
|
||||
Message msg = Program.Instance().MalMeasurementLibManager.CoeMeasurementManager.CreateMessage(_coeDeviceName, _msgName);
|
||||
string batteryGoodState = "1";
|
||||
msg.Set("data.umbilicalRetractBatteryGood", batteryGoodState);
|
||||
var parms = msg.GetParameters();
|
||||
_logger.Info($"Sending {_msgName}, umbilicalRetractBatteryGood={batteryGoodState}");
|
||||
Program.Instance().MalMeasurementLibManager.CoeMeasurementManager.SendMessage(_coeDeviceName, _msgName, parms);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Cannot send message to UUT because UUT is not powered on.");
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user