Major upgrade
This commit is contained in:
@@ -16,9 +16,10 @@ UNPUBLISHED WORK - COPYRIGHT RAYTHEON COMPANY.
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
using System;
|
||||
using Raytheon.Common;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using NLog;
|
||||
using Raytheon.Common;
|
||||
|
||||
namespace BitMeasurementManagerLib
|
||||
{
|
||||
@@ -48,6 +49,7 @@ namespace BitMeasurementManagerLib
|
||||
private readonly bool _shallWeLogIncomingAsciiData;
|
||||
private readonly uint _bitmask;
|
||||
private readonly string _crcFieldName;
|
||||
private readonly ILogger _logger;
|
||||
#endregion
|
||||
|
||||
#region PublicFuctions
|
||||
@@ -66,6 +68,7 @@ namespace BitMeasurementManagerLib
|
||||
unsafe public BitMsgHandler(BitMessageIDs messageIds, MeasurementManagerLib.BitMeasurementManager.MessageReceivedDelegate callback, uint bufferSize, string binLogFileName, string asciiLogFileName, bool shallWeLogOutgoingBinData, bool shallWeLogOutgoingAsciiData, bool shallWeLogIncomingBinData, bool shallWeLogIncomingAsciiData, uint crcBitmask, string crcFieldName, bool shallWePerformVerboseParserLogging)
|
||||
: base(new BitMsgParser(messageIds, shallWePerformVerboseParserLogging), bufferSize)
|
||||
{
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
_messageIds = messageIds;
|
||||
|
||||
// hold onto the callback
|
||||
@@ -166,7 +169,7 @@ namespace BitMeasurementManagerLib
|
||||
{
|
||||
if (_messageIds.ContainsId(msgId) == false)
|
||||
{
|
||||
ErrorLogger.Instance().Write("BitMsgHandler::OnCompleteMessage() - detected unknown msg id: " + msgId.ToString());
|
||||
_logger.Warn("BitMsgHandler::OnCompleteMessage() - detected unknown msg id: " + msgId.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -184,7 +187,7 @@ namespace BitMeasurementManagerLib
|
||||
|
||||
if (maskedStatus != 0)
|
||||
{
|
||||
ErrorLogger.Instance().Write($"Message Status register indicates that a CRC error may have occurred. Raw status read: 0x{rawStatus:X8}. Masked status value: 0x{maskedStatus:X8}");
|
||||
_logger.Warn($"Message Status register indicates that a CRC error may have occurred. Raw status read: 0x{rawStatus:X8}. Masked status value: 0x{maskedStatus:X8}");
|
||||
callbackValue = -1;
|
||||
}
|
||||
}
|
||||
@@ -207,14 +210,10 @@ namespace BitMeasurementManagerLib
|
||||
}
|
||||
|
||||
// some debugging
|
||||
ErrorLogger.Instance().Write("BitMsgHandler::HandleMsg() - added message " + msgId.ToString("X8") + " to buffer ", ErrorLogger.LogLevel.INFO);
|
||||
_logger.Debug("added message " + msgId.ToString("X8") + " to buffer ");
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
//@@@ need to flow error to the host
|
||||
ErrorLogger.Instance().Write("BitMsgHandler::HandleMsg() - caught an error: " + err.Message, ErrorLogger.LogLevel.ERROR);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -271,7 +270,7 @@ namespace BitMeasurementManagerLib
|
||||
{
|
||||
if (_binWriter == null && _shallWeLogIncomingBinData == true)
|
||||
{
|
||||
throw new Exception("BitMsgHandler::WriteIncomingDataToLog() - Trying to log bin data before the log file is open");
|
||||
throw new Exception("Trying to log bin data before the log file is open");
|
||||
}
|
||||
else if (_shallWeLogIncomingBinData == true)
|
||||
{
|
||||
@@ -292,7 +291,7 @@ namespace BitMeasurementManagerLib
|
||||
{
|
||||
if (_asciiWriter == null && _shallWeLogIncomingAsciiData == true)
|
||||
{
|
||||
throw new Exception("BitMsgHandler::WriteIncomingDataToLog() - Trying to log ascii data before the log file is open");
|
||||
throw new Exception("Trying to log ascii data before the log file is open");
|
||||
}
|
||||
else if (_shallWeLogIncomingAsciiData == true)
|
||||
{
|
||||
@@ -318,7 +317,7 @@ namespace BitMeasurementManagerLib
|
||||
{
|
||||
if (_binWriter == null && _shallWeLogOutgoingBinData == true)
|
||||
{
|
||||
throw new Exception("BitMsgHandler::WriteOutgoingDataToLog() - Trying to log bin data before the log file is open");
|
||||
throw new Exception("Trying to log bin data before the log file is open");
|
||||
}
|
||||
else if (_shallWeLogOutgoingBinData == true)
|
||||
{
|
||||
@@ -339,7 +338,7 @@ namespace BitMeasurementManagerLib
|
||||
{
|
||||
if (_asciiWriter == null && _shallWeLogOutgoingAsciiData == true)
|
||||
{
|
||||
throw new Exception("BitMsgHandler::WriteOutgoingDataToLog() - Trying to log ascii data before the log file is open");
|
||||
throw new Exception("Trying to log ascii data before the log file is open");
|
||||
}
|
||||
else if (_shallWeLogOutgoingAsciiData == true)
|
||||
{
|
||||
@@ -362,25 +361,18 @@ namespace BitMeasurementManagerLib
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
try
|
||||
// call the parent dispose first
|
||||
base.Dispose(disposing);
|
||||
|
||||
// now dispose of our resources
|
||||
if (_binWriter != null)
|
||||
{
|
||||
// call the parent dispose first
|
||||
base.Dispose(disposing);
|
||||
|
||||
// now dispose of our resources
|
||||
if (_binWriter != null)
|
||||
{
|
||||
_binWriter.Dispose();
|
||||
}
|
||||
|
||||
if (_asciiWriter != null)
|
||||
{
|
||||
_asciiWriter.Dispose();
|
||||
}
|
||||
_binWriter.Dispose();
|
||||
}
|
||||
catch (Exception err)
|
||||
|
||||
if (_asciiWriter != null)
|
||||
{
|
||||
ErrorLogger.Instance().Write(err.Message + "\r\n" + err.StackTrace);
|
||||
_asciiWriter.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user