/* ************************************************************** */ /* * Module VTWIREUI * This module contains functions for the stretched wire integrated * voltage system user interface. * * Zachary Wolf * 9/18/98 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include /* Needed if linking in external compiler; harmless otherwise */ #include #include "vtwireuir.h" #include "vtwireui.h" #include "vtwire.h" /* ************************************************************** */ /* PRIVATE PARAMETERS */ static struct vtwire_param_struct vtwire_param; /* ************************************************************** */ /* PRIVATE VARIABLES */ static int vtwire_panel; static int vtwireop_panel; /* ************************************************************** */ /* PRIVATE FUNCTION DECLARATIONS */ void vtwireui_error(char* msg); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * vtwireui_init * This function initializes the user interface for the VTwire 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 * vtwire_par, vtwire system parameters * * Zachary Wolf * 9/18/98 */ void vtwireui_init(int top_pos, int left_pos, struct vtwire_param_struct vtwire_par) { /* Save parameters for future use */ vtwire_param = vtwire_par; /* Make sure the user interface panel is desired */ if (vtwire_param.show_ui != VTWIRE_TRUE) return; /* Open the VTwire panel */ vtwire_panel = LoadPanel(0, "vtwireuir.uir", VTWIREPAN); if (vtwire_panel < 0) { vtwireui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vtwire_panel, top_pos, left_pos); /* Display the panel */ DisplayPanel(vtwire_panel); /* Done */ return; } /* ************************************************************** */ /* * vtwireopui_init * This function initializes the user interface for the VTwire 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 * 9/18/98 */ void vtwireopui_init(int top_pos, int left_pos) { /* Open the VTwire panel */ vtwireop_panel = LoadPanel(0, "vtwireuir.uir", VTWIREOP); if (vtwire_panel < 0) { vtwireui_error("Could not open user interface panel"); return; } /* Set the panel position */ SetPanelPos(vtwireop_panel, top_pos, left_pos); /* Display the panel when the user interface runs */ DisplayPanel(vtwireop_panel); /* Done */ return; } /* ************************************************************** */ void vtwireui_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 (vtwire_param.show_ui != VTWIRE_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(vtwire_panel, VTWIREPAN_GRAPH_V_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Plot the V samples */ PlotXY(vtwire_panel, VTWIREPAN_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(vtwire_panel, VTWIREPAN_GRAPH_VT_SAMP, -1, VAL_IMMEDIATE_DRAW); /* Plot the VT samples */ PlotXY(vtwire_panel, VTWIREPAN_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 */ /* ************************************************************** */ /* * vtwireui_error * This function handles error messages for the VTwire user interface. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 9/18/98 */ void vtwireui_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nVTWIREUI 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 vtwireui_quit(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { switch (event) { case EVENT_COMMIT: vtwire_exit(); QuitUserInterface(0); break; } return 0; } /* ************************************************************** */ int CVICALLBACK vtwireui_get_vt(int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { double x0, dx, vt; x0 = 0.; dx = .01; switch (event) { case EVENT_COMMIT: vtwire_get_vt(x0, dx, &vt); printf("\nVT = %f Vs\n", vt); vtwire_move_wire_abs(0.); break; case EVENT_RIGHT_CLICK: break; } return 0; }