#pragma module el_demo_1 "X-1" /* ******************************************************************************** ** ** ** © Copyright 1976, 2005 Hewlett-Packard Development Company, L.P. ** ** ** ** Confidential computer software. Valid license from HP and/or ** ** its subsidiaries required for possession, use, or copying. ** ** ** ** Consistent with FAR 12.211 and 12.212, Commercial Computer Software, ** ** Computer Software Documentation, and Technical Data for Commercial ** ** Items are licensed to the U.S. Government under vendor's standard ** ** commercial license. ** ** ** ** Neither HP nor any of its subsidiaries shall be liable for technical ** ** or editorial errors or omissions contained herein. The information ** ** in this document is provided "as is" without warranty of any kind and ** ** is subject to change without notice. The warranties for HP products ** ** are set forth in the express limited warranty statements accompanying ** ** such products. Nothing herein should be construed as constituting an ** ** additional warranty. ** ** ** ******************************************************************************** ** ** ** FACILITY: ** ** Example ** ** ABSTRACT: ** ** A simple program to manipulate the Lascar Electronice ** EL-USB-2 temperature and humidity logger. For more details about ** this device see the indclude file EL_USB_2.H. ** ** To get UGDRIVER to associated to the logger you will need to add the ** following to the sys$user_config.dat file. For more on how USB devices ** are associated to drivers see the section on USB device configuration in ** UGDRIVER Programmers Guide. ** ** device = "EL-USB-2" ** name = ug ** driver = sys$ugdriver ** begin_private ** usb_config_type = interface ** vendor_id = 4292 ** product_id = 2 ** release_number = 256 ** begin_interface ** interface_class = 0 ** interface_sub_class = 0 ** interface_protocol = 0 ** end_interface ** end_private ** end_device ** ** AUTHOR: Forrest A. Kenney 03-August-2006 ** ** REVISION HISTORY: ** ** X-1 FAK001 Forrest A. Kenney 21-August-2006 ** Initial check in. **/ /* ** Include files */ #include #include /* String descriptors */ #include #include /* LIB RTL routines */ #include #include #include /* System error codes */ #include /* System routines */ #include /* Stand I/O routines */ #include /* Get exit definitions */ #include /* String functions */ #include #include /* Date and Time functions */ #include "el_usb_2.H" typedef struct _display_data { unsigned int pb_id; unsigned int kb_id; int pb_rows; int pb_cols; /* Menu Display items */ unsigned int menu_id; int menu_attr; int menu_cols; int menu_rows; int menu_paste_col; int menu_paste_row; unsigned short int menu_default; unsigned short int menu_item; unsigned int menu_type; unsigned int menu_flags; /* Temperature Didsplay Items */ unsigned int temp_id; int temp_cols; int temp_rows; int temp_paste_col; int temp_paste_row; int temp_attr; /* Status Display items */ unsigned int status_id; int status_cols; int status_rows; int status_paste_col; int status_paste_row; int status_attr; } DISPLAY_DATA; typedef struct __status_display_item { char *text; int row; int col; } STATUS_DISPLAY_ITEM; #define MAIN_MENU_ITEMS 5 #define MENU_STATUS 1 /* Display status */ #define MENU_TEMPERATURE 2 /* Display temperature and humidity */ #define MENU_STOP 3 /* Stop logger */ #define MENU_SETUP 4 /* Configire logger */ #define MENU_EXIT 5 /* exit */ #define MAX_STATUS_DISPLAY_ITEMS 12 /* Global data */ char *done_refresh = "RefreshDone "; DEVICE_DATA device; DISPLAY_DATA display; STATUS_DISPLAY_ITEM status_line[MAX_STATUS_DISPLAY_ITEMS] = {"Current Status", 2, 10, "Logger name :", 4, 6, "status :", 5, 11, "Start Time :", 6, 7, "Start Date :", 7, 7, "Readings :", 8, 9, "Sample Rate :", 9, 6, "Scale :", 10, 12, "High Alarm :", 11, 7, "Low Alarm :", 12, 8, "Serial Number :", 13, 4, "Firmware Version :", 14, 1}; /* Prototypes */ void hangup_ast (unsigned int param); int create_displays (DISPLAY_DATA *data); int init_status_display (DISPLAY_DATA *data); int main_menu (DISPLAY_DATA *data, int *item); int status_display (DISPLAY_DATA *data, STATUS_BLOCK block); int init_logger (DEVICE_DATA *device, DISPLAY_DATA *display); int init_logger_p1 (DISPLAY_DATA *display, STATUS_BLOCK *block); int init_logger_p2 (DISPLAY_DATA *display, STATUS_BLOCK *block); int init_logger_p3 (DISPLAY_DATA *display, STATUS_BLOCK *block); int init_logger_p4 (DISPLAY_DATA *display, STATUS_BLOCK *block); int temp_display (DISPLAY_DATA *data, STATUS_BLOCK *block, LOGGED_DATA *temp_data); /* **++ ** Main - Get us started ** ** Functional description: ** ** Simple mainline code to get us started off. ** ** Calling convention: ** ** int main(argc, argv) ** ** Input parameters: ** ** argc Count of arguments not used ** argv Pointer to arguments not used ** ** Output parameters: ** ** None ** ** Return value: ** ** Lots ** ** Environment: ** ** User mode ** **-- */ int main(int argc, char *argv[]) { char out_buff[80]; int col; int item; unsigned int menu_type = SMG$K_HORIZONTAL; int row; int status; STATUS_BLOCK block; LOGGED_DATA data; struct dsc$descriptor_a menu; struct dsc$descriptor_s out_line; out_line.dsc$a_pointer = &out_buff[0]; out_line.dsc$b_dtype = DSC$K_DTYPE_T; out_line.dsc$b_class = DSC$K_CLASS_S; menu.dsc$w_length = 7; menu.dsc$b_dtype = DSC$K_DTYPE_T; menu.dsc$b_class = DSC$K_CLASS_A; menu.dsc$a_pointer = done_refresh; menu.dsc$b_aflags.dsc$v_fl_bounds = 0; menu.dsc$b_dimct = 1; menu.dsc$l_arsize = 14; if (argc >= 2) { status = open_el_usb_2(&device, argv[1], hangup_ast, 0); if (status == SS$_NORMAL) { status = create_displays(&display); if (status & SS$_NORMAL) { do { status = main_menu(&display, &item); if (status & SS$_NORMAL) { switch (item) { case MENU_STATUS : do { status = get_status(&device, &block); if (status & SS$_NORMAL) { status = init_status_display(&display); status = status_display(&display, block); item = 2; status = smg$select_from_menu(&display.kb_id, &display.status_id, &item, &item); } smg$delete_menu(&display.status_id); smg$unpaste_virtual_display(&display.status_id, &display.pb_id); } while ((status & SS$_NORMAL) && (item != 2)); break; case MENU_TEMPERATURE : do { status = get_status(&device, &block); if ((status & SS$_NORMAL) && (block.status.bits.run) && (block.count <= 16385)) { status = dump_data(&device, &data); if (status & SS$_NORMAL) { row = 4; smg$create_menu(&display.temp_id, &menu, &menu_type, 0, &row); smg$paste_virtual_display(&display.temp_id, &display.pb_id, &display.temp_paste_row, &display.temp_paste_col); if (block.units == 0) { out_line.dsc$w_length = sprintf(&out_buff[0], "%3.1f c", ((float)data.data[block.count-1].degrees/2) - 40.0); } else { out_line.dsc$w_length = sprintf(&out_buff[0], "%3.1f f", (float)data.data[block.count-1].degrees - 40.0); } col = 2; row = 1; smg$put_chars(&display.temp_id, &out_line, &row, &col); row = 2; out_line.dsc$w_length = sprintf(&out_buff[0], "%3.1f %%", (float)data.data[block.count-1].humidity/2); smg$put_chars(&display.temp_id, &out_line, &row, &col); item = 2; smg$select_from_menu(&display.kb_id, &display.temp_id, &item, &item); smg$delete_menu(&display.temp_id); smg$unpaste_virtual_display(&display.temp_id, &display.pb_id); } } else { status = SS$_NODATA; } } while ((status & SS$_NORMAL) && (item != 2)); if (status == SS$_NODATA) { status = SS$_NORMAL; } break; case MENU_STOP : status = get_status(&device, &block); if (status & SS$_NORMAL) { block.status.bits.run = 0; status = setup_logger(&device, &block, &item); } break; case MENU_SETUP : status = init_logger(&device, &display); break; } } } while ((status & SS$_NORMAL) && (item != MENU_EXIT)); } } } else { printf("Not enough device specified\n"); status = SS$_NOSUCHDEV; } return(status); } /* **++ ** hangup_ast - Signal device is unplugged ** ** Functional description: ** ** Signal that device is unplugged. ** ** Calling convention: ** ** void hangup_ast (unsigned int astparam) ** ** Input parameters: ** ** unsigned int astparam Value delivered with AST. ** ** Output parameters: ** ** None ** ** Return value: ** ** None ** ** Environment: ** ** User Mode AST ** **-- */ void hangup_ast(unsigned int ast_param) { exit(SS$_HANGUP); } /* **++ ** status_display - Output Formated status data ** ** Functional description: ** ** Take the status data and display it in a more friendly format ** ** Calling convention: ** ** void status_display (DISPLAY_DATA *data, STATUS_BLOCK block) ** ** Input parameters: ** ** DISPLAY_DATA Pointer to display data block ** STATUS_BLOCK status data from device ** ** Output parameters: ** ** None ** ** Return value: ** ** None ** ** Environment: ** ** User mode. ** **-- */ int status_display(DISPLAY_DATA *data, STATUS_BLOCK block) { char out_string[80]; float low_temp_c = 0.0; float low_temp = 0.0; float high_temp_c = 0.0; float high_temp = 0.0; float low_rh = 0.0; float high_rh = 0.0; int row; int col; int next_col; struct dsc$descriptor_s string; string.dsc$b_dtype = DSC$K_DTYPE_T; string.dsc$b_class = DSC$K_CLASS_S; string.dsc$a_pointer = &out_string[0]; /* ** Compute temperature and humidity data read with get ** status commands */ if (block.units == 0) { low_temp_c = ((float)block.temp_low /2) - 40.0; high_temp_c = ((float)block.temp_high /2) - 40.0; } else { low_temp = (float) (block.temp_low -40); high_temp =(float) (block.temp_high -40); } high_rh = ((float)block.rh_high/2); low_rh = ((float)block.rh_low/2); row = status_line[1].row; col = 20; string.dsc$w_length = sprintf(&out_string[0], "%s", &block.name[0]); smg$put_chars(&data->status_id, &string, &row, &col); row = status_line[2].row; if (block.status.run_stop) { if (block.start_delay == 0) { if (block.status.bits.run) { string.dsc$w_length = sprintf(&out_string[0], "running"); } else { string.dsc$w_length = sprintf(&out_string[0], "stopped"); } smg$put_chars(&data->status_id, &string, &row, &col); next_col = col + string.dsc$w_length; if (block.status.bits.valid) { string.dsc$w_length = sprintf(&out_string[0], ", valid"); smg$put_chars(&data->status_id, &string, &row, &next_col); } } else { string.dsc$w_length = sprintf(&out_string[0], "Delayed start"); smg$put_chars(&data->status_id, &string, &row, &col); } } row = status_line[3].row; string.dsc$w_length = sprintf(&out_string[0], "%02d:%02d:%02d", block.hour, block.min, block.second); smg$put_chars(&data->status_id, &string, &row, &col); row = status_line[4].row; string.dsc$w_length = sprintf(&out_string[0], "%02d-%02d-%04d", block.month, block.day, block.year+2000); smg$put_chars(&data->status_id, &string, &row, &col); row = status_line[5].row; string.dsc$w_length = sprintf(&out_string[0], "%d", block.count); smg$put_chars(&data->status_id, &string, &row, &col); row = status_line[6].row; string.dsc$w_length = sprintf(&out_string[0], "%d seconds", block.sample_rate); smg$put_chars(&data->status_id, &string, &row, &col); row = status_line[7].row; if (block.units) { string.dsc$w_length = sprintf(&out_string[0], "Fahrenheit"); } else { string.dsc$w_length = sprintf(&out_string[0], "Celsius"); } smg$put_chars(&data->status_id, &string, &row, &col); row = status_line[8].row; if (block.rh_temp_flags.bits.temp_high) { string.dsc$w_length = sprintf(&out_string[0], "enabled"); } else { string.dsc$w_length = sprintf(&out_string[0], "disabled"); } smg$put_chars(&data->status_id, &string, &row, &col); next_col = col + string.dsc$w_length; if (block.rh_temp_flags.bits.rh_high) { string.dsc$w_length = sprintf(&out_string[0], ", enabled"); } else { string.dsc$w_length = sprintf(&out_string[0], ", disabled"); } smg$put_chars(&data->status_id, &string, &row, &next_col); row = status_line[9].row; if (block.rh_temp_flags.bits.temp_low) { string.dsc$w_length = sprintf(&out_string[0], "enabled"); } else { string.dsc$w_length = sprintf(&out_string[0], "disabled"); } smg$put_chars(&data->status_id, &string, &row, &col); next_col = col + string.dsc$w_length; if (block.rh_temp_flags.bits.rh_low) { string.dsc$w_length = sprintf(&out_string[0], ", enabled"); } else { string.dsc$w_length = sprintf(&out_string[0], ", disabled"); } smg$put_chars(&data->status_id, &string, &row, &next_col); row = status_line[10].row; string.dsc$w_length = sprintf(&out_string[0], "%d", block.serial_num); smg$put_chars(&data->status_id, &string, &row, &col); row = status_line[11].row; string.dsc$w_length = sprintf(&out_string[0], "%c%c%c%c\n", block.version[0], block.version[1], block.version[2], block.version[3]); smg$put_chars(&data->status_id, &string, &row, &col); return(SS$_NORMAL); } /* **++ ** create_displays - Create the display items ** ** Functional description: ** ** Describe routine ** ** Calling convention: ** ** int create_displays (DISPLAY_DATA *data); ** ** Input parameters: ** ** DISPLAY_DATA *data Pointer to block describing display data ** ** Output parameters: ** ** None ** ** Return value: ** ** SS$_NORMAL - Worked ** SS$_XXX - Failed ** SMG$_XXX - Failed ** ** Environment: ** ** User mode ** **-- */ int create_displays(DISPLAY_DATA *data) { int status; status = smg$create_pasteboard(&data->pb_id, 0, &data->pb_rows, &data->pb_cols); if (status & SS$_NORMAL) { data->menu_attr = SMG$M_BORDER; data->menu_cols = 15; data->menu_rows = 5; data->menu_paste_col = 2; data->menu_paste_row = 2; data->menu_default = 2; data->menu_type = SMG$K_VERTICAL; data->menu_flags = SMG$M_FULL_FIELD; data->temp_cols = 17; data->temp_rows = 4; data->temp_paste_col = 62; data->temp_paste_row = 2; data->temp_attr = SMG$M_BORDER; data->status_cols = 37; data->status_rows = 17; data->status_paste_col = 43; data->status_paste_row = 2; data->status_attr = SMG$M_BORDER; status = smg$create_virtual_keyboard(&data->kb_id); if (status & SS$_NORMAL) { status = smg$create_virtual_display(&data->menu_rows, &data->menu_cols, &data->menu_id, &data->menu_attr); if (status & SS$_NORMAL) { status = smg$create_virtual_display(&data->temp_rows, &data->temp_cols, &data->temp_id, &data->temp_attr); if (status & SS$_NORMAL) { status = smg$create_virtual_display(&data->status_rows, &data->status_cols, &data->status_id, &data->status_attr); } } } } return(status); } /* **++ ** init_status_display - Build up status display ** ** Functional description: ** ** This routine will fill in all the fixed parts of the status display. ** ** Calling convention: ** ** int init_status_display (DISPLAY_DATA *display) ** ** Input parameters: ** ** DISPLAY_DATA *display - Pointer to display data. ** ** Output parameters: ** ** None ** ** Return value: ** ** SS$_NORMAL Worked ** SS$_XXX Failed ** SMG$_XXX Failed ** ** Environment: ** ** User mode ** **-- */ int init_status_display(DISPLAY_DATA *display) { int col = 1; int flags = SMG$M_ERASE_LINE; int i = 0; unsigned int menu_type = SMG$K_HORIZONTAL; int row = 16; int status; struct dsc$descriptor_s out_line; static struct dsc$descriptor_a menu; out_line.dsc$b_dtype = DSC$K_DTYPE_T; out_line.dsc$b_class = DSC$K_CLASS_S; menu.dsc$w_length = 7; menu.dsc$b_dtype = DSC$K_DTYPE_T; menu.dsc$b_class = DSC$K_CLASS_A; menu.dsc$a_pointer = done_refresh; menu.dsc$b_aflags.dsc$v_fl_bounds = 0; menu.dsc$b_dimct = 1; menu.dsc$l_arsize = 14; status = smg$create_menu(&display->status_id, &menu, &menu_type, 0, &row); if (status & SS$_NORMAL) { do { out_line.dsc$w_length = strlen(status_line[i].text); out_line.dsc$a_pointer = status_line[i].text; status = smg$put_chars(&display->status_id, &out_line, &status_line[i].row, &status_line[i].col, &flags); i += 1; } while ((status & SS$_NORMAL) && (i < MAX_STATUS_DISPLAY_ITEMS)); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&display->status_id, &display->pb_id, &display->status_paste_row, &display->status_paste_col); } } return(status); } /* **++ ** main_menu - Display main menu ** ** Functional description: ** ** Paste up main mene and return item selected. ** ** Calling convention: ** ** int main_menu (DISPLAY_DATA *data, int *item) ** ** Input parameters: ** ** DIAPLAY_DATA *data - Pointer to block that describes displays ** int *item - Pointer to item selected from menu ** ** Output parameters: ** ** None ** ** Return value: ** ** SS$_NORMAL Worked ** SS$_XXXXX Failed ** SMG$_XXXX Failed ** ** Environment: ** ** User mode ** **-- */ int main_menu(DISPLAY_DATA *data, int *item) { char *menu_items = "Device StatusTemperature Stop logger Setup Logger Exit "; int status = SS$_NORMAL; struct dsc$descriptor_a menu; menu.dsc$w_length = 13; menu.dsc$b_dtype = DSC$K_DTYPE_T; menu.dsc$b_class = DSC$K_CLASS_A; menu.dsc$a_pointer = menu_items; menu.dsc$b_aflags.dsc$v_fl_bounds = 0; menu.dsc$b_dimct = 1; menu.dsc$l_arsize = MAIN_MENU_ITEMS * 13; status = smg$create_menu(&data->menu_id, &menu, &data->menu_type, &data->menu_flags); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&data->menu_id, &data->pb_id, &data->menu_paste_row, &data->menu_paste_col); if (status & SS$_NORMAL) { status = smg$select_from_menu(&data->kb_id, &data->menu_id, &data->menu_item, &data->menu_default); if (status & SS$_NORMAL) { *item = (int) data->menu_item; status = smg$delete_menu(&data->menu_id); status = smg$unpaste_virtual_display(&data->menu_id, &data->pb_id); } } } return(status); } /* **++ ** init_logger - Drive changing logger state ** ** Functional description: ** ** This routine will get the current logger state and then walk ** changing parameters. The user can quit at any time and will be ** asked to at the end if they really want to do the update. ** ** Calling convention: ** ** int init_logger (DEVICE_DATA *device, DISPLAY_DATA *display) ** ** Input parameters: ** ** DISPLAY_DATA *display Pointer to display data ** ** Output parameters: ** ** None ** ** Return value: ** ** SS$_NORMAL Worked ** SS$_XXX Failed ** SMG$_XXX Failed ** ** Environment: ** ** User mode ** **-- */ int init_logger(DEVICE_DATA *device, DISPLAY_DATA *display) { char *do_it = "Accept ChangesCancel Changes"; int item; unsigned int menu_type = SMG$K_HORIZONTAL; unsigned int v1_id; int v1_rows = 1; int v1_cols = 40; int v1_p_row = 2; int v1_p_col = 1; int status; struct dsc$descriptor_a menu; STATUS_BLOCK block; menu.dsc$w_length = 14; menu.dsc$b_dtype = DSC$K_DTYPE_T; menu.dsc$b_class = DSC$K_CLASS_A; menu.dsc$a_pointer = do_it; menu.dsc$b_aflags.dsc$v_fl_bounds = 0; menu.dsc$b_dimct = 1; menu.dsc$l_arsize = 28; status = get_status(device, &block); if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v1_rows, &v1_cols, &v1_id); if (status & SS$_NORMAL) { status = smg$create_menu(&v1_id, &menu, &menu_type); if (status & SS$_NORMAL) { status = init_logger_p1(display, &block); if (status & SS$_NORMAL) { status = init_logger_p2(display, &block); if (status & SS$_NORMAL) { status = init_logger_p3(display, &block); if (status & SS$_NORMAL) { status = init_logger_p4(display, &block); } } } /* Check one last time before changing device */ if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v1_id, &display->pb_id, &v1_p_row, &v1_p_col); if (status & SS$_NORMAL) { item = 2; status = smg$select_from_menu(&display->kb_id, &v1_id, &item, &item); if ((status & SS$_NORMAL) && (item == 1)) { block.status.bits.run = 1; status = setup_logger(device, &block, &item); } smg$unpaste_virtual_display(&v1_id, &display->pb_id); } } smg$delete_menu(&v1_id); } smg$delete_virtual_display(&v1_id); } } if (status == SS$_ABORT) { /* ** Abort means user quit out so just ignore this error and go back ** to main menu */ status = SS$_NORMAL; } return(status); } /* **++ ** init_logger_p1 - Get first page of setting ** ** Functional description: ** ** This will allow the user to fill in the first page of data to ** write to the logger. ** ** Calling convention: ** ** int init_logger_p1 (DISPALY_DATA *display, STATUS_BLOCK *block) ** ** Input parameters: ** ** DISPLAY_DATA *display Pointer to display data ** STATUS_BLOCK *block Pointre to status block ** ** Output parameters: ** ** None ** ** Return value: ** ** SS$_NORMAL Worked ** SS$_XXX Failed ** SMG$_XXX Failed ** ** Environment: ** ** User mode ** **-- */ int init_logger_p1(DISPLAY_DATA *display, STATUS_BLOCK *block) { char init_string[17]; char *accept = "ContinueQuit "; char *freq = "10 Sec -> 45 Hrs 1 Min -> 11 Days 5 Min -> 51 Days30 Min -> 11 Months 1 Hr ->1.8 Years 6 Hr -> 2+ Years12 Hr -> 2+ Years"; char *line_1 = "Logger Name :"; char *line_2 = "Units :"; char *line_3 = "Sample Rate :"; char *units = "FahrenheitCelsius "; int col; int i; int item = 0; int menu_1_row = 11; unsigned int menu_1_type = SMG$K_HORIZONTAL; unsigned int menu_2_type = SMG$K_VERTICAL; unsigned int menu_3_type = SMG$K_VERTICAL; int row; #define SAMPLE_OPTIONS 8 unsigned short int sample[SAMPLE_OPTIONS] = {0, 10, 60, 300, 1800, 3600, 21600, 43200}; int status; int v1_attr = SMG$M_BORDER; unsigned int v1_id = 0; int v1_rows = 11; int v1_cols = 35; int v1_p_row = 2; int v1_p_col = 44; unsigned int v2_id = 0; int v2_rows = 2; int v2_cols = 12; int v2_p_row = 4; int v2_p_col = 58; unsigned int v3_id = 0; int v3_rows = 4; int v3_cols = 21; int v3_p_row = 7; int v3_p_col = 58; struct dsc$descriptor_s line; struct dsc$descriptor_s in_line; struct dsc$descriptor_s out_line; struct dsc$descriptor_a menu_1; struct dsc$descriptor_a menu_2; struct dsc$descriptor_a menu_3; line.dsc$b_dtype = DSC$K_DTYPE_T; line.dsc$b_class = DSC$K_CLASS_S; memset(&init_string[0], 32, 16); strcpy(&init_string[0], &block->name[0]); out_line.dsc$a_pointer = &init_string[0]; out_line.dsc$b_dtype = DSC$K_DTYPE_T; out_line.dsc$b_class = DSC$K_CLASS_S; out_line.dsc$w_length = 16; in_line.dsc$a_pointer = &block->name[0]; in_line.dsc$b_dtype = DSC$K_DTYPE_T; in_line.dsc$b_class = DSC$K_CLASS_S; in_line.dsc$w_length = 16; menu_1.dsc$w_length = 8; menu_1.dsc$b_dtype = DSC$K_DTYPE_T; menu_1.dsc$b_class = DSC$K_CLASS_A; menu_1.dsc$a_pointer = accept; menu_1.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_1.dsc$b_dimct = 1; menu_1.dsc$l_arsize = 16; menu_2.dsc$w_length = 10; menu_2.dsc$b_dtype = DSC$K_DTYPE_T; menu_2.dsc$b_class = DSC$K_CLASS_A; menu_2.dsc$a_pointer = units; menu_2.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_2.dsc$b_dimct = 1; menu_2.dsc$l_arsize = 20; menu_3.dsc$w_length = 19; menu_3.dsc$b_dtype = DSC$K_DTYPE_T; menu_3.dsc$b_class = DSC$K_CLASS_A; menu_3.dsc$a_pointer = freq; menu_3.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_3.dsc$b_dimct = 1; menu_3.dsc$l_arsize = 133; status = smg$create_virtual_display(&v1_rows, &v1_cols, &v1_id, &v1_attr); if (status & SS$_NORMAL); { status = smg$create_menu(&v1_id, &menu_1, &menu_1_type, 0, &menu_1_row); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v1_id, &display->pb_id, &v1_p_row, &v1_p_col); if (status & SS$_NORMAL) { row = 1; col = 2; line.dsc$a_pointer = line_1; line.dsc$w_length = strlen(line_1); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 3; col = 8; line.dsc$a_pointer = line_2; line.dsc$w_length = strlen(line_2); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 7; col = 2; line.dsc$a_pointer = line_3; line.dsc$w_length = strlen(line_3); status = smg$put_chars(&v1_id, &line, &row, &col); } } } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v2_rows, &v2_cols, &v2_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v2_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v2_id, &display->pb_id, &v2_p_row, &v2_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v3_rows, &v3_cols, &v3_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v3_id, &menu_3, &menu_3_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v3_id, &display->pb_id, &v3_p_row, &v3_p_col); } } } if (status & SS$_NORMAL) { /* ** Allow change of device name string */ row = 1; col = 16; status = smg$set_cursor_abs(&v1_id, &row, &col); if (status & SS$_NORMAL) { status = smg$read_composed_line(&display->kb_id, 0, &in_line, 0, &item, &v1_id, 0, &out_line); if ((status & SS$_NORMAL) && (item < 16)) { memset(&block->name[item], 0, (16-item)); } } } if (status & SS$_NORMAL) { /* ** Now figure out if F or C */ if (block->units == 0) { item = 2; } else { item = 1; } status = smg$select_from_menu(&display->kb_id, &v2_id, &item, &item); if (status & SS$_NORMAL) { if (item == 1) { block->units = 1; /* F */ } else { block->units = 0; /* C */ } } } if (status & SS$_NORMAL) { /* ** Now get sample rate */ item = 0; for (i = 0; i < SAMPLE_OPTIONS; i++) { if (sample[i] == block->sample_rate) { item = i; break; } } if (item == 0) { item = 1; } status = smg$select_from_menu(&display->kb_id, &v3_id, &item, &item); if (status & SS$_NORMAL) { block->sample_rate = sample[item]; } } if (status & SS$_NORMAL) { item = 1; status = smg$select_from_menu(&display->kb_id, &v1_id, &item, &item); if (status & SS$_NORMAL) { if (item == 2) { status = SS$_ABORT; } } } if (v1_id != 0) { smg$delete_menu(&v1_id); smg$delete_virtual_display(&v1_id); } if (v2_id != 0) { smg$delete_menu(&v2_id); smg$delete_virtual_display(&v2_id); } if (v3_id != 0) { smg$delete_menu(&v3_id); smg$delete_virtual_display(&v3_id); } return(status); } /* **++ ** init_logger_p2 - Get temperature flags and values ** ** Functional description: ** ** This section determine if we should set temperature high and low ** limits what the limits are, and if we should hold them if reached. ** ** Calling convention: ** ** int init_logger_p2 (DISPLAY_DATA *display, STATUS_BLOCK *block) ** ** Input parameters: ** ** None ** ** Output parameters: ** ** None ** ** Return value: ** ** SS$_NORMAL Worked ** SS$_XXX Failed ** SMG$_XXX Failed ** ** Environment: ** ** User mode ** **-- */ int init_logger_p2(DISPLAY_DATA *display, STATUS_BLOCK *block) { #define TEMP_SIZE 5 #define TEMP_RANGE 255 char *accept = "ContinueQuit "; char *line_1 = "High Alarm:"; char *line_2 = "Low Alarm:"; char *line_3 = "Temperature F"; char *line_3a = "Temperature C"; char *line_5 = "High:"; char *line_5a = "Hold:"; char *line_6 = "Low:"; char *line_6a = "Hold:"; char *menu_questions = "enable disable"; char temps[TEMP_SIZE * TEMP_RANGE]; int col; float el_temp; int i = 0; int item; int j; int max_index; int min_index; int menu_1_row = 19; unsigned int menu_1_type = SMG$K_HORIZONTAL; unsigned int menu_2_type = SMG$K_HORIZONTAL; unsigned int menu_3_type = SMG$K_VERTICAL; int row; int selected_item; int status; int v1_attr = SMG$M_BORDER; unsigned int v1_id = 0; int v1_rows = 19; int v1_cols = 41; int v1_p_row = 2; int v1_p_col = 39; unsigned int v2_id = 0; int v2_rows = 1; int v2_cols = 20; int v2_p_row = 3; int v2_p_col = 51; unsigned int v3_id = 0; int v3_rows = 1; int v3_cols = 20; int v3_p_row = 5; int v3_p_col = 51; unsigned int v4_id = 0; int v4_rows = 6; int v4_cols = 5; int v4_p_row = 8; int v4_p_col = 45; unsigned int v5_id = 0; int v5_rows = 1; int v5_cols = 20; int v5_p_row = 11; int v5_p_col = 58; unsigned int v6_id = 0; int v6_rows = 6; int v6_cols = 5; int v6_p_row = 14; int v6_p_col = 45; unsigned int v7_id = 0; int v7_rows = 1; int v7_cols = 20; int v7_p_row = 17; int v7_p_col = 58; struct dsc$descriptor_s line; struct dsc$descriptor_a menu_1; struct dsc$descriptor_a menu_2; struct dsc$descriptor_a menu_3; line.dsc$b_dtype = DSC$K_DTYPE_T; line.dsc$b_class = DSC$K_CLASS_S; menu_1.dsc$w_length = 8; menu_1.dsc$b_dtype = DSC$K_DTYPE_T; menu_1.dsc$b_class = DSC$K_CLASS_A; menu_1.dsc$a_pointer = accept; menu_1.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_1.dsc$b_dimct = 1; menu_1.dsc$l_arsize = 16; menu_2.dsc$w_length = 7; menu_2.dsc$b_dtype = DSC$K_DTYPE_T; menu_2.dsc$b_class = DSC$K_CLASS_A; menu_2.dsc$a_pointer = menu_questions; menu_2.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_2.dsc$b_dimct = 1; menu_2.dsc$l_arsize = 14; menu_3.dsc$w_length = 5; menu_3.dsc$b_dtype = DSC$K_DTYPE_T; menu_3.dsc$b_class = DSC$K_CLASS_A; menu_3.dsc$a_pointer = &temps[0]; menu_3.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_3.dsc$b_dimct = 1; menu_3.dsc$l_arsize = TEMP_SIZE * TEMP_RANGE; /* ** Compute an fill in menu of legal temperatures. */ if (block->units == 1) { max_index = MAX_FAHRENHEIT; min_index = MIN_FAHRENHEIT; j = 0; for (i = MIN_FAHRENHEIT; i <= MAX_FAHRENHEIT; i++) { el_temp = i; sprintf(&temps[j], "%5.1f", (el_temp - 40.0)); j += TEMP_SIZE; } } else { max_index = MAX_CELSIUS; min_index = MIN_CELSIUS; j = 0; for (i = MIN_CELSIUS; i <= MAX_CELSIUS; i++) { el_temp = i; sprintf(&temps[j], "%5.1f", ((el_temp/2) - 40.0)); j += TEMP_SIZE; } } /* ** Build and fill in the main display */ status = smg$create_virtual_display(&v1_rows, &v1_cols, &v1_id, &v1_attr); if (status & SS$_NORMAL); { status = smg$create_menu(&v1_id, &menu_1, &menu_1_type, 0, &menu_1_row); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v1_id, &display->pb_id, &v1_p_row, &v1_p_col); if (status & SS$_NORMAL) { row = 2; col = 2; line.dsc$a_pointer = line_1; line.dsc$w_length = strlen(line_1); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 4; col = 3; line.dsc$a_pointer = line_2; line.dsc$w_length = strlen(line_2); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 6; col = 4; if (block->units == 1) { line.dsc$a_pointer = line_3; line.dsc$w_length = strlen(line_3); } else { line.dsc$a_pointer = line_3a; line.dsc$w_length = strlen(line_3a); } status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 10; col = 2; line.dsc$a_pointer = line_5; line.dsc$w_length = strlen(line_5); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 10; col = 15; line.dsc$a_pointer = line_5a; line.dsc$w_length = strlen(line_5a); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 16; col = 3; line.dsc$a_pointer = line_6; line.dsc$w_length = strlen(line_6); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 16; col = 15; line.dsc$a_pointer = line_6; line.dsc$w_length = strlen(line_6); status = smg$put_chars(&v1_id, &line, &row, &col); } } } } } } } } } /* ** Now create the remaing virtual dispalays and paste them in place. */ if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v2_rows, &v2_cols, &v2_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v2_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v2_id, &display->pb_id, &v2_p_row, &v2_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v3_rows, &v3_cols, &v3_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v3_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v3_id, &display->pb_id, &v3_p_row, &v3_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v4_rows, &v4_cols, &v4_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v4_id, &menu_3, &menu_3_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v4_id, &display->pb_id, &v4_p_row, &v4_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v5_rows, &v5_cols, &v5_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v5_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v5_id, &display->pb_id, &v5_p_row, &v5_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v6_rows, &v6_cols, &v6_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v6_id, &menu_3, &menu_3_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v6_id, &display->pb_id, &v6_p_row, &v6_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v7_rows, &v7_cols, &v7_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v7_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v7_id, &display->pb_id, &v7_p_row, &v7_p_col); } } } /* ** Start picking up data only high and low termperature limits are mandatory ** all the others depend upon the answers to the first two. */ if (status & SS$_NORMAL) { if (block->rh_temp_flags.bits.temp_high) { item = 1; } else { item = 2; } status = smg$select_from_menu(&display->kb_id, &v2_id, &item, &item); if ((status & SS$_NORMAL) &&(item == 1)) { block->rh_temp_flags.bits.temp_high = 1; } else { block->rh_temp_flags.bits.temp_high = 0; } } if (status & SS$_NORMAL) { if (block->rh_temp_flags.bits.temp_low) { item = 1; } else { item = 2; } status = smg$select_from_menu(&display->kb_id, &v3_id, &item, &item); if ((status & SS$_NORMAL) &&(item == 1)) { block->rh_temp_flags.bits.temp_low = 1; } else { block->rh_temp_flags.bits.temp_low = 0; } } if ((status & SS$_NORMAL) && (block->rh_temp_flags.bits.temp_high)) { if (block->units == 1) { item = block->temp_high - MIN_FAHRENHEIT + 1 ; } else { item = block->temp_high - MIN_CELSIUS; } status = smg$select_from_menu(&display->kb_id, &v4_id, &item, &item); if (status & SS$_NORMAL) { if (block->units == 1) { block->temp_high = item + MIN_FAHRENHEIT - 1; } else { block->temp_high = item + MIN_CELSIUS - 1; } } } if ((status & SS$_NORMAL) && (block->rh_temp_flags.bits.temp_high)) { if (block->rh_temp_flags.bits.temp_high_hold) { item = 1; } else { item = 2; } status = smg$select_from_menu(&display->kb_id, &v5_id, &item, &item); if (status & SS$_NORMAL) { if (item == 1) { block->rh_temp_flags.bits.temp_high_hold = 1; } else { block->rh_temp_flags.bits.temp_high_hold = 0; } } } if ((status & SS$_NORMAL) && (block->rh_temp_flags.bits.temp_low)) { if (block->units == 1) { item = block->temp_low - MIN_FAHRENHEIT + 1 ; } else { item = block->temp_low - MIN_CELSIUS; } status = smg$select_from_menu(&display->kb_id, &v6_id, &item, &item); if (status & SS$_NORMAL) { if (block->units == 1) { block->temp_low = item + MIN_FAHRENHEIT - 1; } else { block->temp_low = item + MIN_CELSIUS - 1; } } } if ((status & SS$_NORMAL) && (block->rh_temp_flags.bits.temp_low)) { if (block->rh_temp_flags.bits.temp_low_hold) { item = 1; } else { item = 2; } status = smg$select_from_menu(&display->kb_id, &v7_id, &item, &item); if (status & SS$_NORMAL) { if (item == 1) { block->rh_temp_flags.bits.temp_low_hold = 1; } else { block->rh_temp_flags.bits.temp_low_hold = 0; } } } /* ** See if user wants to quit and get out of here */ if (status & SS$_NORMAL) { item = 1; status = smg$select_from_menu(&display->kb_id, &v1_id, &item, &item); if (status & SS$_NORMAL) { if (item == 2) { status = SS$_ABORT; } } } if (v1_id != 0) { smg$delete_menu(&v1_id); smg$delete_virtual_display(&v1_id); } if (v2_id != 0) { smg$delete_menu(&v2_id); smg$delete_virtual_display(&v2_id); } if (v3_id != 0) { smg$delete_menu(&v3_id); smg$delete_virtual_display(&v3_id); } if (v4_id != 0) { smg$delete_menu(&v4_id); smg$delete_virtual_display(&v4_id); } if (v5_id != 0) { smg$delete_menu(&v5_id); smg$delete_virtual_display(&v5_id); } if (v6_id != 0) { smg$delete_menu(&v6_id); smg$delete_virtual_display(&v6_id); } if (v7_id != 0) { smg$delete_menu(&v7_id); smg$delete_virtual_display(&v7_id); } return(status); } /* **++ ** init_logger_p3 - Get humidity flags and values ** ** Functional description: ** ** This section determine if we should set humidity high and low ** limits what the limits are, and if we should hold them if reached. ** ** Calling convention: ** ** int init_logger_p3 (DISPLAY_DATA *display, STATUS_BLOCK *block) ** ** Input parameters: ** ** None ** ** Output parameters: ** ** None ** ** Return value: ** ** SS$_NORMAL Worked ** SS$_XXX Failed ** SMG$_XXX Failed ** ** Environment: ** ** User mode ** **-- */ int init_logger_p3(DISPLAY_DATA *display, STATUS_BLOCK *block) { #define HUMIDITY_SIZE 5 #define HUMIDITY_RANGE 201 char *accept = "ContinueQuit "; char *line_1 = "High Alarm:"; char *line_2 = "Low Alarm:"; char *line_3 = "HUMIDITY %"; char *line_5 = "High:"; char *line_5a = "Hold:"; char *line_6 = "Low:"; char *line_6a = "Hold:"; char *menu_questions = "enable disable"; char humidity[HUMIDITY_SIZE * HUMIDITY_RANGE]; int col; float el_humidity, t; int i = 0; int item; int j; int max_index; int min_index; int menu_1_row = 19; unsigned int menu_1_type = SMG$K_HORIZONTAL; unsigned int menu_2_type = SMG$K_HORIZONTAL; unsigned int menu_3_type = SMG$K_VERTICAL; int row; int selected_item; int status; int v1_attr = SMG$M_BORDER; unsigned int v1_id = 0; int v1_rows = 19; int v1_cols = 41; int v1_p_row = 2; int v1_p_col = 39; unsigned int v2_id = 0; int v2_rows = 1; int v2_cols = 20; int v2_p_row = 3; int v2_p_col = 51; unsigned int v3_id = 0; int v3_rows = 1; int v3_cols = 20; int v3_p_row = 5; int v3_p_col = 51; unsigned int v4_id = 0; int v4_rows = 6; int v4_cols = 8; int v4_p_row = 8; int v4_p_col = 45; unsigned int v5_id = 0; int v5_rows = 1; int v5_cols = 20; int v5_p_row = 11; int v5_p_col = 58; unsigned int v6_id = 0; int v6_rows = 6; int v6_cols = 8; int v6_p_row = 14; int v6_p_col = 45; unsigned int v7_id = 0; int v7_rows = 1; int v7_cols = 20; int v7_p_row = 17; int v7_p_col = 58; struct dsc$descriptor_s line; struct dsc$descriptor_a menu_1; struct dsc$descriptor_a menu_2; struct dsc$descriptor_a menu_3; line.dsc$b_dtype = DSC$K_DTYPE_T; line.dsc$b_class = DSC$K_CLASS_S; menu_1.dsc$w_length = 8; menu_1.dsc$b_dtype = DSC$K_DTYPE_T; menu_1.dsc$b_class = DSC$K_CLASS_A; menu_1.dsc$a_pointer = accept; menu_1.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_1.dsc$b_dimct = 1; menu_1.dsc$l_arsize = 16; menu_2.dsc$w_length = 7; menu_2.dsc$b_dtype = DSC$K_DTYPE_T; menu_2.dsc$b_class = DSC$K_CLASS_A; menu_2.dsc$a_pointer = menu_questions; menu_2.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_2.dsc$b_dimct = 1; menu_2.dsc$l_arsize = 14; menu_3.dsc$w_length = 5; menu_3.dsc$b_dtype = DSC$K_DTYPE_T; menu_3.dsc$b_class = DSC$K_CLASS_A; menu_3.dsc$a_pointer = &humidity[0]; menu_3.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_3.dsc$b_dimct = 1; menu_3.dsc$l_arsize = HUMIDITY_SIZE * HUMIDITY_RANGE; /* ** Compute an fill in menu of legal humidity values */ j = 0; for (i = 0; i < HUMIDITY_RANGE; i++) { el_humidity = i; t = el_humidity / 2.0; sprintf(&humidity[j], "%5.1f", (el_humidity/2.0)); j += HUMIDITY_SIZE; } /* ** Build and fill in the main display */ status = smg$create_virtual_display(&v1_rows, &v1_cols, &v1_id, &v1_attr); if (status & SS$_NORMAL); { status = smg$create_menu(&v1_id, &menu_1, &menu_1_type, 0, &menu_1_row); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v1_id, &display->pb_id, &v1_p_row, &v1_p_col); if (status & SS$_NORMAL) { row = 2; col = 2; line.dsc$a_pointer = line_1; line.dsc$w_length = strlen(line_1); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 4; col = 3; line.dsc$a_pointer = line_2; line.dsc$w_length = strlen(line_2); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 6; col = 6; line.dsc$a_pointer = line_3; line.dsc$w_length = strlen(line_3); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 10; col = 2; line.dsc$a_pointer = line_5; line.dsc$w_length = strlen(line_5); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 10; col = 15; line.dsc$a_pointer = line_5a; line.dsc$w_length = strlen(line_5a); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 16; col = 3; line.dsc$a_pointer = line_6; line.dsc$w_length = strlen(line_6); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 16; col = 15; line.dsc$a_pointer = line_6; line.dsc$w_length = strlen(line_6); status = smg$put_chars(&v1_id, &line, &row, &col); } } } } } } } } } /* ** Now create the remaing virtual dispalays and paste them in place. */ if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v2_rows, &v2_cols, &v2_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v2_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v2_id, &display->pb_id, &v2_p_row, &v2_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v3_rows, &v3_cols, &v3_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v3_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v3_id, &display->pb_id, &v3_p_row, &v3_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v4_rows, &v4_cols, &v4_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v4_id, &menu_3, &menu_3_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v4_id, &display->pb_id, &v4_p_row, &v4_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v5_rows, &v5_cols, &v5_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v5_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v5_id, &display->pb_id, &v5_p_row, &v5_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v6_rows, &v6_cols, &v6_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v6_id, &menu_3, &menu_3_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v6_id, &display->pb_id, &v6_p_row, &v6_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v7_rows, &v7_cols, &v7_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v7_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v7_id, &display->pb_id, &v7_p_row, &v7_p_col); } } } /* ** Start picking up data only high and low termperature limits are mandatory ** all the others depend upon the answers to the first two. */ if (status & SS$_NORMAL) { if (block->rh_temp_flags.bits.rh_high) { item = 1; } else { item = 2; } status = smg$select_from_menu(&display->kb_id, &v2_id, &item, &item); if ((status & SS$_NORMAL) &&(item == 1)) { block->rh_temp_flags.bits.rh_high = 1; } else { block->rh_temp_flags.bits.rh_high = 0; } } if (status & SS$_NORMAL) { if (block->rh_temp_flags.bits.rh_low) { item = 1; } else { item = 2; } status = smg$select_from_menu(&display->kb_id, &v3_id, &item, &item); if ((status & SS$_NORMAL) && (item == 1)) { block->rh_temp_flags.bits.rh_low = 1; } else { block->rh_temp_flags.bits.rh_low = 0; } } if ((status & SS$_NORMAL) && (block->rh_temp_flags.bits.rh_high)) { item = block->rh_high + 1; status = smg$select_from_menu(&display->kb_id, &v4_id, &item, &item); if (status & SS$_NORMAL) { block->rh_high = item - 1; } } if ((status & SS$_NORMAL) && (block->rh_temp_flags.bits.rh_high)) { if (block->rh_temp_flags.bits.rh_high_hold) { item = 1; } else { item = 2; } status = smg$select_from_menu(&display->kb_id, &v5_id, &item, &item); if (status & SS$_NORMAL) { if (item == 1) { block->rh_temp_flags.bits.rh_high_hold = 1; } else { block->rh_temp_flags.bits.rh_high_hold = 0; } } } if ((status & SS$_NORMAL) && (block->rh_temp_flags.bits.rh_low)) { item = block->rh_low + 1; status = smg$select_from_menu(&display->kb_id, &v6_id, &item, &item); if (status & SS$_NORMAL) { block->rh_low = item - 1; } } if ((status & SS$_NORMAL) && (block->rh_temp_flags.bits.rh_low)) { if (block->rh_temp_flags.bits.rh_low_hold) { item = 1; } else { item = 2; } status = smg$select_from_menu(&display->kb_id, &v7_id, &item, &item); if (status & SS$_NORMAL) { if (item == 1) { block->rh_temp_flags.bits.rh_low_hold = 1; } else { block->rh_temp_flags.bits.rh_low_hold = 0; } } } /* ** See if user wants to quit and get out of here */ if (status & SS$_NORMAL) { item = 1; status = smg$select_from_menu(&display->kb_id, &v1_id, &item, &item); if (status & SS$_NORMAL) { if (item == 2) { status = SS$_ABORT; } } } if (v1_id != 0) { smg$delete_menu(&v1_id); smg$delete_virtual_display(&v1_id); } if (v2_id != 0) { smg$delete_menu(&v2_id); smg$delete_virtual_display(&v2_id); } if (v3_id != 0) { smg$delete_menu(&v3_id); smg$delete_virtual_display(&v3_id); } if (v4_id != 0) { smg$delete_menu(&v4_id); smg$delete_virtual_display(&v4_id); } if (v5_id != 0) { smg$delete_menu(&v5_id); smg$delete_virtual_display(&v5_id); } if (v6_id != 0) { smg$delete_menu(&v6_id); smg$delete_virtual_display(&v6_id); } if (v7_id != 0) { smg$delete_menu(&v7_id); smg$delete_virtual_display(&v7_id); } return(status); } /* **++ ** init_logger_p4 - Get time to start logger ** ** Functional description: ** ** This section lets user specify a time in the future to start the ** logger. ** ** Calling convention: ** ** int init_logger_p4 (DISPLAY_DATA *display, STATUS_BLOCK *block) ** ** Input parameters: ** ** None ** ** Output parameters: ** ** None ** ** Return value: ** ** SS$_NORMAL Worked ** SS$_XXX Failed ** SMG$_XXX Failed ** ** Environment: ** ** User mode ** **-- */ int init_logger_p4(DISPLAY_DATA *display, STATUS_BLOCK *block) { char *accept = "ContinueQuit "; char *line_1 = "Set delayed Start Time : "; char *line_2 = "Days : "; char *line_3 = "Hours : "; char *line_4 = "Minutes : "; char *line_5 = "Seconds : "; char *line_6 = "Logging will start at : "; char *menu_1_q = "yesno "; char *days = " 0 1 2 3 4 5 6 7 8 9101112131415"; char *hours = " 0 1 2 3 4 5 6 7 8 91011121314151617181920212223"; char *min_sec = " 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859"; char out_line[80]; int col; int delay = 0; int item; int menu_1_row = 14; unsigned int menu_1_type = SMG$K_HORIZONTAL; unsigned int menu_2_type = SMG$K_HORIZONTAL; unsigned int menu_3_type = SMG$K_VERTICAL; unsigned int menu_4_type = SMG$K_VERTICAL; unsigned int menu_5_type = SMG$K_VERTICAL; int row; int selected_item; int status; int v1_attr = SMG$M_BORDER; unsigned int v1_id = 0; int v1_rows = 14; int v1_cols = 47; int v1_p_row = 2; int v1_p_col = 32; unsigned int v2_id = 0; int v2_rows = 1; int v2_cols = 12; int v2_p_row = 3; int v2_p_col = 58; unsigned int v3_id = 0; int v3_rows = 3; int v3_cols = 4; int v3_p_row = 5; int v3_p_col = 42; unsigned int v4_id = 0; int v4_rows = 3; int v4_cols = 4; int v4_p_row = 5; int v4_p_col = 60; unsigned int v5_id = 0; int v5_rows = 3; int v5_cols = 4; int v5_p_row = 9; int v5_p_col = 42; unsigned int v6_id = 0; int v6_rows = 3; int v6_cols = 4; int v6_p_row = 9; int v6_p_col = 60; struct dsc$descriptor_s line; struct dsc$descriptor_a menu_1; /* Continue Quit */ struct dsc$descriptor_a menu_2; /* Yes No */ struct dsc$descriptor_a menu_3; /* Days */ struct dsc$descriptor_a menu_4; /* Hours */ struct dsc$descriptor_a menu_5; /* Minutes and Seconds */ struct tm *start_time; time_t bin_time; line.dsc$b_dtype = DSC$K_DTYPE_T; line.dsc$b_class = DSC$K_CLASS_S; menu_1.dsc$w_length = 8; menu_1.dsc$b_dtype = DSC$K_DTYPE_T; menu_1.dsc$b_class = DSC$K_CLASS_A; menu_1.dsc$a_pointer = accept; menu_1.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_1.dsc$b_dimct = 1; menu_1.dsc$l_arsize = 16; menu_2.dsc$w_length = 3; menu_2.dsc$b_dtype = DSC$K_DTYPE_T; menu_2.dsc$b_class = DSC$K_CLASS_A; menu_2.dsc$a_pointer = menu_1_q; menu_2.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_2.dsc$b_dimct = 1; menu_2.dsc$l_arsize = strlen(menu_1_q); menu_3.dsc$w_length = 2; menu_3.dsc$b_dtype = DSC$K_DTYPE_T; menu_3.dsc$b_class = DSC$K_CLASS_A; menu_3.dsc$a_pointer = days; menu_3.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_3.dsc$b_dimct = 1; menu_3.dsc$l_arsize = strlen(days); menu_4.dsc$w_length = 2; menu_4.dsc$b_dtype = DSC$K_DTYPE_T; menu_4.dsc$b_class = DSC$K_CLASS_A; menu_4.dsc$a_pointer = hours; menu_4.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_4.dsc$b_dimct = 1; menu_4.dsc$l_arsize = strlen(hours); menu_5.dsc$w_length = 2; menu_5.dsc$b_dtype = DSC$K_DTYPE_T; menu_5.dsc$b_class = DSC$K_CLASS_A; menu_5.dsc$a_pointer = min_sec; menu_5.dsc$b_aflags.dsc$v_fl_bounds = 0; menu_5.dsc$b_dimct = 1; menu_5.dsc$l_arsize = strlen(min_sec); /* ** Build and fill in the main display */ status = smg$create_virtual_display(&v1_rows, &v1_cols, &v1_id, &v1_attr); if (status & SS$_NORMAL); { status = smg$create_menu(&v1_id, &menu_1, &menu_1_type, 0, &menu_1_row); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v1_id, &display->pb_id, &v1_p_row, &v1_p_col); if (status & SS$_NORMAL) { row = 2; col = 3; line.dsc$a_pointer = line_1; line.dsc$w_length = strlen(line_1); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 5; col = 5; line.dsc$a_pointer = line_2; line.dsc$w_length = strlen(line_2); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 5; col = 21; line.dsc$a_pointer = line_3; line.dsc$w_length = strlen(line_3); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 9; col = 2; line.dsc$a_pointer = line_4; line.dsc$w_length = strlen(line_4); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 9; col = 19; line.dsc$a_pointer = line_5; line.dsc$w_length = strlen(line_5); status = smg$put_chars(&v1_id, &line, &row, &col); if (status & SS$_NORMAL) { row = 12; col = 1; line.dsc$a_pointer = line_6; line.dsc$w_length = strlen(line_6); status = smg$put_chars(&v1_id, &line, &row, &col); } } } } } } } } /* ** Now create the remaing virtual dispalays and paste them in place. */ if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v2_rows, &v2_cols, &v2_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v2_id, &menu_2, &menu_2_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v2_id, &display->pb_id, &v2_p_row, &v2_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v3_rows, &v3_cols, &v3_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v3_id, &menu_3, &menu_3_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v3_id, &display->pb_id, &v3_p_row, &v3_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v4_rows, &v4_cols, &v4_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v4_id, &menu_4, &menu_4_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v4_id, &display->pb_id, &v4_p_row, &v4_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v5_rows, &v5_cols, &v5_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v5_id, &menu_5, &menu_5_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v5_id, &display->pb_id, &v5_p_row, &v5_p_col); } } } if (status & SS$_NORMAL) { status = smg$create_virtual_display(&v6_rows, &v6_cols, &v6_id); if (status & SS$_NORMAL); { status = smg$create_menu(&v6_id, &menu_5, &menu_5_type); if (status & SS$_NORMAL) { status = smg$paste_virtual_display(&v6_id, &display->pb_id, &v6_p_row, &v6_p_col); } } } if (status & SS$_NORMAL) { item = 2; status = smg$select_from_menu(&display->kb_id, &v2_id, &item, &item); if ((status & SS$_NORMAL) &&(item == 1)) { item = 1; status = smg$select_from_menu(&display->kb_id, &v3_id, &item, &item); if (status & SS$_NORMAL) { delay += (item - 1) * 24 * 60 * 60; item = 1; status = smg$select_from_menu(&display->kb_id, &v4_id, &item, &item); if (status & SS$_NORMAL) { delay += (item - 1) * 60 * 60; item = 1; status = smg$select_from_menu(&display->kb_id, &v5_id, &item, &item); if (status & SS$_NORMAL) { delay += (item - 1) * 60; item = 1; status = smg$select_from_menu(&display->kb_id, &v6_id, &item, &item); if (status & SS$_NORMAL) { delay += (item - 1); } } } } } /* ** Now figure out the time to start the logger */ time(&bin_time); bin_time += delay; start_time = localtime(&bin_time); block->hour = (unsigned char) start_time->tm_hour; block->min = (unsigned char) start_time->tm_min; block->second = (unsigned char) start_time->tm_sec; block->month = (unsigned char) start_time->tm_mon + 1; block->day = (unsigned char) start_time->tm_mday; block->year = (unsigned char) start_time->tm_year - 100; block->start_delay = delay; line.dsc$a_pointer = &out_line[0]; line.dsc$w_length = sprintf(&out_line[0], "%02d/%02d/%02d %02d:%02d:%02d", block->month, block->day, block->year, block->hour, block->min, block->second); row = 12; col = 25; status = smg$put_chars(&v1_id, &line, &row, &col); } /* ** See if user wants to quit and get out of here */ if (status & SS$_NORMAL) { item = 1; status = smg$select_from_menu(&display->kb_id, &v1_id, &item, &item); if (status & SS$_NORMAL) { if (item == 2) { status = SS$_ABORT; } } } if (v1_id != 0) { smg$delete_menu(&v1_id); smg$delete_virtual_display(&v1_id); } if (v2_id != 0) { smg$delete_menu(&v2_id); smg$delete_virtual_display(&v2_id); } if (v3_id != 0) { smg$delete_menu(&v3_id); smg$delete_virtual_display(&v3_id); } if (v4_id != 0) { smg$delete_menu(&v4_id); smg$delete_virtual_display(&v4_id); } if (v5_id != 0) { smg$delete_menu(&v5_id); smg$delete_virtual_display(&v5_id); } if (v6_id != 0) { smg$delete_menu(&v6_id); smg$delete_virtual_display(&v6_id); } return(status); }