Add alarm event 1 parsing on the Telecommand Frame parser

This commit is contained in:
atef 2025-03-19 11:35:08 +01:00
parent 1435d8bd66
commit aaef2b7489
1 changed files with 20 additions and 2 deletions

View File

@ -80,8 +80,9 @@ public class TelecommandFrameParser
var powerTempAlarm = ParseAndPrintField(response, "Power Temperature Alarm" ); var powerTempAlarm = ParseAndPrintField(response, "Power Temperature Alarm" );
var currentAlarm = ParseAndPrintField(response, "Charge/Discharge Current Alarm" ); var currentAlarm = ParseAndPrintField(response, "Charge/Discharge Current Alarm" );
var totalVoltageAlarm = ParseAndPrintField(response, "Total Battery Voltage Alarm" ); var totalVoltageAlarm = ParseAndPrintField(response, "Total Battery Voltage Alarm" );
var alarmEvent1 = ParseByteAlarm(response, "Alarm Event 1");
var batteryAlarmRecord = new BatteryDeligreenAlarmRecord(cellAlarmList, cellTemperatureAlarm, enviTempAlarm, powerTempAlarm,currentAlarm, totalVoltageAlarm); var batteryAlarmRecord = new BatteryDeligreenAlarmRecord(cellAlarmList, cellTemperatureAlarm, enviTempAlarm, powerTempAlarm,currentAlarm, totalVoltageAlarm, alarmEvent1);
return batteryAlarmRecord; return batteryAlarmRecord;
} }
@ -151,6 +152,23 @@ public class TelecommandFrameParser
_currentIndex += length; _currentIndex += length;
} }
private static Byte ParseByteAlarm(String response, String fieldName)
{
var fieldBytes = response.Substring(_currentIndex, 4);
Byte byteValue = 0;
try
{
var tempAscii = HexToAscii(fieldBytes);
byteValue = byte.Parse(tempAscii, NumberStyles.HexNumber);
}
catch (Exception)
{
Console.WriteLine($"Failed to decode : {fieldName}" + " Alarm");
}
_currentIndex += 4;
return byteValue;
}
private static String ParseAndPrintField(String response, String fieldName) private static String ParseAndPrintField(String response, String fieldName)
{ {
var fieldBytes = response.Substring(_currentIndex, 4); var fieldBytes = response.Substring(_currentIndex, 4);