// //信息类型 // const void InfoSel (char Type,CHAR thpage) { char index = 0; int16_t addrow = 0; Info = INFO_LIST_Reset(); rowindex = 0; if(pInfoTail) do { if (Type == 0) //所有信息 { if(rowindex >= (thispage-1)*8 && rowindex < ((thispage-1)*8+8)) { if (rowindex == (thispage-1)*8) LISTVIEW_DeleteAllRows(hListview); Infoinit(Info,addrow); addrow++; } rowindex++; } else if (Type == 1) //重要信息 { if(Info->type == INFO_Type_VIP) { if(rowindex >= (thispage-1)*8 && rowindex < ((thispage-1)*8+8)) { if (rowindex == (thispage-1)*8) LISTVIEW_DeleteAllRows(hListview); Infoinit(Info,addrow); addrow++; } rowindex++; } } else if (Type == 2) //新信息 { if (Info->state == INFO_STT_New) { if(rowindex >= (thispage-1)*8 && rowindex < ((thispage-1)*8+8)) { if (rowindex == (thispage-1)*8) LISTVIEW_DeleteAllRows(hListview); Infoinit(Info,addrow); addrow++; } rowindex++; } } else if (Type == 3) //搜救信息 { if (Info->type == INFO_Type_Rscue) { if(rowindex >= (thispage-1)*8 && rowindex < ((thispage-1)*8+8)) { if (rowindex == (thispage-1)*8) LISTVIEW_DeleteAllRows(hListview); Infoinit(Info,addrow); addrow++; } rowindex++; } } }while(Info = INFO_LIST_hasPrev()); }
// // Buttoncallback; // void mybutton (WM_MESSAGE *pMsg) { WM_HWIN hWin; WM_KEY_INFO *pInfo; int column,row,row_index,del_row; int i; hWin = pMsg->hWin; switch (pMsg->MsgId) { case USER_MSG_LANGUAGE: //更改语言 pLanguage = &Lgumainwin[Language]; if (Language == 0) { BUTTON_SetFont(hButton,&GUI_Font30); TEXT_SetFont(mainwinText[5],&GUI_Font30); HEADER_SetFont(hListhead,&GUI_Font24); } else { BUTTON_SetFont(hButton,&GUI_Font20_1); TEXT_SetFont(mainwinText[5],&GUI_Font24_1); HEADER_SetFont(hListhead,&GUI_Font16_1); LISTVIEW_SetHeaderHeight(hListview,29); } DisPage(); BUTTON_SetText(hButton,pLanguage->ButtonInfo[0]); for(i = 0; i<7; i++) HEADER_SetItemText(hListhead,i,pLanguage->ListHead[i]); break; case WM_SET_FOCUS: if (pMsg->Data.v) { BUTTON_SetBkColor(hButton,BUTTON_CI_UNPRESSED,GUI_GRAY); BUTTON_SetTextColor(hButton,BUTTON_CI_UNPRESSED,GUI_WHITE); BUTTON_SetFocusColor(hButton,GUI_GRAY); } else { BUTTON_SetBkColor(hButton,BUTTON_CI_UNPRESSED,GUI_WHITE);//BUTTON_SetTextColor (hButton,BUTTON_CI_UNPRESSED,GUI_BLACK); BUTTON_SetTextColor(hButton,BUTTON_CI_UNPRESSED,GUI_BLACK); BUTTON_SetFocusColor(hButton,GUI_WHITE); } BUTTON_Callback(pMsg); break; case WM_KEY: pInfo = (WM_KEY_INFO*)pMsg->Data.p; switch (pInfo->Key) { case GUI_KEY_ENTER: break; case GUI_KEY_PRINT: WM_BringToTop(PrintWin); WM_SetFocus(WM_GetDialogItem(PrintWin,ID_PrintMenu)); break; case GUI_KEY_MENU: WM_BringToTop(Menuwin); WM_SetFocus (WM_GetDialogItem(Menuwin,ID_MENU)); MENU_SetSel (WM_GetDialogItem(Menuwin,ID_MENU),0); MenuSel = 0; break; case GUI_KEY_LOC1: pCannel = " 490 横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_LOC2: pCannel = "4209.5横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_CHS: pCannel = " 486 横"; WM_InvalidateWindow(WM_GetDialogItem(mainwin,ID_TEXT_1)); break; case GUI_KEY_UP: break; case GUI_KEY_DOWN: if (LISTVIEW_GetNumRows(hListview)) { thispage = 1; WM_SetFocus(hListview); LISTVIEW_SetSel(hListview,0); DisPage(); //WM_InvalidateRect(mainwin,&PageRect); //刷新页数提示 } break; case GUI_KEY_LEFT: if(InfoType > 0) InfoType--; else InfoType = 3; switch (InfoType) { case 0: BUTTON_SetText(hWin,pLanguage->ButtonInfo[0]); LISTVIEW_DeleteAllRows(hListview); InfoSel(0,1); break; case 1: BUTTON_SetText(hWin,pLanguage->ButtonInfo[1]); LISTVIEW_DeleteAllRows(hListview); InfoSel(1,1); break; case 2: BUTTON_SetText(hWin,pLanguage->ButtonInfo[2]); LISTVIEW_DeleteAllRows(hListview); InfoSel(2,1); break; case 3: BUTTON_SetText(hWin,pLanguage->ButtonInfo[3]); LISTVIEW_DeleteAllRows(hListview); InfoSel(3,1); break; } if (rowindex<8) { pageNum = 1; } else if (rowindex%8 == 0) pageNum = rowindex/8; else pageNum = rowindex/8+1; thispage = 1; DisPage(); //WM_InvalidateRect(mainwin,&PageRect);//刷新页数提示 break; case GUI_KEY_RIGHT: InfoType++; if(InfoType == 4) InfoType = 0; switch (InfoType) { case 0: BUTTON_SetText(hWin,pLanguage->ButtonInfo[0]); LISTVIEW_DeleteAllRows(hListview); InfoSel(0,1); break; case 1: BUTTON_SetText(hWin,pLanguage->ButtonInfo[1]); LISTVIEW_DeleteAllRows(hListview); InfoSel(1,1); break; case 2: BUTTON_SetText(hWin,pLanguage->ButtonInfo[2]); LISTVIEW_DeleteAllRows(hListview); InfoSel(2,1); break; case 3: BUTTON_SetText(hWin,pLanguage->ButtonInfo[3]); LISTVIEW_DeleteAllRows(hListview); InfoSel(3,1); break; } if (rowindex<8) pageNum = 1; else if (rowindex%8 == 0) pageNum = rowindex/8; else pageNum = rowindex/8+1; thispage = 1; DisPage(); //WM_InvalidateRect(mainwin,&PageRect);//刷新页数提示 break; } break; default : BUTTON_Callback(pMsg); break; } }
/********************************************************************* * * _cbDialog */ static void _cbDialog(WM_MESSAGE * pMsg) { WM_HWIN hItem; int NCode; int Id; // USER START (Optionally insert additional variables) int i; int j; int k; int slave_column; char buffer[10]; new_GUI_value.BUTTON_value.send_button= FALSE; // USER END switch (pMsg->MsgId) { case WM_INIT_DIALOG: // // Initialization of 'id_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0); TEXT_SetText(hItem, "slave id:"); // // Initialization of 'function_radio' // hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0); RADIO_SetText(hItem, "read holding registers", 0); RADIO_SetText(hItem, "write single register", 1); RADIO_SetText(hItem, "read single coil", 2); RADIO_SetText(hItem, "write single coil", 3); RADIO_SetText(hItem, "read multiple coils", 4); // // Initialization of 'multiple_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1); TEXT_SetText(hItem, "MULTIPLE REGISTER REQUEST"); // // Initialization of 'from_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2); TEXT_SetText(hItem, "from:"); // // Initialization of 'to_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3); TEXT_SetText(hItem, "to:"); // // Initialization of 'single_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4); TEXT_SetText(hItem, "SINGLE REGISTER REQUEST"); // // Initialization of 'number_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5); TEXT_SetText(hItem, "number:"); // // Initialization of 'send_button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0); BUTTON_SetText(hItem, "SEND"); // // Initialization of 'response_view' // hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); LISTVIEW_AddColumn(hItem, 60, "address", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_AddColumn(hItem, 80, "slave 1", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_AddColumn(hItem, 80, "slave 2", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetGridVis(hItem, 1); LISTVIEW_AddColumn(hItem, 30, "Col", GUI_TA_LEFT | GUI_TA_VCENTER); LISTVIEW_SetAutoScrollV(hItem, 1); // // Initialization of 'status_view' // hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); LISTVIEW_AddColumn(hItem, 129, "status", GUI_TA_HCENTER | GUI_TA_VCENTER); LISTVIEW_SetGridVis(hItem, 1); LISTVIEW_SetItemText(hItem, 0, 0, "0"); LISTVIEW_SetItemText(hItem, 0, 0, "0"); LISTVIEW_SetRowHeight(hItem, 20); LISTVIEW_SetHeaderHeight(hItem, 20); // // Initialization of 'exit_button' // hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1); BUTTON_SetText(hItem, " X"); // // Initialization of 'write_req_text' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6); TEXT_SetText(hItem, "WRITE REGISTER REQUEST"); // // Initialization of 'value_txt' // hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7); TEXT_SetText(hItem, "value:"); // USER START (Optionally insert additional code for further widget initialization) //aggiungo casella Status hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); LISTVIEW_AddRow(hItem, NULL); LISTVIEW_SetItemText(hItem, 0, 0, "Ready"); //aggiungo caselle di risposta hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); for (i = 0; i < 60; i++) LISTVIEW_AddRow(hItem, NULL); // USER END break; case WM_NOTIFY_PARENT: Id = WM_GetId(pMsg->hWinSrc); NCode = pMsg->Data.v; switch(Id) { case ID_RADIO_0: // Notifications sent by 'function_radio' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_RADIO_0); new_GUI_value.RADIO_value.radio_selection = RADIO_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_0: // Notifications sent by 'send_button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(600, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) modbus_task(); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); if (modbus_rx.error != 0) { GUI_Delay(100); modbus_task(); } hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); if (modbus_rx.error != 0) { LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_RED); GUI_Delay(100); LISTVIEW_SetItemText(hItem, 0, 0, "No Response"); PlayAudio(50, 60); PlayAudio(0, 20); PlayAudio(50, 100); } else if (modbus_rx.func & 0x80) { LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_YELLOW); GUI_Delay(100); LISTVIEW_SetItemText(hItem, 0, 0, "R: Wrong Message"); PlayAudio(90, 60); PlayAudio(90, 20); PlayAudio(90, 100); } else { //cancello vecchi valori hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); LISTVIEW_DeleteAllRows(hItem); GUI_Delay(100); for (i = 0; i < 60; i++) LISTVIEW_AddRow(hItem, NULL); GUI_Delay(100); hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_1); LISTVIEW_SetItemBkColor(hItem, 0,0,0, GUI_GREEN); GUI_Delay(100); LISTVIEW_SetItemText(hItem, 0, 0, "R: Message Accepted"); PlayAudio(600, 20); PlayAudio(600, 20); PlayAudio(200, 20); //se ho fatto una richiesta read if(new_GUI_value.RADIO_value.radio_selection == 0 || new_GUI_value.RADIO_value.radio_selection == 2 || new_GUI_value.RADIO_value.radio_selection == 4) { if(new_GUI_value.SPINBOX_value.slave_id == 1) slave_column = 1; else slave_column = 2; //scrivo sul listview 0 hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0); //mi prendo la sezione dati effettivi //ho chiesto gli holding? if(new_GUI_value.RADIO_value.radio_selection == 0){ for(i = 0; i < modbus_rx.len; i++) { //se leggo holdings sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.multiple_register_from + i +2000); LISTVIEW_SetItemText(hItem, 0, i, buffer); sprintf(buffer, "%d", modbus_rx.data_converted[i]); LISTVIEW_SetItemText(hItem, slave_column, i, buffer); } } //ho chiesto i coils? else if(new_GUI_value.RADIO_value.radio_selection == 4 ){ for(i = 0; i < modbus_rx.len; i++) { sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.multiple_register_from + i ); LISTVIEW_SetItemText(hItem, 0, i, buffer); if(modbus_rx.data_converted[i] != 0) sprintf(buffer, "%s", "ON"); else sprintf(buffer, "%s", "OFF"); LISTVIEW_SetItemText(hItem, slave_column, i, buffer); } } //ho chiesto 1 coil? else if(new_GUI_value.RADIO_value.radio_selection == 2){ sprintf(buffer, "%d", new_GUI_value.SPINBOX_value.single_register_number); LISTVIEW_SetItemText(hItem, 0, 0, buffer); if(modbus_rx.data_converted[0] != 0) sprintf(buffer, "%s", "ON"); else sprintf(buffer, "%s", "OFF"); LISTVIEW_SetItemText(hItem, slave_column, 0, buffer); } } } // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_LISTVIEW_0: // Notifications sent by 'response_view' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_SEL_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_LISTVIEW_1: // Notifications sent by 'status_view' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_SEL_CHANGED: // USER START (Optionally insert code for reacting on notification message) // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_BUTTON_1: // Notifications sent by 'exit_button' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(600, 20); PlayAudio(600, 20); PlayAudio(200, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) new_GUI_value.SPINBOX_value.slave_id = 0; new_GUI_value.SPINBOX_value.multiple_register_from = 0; new_GUI_value.SPINBOX_value.multiple_register_to = 0; new_GUI_value.SPINBOX_value.single_register_number = 0; new_GUI_value.SPINBOX_value.write_value = 0; new_GUI_value.RADIO_value.radio_selection = 0; PlayAudio(900, 20); PlayAudio(1000, 20); PlayAudio(1100, 20); hItem = pMsg->hWin; GUI_EndDialog(hItem, 0); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_0: // Notifications sent by 'slave_id_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_0); new_GUI_value.SPINBOX_value.slave_id = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_1: // Notifications sent by 'from_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_1); new_GUI_value.SPINBOX_value.multiple_register_from = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_2: // Notifications sent by 'to_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_2); new_GUI_value.SPINBOX_value.multiple_register_to = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_3: // Notifications sent by 'number_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_3); new_GUI_value.SPINBOX_value.single_register_number = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; case ID_SPINBOX_4: // Notifications sent by 'write_value_spinbox' switch(NCode) { case WM_NOTIFICATION_CLICKED: // USER START (Optionally insert code for reacting on notification message) PlayAudio(150, 20); // USER END break; case WM_NOTIFICATION_RELEASED: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_MOVED_OUT: // USER START (Optionally insert code for reacting on notification message) // USER END break; case WM_NOTIFICATION_VALUE_CHANGED: // USER START (Optionally insert code for reacting on notification message) hItem = WM_GetDialogItem(pMsg->hWin, ID_SPINBOX_4); new_GUI_value.SPINBOX_value.write_value = SPINBOX_GetValue(pMsg->hWinSrc); // USER END break; // USER START (Optionally insert additional code for further notification handling) // USER END } break; // USER START (Optionally insert additional code for further Ids) // USER END } break; // USER START (Optionally insert additional message handling) // USER END default: WM_DefaultProc(pMsg); break; } }