"""
Concord panel general and specific alarm type codes.
"""

ALARM_SPECIFIC_TYPES = {
0: 'Unspecified',
1: 'Fire',
2: 'Fire Panic',
3: 'Police',
4: 'Police Panic',
5: 'Medical',
6: 'Medical Panic',
7: 'Auxiliary',
8: 'Auxiliary Panic',
9: 'Tamper',
10: 'No Activity',
11: 'Suspicion',
12: 'Not used',
13: 'Low Temperature',
14: 'High Temperature',
15: 'Keystroke Violation (Touchpad Tamper)',
16: 'Duress',
17: 'Exit Fault',
18: 'Explosive Gas',
19: 'Carbon Monoxide',
20: 'Environmental',
21: 'Latchkey',
22: 'Equipment Tamper',
23: 'Holdup',
24: 'Sprinkler',
25: 'Heat',
26: 'Siren Tamper',
27: 'Smoke',
28: 'Repeater Tamper',
29: 'Fire Pump Activated',
30: 'Fire Pump Failure',
31: 'Fire Gate Valve',
32: 'Low CO2 Pressure',
33: 'Low Liquid Pressure',
34: 'Low Liquid Level',
35: 'Entry/Exit',
36: 'Perimeter',
37: 'Interior',
38: 'Near (Two Trip, Concord only)',
39: 'Water Alarm',
}

FIRE_SPECIFIC_TYPES = {
0: 'Unspecified',
1: 'Hardwire',
2: 'Ground Fault',
3: 'Device',
4: 'Supervisory',
5: 'Low Battery',
6: 'Tamper',
7: 'SAM',
8: 'Partial Obscurity',
9: 'Jam',
10: 'Zone AC Fail',
11: 'n/u',
12: 'NAC Trouble',
13: 'Analog Zone Trouble',
14: 'Fire Supervisory',
15: 'Pump Fail',
16: 'Fire Gate Valve Closed',
17: 'CO2 Pressure Trouble',
18: 'Liquid Pressure Trouble',
19: 'Liquid Level Trouble',
}

BYPASS_SPECIFIC_TYPES = {
0: 'Direct Bypass',
1: 'Indirect Bypass',
2: 'Swinger Bypass',
3: 'Inhibit',
}

OPENING_SPECIFIC_TYPES = {
0: 'Normal Open',
1: 'Early Open',
2: 'Late Open',
3: 'Fail To Open',
4: 'Open Exception',
5: 'Open Extension',
6: 'Open Using Keyfob/Keyswitch',
7: 'Scheduled Open',
8: 'Remote Open',
}

CLOSING_SPECIFIC_TYPES = {
0: 'Normal Close',
1: 'Early Close',
2: 'Late Close',
3: 'Fail To Close',
4: 'Close Exception',
5: 'Close Extension',
6: 'Close Using Keyfob/Keyswitch',
7: 'Scheduled Close',
8: 'Remote Close',
9: 'Recent Close (Concord only)',
}

PARTITION_CONFIG_CHG_SPECIFIC_TYPES = {
0: 'User Access Code Added',
1: 'User Access Code Deleted',
2: 'User Access Code Changed',
3: 'User Access Code Expired',
4: 'User Code Authority Changed',
5: 'Authority Levels Changed',
6: 'Schedule Changed',
7: 'Arming or O/C Schedule Changed',
8: 'Zone Added',
9: 'Zone Deleted',
}

PARTITION_EVENT_SPECIFIC_TYPES = {
0: 'Schedule On',
1: 'Schedule Off',
2: 'Latchkey On',
3: 'Latchkey Off',
4: 'Smoke Detectors Reset',
5: 'Valid User Access Code Entered',
6: 'Arming Level Changed',
7: 'Alarm Reported',
8: 'Agent Release',
9: 'Agent Release Restoral',
10: 'Partition Remote Access',
11: 'Keystroke Violation in Partition',
12: 'Manual Force Arm',
13: 'Auto Force Arm',
14: 'Auto Force Arm Failed',
15: 'Arming Protest Begun',
16: 'Arming Protest Ended',
}
PARTITION_TEST_SPECIFIC_TYPES = {
0: 'Manual Phone Test',
1: 'Auto Phone Test',
2: 'Auto Phone Test with existing trouble',
3: 'Phone Test OK',
4: 'Phone Test Failed',
5: 'User Sensor Test Started',
6: 'User Sensor Test Ended',
7: 'User Sensor Test Completed',
8: 'User Sensor Test Incomplete',
9: 'user Sensor Test Trip',
10: 'Installer Sensor Test Started',
11: 'Installer Sensor Test Ended',
12: 'Installer Sensor Test Completed',
13: 'Installer Sensor Test Incomplete',
14: 'Installer Sensor Test Trip',
15: 'Fire Drill Started',
}

SYSTEM_TROUBLE_SPECIFIC_TYPES = {
0: 'Bus Receiver Failure',
1: 'Bus Antenna Tamper',
2: 'Main Low Battery',
3: 'SnapCard Low Battery',
4: 'Module Low Battery',
5: 'Main AC Failure',
6: 'SnapCard AC Failure',
7: 'Module AC Failure',
8: 'Aux. Power Failure',
9: 'Bus Shutdown',
10: 'Bus Low Power Mode',
11: 'Phone Line 1 Failure',
12: 'Phone Line 2 Failure',
13: 'Remote Phone Tamper',
14: 'Watchdog Reset',
15: 'RAM Failure',
16: 'Flash Failure',
17: 'Printer Error',
18: 'History Buffer (almost) Full',
19: 'History Buffer Overflow',
20: 'Report Buffer Overflor',
21: 'Bus Device Failure',
22: 'Failure To Communicate',
23: 'Long Range Radio Trouble',
24: 'Module Tamper Trouble',
25: 'Un-enrolled Modulte Trouble',
26: 'Audio Output Trouble',
27: 'Analog Module Trouble',
28: 'Cell Module Trouble',
29: 'Buddy 1 Failure',
30: 'Buddy 2 Failure',
31: 'Buddy 3 Failure',
32: 'Buddy 4 Failure',
33: 'SnapCard Trouble',
34: 'Analog Loop Short',
35: 'Analog Loop Break',
36: 'Analog Address 0',
37: 'Un-enrolled Analog Head',
39: 'Duplicate Analog Head',
40: 'Microphone Switch Trouble',
41: 'Microphone Trouble',
42: 'Microhone Wiring Trouble',
43: 'JTECH Premise Paging Trouble',
44: 'Voice Siren Tamper Trouble',
45: 'Microburst Transmit Failure',
46: 'Microbust Transmit Disable',
47: 'Micorburst Module Failure',
48: 'Microburst Not In Service',
49: 'Automation Supervisory Trouble',
50: 'Microburst Module Initializing',
51: 'Printer Paper Out Trouble',
}

SYSTEM_CONFIG_CHG_SPECIFIC_TYPES = {
0: 'Program Mode Entry',
1: 'Program Mode Exit Without Change',
2: 'Program Mode Exit With Change',
3: 'Downloader Session Start',
4: 'Downloader Session End Without Change',
5: 'Downloader Session End With Change',
6: 'Downloader Error',
7: 'Downloader Connection Denied',
8: 'Date/Time Changed',
9: 'Module Added',
10: 'Module Deleted',
11: 'Speech Tokens Changed',
12: 'Code Changed',
13: 'Panel First Service (cold reset)',
14: 'Panel Back In Service (warm reset)',
15: 'Installer Code Changed',
}

SYSTEM_EVENT_SPECIFIC_TYPES = {
0: 'Callback Requested',
1: 'Output Activity (not used, see 18.5 & 18.6)',
2: 'Buddy Reception',
3: 'Buddy Transmission Request',
4: 'History Buffer Cleared',
5: 'Output On',
6: 'Output Off',
}

ALARM_CODES = {
    # General type -> (General type name, Specific type -> Specific type name))
    1:  ("Alarm", ALARM_SPECIFIC_TYPES),
    2:  ("Alarm Cancel", ALARM_SPECIFIC_TYPES),
    3:  ("Alarm Restoral", ALARM_SPECIFIC_TYPES),
    4:  ("Fire Trouble", FIRE_SPECIFIC_TYPES),
    5:  ("Fire Trouble Restoral", FIRE_SPECIFIC_TYPES),
    6:  ("Non-Fire Trouble", FIRE_SPECIFIC_TYPES),
    7:  ("Non-Fire Trouble Restoral", FIRE_SPECIFIC_TYPES),
    8:  ("Bypass", BYPASS_SPECIFIC_TYPES),
    9:  ("Unbypass", BYPASS_SPECIFIC_TYPES),
    10: ("Opening", OPENING_SPECIFIC_TYPES),
    11: ("Closing", CLOSING_SPECIFIC_TYPES),
    12: ("Partition Configuration Change", PARTITION_CONFIG_CHG_SPECIFIC_TYPES),
    13: ("Partition Event", PARTITION_EVENT_SPECIFIC_TYPES),
    14: ("Partition Test", PARTITION_TEST_SPECIFIC_TYPES),
    15: ("System Trouble", SYSTEM_TROUBLE_SPECIFIC_TYPES),
    16: ("System Trouble Restoral", SYSTEM_TROUBLE_SPECIFIC_TYPES),
    17: ("System Configuration Change", SYSTEM_CONFIG_CHG_SPECIFIC_TYPES),
    18: ("System Event", SYSTEM_EVENT_SPECIFIC_TYPES),
}
