mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-09 15:27:22 -05:00
Event History Setup: #287;
Add customizable event history line (in ncurses) for various items, but left colors as the default cyan. (Remus Request);
This commit is contained in:
@@ -91,6 +91,7 @@ extern volatile uint8_t exitflag; //fix for issue #136
|
||||
//event history (each item)
|
||||
typedef struct {
|
||||
uint8_t write; //if this event needs to be written to a log file
|
||||
uint8_t color_pair; //this value corresponds to which color pair the line should be in ncurses
|
||||
int8_t systype; //indentifier of which decoded system type this is from (P25, DMR, etc)
|
||||
int8_t subtype; //subtype of systpe (VLC, TLC, PDU data, System Event, etc)
|
||||
uint32_t sys_id1; //sys_id1 through 5 will be a hierarchy of system identifiers
|
||||
|
||||
@@ -115,6 +115,7 @@ void dmr_sd_pdu (dsd_opts * opts, dsd_state * state, uint16_t len, uint8_t * DMR
|
||||
utf8_to_text(state, 0, len-offset, DMR_PDU+offset);
|
||||
dmr_locn(opts, state, len, DMR_PDU);
|
||||
sprintf (state->event_history_s[slot].Event_History_Items[0].gps_s, "%s", state->dmr_lrrp_gps[slot]);
|
||||
state->event_history_s[slot].Event_History_Items[0].color_pair = 4; //Remus, add this line to a decode to change its line color
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -356,11 +357,13 @@ void decode_ip_pdu (dsd_opts * opts, dsd_state * state, uint16_t len, uint8_t *
|
||||
|
||||
fprintf (stderr, "LRRP;");
|
||||
dmr_lrrp (opts, state, len, src24, dst24, input+28); //len is offset with IP and UDP header lens, 4 CRC, and 1 for the 0D token
|
||||
state->event_history_s[slot].Event_History_Items[0].color_pair = 4; //Remus, add this line to a decode to change its line color
|
||||
}
|
||||
else if (port1 == 4004 && port2 == 4004)
|
||||
{
|
||||
fprintf (stderr, "XCMP;");
|
||||
sprintf (state->dmr_lrrp_gps[slot], "XCMP SRC: %d; DST: %d;", src24, dst24);
|
||||
state->event_history_s[slot].Event_History_Items[0].color_pair = 4; //Remus, add this line to a decode to change its line color
|
||||
}
|
||||
else if (port1 == 4005 && port2 == 4005)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ void init_event_history (Event_History_I * event_struct, uint8_t start, uint8_t
|
||||
for (uint8_t i = start; i < stop; i++)
|
||||
{
|
||||
event_struct->Event_History_Items[i].write = 0;
|
||||
event_struct->Event_History_Items[i].color_pair = 4;
|
||||
event_struct->Event_History_Items[i].systype = -1;
|
||||
event_struct->Event_History_Items[i].subtype = -1;
|
||||
event_struct->Event_History_Items[i].sys_id1 = 0;
|
||||
@@ -58,6 +59,7 @@ void push_event_history (Event_History_I * event_struct)
|
||||
for (uint8_t i = 254; i >= 1; i--)
|
||||
{
|
||||
event_struct->Event_History_Items[i].write = event_struct->Event_History_Items[i-1].write;
|
||||
event_struct->Event_History_Items[i].color_pair = event_struct->Event_History_Items[i-1].color_pair;
|
||||
event_struct->Event_History_Items[i].systype = event_struct->Event_History_Items[i-1].systype;
|
||||
event_struct->Event_History_Items[i].subtype = event_struct->Event_History_Items[i-1].subtype;
|
||||
event_struct->Event_History_Items[i].sys_id1 = event_struct->Event_History_Items[i-1].sys_id1;
|
||||
@@ -245,6 +247,13 @@ void watchdog_event_current (dsd_opts * opts, dsd_state * state, uint8_t slot)
|
||||
//create a pointer to the current slot event history
|
||||
Event_History_I * event_struct = &state->event_history_s[slot];
|
||||
|
||||
//ncurses color pairs
|
||||
uint8_t color_pair = 4; //default voice color (unknown gi)
|
||||
if (state->gi[slot] == 1)
|
||||
color_pair = 4; //default private voice color
|
||||
else if (state->gi[slot] == 0)
|
||||
color_pair = 4; //default group voice color
|
||||
|
||||
//TODO: Flesh out more later on.
|
||||
uint32_t source_id = 0;
|
||||
uint32_t target_id = 0;
|
||||
@@ -583,6 +592,7 @@ void watchdog_event_current (dsd_opts * opts, dsd_state * state, uint8_t slot)
|
||||
if (source_id != 0)
|
||||
{
|
||||
event_struct->Event_History_Items[0].write = 0;
|
||||
state->event_history_s[slot].Event_History_Items[0].color_pair = color_pair;
|
||||
if (state->lastsynctype != -1)
|
||||
event_struct->Event_History_Items[0].systype = state->lastsynctype;
|
||||
else event_struct->Event_History_Items[0].systype = 39; //generic digital call
|
||||
@@ -807,6 +817,8 @@ void watchdog_event_datacall (dsd_opts * opts, dsd_state * state, uint32_t src,
|
||||
{
|
||||
UNUSED(opts);
|
||||
state->event_history_s[slot].Event_History_Items[0].write = 0;
|
||||
if (state->event_history_s[slot].Event_History_Items[0].color_pair == 4) //if not set previously by specific decoder //don't touch this one
|
||||
state->event_history_s[slot].Event_History_Items[0].color_pair = 4; //default data color //you can change this one
|
||||
state->event_history_s[slot].Event_History_Items[0].systype = state->lastsynctype;
|
||||
state->event_history_s[slot].Event_History_Items[0].subtype = 6; //data
|
||||
state->event_history_s[slot].Event_History_Items[0].gi = state->gi[slot];
|
||||
|
||||
@@ -1634,9 +1634,11 @@
|
||||
}
|
||||
|
||||
//push a DSD-FME started event so users can see what this section does, and also gives users an idea of when context started
|
||||
state->event_history_s[0].Event_History_Items[0].color_pair = 6;
|
||||
watchdog_event_datacall (opts, state, 0, 0, "Any decoded voice calls or data calls display here;", 0);
|
||||
push_event_history (&state->event_history_s[0]);
|
||||
init_event_history (&state->event_history_s[0], 0, 1);
|
||||
state->event_history_s[0].Event_History_Items[0].color_pair = 6;
|
||||
watchdog_event_datacall (opts, state, 0, 0, "DSD-FME Started and Event History Initialized;", 0);
|
||||
push_event_history (&state->event_history_s[0]);
|
||||
init_event_history (&state->event_history_s[0], 0, 1);
|
||||
|
||||
@@ -80,12 +80,16 @@ void ncursesOpen (dsd_opts * opts, dsd_state * state)
|
||||
start_color();
|
||||
|
||||
#ifdef PRETTY_COLORS
|
||||
init_pair(1, COLOR_YELLOW, COLOR_BLACK); //Yellow/Amber for frame sync/control channel, NV style
|
||||
init_pair(2, COLOR_RED, COLOR_BLACK); //Red for Terminated Calls
|
||||
init_pair(3, COLOR_GREEN, COLOR_BLACK); //Green for Active Calls
|
||||
init_pair(4, COLOR_CYAN, COLOR_BLACK); //Cyan for Site Extra and Patches
|
||||
init_pair(5, COLOR_MAGENTA, COLOR_BLACK); //Magenta for no frame sync/signal
|
||||
init_pair(6, COLOR_WHITE, COLOR_BLACK); //White Card Color Scheme
|
||||
init_pair(1, COLOR_YELLOW, COLOR_BLACK); //Yellow/Amber for frame sync/control channel, NV style
|
||||
init_pair(2, COLOR_RED, COLOR_BLACK); //Red for Terminated Calls
|
||||
init_pair(3, COLOR_GREEN, COLOR_BLACK); //Green for Active Calls
|
||||
init_pair(4, COLOR_CYAN, COLOR_BLACK); //Cyan for Site Extra and Patches
|
||||
init_pair(5, COLOR_MAGENTA, COLOR_BLACK); //Magenta for no frame sync/signal
|
||||
init_pair(6, COLOR_WHITE, COLOR_BLACK); //White Card Color Scheme
|
||||
init_pair(7, COLOR_BLUE, COLOR_BLACK); //Blue on Black
|
||||
init_pair(8, COLOR_BLACK, COLOR_WHITE); //Black on White
|
||||
init_pair(9, COLOR_RED, COLOR_WHITE); //Red on White
|
||||
init_pair(10, COLOR_BLUE, COLOR_WHITE); //Blue on White
|
||||
#else
|
||||
init_pair(1, COLOR_WHITE, COLOR_BLACK); //White Card Color Scheme
|
||||
init_pair(2, COLOR_WHITE, COLOR_BLACK); //White Card Color Scheme
|
||||
@@ -93,6 +97,10 @@ void ncursesOpen (dsd_opts * opts, dsd_state * state)
|
||||
init_pair(4, COLOR_WHITE, COLOR_BLACK); //White Card Color Scheme
|
||||
init_pair(5, COLOR_WHITE, COLOR_BLACK); //White Card Color Scheme
|
||||
init_pair(6, COLOR_WHITE, COLOR_BLACK); //White Card Color Scheme
|
||||
init_pair(7, COLOR_WHITE, COLOR_BLACK); //White Card Color Scheme
|
||||
init_pair(8, COLOR_BLACK, COLOR_WHITE); //White Card Color Scheme
|
||||
init_pair(9, COLOR_BLACK, COLOR_WHITE); //White Card Color Scheme
|
||||
init_pair(10, COLOR_BLACK, COLOR_WHITE); //White Card Color Scheme
|
||||
#endif
|
||||
|
||||
noecho();
|
||||
@@ -1588,35 +1596,56 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
printw ("--Latest Event History ([|])---Slot %d (\\)-------------------------------------\n", state->eh_slot+1);
|
||||
for (uint16_t i = (state->eh_index+1); i < (state->eh_index+11); i++)
|
||||
{
|
||||
// if ((i%255) == 0) continue; //0 is the event in progress before completion
|
||||
|
||||
char text_string[2000];
|
||||
sprintf (text_string, "%s", "BUMBLEBEETUNA");
|
||||
uint8_t slot = state->eh_slot;
|
||||
uint8_t color_pair = state->event_history_s[slot].Event_History_Items[i%255].color_pair; //this is the color pair assignment for this line
|
||||
attron(COLOR_PAIR(4));
|
||||
|
||||
char text_string[2000]; memset (text_string, 0, sizeof(text_string));
|
||||
sprintf (text_string, "%s", "BUMBLEBEETUNA");
|
||||
if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[i%255].event_string, 13) != 0)
|
||||
{
|
||||
memcpy(text_string, state->event_history_s[slot].Event_History_Items[i%255].event_string, 71*sizeof(char));
|
||||
text_string[71] = 0; //terminate string
|
||||
printw ("| #%03d %s \n", i%255, text_string);
|
||||
printw ("| #%03d ", i%255);
|
||||
attron(COLOR_PAIR(color_pair)); //this is where the custom color switch occurs for the event_string
|
||||
printw ("%s\n", text_string);
|
||||
attron(COLOR_PAIR(4));
|
||||
}
|
||||
else printw ("| #%03d \n", i%255); //empty event, but since we can freely scroll now, keeps things uniform
|
||||
|
||||
sprintf (text_string, "%s", "BUMBLEBEETUNA");
|
||||
if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[i%255].text_message, 13) != 0)
|
||||
printw ("| %s \n", state->event_history_s[slot].Event_History_Items[i%255].text_message);
|
||||
{
|
||||
printw ("|");
|
||||
attron(COLOR_PAIR(4)); //feel free to change this to any value you want
|
||||
printw (" %s\n", state->event_history_s[slot].Event_History_Items[i%255].text_message);
|
||||
attron(COLOR_PAIR(4));
|
||||
}
|
||||
|
||||
sprintf (text_string, "%s", "BUMBLEBEETUNA");
|
||||
if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[i%255].alias, 13) != 0)
|
||||
printw ("| Alias: %s \n", state->event_history_s[slot].Event_History_Items[i%255].alias);
|
||||
{
|
||||
printw ("|");
|
||||
attron(COLOR_PAIR(4)); //feel free to change this to any value you want
|
||||
printw (" Alias: %s \n", state->event_history_s[slot].Event_History_Items[i%255].alias);
|
||||
attron(COLOR_PAIR(4));
|
||||
}
|
||||
|
||||
sprintf (text_string, "%s", "BUMBLEBEETUNA");
|
||||
if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[i%255].gps_s, 13) != 0)
|
||||
printw ("| GPS: %s \n", state->event_history_s[slot].Event_History_Items[i%255].gps_s);
|
||||
{
|
||||
printw ("|");
|
||||
attron(COLOR_PAIR(4)); //feel free to change this to any value you want
|
||||
printw (" GPS: %s \n", state->event_history_s[slot].Event_History_Items[i%255].gps_s);
|
||||
attron(COLOR_PAIR(4));
|
||||
}
|
||||
|
||||
sprintf (text_string, "%s", "BUMBLEBEETUNA");
|
||||
if (strncmp(text_string, state->event_history_s[slot].Event_History_Items[i%255].internal_str, 13) != 0)
|
||||
printw ("| DSD-FME: %s \n", state->event_history_s[slot].Event_History_Items[i%255].internal_str);
|
||||
{
|
||||
printw ("|");
|
||||
attron(COLOR_PAIR(4)); //feel free to change this to any value you want
|
||||
printw (" DSD-FME: %s \n", state->event_history_s[slot].Event_History_Items[i%255].internal_str);
|
||||
attron(COLOR_PAIR(4));
|
||||
}
|
||||
|
||||
}
|
||||
printw ("------------------------------------------------------------------------------\n");
|
||||
|
||||
Reference in New Issue
Block a user