/* ************************************************************** */ /* * Module TMAGUI * This module contains functions for the TMAG * user interface. * * Zachary Wolf * 11/17/00 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "tmaguir.h" #include "tmagui.h" #include "tmag.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct tmag_param_struct tmag_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int tmag_panel; static int tmagop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void tmagui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * tmagui_init * This function initializes the user interface. * * Input: * top_pos, vertical position of top left panel corner in screen coordinates * left_pos, horizontal position of top left panel corner in screen coordinates * tmag_par, tmag system parameters * * Zachary Wolf * 11/17/00 */ void tmagui_init(int top_pos, int left_pos, struct tmag_param_struct tmag_par) { /* Declare variables */ int i; char tn_name_string[80]; char name_string[800]; /* Save parameters for future use */ tmag_param = tmag_par; /* Make sure the user interface panel is desired */ if (tmag_param.show_ui != TMAG_TRUE) return; /* Open the TMAG panel */ tmag_panel = LoadPanel(0, "tmaguir.uir", TEMPPAN); if (tmag_panel < 0) { tmagui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(tmag_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(tmag_panel); /* Write the probe names in the text box */ strcpy(name_string, ""); for (i = 0; i < tmag_param.num_tmag_probes; i++) { sprintf(tn_name_string, "T%i: %-10.10s", i, tmag_param.probe[i].name); strcat(name_string, tn_name_string); if ((i+1) % 3 == 0) strcat(name_string, "\n"); else strcat(name_string, " "); } SetCtrlVal (tmag_panel, TEMPPAN_TEXTMSG_DESCRIPTION, name_string); /* Set the number of traces in the strip chart */ SetCtrlAttribute(tmag_panel, TEMPPAN_STRIPCHART_TEMP, ATTR_NUM_TRACES, tmag_param.num_tmag_probes); /* Done */ return; } /* ************************************************************** */ /* * tmagopui_init * This function initializes the user interface for the TMAG system. * * Input: * top_pos, vertical position of top left panel corner in screen coordinates * left_pos, horizontal position of top left panel corner in screen coordinates * * Zachary Wolf * 11/17/00 */ void tmagopui_init(int top_pos, int left_pos) { /* Open the panel */ tmagop_panel = LoadPanel(0, "tmaguir.uir", TEMPOPPAN); if (tmag_panel < 0) { tmagui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(tmagop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(tmagop_panel); /* Done */ return; } /* ************************************************************** */ void tmagui_update(int num_probes, double probe_temps[]) { /* Declare variables */ char temp_string[300]; char temp_val_string[50]; int i; /* Check for the user interface */ if (tmag_param.show_ui != TMAG_TRUE) return; /* Display the new values */ sprintf(temp_string, "%s ", TimeStr()); for (i = 0; i < num_probes; i++) { sprintf(temp_val_string, "%6.2f ", probe_temps[i]); strcat(temp_string, temp_val_string); } strcat(temp_string, "\n"); SetCtrlVal (tmag_panel, TEMPPAN_TEXTBOX_VALUE, temp_string); /* Add the new values to the strip chart */ PlotStripChart(tmag_panel, TEMPPAN_STRIPCHART_TEMP, probe_temps, num_probes, 0, 0, VAL_DOUBLE); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * tmagui_error * This function handles error messages for the TMAG user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 11/17/00 */ void tmagui_error(char* message) { /* Declare variables */ char buf[TMAG_MAX_CMD]; /* Notify the operator of the error */ printf("\nTMAGUI ERROR: %s\n", message); Beep(); Delay(.5); Beep(); /* Terminate the program if the operator desires */ printf("Press ENTER to continue.\nPress any key then ENTER to terminate program.\n"); fgets(buf, TMAG_MAX_CMD, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK tmagui_get_temps(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int num_probes; double probe_temps[TMAG_MAX_NUM_PROBES]; int i; switch (event) { case EVENT_COMMIT: tmag_get_num_probes(&num_probes); for (i = 0; i < num_probes; i++) probe_temps[i] = i; tmagui_update(num_probes, probe_temps); break; case EVENT_RIGHT_CLICK: break; } return 0; } /* ************************************************************** */ int CVICALLBACK tmagui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: tmag_exit(); QuitUserInterface(0); break; case EVENT_RIGHT_CLICK: break; } return 0; }