Big changes
This commit is contained in:
123
Source/TSRealLib/Common/Raytheon.Common/Interfaces/IDisplay.cs
Normal file
123
Source/TSRealLib/Common/Raytheon.Common/Interfaces/IDisplay.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
// **********************************************************************************************************
|
||||
// IDisplay.cs
|
||||
// 2/17/2023
|
||||
// NGI - Next Generation Interceptor
|
||||
//
|
||||
// Contract No. HQ0856-21-C-0003/1022000209
|
||||
//
|
||||
// THIS DOCUMENT DOES NOT CONTAIN TECHNOLOGY OR TECHNICAL DATA CONTROLLED UNDER EITHER THE U.S.
|
||||
// INTERNATIONAL TRAFFIC IN ARMS REGULATIONS OR THE U.S. EXPORT ADMINISTRATION REGULATIONS.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
||||
//
|
||||
// DESTRUCTION NOTICE: FOR CLASSIFIED DOCUMENTS FOLLOW THE PROCEDURES IN DOD 5220.22-M,
|
||||
// NATIONAL INDUSTRIAL SECURITY PROGRAM OPERATING MANUAL, FEBRUARY 2006,
|
||||
// INCORPORATING CHANGE 1, MARCH 28, 2013, CHAPTER 5, SECTION 7, OR DODM 5200.01-VOLUME 3,
|
||||
// DOD INFORMATION SECURITY PROGRAM: PROTECTION OF CLASSIFIED INFORMATION, ENCLOSURE 3,
|
||||
// SECTION 17. FOR CONTROLLED UNCLASSIFIED INFORMATION FOLLOW THE PROCEDURES IN DODM 5200.01-VOLUME 4,
|
||||
// INFORMATION SECURITY PROGRAM: CONTROLLED UNCLASSIFIED INFORMATION.
|
||||
//
|
||||
// CONTROLLED BY: MISSILE DEFENSE AGENCY
|
||||
// CONTROLLED BY: GROUND-BASED MIDCOURSE DEFENSE PROGRAM OFFICE
|
||||
// CUI CATEGORY: CTI
|
||||
// DISTRIBUTION/DISSEMINATION CONTROL: F
|
||||
// POC: Alex Kravchenko (1118268)
|
||||
// **********************************************************************************************************
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Raytheon.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum for tagging the logged data.
|
||||
/// </summary>
|
||||
public enum LogLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// (Ordinal = 0) : Most verbose level. Used for development and seldom enabled in production.
|
||||
/// </summary>
|
||||
TRACE,
|
||||
/// <summary>
|
||||
/// (Ordinal = 1) : Debugging the application behavior from internal events of interest.
|
||||
/// </summary>
|
||||
DEBUG,
|
||||
/// <summary>
|
||||
/// An informational log statement.
|
||||
/// (Ordinal = 2) : Information that highlights progress or application lifetime events.
|
||||
/// </summary>
|
||||
INFO,
|
||||
/// <summary>
|
||||
/// (Ordinal = 3) : Warnings about validation issues or temporary failures that can be recovered.
|
||||
/// </summary>
|
||||
WARN,
|
||||
/// <summary>
|
||||
/// (Ordinal = 4) : Errors where functionality has failed or <see cref="System.Exception"/> have been caught.
|
||||
/// an error log statement.
|
||||
/// </summary>
|
||||
ERROR,
|
||||
/// <summary>
|
||||
/// (Ordinal = 5) : Most critical level. Application is about to abort.
|
||||
/// </summary>
|
||||
FATAL,
|
||||
/// <summary>
|
||||
/// Off log level (Ordinal = 6)
|
||||
/// </summary>
|
||||
OFF
|
||||
}
|
||||
|
||||
public interface IDisplay
|
||||
{
|
||||
/// <summary>
|
||||
/// user interface capability with error logger
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="logLevel"></param>
|
||||
void ShowMessage(string message, LogLevel logLevel = LogLevel.INFO);
|
||||
}
|
||||
|
||||
public interface IChillerDisplay
|
||||
{
|
||||
void ChillerMonitorUiUpdate(ActiveHealthMonitorData data, int errorCode);
|
||||
}
|
||||
|
||||
public interface IDioDisplay
|
||||
{
|
||||
void DioControlUiUpdate(List<string> inputNames, List<string> outputNames);
|
||||
}
|
||||
|
||||
public interface IFpgaDisplay
|
||||
{
|
||||
void FpgaControlUiUpdate(List<string> fpgaNames);
|
||||
}
|
||||
|
||||
public interface IPowerControlDisplay
|
||||
{
|
||||
void PowerControlUiUpdate(List<string> powerFormNames);
|
||||
}
|
||||
|
||||
public interface IPowerMonitorDisplay
|
||||
{
|
||||
void PowerMonitorUiUpdate(List<PowerMonitorCallbackData> callBackDataList, int errorCode);
|
||||
}
|
||||
|
||||
public interface IHealthMonitorDisplay
|
||||
{
|
||||
void HealthMonitorControlUiUpdate(List<ActiveHealthMonitorData> callBackDataList);
|
||||
}
|
||||
|
||||
public interface INGIDisplay : IDisplay, IChillerDisplay, IDioDisplay, IFpgaDisplay, IPowerControlDisplay, IPowerMonitorDisplay, IHealthMonitorDisplay
|
||||
{
|
||||
}
|
||||
|
||||
public interface IHandleCriticalError
|
||||
{
|
||||
void HandleCriticalError(string message, bool shallWeStopThreads = true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
// 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;
|
||||
|
||||
namespace Raytheon.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines an interface for specific message parsing routines
|
||||
/// used in conjunction with MsgDevice
|
||||
/// </summary>
|
||||
public interface IMsgParser
|
||||
{
|
||||
/// <summary>
|
||||
/// Will parse data looking for a complete message
|
||||
/// </summary>
|
||||
/// <param name="pData">The data to parse</param>
|
||||
/// <param name="numBytesInPdata">The number of bytes in pData</param>
|
||||
/// <param name="bytesToRemove">The data to remove once the parse job is complete</param>
|
||||
/// <param name="messageId">The ID of the message that was parsed</param>
|
||||
/// <param name="errorCode">optional error codes for a child parser to user</param>
|
||||
/// <returns>true if a complete message was found, false otherwise</returns>
|
||||
bool Run(IntPtr pData, uint numBytesInPdata, ref uint bytesToRemove, ref uint messageId, ref uint errorCode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// 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;
|
||||
|
||||
namespace Raytheon.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface to a serial port device
|
||||
/// </summary>
|
||||
public interface ISerialPort : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Close the communication interface
|
||||
/// </summary>
|
||||
void Close();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
void Open();
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dataRead"></param>
|
||||
/// <returns></returns>
|
||||
UInt32 Read(ref byte[] dataRead);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="dataToWrite"></param>
|
||||
void Write(byte[] dataToWrite);
|
||||
|
||||
void Write(String dataToWrite);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// **********************************************************************************************************
|
||||
// IWorkerInterface.cs
|
||||
// 2/17/2023
|
||||
// NGI - Next Generation Interceptor
|
||||
//
|
||||
// Contract No. HQ0856-21-C-0003/1022000209
|
||||
//
|
||||
// THIS DOCUMENT DOES NOT CONTAIN TECHNOLOGY OR TECHNICAL DATA CONTROLLED UNDER EITHER THE U.S.
|
||||
// INTERNATIONAL TRAFFIC IN ARMS REGULATIONS OR THE U.S. EXPORT ADMINISTRATION REGULATIONS.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
||||
//
|
||||
// DESTRUCTION NOTICE: FOR CLASSIFIED DOCUMENTS FOLLOW THE PROCEDURES IN DOD 5220.22-M,
|
||||
// NATIONAL INDUSTRIAL SECURITY PROGRAM OPERATING MANUAL, FEBRUARY 2006,
|
||||
// INCORPORATING CHANGE 1, MARCH 28, 2013, CHAPTER 5, SECTION 7, OR DODM 5200.01-VOLUME 3,
|
||||
// DOD INFORMATION SECURITY PROGRAM: PROTECTION OF CLASSIFIED INFORMATION, ENCLOSURE 3,
|
||||
// SECTION 17. FOR CONTROLLED UNCLASSIFIED INFORMATION FOLLOW THE PROCEDURES IN DODM 5200.01-VOLUME 4,
|
||||
// INFORMATION SECURITY PROGRAM: CONTROLLED UNCLASSIFIED INFORMATION.
|
||||
//
|
||||
// CONTROLLED BY: MISSILE DEFENSE AGENCY
|
||||
// CONTROLLED BY: GROUND-BASED MIDCOURSE DEFENSE PROGRAM OFFICE
|
||||
// CUI CATEGORY: CTI
|
||||
// DISTRIBUTION/DISSEMINATION CONTROL: F
|
||||
// POC: Alex Kravchenko (1118268)
|
||||
// **********************************************************************************************************
|
||||
using System;
|
||||
|
||||
namespace Raytheon.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface that defines required functions for a worker.
|
||||
/// Typically a worker is invoked as a thread.
|
||||
/// </summary>
|
||||
public interface IWorkerInterface : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The function that is passed into the thread.
|
||||
/// </summary>
|
||||
void DoWork();
|
||||
|
||||
/// <summary>
|
||||
/// Commands the worker to quit.
|
||||
/// </summary>
|
||||
void QuitWork();
|
||||
}
|
||||
}
|
||||
215
Source/TSRealLib/Common/Raytheon.Common/Interfaces/MsgDevice.cs
Normal file
215
Source/TSRealLib/Common/Raytheon.Common/Interfaces/MsgDevice.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
// 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;
|
||||
|
||||
namespace Raytheon.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class for handling incoming messages
|
||||
/// </summary>
|
||||
public abstract class MsgDevice : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// A callback def for a completed message
|
||||
/// </summary>
|
||||
/// <param name="msgId"></param>
|
||||
/// <param name="pData"></param>
|
||||
/// <param name="numBytes"></param>
|
||||
/// <param name="errorCode"></param>
|
||||
unsafe public delegate void CompleteMessageCallback(uint msgId, IntPtr pData, uint numBytes, uint errorCode);
|
||||
|
||||
private DataBuffer _dataBuffer;
|
||||
private AutoResetEvent _dataInBufferEvent;
|
||||
private IWorkerInterface _msgProcessorWorker;
|
||||
private bool _isProcessorThreadRunning;
|
||||
private Thread _msgProcessorThread;
|
||||
|
||||
/// <summary>
|
||||
/// The constructor
|
||||
/// </summary>
|
||||
/// <param name="msgParser"></param>
|
||||
/// <param name="bufferSize"></param>
|
||||
public MsgDevice(IMsgParser msgParser, uint bufferSize)
|
||||
{
|
||||
try
|
||||
{
|
||||
_isProcessorThreadRunning = false;
|
||||
_dataBuffer = new DataBuffer(bufferSize);
|
||||
_dataInBufferEvent = new AutoResetEvent(false);
|
||||
_msgProcessorWorker = new MsgProcessorWorker(msgParser, ref _dataBuffer, ref _dataInBufferEvent);
|
||||
_msgProcessorThread = new Thread(_msgProcessorWorker.DoWork);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The finalizer
|
||||
/// </summary>
|
||||
~MsgDevice()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The public dispose function. Necessary for commanding threads to quit
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add data to the buffer
|
||||
/// </summary>
|
||||
/// <param name="data">The data to add</param>
|
||||
/// <param name="numBytes">the number of bytes to add</param>
|
||||
protected void AddToBuffer(byte[] data, uint numBytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
_dataBuffer.Add(data, numBytes);
|
||||
|
||||
_dataInBufferEvent.Set();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear all data from the buffer
|
||||
/// </summary>
|
||||
protected void ClearBuffer()
|
||||
{
|
||||
try
|
||||
{
|
||||
_dataBuffer.RemoveAll();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The local dispose function. Necessary for commanding threads to quit
|
||||
/// </summary>
|
||||
/// <param name="disposing"></param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
try
|
||||
{
|
||||
_msgProcessorWorker.QuitWork();
|
||||
|
||||
Thread.Sleep(500);
|
||||
|
||||
_msgProcessorThread.Abort();
|
||||
|
||||
if (_msgProcessorThread.IsAlive)
|
||||
{
|
||||
_msgProcessorThread.Join();
|
||||
}
|
||||
|
||||
_dataInBufferEvent.Dispose();
|
||||
|
||||
_msgProcessorWorker.Dispose();
|
||||
|
||||
_dataBuffer.Dispose();
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ErrorLogger.Instance().Write(err.Message + "\r\n" + err.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run the message processor thread
|
||||
/// </summary>
|
||||
protected void RunThread()
|
||||
{
|
||||
try
|
||||
{
|
||||
_msgProcessorThread.Start();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the callback that will be invoked when a complete message is parsed out
|
||||
/// </summary>
|
||||
/// <param name="callback">The callback function</param>
|
||||
protected void SetCompleteMessageCallback(CompleteMessageCallback callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
((MsgProcessorWorker)_msgProcessorWorker).SetCallback(callback);
|
||||
|
||||
// now that the callback is set, we can run the thread
|
||||
if (_isProcessorThreadRunning == false)
|
||||
{
|
||||
_msgProcessorThread.Start();
|
||||
_isProcessorThreadRunning = true;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop the message processor thread
|
||||
/// </summary>
|
||||
protected void QuitThread()
|
||||
{
|
||||
try
|
||||
{
|
||||
_msgProcessorWorker.QuitWork();
|
||||
|
||||
if (_msgProcessorThread.IsAlive)
|
||||
{
|
||||
_msgProcessorThread.Join();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// abstract function for the children to implement
|
||||
/// </summary>
|
||||
/// <param name="data">The data to add</param>
|
||||
/// <param name="numBytes">The number of bytes to add</param>
|
||||
public abstract void AddData(byte[] data, uint numBytes);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user