/* ************************************************************** */ /* * Module VRAMPUI * This module contains functions for the current ramp * voltage sample system user interface. * * Zachary Wolf * 5/7/02 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "vrampuir.h" #include "vrampui.h" #include "vramp.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct vramp_param_struct vramp_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int vramp_panel; static int vrampop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void vrampui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * vrampui_init * This function initializes the user interface for the VTramp 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 * vramp_par, vramp system parameters * * Zachary Wolf * 5/7/02 */ void vrampui_init(int top_pos, int left_pos, struct vramp_param_struct vramp_par) { /* Save parameters for future use */ vramp_param = vramp_par; /* Make sure the user interface panel is desired */ if (vramp_param.show_ui != VRAMP_TRUE) return; /* Open the Vramp panel */ vramp_panel = LoadPanel(0, "vrampuir.uir", VRAMPPAN); if (vramp_panel < 0) { vrampui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vramp_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(vramp_panel); /* Done */ return; } /* ************************************************************** */ /* * vrampopui_init * This function initializes the user interface for the Vramp 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 * 5/7/02 */ void vrampopui_init(int top_pos, int left_pos) { /* Open the VTwire panel */ vrampop_panel = LoadPanel(0, "vrampuir.uir", VRAMPOP); if (vramp_panel < 0) { vrampui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vrampop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(vrampop_panel); /* Done */ return; } /* ************************************************************** */ void vrampui_update(long int num_samp, double t_samp[], double imag_samp[], double v_samp[]) { /* Check for the user interface */ if (vramp_param.show_ui != VRAMP_TRUE) return; /* Remove previous Imag sample plot */ DeleteGraphPlot(vramp_panel, VRAMPPAN_GRAPH_IMAG_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Plot the Imag samples */ PlotXY(vramp_panel, VRAMPPAN_GRAPH_IMAG_SAMP, t_samp, imag_samp, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED); /* Remove previous V sample plot */ DeleteGraphPlot(vramp_panel, VRAMPPAN_GRAPH_V_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Plot the V samples */ PlotXY(vramp_panel, VRAMPPAN_GRAPH_V_SAMP, t_samp, v_samp, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * vrampui_error * This function handles error messages for the VTwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 5/7/02 */ void vrampui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nVRAMPUI 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, 80, stdin); if (buf[0] == '\n') return; else exit(0); } /* ************************************************************** */ /* PRIVATE USER INTERFACE FUNCTIONS */ /* ************************************************************** */ int CVICALLBACK vrampui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: vramp_exit(); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vrampui_get_v(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { /* Declare variables */ long int num_samp; double imag; double t_samp[VRAMP_MAX_NUM_SAMP]; double imag_samp[VRAMP_MAX_NUM_SAMP]; double v_samp[VRAMP_MAX_NUM_SAMP]; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, VRAMPOP_NUMERIC_IMAG, &imag); vramp_get_v(imag, &num_samp, t_samp, imag_samp, v_samp); vramp_plt_v(num_samp, t_samp, imag_samp, v_samp); break; case EVENT_RIGHT_CLICK: break; } /* Done */ return 0; }