#sql_dbi events map

events_map = {
	"grp_v_ch_grant_mbt":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'options'],
		['frequency', 'frequency'],
		['tgid', 'group'],
		['suid', 'srcaddr'],
	],
	"grg_exenc_cmd":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'mfrid'],
		['tgid', 'sg'],
		['p', 'keyid'],
	],
	"grp_v_ch_grant":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'mfrid'],
		['p', 'options'],
		['frequency', 'frequency'],
		['tgid', 'group'],
		['suid', 'srcaddr'],
	],
	"mot_grg_cn_grant":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'mfrid'],
		['frequency', 'frequency'],
		['tgid', 'sg'],
		['suid', 'sa'],
	],	
	"grp_v_ch_grant_updt":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'mfrid'],
		['frequency', 'frequency1'],
		['tgid', 'group1'],
	],
	"grp_v_ch_grant_updt_exp":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'mfrid'],
		['p', 'options'],
		['frequency', 'frequency'],
		['tgid', 'group'],
	],
	"ack_resp_fne":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'aiv'],
		['p2', 'ex'],
		['p3', 'addl'],
		['wacn', 'wacn'],
		['suid', 'source'],
		['suid2', 'target'],
	],
	"deny_resp":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'aiv'],
		['p2', 'reason'],
		['p3', 'additional'],
		['suid', 'target'],
	],
	"grp_aff_resp":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'affiliation'],
		['p2', 'group_aff_value'],
		['tgid', 'announce_group'],
		['tgid2', 'group'],
		['suid', 'target'],
	],
	"grp_aff_q":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['suid', 'source'],
		['suid2', 'target'],
	],
	"loc_reg_resp":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'rv'],
		['p2', 'rfss'],
		['p3', 'siteid'],
		['tgid', 'group'],
		['suid', 'target'],
	],
	"u_reg_resp":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'rv'],
		['suid', 'source'],
		['suid2', 'target'],
	],
	"u_reg_cmd":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['suid', 'source'],
		['suid2', 'target'],
	],
	"u_de_reg_ack":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['wacn', 'wacn'],
		['suid', 'source'],
	],
	"ext_fnct_cmd":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'mfrid'],
		['p', 'efclass'],
		['p2', 'efoperand'],
		['suid', 'efargs'],
	],
	"end_call":	[
		['time', 'time'],
		['sysid', 'sysid'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'code'],
		['suid', 'srcaddr'],
		['tgid', 'tgid'],
		['p2', 'duration'],
		['p3', 'count'],
	],
}

# cc_event to numerical id (oplog and sql_dbi)
cc_events = {
	"ack_resp_fne":	1,
	"deny_resp":	2,
	"end_call":	3,
	"ext_fnct_cmd":	4,
	"grg_exenc_cmd":	5,
	"grp_aff_q":	6,
	"grp_aff_resp":	7,
	"grp_v_ch_grant":	8,
	"grp_v_ch_grant_mbt":	9,
	"grp_v_ch_grant_updt":	10,
	"grp_v_ch_grant_updt_exp":	11,
	"loc_reg_resp":	12,
	"u_de_reg_ack":	13,
	"u_reg_cmd":	14,
	"u_reg_resp":	15,
	"mot_grg_cn_grant":	16,	
}

# sql column names to DataTables (Oplog)
oplog_map = {
	"grp_v_ch_grant_mbt":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'MFRID'],
		['p', 'Options'],
		['frequency', 'Frequency'],
		['tgid', 'Talkgroup ID'],	
		['tgid', 'Talkgroup'],				
		['suid', 'Source ID'],
		['suid', 'Source'],	
	],
	"grg_exenc_cmd":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'MFRID'],
		['tgid', 'SG (tgid)'],
		['p', 'Key ID'],
	],
	"grp_v_ch_grant":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'MFRID'],
		['p', 'Options'],
		['frequency', 'Frequency'],
		['tgid', 'Talkgroup ID'],	
		['tgid', 'Talkgroup'],				
		['suid', 'Source ID'],
		['suid', 'Source'],		
	],
	"mot_grg_cn_grant":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'MFRID'],
		['frequency', 'Frequency'],
		['tgid', 'Talkgroup ID'],
		['tgid', 'Talkgroup'],		
		['suid', 'Source ID'],
		['suid', 'Source'],		
	],		
	"grp_v_ch_grant_updt":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'MFRID'],
		['frequency', 'Frequency'],
		['tgid', 'Talkgroup ID'],
		['tgid', 'Talkgroup'],		
	],
	"grp_v_ch_grant_updt_exp":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'mfrid'],
		['p', 'Options'],
		['frequency', 'Frequency'],
		['tgid', 'Talkgroup ID'],
		['tgid', 'Talkgroup'],		
	],
	"ack_resp_fne":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'aiv'],
		['p2', 'ex'],
		['p3', 'Additional'],
		['wacn', 'wacn'],
		['suid', 'System Source'],
		['suid2', 'Target ID'],
		['suid2', 'Target'],		
	],
	"deny_resp":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'aiv'],
		['p2', 'Reason'],
		['p3', 'Additional'],
		['suid', 'Target ID'],
		['suid', 'Target'],		
	],
	"grp_aff_resp":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'Affiliation'],
		['p2', 'Group Aff Value'],
		['tgid', 'Announce Group'],
		['tgid2', 'Talkgroup ID'],	
		['tgid2', 'Talkgroup'],	
		['suid', 'Target ID'],
		['suid', 'Target'],		
	],
	"grp_aff_q":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['suid', 'System Source'],	
		['suid2', 'Target ID'],
		['suid2', 'Target'],		
	],
	"loc_reg_resp":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'rv'],
		['p2', 'RFSS'],
		['p3', 'Site'],
		['tgid', 'Talkgroup ID'],
		['tgid', 'Talkgroup'],			
		['suid', 'Target ID'],
		['suid', 'Target'],		
	],
	"u_reg_resp":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'rv'],
		['suid', 'Source ID'],
		['suid', 'Source'],		
		['suid2', 'Target'],
	],
	"u_reg_cmd":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['suid', 'System Source'],
		['suid2', 'Target ID'],
		['suid2', 'Target'],		
	],
	"u_de_reg_ack":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['wacn', 'WACN'],
		['suid', 'Source ID'],
		['suid', 'Source'],		
	],
	"ext_fnct_cmd":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['mfrid', 'MFRID'],
		['p', 'Class'],
		['p2', 'Operand'],
		['suid', 'System Source'],
	],
	"end_call":	[
		['time', 'Time'],
		['sysid', 'System'],
		['opcode', 'opcode'],
		['cc_event', 'cc_event'],
		['p', 'Code'],
		['suid', 'Source ID'],
		['suid', 'Source'],		
		['tgid', 'Talkgroup ID'],
		['tgid', 'Talkgroup'],		
		['p2', 'Duration (ms)'],
		['p3', 'Count (p3)'],
	],
}

# friendly long description strings, used in Oplog
cc_desc = {
	"ack_resp_fne":				"Acknowledge Response FNE - 0x20",
	"deny_resp":				"Deny Response - 0x27",
	"end_call":					"End Call (not a naitve control channel event)",
	"ext_fnct_cmd":				"Extended Function Command - 0x24",
	"grg_exenc_cmd":			"Harris Group Regroup Explicit Encryption Command - 0x30",
	"grp_aff_q":				"Group Affiliation Query - 0x2A",
	"grp_aff_resp":				"Group Affiliation Response - 0x2B",
	"grp_v_ch_grant":			"Group Voice Channel Grant - 0x00",
	"grp_v_ch_grant_mbt":		"Group Voice Channel Grant, Multiple Block Trunking",
	"grp_v_ch_grant_updt":		"Group Voice Channel Grant Update - 0x02",
	"grp_v_ch_grant_updt_exp":	"Group Voice Channel Grant Update, Explicit - 0x03",
	"loc_reg_resp":				"Location Registration Response 0x2B",
	"mot_grg_cn_grant":			"Motorola Patch Channel Grant - 0x02",	
	"u_de_reg_ack":				"De-Registration Acknowledge (Logout) - 0x2F",
	"u_reg_cmd":				"Unit Registration Command (Force Unit Registration) - 0x2D",
	"u_reg_resp":				"Unit Registration Response - 0x2C"
}
