/* ************************************************************** */ /* * Module RTUI * This module contains functions for the RT * user interface. * * Zachary Wolf * 12/20/00 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "rtuir.h" #include "rtui.h" /* ************************************************************** */ /* PRIVATE VARIABLES */ static int rt_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONSS */ void rtui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * rtui_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 * * Zachary Wolf * 12/20/00 */ void rtui_init(int top_pos, int left_pos) { /* Declare variables */ char name_string[800]; /* Open the RT panel */ rt_panel = LoadPanel(0, "rtuir.uir", RTPAN); if (rt_panel < 0) { rtui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(rt_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(rt_panel); /* Write the measurement names in the text box */ strcpy(name_string, "Time, Imag (A), Vmag (V), Rmag (mohm)"); SetCtrlVal (rt_panel, RTPAN_TEXTMSG_DESCRIPTION, name_string); /* Done */ return; } /* ************************************************************** */ void rtui_update(double imag, double vmag, double rmag) { /* Declare variables */ char val_string[300]; /* Display the new values */ sprintf(val_string, "%s %8.2f %8.2f %8.2f\n", TimeStr(), imag, vmag, rmag*1000.); SetCtrlVal (rt_panel, RTPAN_TEXTBOX_VALUE, val_string); /* Add the new values to the strip chart */ PlotStripChartPoint(rt_panel, RTPAN_STRIPCHART_RES, rmag*1000.); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * rtui_error * This function handles error messages for the RT user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 11/17/00 */ void rtui_error(char* message) { /* Declare variables */ char buf[81]; /* Notify the operator of the error */ printf("\nRTUI 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."); fgets(buf, 80, stdin); if (buf[0] == '\n') return; else exit(0); }