/* ************************************************************** */ /* * Module VTRAMPUI * This module contains functions for the current ramp integrated * voltage system user interface. * * Zachary Wolf * 4/16/02 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "vtrampuir.h" #include "vtrampui.h" #include "vtramp.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct vtramp_param_struct vtramp_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int vtramp_panel; static int vtrampop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void vtrampui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * vtrampui_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 * vtramp_par, vtramp system parameters * * Zachary Wolf * 4/16/02 */ void vtrampui_init(int top_pos, int left_pos, struct vtramp_param_struct vtramp_par) { /* Save parameters for future use */ vtramp_param = vtramp_par; /* Make sure the user interface panel is desired */ if (vtramp_param.show_ui != VTRAMP_TRUE) return; /* Open the VTwire panel */ vtramp_panel = LoadPanel(0, "vtrampuir.uir", VTRAMPPAN); if (vtramp_panel < 0) { vtrampui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vtramp_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(vtramp_panel); /* Done */ return; } /* ************************************************************** */ /* * vtrampopui_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 * * Zachary Wolf * 4/16/02 */ void vtrampopui_init(int top_pos, int left_pos) { /* Open the VTwire panel */ vtrampop_panel = LoadPanel(0, "vtrampuir.uir", VTRAMPOP); if (vtramp_panel < 0) { vtrampui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vtrampop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(vtrampop_panel); /* Done */ return; } /* ************************************************************** */ void vtrampui_update(double delta_t_samp, int num_samp, double v_samp[], double vt_samp[]) { /* Declare variables */ double* samp_time; int i; /* Check for the user interface */ if (vtramp_param.show_ui != VTRAMP_TRUE) return; /* Fill array of sample times for V and VT sample X axis */ samp_time = malloc((num_samp + 1) * sizeof(double)); for (i = 0; i < num_samp; i++) samp_time[i] = i * delta_t_samp; /* Remove previous V sample plot */ DeleteGraphPlot(vtramp_panel, VTRAMPPAN_GRAPH_V_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Plot the V samples */ PlotXY(vtramp_panel, VTRAMPPAN_GRAPH_V_SAMP, samp_time, v_samp, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED); /* Remove previous VT sample plot */ DeleteGraphPlot(vtramp_panel, VTRAMPPAN_GRAPH_VT_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Plot the VT samples */ PlotXY(vtramp_panel, VTRAMPPAN_GRAPH_VT_SAMP, samp_time, vt_samp, num_samp, VAL_DOUBLE, VAL_DOUBLE, VAL_SCATTER, VAL_SMALL_SOLID_SQUARE, VAL_SOLID, 1, VAL_RED); /* Free internal storage */ free(samp_time); /* Done */ return; } /* ************************************************************** */ /* PRIVATE FUNCTIONS */ /* ************************************************************** */ /* * vtrampui_error * This function handles error messages for the VTwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 4/16/02 */ void vtrampui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nVTRAMPUI 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 vtrampui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: vtramp_exit(); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vtrampui_get_vt(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double imag, vt; switch (event) { case EVENT_COMMIT: GetCtrlVal (panel, VTRAMPOP_NUMERIC_IMAG, &imag); vtramp_get_vt(imag, &vt); printf("\nVT = %f Vs\n", vt); break; case EVENT_RIGHT_CLICK: break; } return 0; }