private void ParsePayload()
{
// First, handle all of the events related to the alarm system
switch (Command)
{
case ResponseCommand.TimeDateBroadcast:
DateBroadcast = DateTime.ParseExact(Data.Substring(0, 10), "hhmmMMDDYY", System.Globalization.CultureInfo.InvariantCulture);
break;
case ResponseCommand.IndoorTemperatureBroadcast:
case ResponseCommand.OutdoorTemperatureBroadcast:
ThermostatId = Convert.ToInt32(Data.Substring(0, 1));
Temperature = Convert.ToInt32(Data.Substring(1, 3));
break;
case ResponseCommand.EnvisalinkZoneTimerDump:
SecondsSinceOpened = new Int32[64];
for (int i = 0; i < 64; i++)
{
string swappedBytes = Data.Substring((i * 4) + 2, 2) + Data.Substring(i * 4, 2);
int val = Convert.ToInt32(swappedBytes, 16);
if (val > 0)
SecondsSinceOpened[i] = (65535 - val) * 5;
}
break;
case ResponseCommand.RingDetected:
case ResponseCommand.DuressAlarm:
case ResponseCommand.FKeyAlarm:
case ResponseCommand.FKeyRestore:
case ResponseCommand.AKeyAlarm:
case ResponseCommand.AKeyRestoral:
case ResponseCommand.PKeyAlarm:
case ResponseCommand.PKeyRestore:
case ResponseCommand.TwoWireSmokeAuxAlarm:
case ResponseCommand.TwoWireSmokeAuxRestore:
case ResponseCommand.PanelBatteryTrouble:
case ResponseCommand.PanelBatteryTroubleRestore:
case ResponseCommand.PanelACTrouble:
case ResponseCommand.PanelACRestore:
case ResponseCommand.SystemBellTrouble:
case ResponseCommand.SystemBellTroubleRestoral:
case ResponseCommand.FtcTrouble:
case ResponseCommand.BufferNearFull:
case ResponseCommand.GeneralSystemTamper:
case ResponseCommand.GeneralSystemTamperRestore:
case ResponseCommand.FireTroubleAlarm:
case ResponseCommand.FireTroubleAlarmRestore:
case ResponseCommand.VerboseTroubleStatus:
case ResponseCommand.CodeRequired:
case ResponseCommand.CommandOutputPressed:
case ResponseCommand.MasterCodeRequired:
case ResponseCommand.InstallersCodeRequired:
break;
case ResponseCommand.KeypadLedStatePartition1Only:
case ResponseCommand.KeypadLedflashStatePartition1Only:
PartitionId = 1;
break;
case ResponseCommand.PartitionReady:
case ResponseCommand.PartitionNotReady:
case ResponseCommand.PartitionReadyForceArmingEnabled:
case ResponseCommand.PartitionInAlarm:
case ResponseCommand.PartitionDisarmed:
case ResponseCommand.ExitDelayinProgress:
case ResponseCommand.EntryDelayinProgress:
case ResponseCommand.KeypadLockout:
case ResponseCommand.PartitionFailedtoArm:
case ResponseCommand.PgmOutputisinProgress:
case ResponseCommand.ChimeEnabled:
case ResponseCommand.ChimeDisabled:
case ResponseCommand.InvalidAccessCode:
case ResponseCommand.FunctionNotAvailable:
case ResponseCommand.FailuretoArm:
case ResponseCommand.PartitionisBusy:
case ResponseCommand.SystemArminginProgress:
case ResponseCommand.SpecialClosing:
case ResponseCommand.PartialClosing:
case ResponseCommand.SpecialOpening:
case ResponseCommand.TroubleLedon:
case ResponseCommand.TroubleLedoff:
PartitionId = Convert.ToInt32(Data.Substring(0, 1));
break;
case ResponseCommand.PartitionArmed:
PartitionId = Convert.ToInt32(Data.Substring(0, 1));
ArmingMode = (TpiArmedMode)Convert.ToInt32(Data.Substring(1, 1));
break;
case ResponseCommand.UserClosing:
case ResponseCommand.UserOpening:
PartitionId = Convert.ToInt32(Data.Substring(0, 1));
UserId = Convert.ToInt32(Data.Substring(1, 4));
break;
case ResponseCommand.ZoneAlarm:
case ResponseCommand.ZoneAlarmRestore:
case ResponseCommand.ZoneTamper:
case ResponseCommand.ZoneTamperRestore:
PartitionId = Convert.ToInt32(Data.Substring(0, 1));
ZoneId = Convert.ToInt32(Data.Substring(1));
break;
case ResponseCommand.ZoneFault:
case ResponseCommand.ZoneFaultRestore:
case ResponseCommand.ZoneOpen:
case ResponseCommand.ZoneRestored:
ZoneId = Convert.ToInt32(Data);
break;
case ResponseCommand.LoginInteraction:
case ResponseCommand.CommandAcknowledge:
break;
default:
MyLogger.LogError($"Invalid data returned [{Data}]");
break;
}
}
#endregion