/* ************************************************************** */ /* * Module AMBIENTPARAM * This module contains functions to assist in parameter handling * for the AMBIENT module. * * Zachary Wolf * 3/25/02 */ /* ************************************************************** */ /* INCLUDES */ #include #include #include "ambient.h" /* ************************************************************** */ /* PRIVATE FUNCTIONS */ void ambientparam_error(char* message); /* ************************************************************** */ /* PUBLIC FUNCTIONS */ /* ************************************************************** */ /* * ambientparam_fill_param_struct * This function fills the parameter structure using # defined * parameters. * * Zachary Wolf * 3/25/02 */ void ambientparam_fill_param_struct(struct ambient_param_struct* ambient_param) { /* Declare variables */ int i; /* Include parameter definitions */ #include "param.h" /* Set the AMBIENT parameters */ ambient_param->board_addr = AMBIENT_BOARD_ADDR; ambient_param->hp3457_addr = AMBIENT_HP3457_ADDR; ambient_param->k7011_addr = AMBIENT_K7011_ADDR; ambient_param->meas_system = AMBIENT_MEAS_SYSTEM; ambient_param->k7011_card_num = AMBIENT_K7011_CARD_NUM; ambient_param->k7011_hp3457_chan = AMBIENT_K7011_HP3457_CHAN; ambient_param->show_ui = AMBIENT_SHOW_UI; if (AMBIENT_NUM_SENSORS <= AMBIENT_MAX_NUM_SENSORS) { ambient_param->num_sensors = AMBIENT_NUM_SENSORS; } else { printf("\nError: Too many ambient sensors requested!\n"); printf("No measurements will be made.\n"); ambient_param->num_sensors = 0; } for (i = 0; i < ambient_param->num_sensors; i++) { if (strcmp(AMBIENT_SENSOR_TYPE[i], "AMBIENT_HPTHERM_T") == 0) ambient_param->sensor[i].sensor_type = AMBIENT_HPTHERM_T; else if (strcmp(AMBIENT_SENSOR_TYPE[i], "AMBIENT_YSI44036_T") == 0) ambient_param->sensor[i].sensor_type = AMBIENT_YSI44036_T; else if (strcmp(AMBIENT_SENSOR_TYPE[i], "AMBIENT_OMHX93AV_T") == 0) ambient_param->sensor[i].sensor_type = AMBIENT_OMHX93AV_T; else if (strcmp(AMBIENT_SENSOR_TYPE[i], "AMBIENT_OMHX93AV_RH") == 0) ambient_param->sensor[i].sensor_type = AMBIENT_OMHX93AV_RH; else if (strcmp(AMBIENT_SENSOR_TYPE[i], "AMBIENT_OMEWSBPA_P") == 0) ambient_param->sensor[i].sensor_type = AMBIENT_OMEWSBPA_P; else ambientparam_error("Unknown sensor type. Can not proceed."); ambient_param->sensor[i].chan_num = AMBIENT_SENSOR_CHAN_NUM[i]; strcpy(ambient_param->sensor[i].name, AMBIENT_SENSOR_NAME[i]); } /* Done */ return; } /* ************************************************************** */ /* * ambientparam_error * This function handles error messages for the module. * * Input: * message, string to display in standard I/O * * Zachary Wolf * 3/22/02 */ void ambientparam_error(char* message) { /* Declare variables */ char buf[80]; /* Notify the operator of the error */ printf("\nAMBIENT ERROR: %s\n", message); Beep(); Delay(.5); Beep(); /* Terminate the program if the operator desires */ printf("Press ENTER to terminate program.\n"); fgets(buf, 80, stdin); exit(0); }