BOOL CBacnetProgramEdit::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: Add extra initialization here my_panel = bac_gloab_panel; //Set the panel number GetDlgItem(IDC_RICHEDIT2_PROGRAM)->SetFocus(); CHARFORMAT cf; ZeroMemory(&cf, sizeof(CHARFORMAT)); cf.cbSize = sizeof(CHARFORMAT); cf.dwMask|=CFM_BOLD; cf.dwEffects&=~CFE_BOLD; //cf.dwEffects|=~CFE_BOLD; //粗体,取消用cf.dwEffects&=~CFE_BOLD; cf.dwMask|=CFM_ITALIC; cf.dwEffects&=~CFE_ITALIC; //cf.dwEffects|=~CFE_ITALIC; //斜体,取消用cf.dwEffects&=~CFE_ITALIC; cf.dwMask|=CFM_UNDERLINE; cf.dwEffects&=~CFE_UNDERLINE; //cf.dwEffects|=~CFE_UNDERLINE; //斜体,取消用cf.dwEffects&=~CFE_UNDERLINE; cf.dwMask|=CFM_COLOR; cf.crTextColor = RGB(0,0,255); //设置颜色 cf.dwMask|=CFM_SIZE; cf.yHeight =300; //设置高度 cf.dwMask|=CFM_FACE; _tcscpy(cf.szFaceName ,_T("SimSun-ExtB")); // strcpy(cf.szFaceName ,_T("隶书")); //设置字体 ((CRichEditCtrl*)GetDlgItem(IDC_RICHEDIT2_PROGRAM))->SetSelectionCharFormat(cf); ((CRichEditCtrl*)GetDlgItem(IDC_RICHEDIT2_PROGRAM))->SetDefaultCharFormat(cf); //((CRichEditCtrl*)GetDlgItem(IDC_RICHEDIT2_PROGRAM))->PasteSpecial(CF_TEXT); ((CRichEditCtrl*)GetDlgItem(IDC_RICHEDIT2_PROGRAM))->PostMessage(WM_VSCROLL, SB_BOTTOM,0); //int retry_count =0; //do //{ // retry_count ++; // g_invoke_id = GetPrivateData(g_bac_instance,READPROGRAMCODE_T3000,program_list_line,program_list_line,100); // Sleep(200); //} while ((retry_count<10)&&(g_invoke_id<0)); //if(g_invoke_id>=0) //{ // CString temp_cs_show; // temp_cs_show.Format(_T("Task ID = %d. Read program code from item %d "),g_invoke_id,program_list_line); // Post_Invoke_ID_Monitor_Thread(MY_INVOKE_ID,g_invoke_id,this->m_hWnd,temp_cs_show); //} //Post_Invoke_ID_Monitor_Thread(MY_INVOKE_ID,g_invoke_id,this->m_hWnd); RegisterHotKey(GetSafeHwnd(),KEY_F2,NULL,VK_F2);//F2键 RegisterHotKey(GetSafeHwnd(),KEY_F3,NULL,VK_F3); RegisterHotKey(GetSafeHwnd(),KEY_F7,NULL,VK_F7); RegisterHotKey(GetSafeHwnd(),KEY_F6,NULL,VK_F6); RegisterHotKey(GetSafeHwnd(),KEY_F8,NULL,VK_F8); Initial_static(); init_info_table(); Init_table_bank(); mParent_Hwnd = g_hwnd_now; m_program_edit_hwnd = this->m_hWnd; g_hwnd_now = m_program_edit_hwnd; copy_data_to_ptrpanel(TYPE_ALL); memset(my_display,0,sizeof(my_display)); PostMessage(WM_REFRESH_BAC_PROGRAM_RICHEDIT,NULL,NULL); return FALSE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
LRESULT CBacnetProgram::Fresh_Program_List(WPARAM wParam,LPARAM lParam) { // Str_in_point Get_Str_in_Point(int index); int Fresh_Item; int isFreshOne = (int)lParam; if(isFreshOne == REFRESH_ON_ITEM) { Fresh_Item = (int)wParam; } else { if(m_program_list.IsDataNewer((char *)&m_Program_data.at(0),sizeof(Str_program_point) * BAC_PROGRAM_ITEM_COUNT)) { //避免list 刷新时闪烁;在没有数据变动的情况下不刷新List; m_program_list.SetListData((char *)&m_Program_data.at(0),sizeof(Str_program_point) * BAC_PROGRAM_ITEM_COUNT); } else { return 0; } } bac_program_pool_size = 26624; bac_program_size = 0; bac_free_memory = 26624; for (int i=0;i<(int)m_Program_data.size();i++) { CString temp_item,temp_value,temp_cal,temp_filter,temp_status,temp_lable; CString temp_des; CString temp_units; if(isFreshOne) { i = Fresh_Item; } MultiByteToWideChar( CP_ACP, 0, (char *)m_Program_data.at(i).description, (int)strlen((char *)m_Program_data.at(i).description)+1, temp_des.GetBuffer(MAX_PATH), MAX_PATH ); temp_des.ReleaseBuffer(); m_program_list.SetItemText(i,PROGRAM_FULL_LABLE,temp_des); if(m_Program_data.at(i).auto_manual==0) m_program_list.SetItemText(i,PROGRAM_AUTO_MANUAL,_T("Auto")); else m_program_list.SetItemText(i,PROGRAM_AUTO_MANUAL,_T("Manual")); if(m_Program_data.at(i).on_off==0) m_program_list.SetItemText(i,PROGRAM_STATUS,ProgramStatus[1]); else m_program_list.SetItemText(i,PROGRAM_STATUS,ProgramStatus[0]); temp_value.Format(_T("%d"),m_Program_data.at(i).bytes); m_program_list.SetItemText(i,PROGRAM_SIZE_LIST,temp_value); bac_program_size = bac_program_size + m_Program_data.at(i).bytes; if(m_Program_data.at(i).com_prg==0) m_program_list.SetItemText(i,PROGRAM_RUN_STATUS,_T("Normal")); else m_program_list.SetItemText(i,PROGRAM_RUN_STATUS,_T("Abnormal")); CString temp_des2; MultiByteToWideChar( CP_ACP, 0, (char *)m_Program_data.at(i).label, (int)strlen((char *)m_Program_data.at(i).label)+1, temp_des2.GetBuffer(MAX_PATH), MAX_PATH ); temp_des2.ReleaseBuffer(); m_program_list.SetItemText(i,PROGRAM_LABEL,temp_des2); if(isFreshOne) { break; } } bac_free_memory = bac_program_pool_size - bac_program_size; copy_data_to_ptrpanel(TYPE_PROGRAM); return 0; }
LRESULT CBacnetInput::Fresh_Input_List(WPARAM wParam,LPARAM lParam) { // Str_in_point Get_Str_in_Point(int index); int Fresh_Item; int isFreshOne = (int)lParam; if(isFreshOne == REFRESH_ON_ITEM) { Fresh_Item = (int)wParam; } else { if(m_input_list.IsDataNewer((char *)&m_Input_data.at(0),sizeof(Str_in_point) * BAC_INPUT_ITEM_COUNT)) { //避免list 刷新时闪烁;在没有数据变动的情况下不刷新List; m_input_list.SetListData((char *)&m_Input_data.at(0),sizeof(Str_in_point) * BAC_INPUT_ITEM_COUNT); } else { return 0; } } if(0) { int temp_select_raw = 0; int temp_select_col = 0; m_input_list.Get_Selected_Item(temp_select_raw,temp_select_col); m_input_list.SetItemBkColor(temp_select_raw,temp_select_col,LIST_ITEM_SELECTED,0); } //m_input_list.DeleteAllItems(); for (int i=0; i<(int)m_Input_data.size(); i++) { CString temp_item,temp_value,temp_cal,temp_filter,temp_status,temp_lable; CString temp_des; CString temp_units; if(isFreshOne) { i = Fresh_Item; } MultiByteToWideChar( CP_ACP, 0, (char *)m_Input_data.at(i).description, (int)strlen((char *)m_Input_data.at(i).description)+1, temp_des.GetBuffer(MAX_PATH), MAX_PATH ); temp_des.ReleaseBuffer(); m_input_list.SetItemText(i,INPUT_FULL_LABLE,temp_des); if(m_Input_data.at(i).auto_manual==0) { m_input_list.SetItemText(i,INPUT_AUTO_MANUAL,_T("Auto")); m_input_list.SetCellEnabled(i,INPUT_VALUE,0); } else { m_input_list.SetItemText(i,INPUT_AUTO_MANUAL,_T("Manual")); m_input_list.SetCellEnabled(i,INPUT_VALUE,1); } if(m_Input_data.at(i).digital_analog == BAC_UNITS_ANALOG) { m_input_list.SetCellEnabled(i,INPUT_CAL,1); m_input_list.SetItemText(i,INPUT_RANGE,Input_Analog_Units_Array[m_Input_data.at(i).range]); m_input_list.SetItemText(i,INPUT_UNITE,Input_List_Analog_Units[m_Input_data.at(i).range]); CString cstemp_value; float temp_float_value; temp_float_value = ((float)m_Input_data.at(i).value) / 1000; cstemp_value.Format(_T("%.2f"),temp_float_value); m_input_list.SetItemText(i,INPUT_VALUE,cstemp_value); //CString temp_value; //temp_value.Format(_T("%d"),m_Input_data.at(i).value); //m_input_list.SetItemText(i,INPUT_VALUE,temp_value); temp_cal.Format(_T("%d"),(m_Input_data.at(i).calibration)); m_input_list.SetItemText(i,INPUT_CAL,temp_cal); } else if(m_Input_data.at(i).digital_analog == BAC_UNITS_DIGITAL) { m_input_list.SetItemText(i,INPUT_CAL,_T("")); #if 0 if(m_Input_data.at(i).range>=12) m_input_list.SetItemText(i,INPUT_RANGE,Digital_Units_Array[m_Input_data.at(i).range -11]); else m_input_list.SetItemText(i,INPUT_RANGE,Digital_Units_Array[m_Input_data.at(i).range]); #endif if(m_Input_data.at(i).range<=22) m_input_list.SetItemText(i,INPUT_RANGE,Digital_Units_Array[m_Input_data.at(i).range]); else m_input_list.SetItemText(i,INPUT_RANGE,Digital_Units_Array[0]); m_input_list.SetItemText(i,INPUT_UNITE,_T("")); if((m_Input_data.at(i).range>22) || (m_Input_data.at(i).range == 0)) { m_input_list.SetItemText(i,INPUT_UNITE,Digital_Units_Array[0]); } else { CString temp1; CStringArray temparray; #if 0 if(m_Input_data.at(i).range>=12) temp1 = Digital_Units_Array[m_Input_data.at(i).range - 11];//11 is the sizeof the array else #endif temp1 = Digital_Units_Array[m_Input_data.at(i).range]; SplitCStringA(temparray,temp1,_T("/")); if((temparray.GetSize()==2)) { if(m_Input_data.at(i).control == 0) m_input_list.SetItemText(i,INPUT_VALUE,temparray.GetAt(0)); else m_input_list.SetItemText(i,INPUT_VALUE,temparray.GetAt(1)); } } } temp_filter.Format(_T("%d"),(int)pow((double)2,(int)m_Input_data.at(i).filter)); m_input_list.SetItemText(i,INPUT_FITLER,temp_filter); if(m_Input_data.at(i).decom==0) temp_status.Format(Decom_Array[0]); else if(m_Input_data.at(i).decom==1) temp_status.Format(Decom_Array[1]); else temp_status.Empty(); m_input_list.SetItemText(i,INPUT_DECOM,temp_status); CString temp_des2; MultiByteToWideChar( CP_ACP, 0, (char *)m_Input_data.at(i).label, (int)strlen((char *)m_Input_data.at(i).label)+1, temp_des2.GetBuffer(MAX_PATH), MAX_PATH ); temp_des2.ReleaseBuffer(); m_input_list.SetItemText(i,INPUT_LABLE,temp_des2); if(isFreshOne) { break; } //ptr_panel } copy_data_to_ptrpanel(TYPE_INPUT); return 0; }
LRESULT CBacnetVariable::Fresh_Variable_List(WPARAM wParam,LPARAM lParam) { int Fresh_Item; int isFreshOne = (int)lParam; if(isFreshOne == REFRESH_ON_ITEM) { Fresh_Item = (int)wParam; } else { if(m_variable_list.IsDataNewer((char *)&m_Variable_data.at(0),sizeof(Str_variable_point) * BAC_VARIABLE_ITEM_COUNT)) { //避免list 刷新时闪烁;在没有数据变动的情况下不刷新List; m_variable_list.SetListData((char *)&m_Variable_data.at(0),sizeof(Str_variable_point) * BAC_VARIABLE_ITEM_COUNT); } else { return 0; } } for (int i=0;i<(int)m_Variable_data.size();i++) { CString temp_item,temp_value,temp_cal,temp_filter,temp_status,temp_lable; CString temp_des; CString temp_units; if(isFreshOne) { i = Fresh_Item; } if(i>=variable_item_limit_count) { return 0; } MultiByteToWideChar( CP_ACP, 0, (char *)m_Variable_data.at(i).description, (int)strlen((char *)m_Variable_data.at(i).description)+1, temp_des.GetBuffer(MAX_PATH), MAX_PATH ); temp_des.ReleaseBuffer(); m_variable_list.SetItemText(i,VARIABLE_FULL_LABLE,temp_des); if(m_Variable_data.at(i).auto_manual==0) { m_variable_list.SetItemText(i,VARIABLE_AUTO_MANUAL,_T("Auto")); } else { m_variable_list.SetItemText(i,VARIABLE_AUTO_MANUAL,_T("Manual")); } if(m_Variable_data.at(i).digital_analog == BAC_UNITS_DIGITAL) { if((m_Variable_data.at(i).range == 0) || (m_Variable_data.at(i).range>30)) { CString cstemp_value2; float temp_float_value1; temp_float_value1 = ((float)m_Variable_data.at(i).value) / 1000; cstemp_value2.Format(_T("%.3f"),temp_float_value1); m_variable_list.SetItemText(i,VARIABLE_VALUE,cstemp_value2); m_variable_list.SetItemText(i,VARIABLE_UNITE,Variable_Analog_Units_Array[0]); } else { CString temp1; CStringArray temparray; if((m_Variable_data.at(i).range < 23) &&(m_Variable_data.at(i).range !=0)) temp1 = Digital_Units_Array[m_Variable_data.at(i).range]; else if((m_Variable_data.at(i).range >=23) && (m_Variable_data.at(i).range <= 30)) { if(receive_customer_unit) temp1 = temp_unit_no_index[m_Variable_data.at(i).range - 23]; } else { temp1 = Digital_Units_Array[0]; m_variable_list.SetItemText(i,VARIABLE_UNITE,temp1); } SplitCStringA(temparray,temp1,_T("/")); if((temparray.GetSize()==2)) { if(m_Variable_data.at(i).control == 0) m_variable_list.SetItemText(i,VARIABLE_VALUE,temparray.GetAt(0)); else m_variable_list.SetItemText(i,VARIABLE_VALUE,temparray.GetAt(1)); m_variable_list.SetItemText(i,VARIABLE_UNITE,temp1); } } #if 0 m_variable_list.SetItemText(i,VARIABLE_UNITE,Digital_Units_Array[m_Variable_data.at(i).range]); //单位 这个要商量 看要怎么搞; if((m_Variable_data.at(i).range >= 12)&&(m_Variable_data.at(i).range <= 22)) { CString temp1; CStringArray temparray; temp1 = Digital_Units_Array[m_Variable_data.at(i).range - 11];//11 is the sizeof the array SplitCStringA(temparray,temp1,_T("/")); if((temparray.GetSize()==2)&&(!temparray.GetAt(1).IsEmpty())) { m_variable_list.SetItemText(i,VARIABLE_VALUE,temparray.GetAt(1)); } m_variable_list.SetItemText(i,VARIABLE_UNITE,temp1); } else if((m_Variable_data.at(i).range >= 1)&&(m_Variable_data.at(i).range <= 11)) { CString temp1; CStringArray temparray; temp1 = Digital_Units_Array[m_Variable_data.at(i).range]; SplitCStringA(temparray,temp1,_T("/")); if((temparray.GetSize()==2)&&(!temparray.GetAt(0).IsEmpty())) { m_variable_list.SetItemText(i,VARIABLE_VALUE,temparray.GetAt(0)); } m_variable_list.SetItemText(i,VARIABLE_UNITE,temp1); } else { m_variable_list.SetItemText(i,VARIABLE_VALUE,_T("0")); } #endif } else { if(m_Variable_data.at(i).range == 20) //如果是时间; { m_variable_list.SetItemText(i,VARIABLE_UNITE,Variable_Analog_Units_Array[m_Variable_data.at(i).range]); char temp_char[50]; int time_seconds = m_Variable_data.at(i).value / 1000; intervaltotextfull(temp_char,time_seconds,0,0); CString temp_11; MultiByteToWideChar( CP_ACP, 0, temp_char, strlen(temp_char) + 1, temp_11.GetBuffer(MAX_PATH), MAX_PATH ); temp_11.ReleaseBuffer(); m_variable_list.SetItemText(i,VARIABLE_VALUE,temp_11); //temp_value.Format(_T("%d"),m_Variable_data.at(i).value); //m_variable_list.SetItemText(i,VARIABLE_VALUE,temp_value); } //else if(m_Variable_data.at(i).range == 0) //{ // m_variable_list.SetItemText(i,VARIABLE_UNITE,Variable_Analog_Units_Array[0]); //} else if(m_Variable_data.at(i).range<=sizeof(Variable_Analog_Units_Array)/sizeof(Variable_Analog_Units_Array[0])) { m_variable_list.SetItemText(i,VARIABLE_UNITE,Variable_Analog_Units_Array[m_Variable_data.at(i).range]); CString cstemp_value; float temp_float_value; temp_float_value = ((float)m_Variable_data.at(i).value) / 1000; cstemp_value.Format(_T("%.3f"),temp_float_value); m_variable_list.SetItemText(i,VARIABLE_VALUE,cstemp_value); //temp_value.Format(_T("%d"),m_Variable_data.at(i).value); //m_variable_list.SetItemText(i,VARIABLE_VALUE,temp_value); } else { m_variable_list.SetItemText(i,VARIABLE_UNITE,Variable_Analog_Units_Array[0]); CString cstemp_value; float temp_float_value; temp_float_value = ((float)m_Variable_data.at(i).value) / 1000; cstemp_value.Format(_T("%.3f"),temp_float_value); m_variable_list.SetItemText(i,VARIABLE_VALUE,cstemp_value); } } CString temp_des2; MultiByteToWideChar( CP_ACP, 0, (char *)m_Variable_data.at(i).label, (int)strlen((char *)m_Variable_data.at(i).label)+1, temp_des2.GetBuffer(MAX_PATH), MAX_PATH ); temp_des2.ReleaseBuffer(); m_variable_list.SetItemText(i,VARIABLE_LABLE,temp_des2); if(isFreshOne) { break; } } copy_data_to_ptrpanel(TYPE_VARIABLE); return 0; }
LRESULT CBacnetOutput::Fresh_Output_List(WPARAM wParam,LPARAM lParam) { int Fresh_Item; int isFreshOne = (int)lParam; int digital_special_output_count = 0; int analog_special_output_count = 0; if(bacnet_device_type == BIG_MINIPANEL) { digital_special_output_count = BIG_MINIPANEL_OUT_D; analog_special_output_count = BIG_MINIPANEL_OUT_A; } else if(bacnet_device_type == SMALL_MINIPANEL) { digital_special_output_count = SMALL_MINIPANEL_OUT_D; analog_special_output_count = SMALL_MINIPANEL_OUT_A; } else if(bacnet_device_type == TINY_MINIPANEL) { digital_special_output_count = TINY_MINIPANEL_OUT_D; analog_special_output_count = TINY_MINIPANEL_OUT_A; } else if(bacnet_device_type == T38AI8AO6DO) { digital_special_output_count = T38AI8AO6DO_OUT_D; analog_special_output_count = T38AI8AO6DO_OUT_A; } else if(bacnet_device_type == PID_T322AI) { digital_special_output_count = T322AI_OUT_D; analog_special_output_count = T322AI_OUT_A; } //if(pFrame->m_product.at(selected_product_index).product_class_id == T38AI8AO6DO) if((bacnet_device_type == T38AI8AO6DO) || (bacnet_device_type == PID_T322AI)) { OUTPUT_LIMITE_ITEM_COUNT = digital_special_output_count + analog_special_output_count; } else { OUTPUT_LIMITE_ITEM_COUNT = BAC_OUTPUT_ITEM_COUNT; } bool temp_need_show_external = false; for (int z= 0 ;z < (int)m_Output_data.size();z++) { if(z>= OUTPUT_LIMITE_ITEM_COUNT) break; if((m_Output_data.at(z).sub_id !=0) && (m_Output_data.at(z).sub_product !=0)) { temp_need_show_external = true; break; } } if(show_output_external != temp_need_show_external) { show_output_external = temp_need_show_external; if(temp_need_show_external) { CRect temp_rect; temp_rect = Output_rect; temp_rect.right = 1150; temp_rect.top = temp_rect.top + 24; m_output_list.MoveWindow(temp_rect); m_output_list.SetColumnWidth(OUTPUT_EXTERNAL,60); m_output_list.SetColumnWidth(OUTPUT_PRODUCT,80); m_output_list.SetColumnWidth(OUTPUT_EXT_NUMBER,80); } else { CRect temp_rect; temp_rect = Output_rect; temp_rect.right = 950; temp_rect.top = temp_rect.top + 24; m_output_list.MoveWindow(temp_rect); m_output_list.SetColumnWidth(OUTPUT_EXTERNAL,0); m_output_list.SetColumnWidth(OUTPUT_PRODUCT,0); m_output_list.SetColumnWidth(OUTPUT_EXT_NUMBER,0); } } if(isFreshOne == REFRESH_ON_ITEM) { Fresh_Item = (int)wParam; } else { if(m_output_list.IsDataNewer((char *)&m_Output_data.at(0),sizeof(Str_out_point) * BAC_OUTPUT_ITEM_COUNT)) { //避免list 刷新时闪烁;在没有数据变动的情况下不刷新List; m_output_list.SetListData((char *)&m_Output_data.at(0),sizeof(Str_out_point) * BAC_OUTPUT_ITEM_COUNT); } else { return 0; } } CString temp1; //int Fresh_Item; //int isFreshOne = (int)lParam; //if(isFreshOne == REFRESH_ON_ITEM) //{ // Fresh_Item = (int)wParam; //} for (int i=0;i<(int)m_Output_data.size();i++) { if(isFreshOne) { i = Fresh_Item; } if(i>=output_item_limit_count) break; if(i>= OUTPUT_LIMITE_ITEM_COUNT) { for (int a=0;a<OUTPUT_COL_NUMBER; a++) { m_output_list.SetItemText(i,a,_T("")); } continue; } CString temp_item,temp_value,temp_cal,temp_filter,temp_status,temp_lable; CString temp_des; CString temp_units; MultiByteToWideChar( CP_ACP, 0, (char *)m_Output_data.at(i).description, (int)strlen((char *)m_Output_data.at(i).description)+1, temp_des.GetBuffer(MAX_PATH), MAX_PATH ); temp_des.ReleaseBuffer(); temp_item.Format(_T("OUT%d"),i+1); m_output_list.SetItemText(i,OUTPUT_NUM,temp_item); m_output_list.SetItemText(i,OUTPUT_FULL_LABLE,temp_des); m_output_list.SetCellEnabled(i,OUTPUT_HW_SWITCH,0); //int digital_special_output_count = 0; //int analog_special_output_count = 0; m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T("")); //这样加实在是情非得已,老毛非得加一堆条件,还要smart; if((bacnet_device_type == BIG_MINIPANEL) || ((bacnet_device_type == SMALL_MINIPANEL)) || (bacnet_device_type == TINY_MINIPANEL) || (bacnet_device_type == T38AI8AO6DO) || (bacnet_device_type == PID_T322AI) ) { //if(bacnet_device_type == BIG_MINIPANEL) //{ // digital_special_output_count = BIG_MINIPANEL_OUT_D; // analog_special_output_count = BIG_MINIPANEL_OUT_A; //} //else if(bacnet_device_type == SMALL_MINIPANEL) //{ // digital_special_output_count = SMALL_MINIPANEL_OUT_D; // analog_special_output_count = SMALL_MINIPANEL_OUT_A; //} //else if(bacnet_device_type == TINY_MINIPANEL) //{ // digital_special_output_count = TINY_MINIPANEL_OUT_D; // analog_special_output_count = TINY_MINIPANEL_OUT_A; //} //else if(bacnet_device_type == T38AI8AO6DO) //{ // digital_special_output_count = T38AI8AO6DO_OUT_D; // analog_special_output_count = T38AI8AO6DO_OUT_A; //} if(i < (digital_special_output_count +analog_special_output_count) ) { if(m_Output_data.at(i).hw_switch_status == HW_SW_OFF) { m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T("MAN-OFF")); m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,0); m_output_list.SetItemTextColor(i,-1,RGB(255,0,0),0); } else if(m_Output_data.at(i).hw_switch_status == HW_SW_HAND) { m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T("MAN-ON")); m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,0); m_output_list.SetItemTextColor(i,-1,RGB(255,0,0),0); } else { m_output_list.SetItemTextColor(i,-1,RGB(0,0,0),0); //if((i%2)==0) //恢复前景和 背景 颜色; // m_output_list.SetItemBkColor(i,-1,LIST_ITEM_DEFAULT_BKCOLOR,0); //else // m_output_list.SetItemBkColor(i,-1,LIST_ITEM_DEFAULT_BKCOLOR_GRAY,0); m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T("AUTO")); m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,1); if(m_Output_data.at(i).auto_manual==0) //In output table if it is auto ,the value can't be edit by user { m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Auto")); //m_output_list.SetCellEnabled(i,OUTPUT_VALUE,0); } else { m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Manual")); //m_output_list.SetCellEnabled(i,OUTPUT_VALUE,1); } } } else { m_output_list.SetItemTextColor(i,-1,RGB(0,0,0),0); m_output_list.SetItemText(i,OUTPUT_HW_SWITCH,_T("AUTO")); m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,1); if(m_Output_data.at(i).auto_manual==0) //In output table if it is auto ,the value can't be edit by user { m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Auto")); //m_output_list.SetCellEnabled(i,OUTPUT_VALUE,0); } else { m_Output_data.at(i).auto_manual = 1; m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Manual")); //m_output_list.SetCellEnabled(i,OUTPUT_VALUE,1); } } } else { m_output_list.SetCellEnabled(i,OUTPUT_AUTO_MANUAL,1); if(m_Output_data.at(i).auto_manual==0) //In output table if it is auto ,the value can't be edit by user { m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Auto")); //m_output_list.SetCellEnabled(i,OUTPUT_VALUE,0); } else { m_Output_data.at(i).auto_manual = 1; m_output_list.SetItemText(i,OUTPUT_AUTO_MANUAL,_T("Manual")); //m_output_list.SetCellEnabled(i,OUTPUT_VALUE,1); } } m_output_list.SetCellEnabled(i,OUTPUT_UNITE,0); if(m_Output_data.at(i).digital_analog == BAC_UNITS_ANALOG) { //m_output_list.SetCellEnabled(i,OUTPUT_0_PERSENT,1); //m_output_list.SetCellEnabled(i,OUTPUT_100_PERSENT,1); if(m_Output_data.at(i).range == 0) m_output_list.SetItemText(i,OUTPUT_RANGE,_T("Unused")); else if(m_Output_data.at(i).range < (sizeof(OutPut_List_Analog_Range)/sizeof(OutPut_List_Analog_Range[0]))) m_output_list.SetItemText(i,OUTPUT_RANGE,OutPut_List_Analog_Range[m_Output_data.at(i).range]); else m_output_list.SetItemText(i,OUTPUT_RANGE,_T("Out of range")); if(m_Output_data.at(i).range < (sizeof(OutPut_List_Analog_Units)/sizeof(OutPut_List_Analog_Units[0]))) m_output_list.SetItemText(i,OUTPUT_UNITE,OutPut_List_Analog_Units[m_Output_data.at(i).range]); else m_output_list.SetItemText(i,OUTPUT_UNITE,_T("Unused")); CString temp_low,temp_high; temp_low.Format(_T("%d"),0); temp_high.Format(_T("%d"),0); CString temp_value; temp_value.Format(_T("%.2f"),((float)m_Output_data.at(i).value) / 1000); m_output_list.SetItemText(i,OUTPUT_VALUE,temp_value); #if 0 CString cstemp_value; float temp_float_value; temp_float_value = ((float)m_Output_data.at(i).value) / 1000; cstemp_value.Format(_T("%.2f"),temp_float_value); m_output_list.SetItemText(i,OUTPUT_VALUE,cstemp_value); #endif //m_output_list.SetItemText(i,OUTPUT_0_PERSENT,temp_low); //m_output_list.SetItemText(i,OUTPUT_100_PERSENT,temp_high); } else if(m_Output_data.at(i).digital_analog == BAC_UNITS_DIGITAL) { //m_output_list.SetCellEnabled(i,OUTPUT_0_PERSENT,0); //m_output_list.SetCellEnabled(i,OUTPUT_100_PERSENT,0); //m_output_list.SetItemText(i,OUTPUT_0_PERSENT,_T("")); //m_output_list.SetItemText(i,OUTPUT_100_PERSENT,_T("")); /*m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[m_Output_data.at(i).range]);*/ m_output_list.SetItemText(i,OUTPUT_UNITE,_T("")); if(m_Output_data.at(i).range == 0) { CString temp_value2; temp_value2.Format(_T("%.2f"),((float)m_Output_data.at(i).value) / 1000); m_output_list.SetItemText(i,OUTPUT_VALUE,temp_value2); m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[0]); } else if(m_Output_data.at(i).range<=22) m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[m_Output_data.at(i).range]); else if((m_Output_data.at(i).range >= 23) && (m_Output_data.at(i).range <= 30)) { if(receive_customer_unit) m_output_list.SetItemText(i,OUTPUT_RANGE,temp_unit_no_index[m_Output_data.at(i).range - 23]); else m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[0]); } else m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[0]); #if 0 if(m_Output_data.at(i).range>=12) m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[m_Output_data.at(i).range -11]); else m_output_list.SetItemText(i,OUTPUT_RANGE,Digital_Units_Array[m_Output_data.at(i).range]); #endif if((m_Output_data.at(i).range>30) || (m_Output_data.at(i).range == 0)) { //m_output_list.SetItemText(i,OUTPUT_UNITE,Digital_Units_Array[0]); } else { CStringArray temparray; if((m_Output_data.at(i).range < 23) &&(m_Output_data.at(i).range !=0)) temp1 = Digital_Units_Array[m_Output_data.at(i).range]; else if((m_Output_data.at(i).range >=23) && (m_Output_data.at(i).range <= 30)) { if(receive_customer_unit) temp1 = temp_unit_no_index[m_Output_data.at(i).range - 23]; } else { temp1.Empty(); m_output_list.SetItemText(i,OUTPUT_VALUE,_T("")); } SplitCStringA(temparray,temp1,_T("/")); if((temparray.GetSize()==2)) { if(m_Output_data.at(i).control == 0) m_output_list.SetItemText(i,OUTPUT_VALUE,temparray.GetAt(0)); else m_output_list.SetItemText(i,OUTPUT_VALUE,temparray.GetAt(1)); } } } CString main_sub_panel; #pragma region External info if((m_Output_data.at(i).sub_id !=0) && //(m_Input_data.at(input_list_line).sub_number !=0) && (m_Output_data.at(i).sub_product !=0)) { unsigned char temp_pid = m_Output_data.at(i).sub_product; if((temp_pid == PM_T3PT10) || (temp_pid == PM_T3IOA) || (temp_pid == PM_T332AI) || (temp_pid == PM_T38AI16O) || (temp_pid == PM_T38I13O) || (temp_pid == PM_T34AO) || (temp_pid == PM_T322AI) || (temp_pid == PM_T38AI8AO6DO) || (temp_pid == PM_T36CT)) { CString temp_name; temp_name = GetProductName(m_Output_data.at(i).sub_product); CString show_info; CString temp_id; CString temp_number; bitset<8> mytest((unsigned char)m_Output_data.at(i).sub_number); bool highest_bit; highest_bit = mytest.test(7); unsigned char temp_sub_number = 0; mytest = mytest.set(7,0); temp_sub_number = (unsigned char)mytest.to_ulong(); if(highest_bit) temp_number.Format(_T("AO%d"),temp_sub_number + 1); else temp_number.Format(_T("DO%d"),temp_sub_number + 1); m_output_list.SetItemText(i,OUTPUT_EXTERNAL,_T("External")); m_output_list.SetItemTextColor(i,OUTPUT_EXTERNAL,RGB(0,0,255),FALSE); m_output_list.SetItemText(i,OUTPUT_PRODUCT,temp_name); m_output_list.SetItemText(i,OUTPUT_EXT_NUMBER,temp_number); main_sub_panel.Format(_T("%d-%d"),(unsigned char)Station_NUM,(unsigned char)m_Output_data.at(i).sub_id); m_output_list.SetItemText(i,OUTPUT_PANEL,main_sub_panel); //temp_id.Format(_T(" Sub ID: %u "),(unsigned char)m_Input_data.at(input_list_line).sub_id); //temp_number.Format(_T("Input%d"),(unsigned char)m_Input_data.at(input_list_line).sub_number + 1); //show_info = _T("Module:") + temp_name +_T(" ") + temp_id + temp_number; //m_input_item_info.SetWindowTextW(show_info); } else { main_sub_panel.Format(_T("%d"),(unsigned char)Station_NUM); m_output_list.SetItemText(i,OUTPUT_PANEL,main_sub_panel); } } else { main_sub_panel.Format(_T("%d"),(unsigned char)Station_NUM); m_output_list.SetItemText(i,OUTPUT_PANEL,main_sub_panel); } #pragma endregion External info if(m_Output_data.at(i).decom==0) temp_status.Format(Output_Decom_Array[0]); else if(m_Output_data.at(i).decom==1) temp_status.Format(Output_Decom_Array[1]); else temp_status.Empty(); m_output_list.SetItemText(i,OUTPUT_DECOM,temp_status); CString temp_pwm_period; temp_pwm_period.Format(_T("%u"),(unsigned char)m_Output_data.at(i).pwm_period); m_output_list.SetItemText(i,OUTPUT_PWM_PERIOD,temp_pwm_period); CString temp_des2; MultiByteToWideChar( CP_ACP, 0, (char *)m_Output_data.at(i).label, (int)strlen((char *)m_Output_data.at(i).label)+1, temp_des2.GetBuffer(MAX_PATH), MAX_PATH ); temp_des2.ReleaseBuffer(); m_output_list.SetItemText(i,OUTPUT_LABLE,temp_des2); if(isFreshOne) { break; } } copy_data_to_ptrpanel(TYPE_OUTPUT); Invalidate(); return 0; }