Add alarm event 1 parsing on the Telecommand Frame parser
This commit is contained in:
parent
1435d8bd66
commit
aaef2b7489
|
|
@ -80,8 +80,9 @@ public class TelecommandFrameParser
|
|||
var powerTempAlarm = ParseAndPrintField(response, "Power Temperature Alarm" );
|
||||
var currentAlarm = ParseAndPrintField(response, "Charge/Discharge Current 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;
|
||||
}
|
||||
|
|
@ -151,6 +152,23 @@ public class TelecommandFrameParser
|
|||
_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)
|
||||
{
|
||||
var fieldBytes = response.Substring(_currentIndex, 4);
|
||||
|
|
|
|||
Loading…
Reference in New Issue