/****************************************************************************** * * Title : commandStatusUir.c * Version 0.0 * * Description: Callback functions for the command status window. * Related files: commandStatusUir.uir * * Author: Lukas Tomasek, tomasekl@fzu.cz * ******************************************************************************/ /****************************************************************************** * Header files * ******************************************************************************/ #include #include #include "commandStatusUir.h" #include "uirUtility.h" #include "globalDefinitions.h" #include "hostUtility.h" #include "commandListEditUir.h" /****************************************************************************** * LW_CVI callback functions * ******************************************************************************/ /*============================================================================= * commandStatusMenu() *============================================================================= * * * */ void CVICALLBACK commandStatusMenu (int menuBar, int menuItem, void *callbackData, int panel){ int status; UINT8 hostIndex; char string[300]; char commandLineString[MAX_PATHNAME_LEN]=EXTERNAL_EDITOR; char fileName[MAX_PATHNAME_LEN]; struct HOST *host; switch(menuItem){ case CSTAT_MENU_CLEAR_STATUS_WINDOW: status=ResetTextBox (panel, CLISTP_STATUS_BOX, ""); UIR_STATUS_CHECK(status, ResetTextBox()); break; case CSTAT_MENU_OPEN_STATUS_FILE: GET_CTRL_VAL(&status, panel, CLISTP_HOST_INDEX, &hostIndex); host=global.host[hostIndex]; strcpy(fileName, host->dataDir); strcat(fileName, COMMAND_STATUS_FILE_NAME); sprintf(string,"%d.TXT", host->slotNumber); strcat(fileName, string); strcat(commandLineString," "); status=LaunchExecutable (strcat(commandLineString, fileName)); if(status!=0){ programError(__FILE__, __LINE__, PROGRAM_ERROR, "LaunchExecutable()", status, ""); } break; case CSTAT_MENU_CMD_LIST_EDITOR: status=DisplayPanel(global.panel.commandListEdit); UIR_STATUS_CHECK(status, DisplayPanel()); break; case CSTAT_MENU_CLOSE_WINDOW: status=HidePanel(panel); UIR_STATUS_CHECK(status, HidePanel()); break; default: ; } } /*============================================================================= * commandButtons() *============================================================================= * * * */ int CVICALLBACK commandButtons(int panel, int control, int event, void *callbackData, int eventData1, int eventData2){ unsigned char hostIndex; ERROR_ID errorId; int status; struct HOST *host; char file[PATHNAME_LENGTH]; char text[300]; unsigned int fileSize; struct COMMAND_LIST *commandList; int option; GET_CTRL_VAL(&status, panel, CLISTP_HOST_INDEX, &hostIndex); host=global.host[hostIndex]; switch(event){ case EVENT_COMMIT: switch(control){ case CLISTP_RESET_REP_LIST_NUM: host->option.commandListRepetitions=0; SET_CTRL_VAL(&status, host->panel.commandListStatus, CLISTP_NUM_OF_LIST_REP, host->option.commandListRepetitions); break; case CLISTP_RESET_CMDREP: host->option.commandRepetitions=0; SET_CTRL_VAL(&status, host->panel.commandListStatus, CLISTP_CMDREP, host->option.commandRepetitions); break; case CLISTP_SEND_LIST: GET_CTRL_VAL(&status, panel, CLISTP_LIST_FILE, file); if(file[0]==0) { status = MessagePopup ("WARNING", "No list selected!"); UIR_STATUS_CHECK(status, MessagePopup()); break; } if((host->controlThreadBusy)||(host->controlThreadState!=CONTROL_IDLE)){ sprintf(text, "Cannot load PrimList to fifo(slot#%d) - ControlThread is busy!!", host->slotNumber); status = MessagePopup ("WARNING", text); UIR_STATUS_CHECK(status, MessagePopup()); break; } errorId=getFileSize(file, &fileSize); ERROR_CHECK(errorId, getFileSize()); if(errorId!=SUCCESS) return(errorId); commandList=calloc(sizeof(struct COMMAND_LIST), sizeof(UINT8)); if(commandList==NULL){ ERROR_CHECK(PROGRAM_ERROR, calloc()); return(0); } errorId=readFromBinFile(file, commandList, fileSize); ERROR_CHECK(errorId, readFromBinFile()); if(errorId!=SUCCESS){ free(commandList); return(0); } strcpy(host->cListFile, file); errorId=runCommandList(host, commandList); ERROR_CHECK(errorId, runTestList()); free(commandList); break; case CLISTP_EDIT_CLIST: /* open command list in CommandListEdit Window */ GET_CTRL_VAL(&status, panel, CLISTP_LIST_FILE, file); if(file[0]==0) break; (void) clistEditButtons(global.panel.commandListEdit, CLIST_EDIT_CLEAR_LIST, EVENT_COMMIT, 0, 1, 0); (void) clistEditButtons(global.panel.commandListEdit, CLIST_EDIT_INSERT_LIST, EVENT_COMMIT, file, 1, 0); SetActivePanel(global.panel.commandListEdit); break; default: break; } break; case EVENT_VAL_CHANGED: switch(control){ case CLISTP_NUM_OF_LIST_REP: GET_CTRL_VAL(&status, panel, control, &host->option.commandListRepetitions); break; default: break; } case EVENT_LEFT_CLICK: switch(control){ case CLISTP_LIST_FILE: status = FileSelectPopup (global.testingDataDir, "*.clist", "*.clist", "",VAL_SELECT_BUTTON, 0, 1, 1, 1, file); if(status==VAL_NO_FILE_SELECTED){ file[0]=0; break; } SET_CTRL_VAL(&status, panel, control, file); break; default: break; } break; } return 0; } /******************************************************************************/