void T38AI8AO::Fresh(){ if (is_connect()) { for (int i=0;i<3;i++) { Read_Multi(g_tstat_id,&product_register_value[i*100],i*100,100); } InitialRegister(); InitialDialog(); if(hFirstThread != NULL) TerminateThread(hFirstThread, 0); hFirstThread=NULL; if (!hFirstThread) { hFirstThread = CreateThread(NULL,NULL,_BackFreshing_8IAO,this,NULL,0); } //AfxBeginThread(_BackFreshing,this); } else { SetPaneString(1,_T("Disconnection")); AfxMessageBox(_T("Please Connect your device")); } }
DWORD WINAPI CCO2_View::StartRefresh(LPVOID lpVoid) { CCO2_View *pParent = (CCO2_View *)lpVoid; int read_ret=0; register_critical_section.Lock(); for(int i=0;i<7;i++) { if(Read_Multi(g_tstat_id,&multi_register_value[i*64],i*64,64)>0) read_ret++; } register_critical_section.Unlock(); if(read_ret<7) pParent->PostMessage(WM_REFRESH_CO2_DLG,REFRESH_FAIL,0); memset(product_register_value,0,sizeof(product_register_value)); memcpy_s(product_register_value,sizeof(product_register_value),multi_register_value,sizeof(multi_register_value));// if(pParent->IsWindowVisible()) { pParent->PostMessage(WM_REFRESH_CO2_DLG,REFRESH_DLG,0); pParent->PostMessage(WM_REFRESH_CO2_DLG,ENABLE_REFRESH_BUTTON,0); } pParent->RefreshThread=NULL; return 0; }
UINT _BackFreshing(LPVOID pParam) { T38AI8AO* dlg=(T38AI8AO*)(pParam); Sleep(10*1000); while(1) { if(bPauseMultiRead) continue; if (!is_connect()) { continue; } Sleep(10*1000); bPauseMultiRead=TRUE; for(int i=0;i<3;i++) //Modify by Fance , tstat 6 has more register than 512; { register_critical_section.Lock(); Read_Multi(g_tstat_id,&multi_register_value[i*64],i*64,64); register_critical_section.Unlock(); } bPauseMultiRead=FALSE; memcpy_s(product_register_value,sizeof(product_register_value),multi_register_value,sizeof(multi_register_value)); dlg->InitialDialog(); } return 1; }
void T3000_Default_MainView::OnEnKillfocusEditAesEncrypt() { CString str; m_Edit_AESPassword.GetWindowTextW(str); if (str.GetLength()<=0) { return; } unsigned char AESPwd[16]; memset(AESPwd, 0, 16); for (int i = 0;i<str.GetLength();i++) { AESPwd[i] = str.GetAt(i); } int ret = Write_Multi_org(g_tstat_id, AESPwd, 600, 16, 5); Read_Multi(g_tstat_id, &product_register_value[599], 599, 100); if (product_register_value[599] == 0) { m_Edit_AESPassword.EnableWindow(FALSE); GetDlgItem(IDC_CHECK_PASSWORD)->EnableWindow(FALSE); } else { m_Edit_AESPassword.EnableWindow(TRUE); m_Edit_AESPassword.SetWindowTextW(GetTextFromReg(600) + GetTextFromReg(604)); //m_Edit_AESPassword.SetPasswordChar('*'); ((CButton *)GetDlgItem(IDC_CHECK_PASSWORD))->SetCheck(1); } }
void CNetworkControllView::ReadNCTable() { WORD wNumLow = Read_One(m_IDaddress, TABLE_NODE_NUM_REG); if (wNumLow < 0) { return; } WORD wNum = Read_One(m_IDaddress, TABLE_NODE_NUM_REG+1); wNum = (wNum << 8) + wNumLow; unsigned short* szNode = new unsigned short[TABLE_NODE_SIZE]; for (int i = 0; i < wNum; i++) { ZeroMemory(szNode, TABLE_NODE_SIZE); int nRet = Read_Multi(m_IDaddress, szNode, TABLE_NODE_NUM_REG+2, TABLE_NODE_SIZE); if (nRet >0) { AddNodeToNCTable(szNode); } } delete []szNode; }
CString CDisplayConfig::GetTextFromReg(unsigned short reg){ CString str_temp; unsigned short temp_buffer[4]; unsigned short temp_buffer_Char[THE_CHAR_LENGTH]; unsigned char p[THE_CHAR_LENGTH+1]={'\0'}; if (Read_Multi(g_tstat_id,temp_buffer,reg,4)) { unsigned short Hi_Char,Low_Char; for (int i=0;i<4;i++) { Hi_Char=temp_buffer[i]; Hi_Char=Hi_Char&0xff00; Hi_Char=Hi_Char>>8; Low_Char=temp_buffer[i]; Low_Char=Low_Char&0x00ff; temp_buffer_Char[2*i]=Hi_Char; temp_buffer_Char[2*i+1]=Low_Char; } for (int i=0;i<THE_CHAR_LENGTH;i++) { p[i] =(unsigned char)temp_buffer_Char[i]; } str_temp.Format(_T("%c%c%c%c%c%c%c%c"),p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]); }
BOOL CAirQuality::prodtopc() { KillTimer(AirQualityTimer); #if 1 //读取串口号,从数据库 open_com(comnum); int sumret = 0; BOOL flag = FALSE; //读取AirQuality数据 BOOL ret_bool = FALSE; long start = clock(),end(0); memset(&shmPRegister,0,sizeof(shmPRegister)); for(int i=0;i<4;i++) { int ret = Read_Multi(g_tstat_id,&shmPRegister[i*64],i*64,64,2); sumret += ret; if (sumret<0) { TRACE(_T("write_multi ret sum = %d\n"),sumret); SetTimer(AirQualityTimer,1000,NULL); return FALSE; } } for (int i = 0;i<400;i++) { // vecminipanel.at(i).CStvalue = shmPRegister[i]; // error C2593: 'operator =' is ambiguous vecairquality.at(i).CStvalue.Format(_T("%d"),shmPRegister[i]); } if (sumret>200) { flag = TRUE; } TRACE(_T("write_multi ret sum = %d\n"),sumret); end = clock(); long resultvalue = (end - start)/1000; TRACE(_T("GetData() usetime %d second\n"),resultvalue); SetTimer(AirQualityTimer,1000,NULL); #endif return flag; }
void COutsidDailog::OnBnClickedButton1() { int i; for(i=0;i<7;i++) { register_critical_section.Lock(); Read_Multi(g_tstat_id,&multi_register_value[i*64],i*64,64); register_critical_section.Unlock(); } Refresh(); }
// Annual_Routines 消息处理程序 description2 Annual_Routines::read_addr(unsigned char addr2) { description2 temp_description; memset(&temp_description,0,sizeof(description2)); unsigned short temp_buffer[AR_DESCRIPTION_SIZE]; memset(&temp_buffer[0],0,sizeof(temp_buffer)); if(m_strtype.CompareNoCase(_T("Lightingcontroller")) == 0) Read_Multi(254,temp_buffer,5228+addr2*AR_DESCRIPTION_SIZE,AR_DESCRIPTION_SIZE); else Read_Multi(g_tstat_id,temp_buffer,MODBUS_AR_DESCRIP_FIRST+addr2*AR_DESCRIPTION_SIZE,AR_DESCRIPTION_SIZE); int i=0; char *p; p=(char *)&temp_description;///////////////*****pointer attention for(i=0;i<AR_DESCRIPTION_SIZE;i++) { (*p)=temp_buffer[i]; p++; } return temp_description; }
void keep_back_mac_address(int id) { unsigned short get_mac_address[6]={0}; Read_Multi(id,get_mac_address,100,6); mac_address_list temp; temp.the_id=id; temp.mac1=get_mac_address[0]; temp.mac2=get_mac_address[1]; temp.mac3=get_mac_address[2]; temp.mac4=get_mac_address[3]; temp.mac5=get_mac_address[4]; temp.mac6=get_mac_address[5]; m_mac_address_list.push_back(temp); }
DWORD WINAPI UpdateCO2_Note_Thread(LPVOID lPvoid) { CCO2_NodeView * mparent = (CCO2_NodeView *)lPvoid; while (1) { for (int i = 0; i < 5; i++) { int itemp = 0; itemp = Read_Multi(g_tstat_id, &product_register_value[i * 100], i * 100, 100, 5); } PostMessage(mparent->m_hWnd, WM_CO2_NODE_THREAD_READ, NULL, NULL); Sleep(15000); } h_co2_node_thread = NULL; return 1; }
bool found_same_net_work_controller_by_mac(int id) {//because net cable no baudrate,so inspect here if(read_one(id,7)!=NET_WORK_CONT_PRODUCT_MODEL)//it is not a net work controller return false; unsigned short get_mac_address[6]={0}; Read_Multi(id,get_mac_address,100,6); for(int j=0;j<m_mac_address_list.size();j++) { if(get_mac_address[0]==m_mac_address_list.at(j).mac1 && get_mac_address[1]==m_mac_address_list.at(j).mac2 && get_mac_address[2]==m_mac_address_list.at(j).mac3 && get_mac_address[3]==m_mac_address_list.at(j).mac4 && get_mac_address[4]==m_mac_address_list.at(j).mac5 && get_mac_address[5]==m_mac_address_list.at(j).mac6) return true;//////////////////only here return true } return false; }
void T38AI8AO::OnBnClickedButtonReset() { if(AfxMessageBox(_T(" This will reset the module to the factory defaults,Are you sure to reset it ?"))==IDOK) { // write_one(g_tstat_id,299,1); write_one(g_tstat_id,300,1); unsigned short RangeData[10]; int multi_ret = Read_Multi(g_tstat_id,RangeData,RANGE_INPUT1,10) ; if (multi_ret >0 ) { for (int i=0; i<10 ; i++) { product_register_value[RANGE_INPUT1+i] = RangeData[i]; } InitialDialog(); } } }
void T38AI8AO::Fresh(){ float progress; if (is_connect()) { CDialog_Progess* pDlg = new CDialog_Progess(this,1,100); pDlg->Create(IDD_DIALOG10_Progress, this); pDlg->ShowProgress(0,0); pDlg->ShowWindow(SW_SHOW); RECT RECT_SET1; GetClientRect(&RECT_SET1); pDlg->MoveWindow(RECT_SET1.left+400,RECT_SET1.bottom-19,RECT_SET1.right/2+20,20); for (int i=0;i<3;i++) { if (pDlg!=NULL) { progress=float((i+1)*(100/3)); pDlg->ShowProgress(int(progress),(int)progress); } Read_Multi(g_tstat_id,&product_register_value[i*100],i*100,100); } pDlg->ShowWindow(SW_HIDE); if(pDlg!=NULL) {delete pDlg; pDlg=NULL;} InitialRegister(); InitialDialog(); AfxBeginThread(_BackFreshing,this); } else { SetPaneString(1,_T("Disconnection")); AfxMessageBox(_T("Please Connect your device")); } }
void T332AI::OnCbnSelchangeRangecombo() { BeginWaitCursor(); CString strTemp; int lRow = m_msflexgrid_input.get_RowSel(); int lCol = m_msflexgrid_input.get_ColSel(); int sel=m_comboxRange.GetCurSel(); m_comboxRange.ShowWindow(FALSE); if (product_register_value[Range1+lRow-1]==sel) { return; } int ret=write_one(g_tstat_id,Range1+lRow-1,sel); if (ret>0) { product_register_value[Range1+lRow-1]=sel; } Sleep(500); Read_Multi(g_tstat_id,&product_register_value[Range1],Range1,32); InitialDialog(); EndWaitCursor(); }
DWORD WINAPI _BackFreshing_8IAO(LPVOID pParam) { T38AI8AO* dlg=(T38AI8AO*)(pParam); Sleep(10*1000); while(1) { if (!is_connect()) { continue; } Sleep(3*1000); for(int i=0;i<3;i++) //Modify by Fance , tstat 6 has more register than 512; { if(g_bPauseMultiRead) { return 0; } Read_Multi(g_tstat_id,&multi_register_value[i*100],i*100,100); } memcpy_s(product_register_value,sizeof(product_register_value),multi_register_value,sizeof(multi_register_value)); dlg->InitialDialog(); } return 1; }
BOOL CDialogT3::MiniUpdateData() { KillTimer(T3_MODEL); #if 1 //读取串口号,从数据库 open_com(comnum); int sumret = 0; BOOL flag = FALSE; //读取miniPanel数据 BOOL ret_bool = FALSE; long start = clock(),end(0); memset(&shmPRegister,0,sizeof(shmPRegister)); for(int i=0; i<4; i++) { int ret = Read_Multi(g_tstat_id,&shmPRegister[i*64],i*64,64,2); sumret += ret; if (sumret<0) { TRACE(_T("write_multi ret sum = %d\n"),sumret); SetTimer(MiniPanelTimer,1000,NULL); return FALSE; } } for (int i = 0; i<230; i++) { // vecminipanel.at(i).CStvalue = shmPRegister[i]; // error C2593: 'operator =' is ambiguous vect3model.at(i).CStvalue.Format(_T("%d"),shmPRegister[i]); if (i>=124&&i<=147) { switch(shmPRegister[i]) { case 0: vect3model.at(i).CStautomannel = _T("OFF"); break; case 1: vect3model.at(i).CStautomannel = _T("Manual"); break; case 2: vect3model.at(i).CStautomannel = _T("Auto"); break; default: break; } } if (i>=100&&i<=123) { if (shmPRegister[i]>512) vect3model.at(i).CStvalue = _T("ON"); else vect3model.at(i).CStvalue = _T("OFF"); } } if (sumret>200) { flag = TRUE; } TRACE(_T("write_multi ret sum = %d\n"),sumret); end = clock(); long resultvalue = (end - start)/1000; TRACE(_T("GetData() usetime %d second\n"),resultvalue); SetTimer(T3_MODEL,1000,NULL); #endif return flag; }
void T3000_Default_MainView::Fresh(){ CString strTemp; strTemp.Format(_T("%d"),g_tstat_id); GetDlgItem(IDC_ID_EDIT)->SetWindowTextW(strTemp); strTemp.Format(_T("%d"),get_serialnumber()); GetDlgItem(IDC_SERIALNUM_EDIT)->SetWindowTextW(strTemp); m_brandrate_combox.ResetContent(); m_brandrate_combox.AddString(L"9600"); m_brandrate_combox.AddString(L"19200"); m_brandrate_combox.AddString(L"38400"); m_brandrate_combox.AddString(L"57600"); m_brandrate_combox.AddString(L"115200"); m_brandrate_combox.AddString(L"76800"); if((product_register_value[15] >= 0) && (product_register_value[15] <= 5)) m_brandrate_combox.SetCurSel(product_register_value[15]); m_mstpmodbus_combox.ResetContent(); m_mstpmodbus_combox.AddString(L"BACnet MSTP"); m_mstpmodbus_combox.AddString(L"Modbus"); if (product_register_value[7] == PM_TSTAT8|| (product_register_value[7] == PM_TSTAT8_WIFI) || (product_register_value[7] == PM_TSTAT8_OCC) || (product_register_value[7] == PM_TSTAT7_ARM) || (product_register_value[7] == PM_TSTAT8_220V)) { if (product_register_value[21] == 0) { m_mstpmodbus_combox.SetCurSel(1); } else { m_mstpmodbus_combox.SetCurSel(0); } unsigned int temp_device_id; temp_device_id = product_register_value[992] * 65536 + product_register_value[991]; CString cs_deviceid; cs_deviceid.Format(_T("%u"), temp_device_id); GetDlgItem(IDC_EDIT_BACNET_DEVICE_ID)->SetWindowTextW(cs_deviceid); if (product_register_value[4] >= 86) { GetDlgItem(IDC_EDIT_BACNET_DEVICE_ID)->EnableWindow(true); } else { GetDlgItem(IDC_EDIT_BACNET_DEVICE_ID)->EnableWindow(false); } } else { GetDlgItem(IDC_EDIT_BACNET_DEVICE_ID)->EnableWindow(false); if (product_register_value[21] == 0) { m_mstpmodbus_combox.SetCurSel(0); } else { m_mstpmodbus_combox.SetCurSel(1); } } strTemp.Format(_T("%d"), product_register_value[39]); m_Editor_macmstp.SetWindowTextW(strTemp); strTemp.Format(_T("%d"), product_register_value[38]); m_BipPort_Edit.SetWindowTextW(strTemp); strTemp.Format(_T("%0.1f"),get_curtstat_version()); GetDlgItem(IDC_FIRMWARV_EDIT)->SetWindowTextW(strTemp); strTemp.Format(_T("%d"),product_register_value[8]);//8 GetDlgItem(IDC_HARDWAREV_EDIT)->SetWindowTextW(strTemp); int nModel=product_register_value[7]; CString ProductName = GetProductName(nModel); if (nModel == PM_CS_RSM_AC||nModel == PM_CS_SM_AC) { if (product_register_value[11] == 0) { ProductName+=_T("-100A"); } else if (product_register_value[11]==1) { ProductName+=_T("-200A"); } else if (product_register_value[11]==2) { ProductName+=_T("-300A"); } } GetDlgItem(IDC_MODEL_EDIT)->SetWindowTextW(ProductName); strTemp.Format(_T("%d"),product_register_value[9]); GetDlgItem(IDC_PIC_EDIT)->SetWindowText(strTemp); GetDlgItem(IDC_BUTTON_WIFI_CONFIG)->ShowWindow(FALSE); MODBUS_BAUDRATE = 15; if ( product_register_value[7] == PM_T322AI || product_register_value[7] == PM_T38AI8AO6DO || product_register_value[7] == PM_T3PT12 || product_register_value[7] == PM_T36CTA || product_register_value[7] == PM_PWMETER ||product_register_value[7]==STM32_HUM_NET ) { GetDlgItem (IDC_STATIC_IPTIPS)->ShowWindow (TRUE); GetDlgItem (IDC_APPLYBUTTON)->ShowWindow (TRUE); GetDlgItem (IDC_STATIC_IPMODEL)->ShowWindow (TRUE); GetDlgItem (IDC_STATIC_IPADDRESS)->ShowWindow (TRUE); GetDlgItem (IDC_STATICSUBNETMASK)->ShowWindow (TRUE); GetDlgItem (IDC_STATICGATEWAYADDRESS)->ShowWindow (TRUE); GetDlgItem (IDC_STATIC_LISTENNINGPORT)->ShowWindow (TRUE); GetDlgItem (IDC_STATICMACADDRESS)->ShowWindow (TRUE); CString strtemp; int CO2_NET_MODBUS_MAC_ADDRESS_START = 40; strtemp.Format(_T("%02X-%02X-%02X-%02X-%02X-%02X"),product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START],product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START+1],product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START+2],product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START+3],product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START+4],product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START+5]); m_Edit_MacAddress.SetWindowText(strtemp); m_Edit_MacAddress.ShowWindow (TRUE); int CO2_NET_MODBUS_IP_MODE = 46; m_ip_model.SetCurSel(product_register_value[CO2_NET_MODBUS_IP_MODE]); m_ip_model.ShowWindow (TRUE); int CO2_NET_MODBUS_IP_ADDRESS_START = 47; m_ipaddress.SetAddress((BYTE)product_register_value[CO2_NET_MODBUS_IP_ADDRESS_START], (BYTE)product_register_value[CO2_NET_MODBUS_IP_ADDRESS_START+1], (BYTE)product_register_value[CO2_NET_MODBUS_IP_ADDRESS_START+2], (BYTE)product_register_value[CO2_NET_MODBUS_IP_ADDRESS_START+3]); int CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START = 51; m_ipaddress.ShowWindow (TRUE); m_Subnet_Mask.SetAddress((BYTE)product_register_value[CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START], (BYTE)product_register_value[CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START+1], (BYTE)product_register_value[CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START+2], (BYTE)product_register_value[CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START+3]); int CO2_NET_MODBUS_GATEWAY_ADDRESS_START = 55; m_Subnet_Mask.ShowWindow (TRUE); m_GatewayAddress.SetAddress((BYTE)product_register_value[CO2_NET_MODBUS_GATEWAY_ADDRESS_START], (BYTE)product_register_value[CO2_NET_MODBUS_GATEWAY_ADDRESS_START+1], (BYTE)product_register_value[CO2_NET_MODBUS_GATEWAY_ADDRESS_START+2], (BYTE)product_register_value[CO2_NET_MODBUS_GATEWAY_ADDRESS_START+3]); int CO2_NET_MODBUS_LISTEN_PORT_AT_TCP_SERVER_MODE_START = 60; m_GatewayAddress.ShowWindow (TRUE); strtemp.Format(_T("%d"),product_register_value[CO2_NET_MODBUS_LISTEN_PORT_AT_TCP_SERVER_MODE_START]); m_ListenPort.SetWindowText(strtemp); m_ListenPort.ShowWindow (TRUE); } else if ( product_register_value[7] == PM_TSTAT8_WIFI) { GetDlgItem(IDC_STATIC_IPTIPS)->ShowWindow(TRUE); GetDlgItem(IDC_APPLYBUTTON)->ShowWindow(TRUE); GetDlgItem(IDC_STATIC_IPMODEL)->ShowWindow(TRUE); GetDlgItem(IDC_STATIC_IPADDRESS)->ShowWindow(TRUE); GetDlgItem(IDC_STATICSUBNETMASK)->ShowWindow(TRUE); GetDlgItem(IDC_STATICGATEWAYADDRESS)->ShowWindow(TRUE); GetDlgItem(IDC_STATIC_LISTENNINGPORT)->ShowWindow(TRUE); GetDlgItem(IDC_STATICMACADDRESS)->ShowWindow(TRUE); GetDlgItem(IDC_BUTTON_WIFI_CONFIG)->ShowWindow(TRUE); GetDlgItem(IDC_STATIC_BIPPORT)->ShowWindow(FALSE); GetDlgItem(IDC_EDIT_BIPPORT)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_MAC_MSTP)->ShowWindow(FALSE); GetDlgItem(IDC_EDIT_MSTP_MAC)->ShowWindow(FALSE); CString strtemp; int CO2_NET_MODBUS_MAC_ADDRESS_START = 40; strtemp.Format(_T("%02X-%02X-%02X-%02X-%02X-%02X"), product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START], product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START + 1], product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START + 2], product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START + 3], product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START + 4], product_register_value[CO2_NET_MODBUS_MAC_ADDRESS_START + 5]); m_Edit_MacAddress.SetWindowText(strtemp); m_Edit_MacAddress.ShowWindow(TRUE); int CO2_NET_MODBUS_IP_MODE = 46; m_ip_model.SetCurSel(product_register_value[CO2_NET_MODBUS_IP_MODE]); m_ip_model.ShowWindow(TRUE); int CO2_NET_MODBUS_IP_ADDRESS_START = 47; m_ipaddress.SetAddress((BYTE)product_register_value[CO2_NET_MODBUS_IP_ADDRESS_START], (BYTE)product_register_value[CO2_NET_MODBUS_IP_ADDRESS_START + 1], (BYTE)product_register_value[CO2_NET_MODBUS_IP_ADDRESS_START + 2], (BYTE)product_register_value[CO2_NET_MODBUS_IP_ADDRESS_START + 3]); int CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START = 51; m_ipaddress.ShowWindow(TRUE); m_Subnet_Mask.SetAddress((BYTE)product_register_value[CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START], (BYTE)product_register_value[CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START + 1], (BYTE)product_register_value[CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START + 2], (BYTE)product_register_value[CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_START + 3]); int CO2_NET_MODBUS_GATEWAY_ADDRESS_START = 55; m_Subnet_Mask.ShowWindow(TRUE); m_GatewayAddress.SetAddress((BYTE)product_register_value[CO2_NET_MODBUS_GATEWAY_ADDRESS_START], (BYTE)product_register_value[CO2_NET_MODBUS_GATEWAY_ADDRESS_START + 1], (BYTE)product_register_value[CO2_NET_MODBUS_GATEWAY_ADDRESS_START + 2], (BYTE)product_register_value[CO2_NET_MODBUS_GATEWAY_ADDRESS_START + 3]); int CO2_NET_MODBUS_LISTEN_PORT_AT_TCP_SERVER_MODE_START = 60; m_GatewayAddress.ShowWindow(TRUE); strtemp.Format(_T("%d"), product_register_value[CO2_NET_MODBUS_LISTEN_PORT_AT_TCP_SERVER_MODE_START]); m_ListenPort.SetWindowText(strtemp); m_ListenPort.ShowWindow(TRUE); } else if(product_register_value[7] == PWM_TRANSDUCER) { GetDlgItem(IDC_STATIC_IPTIPS)->ShowWindow(FALSE); GetDlgItem(IDC_APPLYBUTTON)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_IPMODEL)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_IPADDRESS)->ShowWindow(FALSE); GetDlgItem(IDC_STATICSUBNETMASK)->ShowWindow(FALSE); GetDlgItem(IDC_STATICGATEWAYADDRESS)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_LISTENNINGPORT)->ShowWindow(FALSE); GetDlgItem(IDC_STATICMACADDRESS)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_BIPPORT)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_MAC_MSTP)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_MSTP_MODBUS)->ShowWindow(FALSE); m_Edit_MacAddress.ShowWindow(FALSE); m_ip_model.ShowWindow(FALSE); m_ipaddress.ShowWindow(FALSE); m_Subnet_Mask.ShowWindow(FALSE); m_GatewayAddress.ShowWindow(FALSE); m_ListenPort.ShowWindow(FALSE); m_Editor_macmstp.ShowWindow(FALSE); m_mstpmodbus_combox.ShowWindow(FALSE); m_BipPort_Edit.ShowWindow(FALSE); } else { GetDlgItem (IDC_STATIC_IPTIPS)->ShowWindow (FALSE); GetDlgItem (IDC_APPLYBUTTON)->ShowWindow (FALSE); GetDlgItem (IDC_STATIC_IPMODEL)->ShowWindow (FALSE); GetDlgItem (IDC_STATIC_IPADDRESS)->ShowWindow (FALSE); GetDlgItem (IDC_STATICSUBNETMASK)->ShowWindow (FALSE); GetDlgItem (IDC_STATICGATEWAYADDRESS)->ShowWindow (FALSE); GetDlgItem (IDC_STATIC_LISTENNINGPORT)->ShowWindow (FALSE); GetDlgItem (IDC_STATICMACADDRESS)->ShowWindow (FALSE); GetDlgItem (IDC_STATIC_AEC_ENCRYPT)->ShowWindow(FALSE); GetDlgItem (IDC_EDIT_AES_ENCRYPT)->ShowWindow(FALSE); GetDlgItem (IDC_CHECK_PASSWORD)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_ACE)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_BIPPORT)->ShowWindow(FALSE); GetDlgItem(IDC_EDIT_BIPPORT)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_MAC_MSTP)->ShowWindow(FALSE); GetDlgItem(IDC_EDIT_MSTP_MAC)->ShowWindow(FALSE); m_Edit_MacAddress.ShowWindow (FALSE); m_ip_model.ShowWindow (FALSE); m_ipaddress.ShowWindow (FALSE); m_Subnet_Mask.ShowWindow (FALSE); m_GatewayAddress.ShowWindow (FALSE); m_ListenPort.ShowWindow (FALSE); GetDlgItem(IDC_STATIC_NETWORKID)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_NETWORKID2)->ShowWindow(FALSE); GetDlgItem(IDC_STATIC_NETWORKID3)->ShowWindow(FALSE); GetDlgItem(IDC_EDIT_NETWORKID)->ShowWindow(FALSE); GetDlgItem(IDC_EDIT_NODEID)->ShowWindow(FALSE); GetDlgItem(IDC_EDIT_FREID)->ShowWindow(FALSE); } if (product_register_value[7] == PM_TSTAT5i || product_register_value[7] == PM_TSTAT6 || product_register_value[7] == PM_TSTAT7 || product_register_value[7] == PM_TSTAT8 || (product_register_value[7] == PM_TSTAT8_WIFI) || (product_register_value[7] == PM_TSTAT8_OCC) || (product_register_value[7] == PM_TSTAT7_ARM) || (product_register_value[7] == PM_TSTAT8_220V) ) { bitset<16> value109(product_register_value[109]); int sel = value109[4];//第五位 m_combox_mrd.SetCurSel(sel); } else { bitset<16> value184(product_register_value[184]); int sel = value184[4];//第五位 m_combox_mrd.SetCurSel(sel); } Read_Multi(g_tstat_id, &product_register_value[599], 599, 100); if (product_register_value[599] == 0) { m_Edit_AESPassword.EnableWindow(FALSE); GetDlgItem(IDC_CHECK_PASSWORD)->EnableWindow(FALSE); } else { m_Edit_AESPassword.EnableWindow(TRUE); m_Edit_AESPassword.SetWindowTextW(GetTextFromReg(600)+ GetTextFromReg(604)); //m_Edit_AESPassword.SetPasswordChar('*'); ((CButton *)GetDlgItem(IDC_CHECK_PASSWORD))->SetCheck(1); } strTemp.Format(_T("%d"), (int)product_register_value[608]); m_Edit_Network.SetWindowTextW(strTemp); strTemp.Format(_T("%d"), (int)product_register_value[609]); m_Edit_NodeID.SetWindowTextW(strTemp); long long Freq = ((long long)product_register_value[610]) * 65536 + ((long long)product_register_value[611]); strTemp.Format(_T("%ld HZ"), Freq); m_Edit_FrequenceID.SetWindowTextW(strTemp); if (PM_T36CTA == product_register_value[7]) { m_Edit_FrequenceID.ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_AEC_ENCRYPT)->ShowWindow(SW_SHOW); GetDlgItem(IDC_EDIT_AES_ENCRYPT)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_NETWORKID)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_NETWORKID2)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_NETWORKID3)->ShowWindow(SW_SHOW); GetDlgItem(IDC_EDIT_NETWORKID)->ShowWindow(SW_SHOW); GetDlgItem(IDC_EDIT_NODEID)->ShowWindow(SW_SHOW); GetDlgItem(IDC_EDIT_FREID)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC_ACE)->ShowWindow(SW_SHOW); } else { m_Edit_FrequenceID.ShowWindow(SW_HIDE); GetDlgItem(IDC_STATIC_AEC_ENCRYPT)->ShowWindow(SW_HIDE); GetDlgItem(IDC_EDIT_AES_ENCRYPT)->ShowWindow(SW_HIDE); GetDlgItem(IDC_STATIC_NETWORKID)->ShowWindow(SW_HIDE); GetDlgItem(IDC_STATIC_NETWORKID2)->ShowWindow(SW_HIDE); GetDlgItem(IDC_STATIC_NETWORKID3)->ShowWindow(SW_HIDE); GetDlgItem(IDC_EDIT_NETWORKID)->ShowWindow(SW_HIDE); GetDlgItem(IDC_EDIT_NODEID)->ShowWindow(SW_HIDE); GetDlgItem(IDC_EDIT_FREID)->ShowWindow(SW_HIDE); GetDlgItem(IDC_STATIC_ACE)->ShowWindow(SW_HIDE); } switch_product_last_view(); }
void WeeklyRout_InsertDia::load_grid() { m_FlexGrid.put_TextMatrix(0,1,_T("Mon")); m_FlexGrid.put_TextMatrix(0,2,_T("Tue")); m_FlexGrid.put_TextMatrix(0,3,_T("Wed")); m_FlexGrid.put_TextMatrix(0,4,_T("Thu")); m_FlexGrid.put_TextMatrix(0,5,_T("Fri")); m_FlexGrid.put_TextMatrix(0,6,_T("Sat")); m_FlexGrid.put_TextMatrix(0,7,_T("Sun")); m_FlexGrid.put_TextMatrix(0,8,_T("Holiday1")); m_FlexGrid.put_TextMatrix(0,9,_T("Holiday2")); m_FlexGrid.put_TextMatrix(1,0,_T("ON")); m_FlexGrid.put_TextMatrix(2,0,_T("OFF")); m_FlexGrid.put_TextMatrix(3,0,_T("ON")); m_FlexGrid.put_TextMatrix(4,0,_T("OFF")); m_FlexGrid.put_TextMatrix(5,0,_T("ON")); m_FlexGrid.put_TextMatrix(6,0,_T("OFF")); m_FlexGrid.put_TextMatrix(7,0,_T("ON")); m_FlexGrid.put_TextMatrix(8,0,_T("OFF")); m_FlexGrid.put_ColWidth(0,400); unsigned short p[72]={0}; memset(p,0,sizeof(p)); if (m_strtype.CompareNoCase(_T("LightingController")) == 0) Read_Multi(254,p,6488 + WR_TIME_SIZE*(m_addr-1),0x48);//由上到下,由左到右,from up to lower ,from left to right else Read_Multi(g_tstat_id,p,MODBUS_WR_ONTIME_FIRST + WR_TIME_SIZE*(m_addr-1),0x48);//由上到下,由左到右,from up to lower ,from left to right CString str; int i=0,j=0,k=0; for(i=1;i<GRID_COL_NUMBER;i++) for(j=1;j<GRID_ROW_NUMBER;j++) { if(j%2==1) { k=(i-1)*(GRID_ROW_NUMBER-1)+j-1;//1 int itemp1,itemp2; if(p[k]==255) itemp1=0; else itemp1=p[k]; if(p[k+1]==255) itemp2=0; else itemp2=p[k+1]; str.Format(_T("%d:%d"),itemp1,itemp2); inspect_input_string(j,i,str);///////////////inspect m_FlexGrid.put_TextMatrix(j,i,str); } } if (m_strtype.CompareNoCase(_T("LightingController")) == 0) Read_Multi(254,p,7928 + WR_TIME_SIZE*(m_addr-1),0x48);//由上到下,由左到右,from up to lower ,from left to right else Read_Multi(g_tstat_id,p,MODBUS_WR_OFFTIME_FIRST + WR_TIME_SIZE*(m_addr-1),0x48);//由上到下,由左到右,from up to lower ,from left to right for(i=1;i<GRID_COL_NUMBER;i++) for(j=1;j<GRID_ROW_NUMBER;j++) { if(j%2==0) { k=(i-1)*(GRID_ROW_NUMBER-1)+j-2;//2 int itemp1,itemp2; if(p[k]==255) itemp1=0; else itemp1=p[k]; if(p[k+1]==255) itemp2=0; else itemp2=p[k+1]; str.Format(_T("%d:%d"),itemp1,itemp2); inspect_input_string(j,i,str);///////////////inspect m_FlexGrid.put_TextMatrix(j,i,str); } } }
BOOL Cconfigure::OnInitDialog() { CDialog::OnInitDialog(); m_msflexgrid.put_Rows(25); //行 //set row high m_msflexgrid.put_WordWrap(TRUE); m_msflexgrid.put_RowHeight(0,500); //title middle show for (int n=0; n<=3; n++) { m_msflexgrid.put_ColAlignment(n,4); } //设置行的高度 CString str; for(int i=1; i<25; i++) { str.Format(_T("INPUT%d"),i); m_msflexgrid.put_RowHeight(i,300); m_msflexgrid.put_TextMatrix(i,0,str); m_msflexgrid.put_TextMatrix(i,1,_T("ON/OFF")); } //设置列宽 m_msflexgrid.put_ColWidth(0,1200); m_msflexgrid.put_ColWidth(1,1500); m_msflexgrid.put_ColWidth(2,1500); m_msflexgrid.put_ColWidth(3,1500); m_msflexgrid.put_TextMatrix(0,0,_T("INPUTS")); m_msflexgrid.put_TextMatrix(0,1,_T("TYPE")); m_msflexgrid.put_TextMatrix(0,2,_T("Function")); m_msflexgrid.put_TextMatrix(0,3,_T("Override Time (second)")); //读取硬件数据 //201…224 1 * 24 switch (1..24) types: 0 --- low active, 1--- high active, 2 --- falling edge active, 3 --- rising edge active //252…275 2 * 24 override time for each switch. Uint is second. 2bytes = 65536s =~18hours max. memset(m_switch,0,sizeof(m_switch)); memset(m_overridetime,0,sizeof(m_overridetime)); int flg = Read_Multi(g_tstat_id,m_switch,201,24); int flag = Read_Multi(g_tstat_id,m_overridetime,252,24); WORD itemp[24]; memcpy(itemp,m_switch,sizeof(m_switch)); CString strtemp; for (int i = 0; i<24; i++) { //TYPE itemp[i]= itemp[i]&0x0F; switch(itemp[i]) { case 0: m_msflexgrid.put_TextMatrix(i+1,1,_T("ON/OFF")); break; case 1: m_msflexgrid.put_TextMatrix(i+1,1,_T("OFF/ON")); break; case 2: m_msflexgrid.put_TextMatrix(i+1,1,_T("SW OPEN PULSE")); break; case 3: m_msflexgrid.put_TextMatrix(i+1,1,_T("SW CLOSE PULSE")); break; } //Function m_switch[i] = m_switch[i]>>4; switch(m_switch[i]) { case 0: m_msflexgrid.put_TextMatrix(i+1,2,_T("ONLY ON")); break; case 1: m_msflexgrid.put_TextMatrix(i+1,2,_T("ON&OFF")); break; } //Overridetime strtemp.Format(_T("%d"),m_overridetime[i]); m_msflexgrid.put_TextMatrix(i+1,3,strtemp); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CBatchSNDlg::OnBnClickedCalibrationPointReport() { CString Product_Head_File_Name; CString strFilter; CString strFilename; CString strTemp; CString RegisterName; CString RegisterID; CString logstr; _variant_t temp_variant; _Application app; Workbooks books; _Workbook book; Worksheets sheets; _Worksheet sheet; Range range; Range rgMyRge1, rgMyRge2; COleVariant covTrue((short)TRUE), covFalse((short)FALSE), covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR); int CurrentRow; if (!app.CreateDispatch(_T("Excel.Application"),NULL)) { AfxMessageBox(_T("Create Excel false!")); return; } //遍历所有行 strFilename=g_strExePth+_T("Calibration Sensor Report.xls"); books.AttachDispatch(app.GetWorkbooks()); book.AttachDispatch(books.Add(_variant_t(strFilename))); sheets.AttachDispatch(book.GetWorksheets()); sheet.AttachDispatch(sheets.GetItem(_variant_t("Sheet1"))); range.AttachDispatch(sheet.GetCells()); CString ContentData; CTime time = CTime::GetCurrentTime(); ContentData.Format(_T("Calibration Date")); range.SetItem(_variant_t((long)(1)),_variant_t((long)(1)),_variant_t(ContentData)); ContentData.Format(_T("%d-%d-%d"),time.GetYear(),time.GetMonth(),time.GetDay()); range.SetItem(_variant_t((long)(1)),_variant_t((long)(3)),_variant_t(ContentData)); range.AttachDispatch(sheet.GetCells()); for (int i=0;i<(int)m_modbus_IDs.size();i++) { if (!m_modbus_IDs.at(i).Result) { continue; } CurrentRow = 3 + 7*i; unsigned short databuffer[30]; Read_Multi(m_modbus_IDs.at(i).ModbusID,&databuffer[0],2000,30); ContentData = _T("Serial Number"); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(1)),_variant_t(ContentData)); ContentData.Format(_T("%d"),databuffer[2027 - 2000]); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(2)),_variant_t(ContentData)); ContentData = _T("Points"); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(3)),_variant_t(ContentData)); ContentData.Format(_T("%d"),databuffer[2003 - 2000]); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(4)),_variant_t(ContentData)); ++CurrentRow; ContentData = _T("Temperature"); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(1)),_variant_t(ContentData)); ContentData.Format(_T("%0.1f"),((float)((short)databuffer[2000 - 2000]))/10); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(2)),_variant_t(ContentData)); ContentData = _T("Humidity"); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(3)),_variant_t(ContentData)); ContentData.Format(_T("%0.1f"),((float)((short)databuffer[2001 - 2000]))/10); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(4)),_variant_t(ContentData)); ++CurrentRow; ContentData = _T("RH"); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(1)),_variant_t(ContentData)); for (int j = 0;j<10;j++) { ContentData.Format(_T("%0.1f"),((float)((short)databuffer[2004 - 2000 + 2*j]))/10); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(2+j)),_variant_t(ContentData)); } ++CurrentRow; ContentData = _T("Frequency"); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(1)),_variant_t(ContentData)); for (int j = 0;j<10;j++) { ContentData.Format(_T("%d"),databuffer[2005 - 2000 + 2*j]); range.SetItem(_variant_t((long)(CurrentRow)),_variant_t((long)(2+j)),_variant_t(ContentData)); } } AfxMessageBox(_T("Export Completely")); app.SetVisible(true); range.ReleaseDispatch(); sheet.ReleaseDispatch(); sheets.ReleaseDispatch(); book.ReleaseDispatch(); books.ReleaseDispatch(); app.ReleaseDispatch(); }
void Timer_Calibrate::OnTimer(UINT nIDEvent) { UpdateData(true); Read_Multi(g_tstat_id,machine_time,200,8,3); if(machine_time[1]<10) m_machine_time.Format(_T(" %d/%d/%d0%d %d:%d:%d"),machine_time[2],machine_time[4],machine_time[0],machine_time[1],machine_time[5],machine_time[6],machine_time[7]); else m_machine_time.Format(_T(" %d/%d/%d%d %d:%d:%d"),machine_time[2],machine_time[4],machine_time[0],machine_time[1],machine_time[5],machine_time[6],machine_time[7]); if(machine_time[5]>12) m_machine_time+=_T(" PM"); else m_machine_time+=_T(" AM"); if(had_select==false) m_NCDateCtrl.SetDate(machine_time[0]*100+machine_time[1],machine_time[2],machine_time[4]); m_NCTimeCtrl.SetTime(machine_time[5],machine_time[6],machine_time[7]); m_time_time=m_time_time.GetCurrentTime(); TIME_ZONE_INFORMATION temp; GetTimeZoneInformation(&temp); m_time_zone_str=temp.StandardName; int i_temp=read_one(g_tstat_id,11); if(temp.Bias>0) { m_time_zone=_T("-"); CString t; t.Format(_T("%d"),temp.Bias/60); m_time_zone=m_time_zone+t; if(i_temp==255) { m_building_time_zone.SetCurSel(12-temp.Bias/60); write_one(g_tstat_id,11,short(12-temp.Bias/60)); } else if(i_temp>=0) m_building_time_zone.SetCurSel(i_temp); } else { m_time_zone=_T("+"); CString t; t.Format(_T("%d"),temp.Bias/-60); m_time_zone=m_time_zone+t; if(i_temp==255) { m_building_time_zone.SetCurSel(12-temp.Bias/60); write_one(g_tstat_id,11,(short)(12-temp.Bias/60)); } else if(i_temp>=0) m_building_time_zone.SetCurSel(i_temp); } UpdateData(false); /* m_time_time=m_time_time.GetCurrentTime(); UpdateData(false); */ CDialog::OnTimer(nIDEvent); }
void CARDDlg::OnBnClickedOk() { CString ip; CString strport; m_ipaddress.GetWindowText(ip); m_porteditor.GetWindowText(strport); if (ip.IsEmpty()||strport.IsEmpty()) { AfxMessageBox(_T("ip or port can not be empty!")); return; } short port=_wtoi(strport); SetCommunicationType(1); BOOL is_open=Open_Socket2(ip,port); if (is_open) { //unsigned short data[2]; //int ModelID=Read_Multi(209,data,6,2);// (255,6,20); //CString show; //show.Format(_T("Add=%d,Model=%d"),data[0],data[1]); //ModelID=read_one(data[0],7); //AfxMessageBox(show); //show.Format(_T("Model=%d"),ModelID); //AfxMessageBox(show); unsigned short Data[10]; int ret=Read_Multi(255,Data,0,10); if (ret<0) { AfxMessageBox(_T("Can't get the information of your device!\n Please try again.")); ret; } CString strSql; CString strMainBuildName,strSubBuildingName,strSID,strFloorName,strRoomName,strProID; CString strProName,strProType,strScreenID,strBaudrate,strGraphicID,strHdVersion,strStVersion,strCom,strEPSize; /* CString temp_str=_T("select * from Building where Default_SubBuilding=-1"); m_pRs->Open(_variant_t(temp_str),_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText); int recordcount=m_pRs->GetRecordCount(); if(m_pRs->GetRecordCount()<=0) { AfxMessageBox(_T("There is no default building,please select a building First.")); return; } if(m_pRs->State) m_pRs->Close(); if(m_pCon->State) m_pCon->Close();*/ CMainFrame* pFrame=(CMainFrame*)(AfxGetApp()->m_pMainWnd); strMainBuildName= pFrame->m_strCurMainBuildingName; strSubBuildingName= pFrame->m_strCurSubBuldingName; int SN=Data[3]*256*256*256+Data[2]*256*256+Data[1]*256+Data[0]; strSID.Format(_T("%d"),SN); strFloorName=_T("floor1"); strRoomName=_T("room1"); strProName.Format(_T("%s:%d--%d"),GetProductName(Data[7]).GetBuffer(),SN,Data[6]); strProType.Format(_T("%d"),Data[7]); strProID.Format(_T("%d"),Data[6]); strScreenID.Format(_T("Screen(S:%d--%d)"),SN,Data[6]); m_ipaddress.GetWindowText(strBaudrate); strGraphicID=_T("Clicking here to add a image..."); strHdVersion=_T("0.0"); strStVersion=_T("0.0"); m_porteditor.GetWindowText(strCom); strEPSize=_T("0.0"); try { CADO ado; ado.OnInitADOConn(); strSql.Format(_T("Select * from ALL_NODE where Product_name='%s'"),strProName.GetBuffer()); ado.m_pRecordset=ado.OpenRecordset(strSql); if (!ado.m_pRecordset->EndOfFile)//有表但是没有对应序列号的值 { AfxMessageBox(_T("Already Exists!")); return; //ado.m_pRecordset->Close(); } strSql.Format(_T("insert into ALL_NODE (MainBuilding_Name,Building_Name,Serial_ID,Floor_name,Room_name,Product_name,Product_class_ID,Product_ID,Screen_Name,Bautrate,Background_imgID,Hardware_Ver,Software_Ver,Com_Port,EPsize) values('" +strMainBuildName+"','" +strSubBuildingName +"','" +strSID+"','" +strFloorName+"','" +strRoomName+"','" +strProName+"','" +strProType+"','" +strProID+"','" +strScreenID+"','" +strBaudrate+"','" +strGraphicID+"','" +strHdVersion+"','" +strStVersion+"','" +strCom+"','" +strEPSize+"')")); ado.m_pRecordset=ado.OpenRecordset(strSql); ado.CloseConn(); AfxMessageBox(_T("Add OK!")); CDialogEx::OnOK(); } catch (CException* e) { AfxMessageBox(_T("Add Fail!")); } } else { AfxMessageBox(_T("Can not Connect")); } }
BOOL Cconfigure::OnInitDialog() { CDialog::OnInitDialog(); unsigned short Data[4]; Read_Multi(g_tstat_id,Data,0,4); m_sn=Data[0]+Data[1]*256+Data[2]*256*256+Data[3]*256*256*256; m_msflexgrid.put_Rows(25); //行 //set row high m_msflexgrid.put_WordWrap(TRUE); m_msflexgrid.put_RowHeight(0,500); //title middle show for (int n=0;n<=3;n++) { m_msflexgrid.put_ColAlignment(n,4); } //设置行的高度 CString str; for(int i=1;i<25;i++) { str=Get_Table_Name(m_sn,_T("Input"),i); m_msflexgrid.put_RowHeight(i,300); m_msflexgrid.put_TextMatrix(i,0,str); m_msflexgrid.put_TextMatrix(i,1,_T("ON/OFF")); } m_msflexgrid.put_Cols(6); //设置列宽 m_msflexgrid.put_ColWidth(0,1200); m_msflexgrid.put_ColWidth(1,1500); m_msflexgrid.put_ColWidth(2,1500); m_msflexgrid.put_ColWidth(3,1500); m_msflexgrid.put_TextMatrix(0,0,_T("INPUTS")); m_msflexgrid.put_TextMatrix(0,1,_T("TYPE")); m_msflexgrid.put_TextMatrix(0,2,_T("Function")); m_msflexgrid.put_TextMatrix(0,3,_T("Override Time(s)")); m_msflexgrid.put_TextMatrix(0,4,_T("Manual Block")); m_msflexgrid.put_TextMatrix(0,5,_T("Delay Time(s)")); //读取硬件数据 //201…224 1 * 24 switch (1..24) types: 0 --- low active, 1--- high active, 2 --- falling edge active, 3 --- rising edge active //252…275 2 * 24 override time for each switch. Uint is second. 2bytes = 65536s =~18hours max. memset(m_switch,0,sizeof(m_switch)); memset(m_overridetime,0,sizeof(m_overridetime)); memset(m_MB,0,sizeof(m_MB)); memset(m_DT,0,sizeof(m_DT)); int flg = Read_Multi(g_tstat_id,m_switch,201,24); int flag = Read_Multi(g_tstat_id,m_overridetime,252,24); Read_Multi(g_tstat_id,m_MB,4172,24); Read_Multi(g_tstat_id,m_DT,14536,24); WORD itemp[24]; memcpy(itemp,m_switch,sizeof(m_switch)); CString strtemp; for (int i = 0;i<24;i++) { //TYPE itemp[i]= itemp[i]&0x0F; switch(itemp[i]) { case 1: m_msflexgrid.put_TextMatrix(i+1,1,_T("Low")); break; case 2: m_msflexgrid.put_TextMatrix(i+1,1,_T("High")); break; case 4: m_msflexgrid.put_TextMatrix(i+1,1,_T("Edge")); break; } //Function m_switch[i] = m_switch[i]>>4; switch(m_switch[i]) { case 1: m_msflexgrid.put_TextMatrix(i+1,2,_T("ONLY ON")); break; case 2: m_msflexgrid.put_TextMatrix(i+1,2,_T("ON/OFF")); break; } //Overridetime strtemp.Format(_T("%d"),m_overridetime[i]); m_msflexgrid.put_TextMatrix(i+1,3,strtemp); if (m_MB[i]==1) { strtemp=_T("ON"); } else { strtemp=_T("OFF"); } m_msflexgrid.put_TextMatrix(i+1,4,strtemp); strtemp.Format(_T("%d"),m_DT[i]); m_msflexgrid.put_TextMatrix(i+1,5,strtemp); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CNewTstatSchedulesDlg::LoadSheduleDataAndColor() { Read_Multi(g_tstat_id, m_SchduleBuffer, 813, 104, 5); for (int i=0;i<48;i++) { Schedule_Node SN; WeeklyEvent[i].Day = i / 6; if (m_SchduleBuffer[2 * i]>23|| m_SchduleBuffer[2 * i + 1]>59) { continue; } if (m_SchduleBuffer[2*i] == 0 && m_SchduleBuffer[2 * i + 1]==0) { continue; } WeeklyEvent[i].Hour = m_SchduleBuffer[2 * i]; WeeklyEvent[i].Minite = m_SchduleBuffer[2 * i + 1]; WeeklyEvent[i].Event_Number = GetEventNumber(i); SN.Hour = m_SchduleBuffer[2 * i]; SN.Minite = m_SchduleBuffer[2 * i + 1]; if (WeeklyEvent[i].Day == 0) { SN.Monday = WeeklyEvent[i].Event_Number; } else if (WeeklyEvent[i].Day == 1) { SN.Tuesday = WeeklyEvent[i].Event_Number; } else if (WeeklyEvent[i].Day == 2) { SN.Wednesday = WeeklyEvent[i].Event_Number; } else if (WeeklyEvent[i].Day == 3) { SN.Thursday = WeeklyEvent[i].Event_Number; } else if (WeeklyEvent[i].Day == 4) { SN.Friday = WeeklyEvent[i].Event_Number; } else if (WeeklyEvent[i].Day == 5) { SN.Saturday = WeeklyEvent[i].Event_Number; } else if (WeeklyEvent[i].Day == 6) { SN.Sunday = WeeklyEvent[i].Event_Number; } else if (WeeklyEvent[i].Day == 7) { SN.Holiday = WeeklyEvent[i].Event_Number; } InsertAndUpdate_Schdule(SN); } m_ScheduleList.sort(); list<Schedule_Node>::iterator it; int index = 0; for (it = m_ScheduleList.begin(); it != m_ScheduleList.end(); ++it) { it->Col_Monday = m_COLScheduleMode[it->Monday]; if (it->Monday == 0 && index != 0) { COLORREF PreviousScheduleColor = GetItemColor(index - 1, 2); it->Col_Monday = PreviousScheduleColor; } it->Col_Tuesday = m_COLScheduleMode[it->Tuesday]; if (it->Tuesday == 0 && index != 0) { COLORREF PreviousScheduleColor = GetItemColor(index - 1, 3); it->Col_Tuesday = PreviousScheduleColor; } it->Col_Wednesday = m_COLScheduleMode[it->Wednesday]; if (it->Wednesday == 0 && index != 0) { COLORREF PreviousScheduleColor = GetItemColor(index - 1, 4); it->Col_Wednesday = PreviousScheduleColor; } it->Col_Thursday = m_COLScheduleMode[it->Thursday]; if (it->Thursday == 0 && index != 0) { COLORREF PreviousScheduleColor = GetItemColor(index - 1, 5); it->Col_Thursday = PreviousScheduleColor; } it->Col_Friday = m_COLScheduleMode[it->Friday]; if (it->Friday == 0 && index != 0) { COLORREF PreviousScheduleColor = GetItemColor(index - 1, 6); it->Col_Friday = PreviousScheduleColor; } it->Col_Saturday = m_COLScheduleMode[it->Saturday]; if (it->Saturday == 0 && index != 0) { COLORREF PreviousScheduleColor = GetItemColor(index - 1, 7); it->Col_Saturday = PreviousScheduleColor; } it->Col_Sunday = m_COLScheduleMode[it->Sunday]; if (it->Sunday == 0 && index != 0) { COLORREF PreviousScheduleColor = GetItemColor(index - 1, 8); it->Col_Sunday = PreviousScheduleColor; } it->Col_Holiday = m_COLScheduleMode[it->Holiday]; if (it->Holiday == 0 && index != 0) { COLORREF PreviousScheduleColor = GetItemColor(index - 1, 9); it->Col_Holiday = PreviousScheduleColor; } index++; } }
void Timer_Calibrate::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 //OnOK(); KILLTIMER; had_select=false; UpdateData(true); unsigned char t_time[8]= {0}; unsigned short temp_us=0; temp_us=m_date_time.GetYear(); t_time[0]=temp_us/100; t_time[1]=temp_us%100; t_time[2]=m_date_time.GetMonth(); t_time[3]=m_date_time.GetDayOfWeek(); // if(t_time[3]==1) // t_time[3]=6; // else // t_time[3]-=2; if(t_time[3]==1) t_time[3]=7; else t_time[3]-=1; t_time[4]=m_date_time.GetDay(); t_time[5]=m_time_time.GetHour(); t_time[6]=m_time_time.GetMinute(); t_time[7]=m_time_time.GetSecond(); Write_Multi(g_tstat_id,t_time,200,8); int t=_wtoi(m_time_zone.Right(m_time_zone.GetLength()-1)); if(m_time_zone.Left(1)=="+") t+=12; else t=12-t; write_one(g_tstat_id,11,t); Read_Multi(g_tstat_id,machine_time,200,8,3); if(machine_time[1]<10) m_machine_time.Format(_T(" %d/%d/%d0%d %d:%d:%d"),machine_time[2],machine_time[4],machine_time[0],machine_time[1],machine_time[5],machine_time[6],machine_time[7]); else m_machine_time.Format(_T(" %d/%d/%d%d %d:%d:%d"),machine_time[2],machine_time[4],machine_time[0],machine_time[1],machine_time[5],machine_time[6],machine_time[7]); if(machine_time[5]>12) m_machine_time+=_T(" PM"); else m_machine_time+=_T(" AM"); m_NCDateCtrl.SetDate(machine_time[0]*100+machine_time[1],machine_time[2],machine_time[4]); m_NCTimeCtrl.SetTime(machine_time[5],machine_time[6],machine_time[7]); if(had_select==false) m_time_time=m_time_time.GetCurrentTime(); TIME_ZONE_INFORMATION temp; GetTimeZoneInformation(&temp); m_time_zone_str=temp.StandardName; int i_temp=read_one(g_tstat_id,11); if(temp.Bias>0) { m_time_zone=_T("-"); CString t; t.Format(_T("%d"),temp.Bias/60); m_time_zone=m_time_zone+t; if(i_temp==255) { m_building_time_zone.SetCurSel(12-temp.Bias/60); write_one(g_tstat_id,11,(short)(12-temp.Bias/60)); } else if(i_temp>=0) m_building_time_zone.SetCurSel(i_temp); } else { m_time_zone=_T("+"); CString t; t.Format(_T("%d"),temp.Bias/-60); m_time_zone=m_time_zone+t; if(i_temp==255) { m_building_time_zone.SetCurSel(12-temp.Bias/60); write_one(g_tstat_id,11,(short)(12-temp.Bias/60)); } else if(i_temp>=0) m_building_time_zone.SetCurSel(i_temp); } UpdateData(FALSE); SETTIMER; }
BOOL Timer_Calibrate::OnInitDialog() { CDialog::OnInitDialog(); m_DatetimeEdit.ShowWindow(SW_HIDE); GetDlgItem(IDC_STATIC101)->ShowWindow(SW_HIDE); // TODO: 在此添加额外的初始化 had_select=false; SETTIMER; //SetTimer(1,30000,NULL); CString strtemp; for(int i=-12; i<=13; i++) { if(i>=0) strtemp.Format(_T("(GMT+%d)"),i); else strtemp.Format(_T("(GMT%d)"),i); m_building_time_zone.AddString(strtemp); } UpdateData(true); Read_Multi(g_tstat_id,machine_time,200,8,3); //unsigned char local_time[8]; // memcpy(&local_time[0], &multi_register_value[200],8); // memcpy(&machine_time[0], &multi_register_value[200],8*sizeof(unsigned short)); if(machine_time[1]<10) m_machine_time.Format(_T(" %d/%d/%d0%d %d:%d:%d"),machine_time[2],machine_time[4],machine_time[0],machine_time[1],machine_time[5],machine_time[6],machine_time[7]); else m_machine_time.Format(_T(" %d/%d/%d%d %d:%d:%d"),machine_time[2],machine_time[4],machine_time[0],machine_time[1],machine_time[5],machine_time[6],machine_time[7]); if(machine_time[5]>12) m_machine_time+=_T(" PM"); else m_machine_time+=_T(" AM"); m_NCDateCtrl.SetDate(machine_time[0]*100+machine_time[1],machine_time[2],machine_time[4]); m_NCTimeCtrl.SetTime(machine_time[5],machine_time[6],machine_time[7]); if(had_select==false) m_time_time=m_time_time.GetCurrentTime(); TIME_ZONE_INFORMATION temp; GetTimeZoneInformation(&temp); m_time_zone_str=temp.StandardName; int i_temp=read_one(g_tstat_id,11); if(temp.Bias>0) { m_time_zone=_T("-"); CString t; t.Format(_T("%d"),temp.Bias/60); m_time_zone=m_time_zone+t; if(i_temp==255) { m_building_time_zone.SetCurSel(12-temp.Bias/60); write_one(g_tstat_id,11,short(12-temp.Bias/60)); } else if(i_temp>=0) m_building_time_zone.SetCurSel(i_temp); } else { m_time_zone=_T("+"); CString t; t.Format(_T("%d"),temp.Bias/-60); m_time_zone=m_time_zone+t; if(i_temp==255) { m_building_time_zone.SetCurSel(12-temp.Bias/60); write_one(g_tstat_id,11,short(12-temp.Bias/60)); } else if(i_temp>=0) m_building_time_zone.SetCurSel(i_temp); } UpdateData(false); SETTIMER; return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
void binarySearchforview_networkcontroller(BYTE devLo, BYTE devHi) { // had_scaned=true;////////////////////////////////////////////////had scan if(net_work_is_exist_or_not==true) Sleep(200); else Sleep(10);// int a=NetController_CheckTstatOnline(devLo,devHi); TRACE("L:%d H:%d a:%d\n",devLo,devHi,a); if(binary_search_crc(a)) return ; char c_array_temp[5]={'0'}; CString temp=""; if(a>0) { ///////****************************************************************8888888 // TRACE("L:%d H:%d\n",devLo,devHi); // TRACE("%d\n",a); /* #if 1 binary_search_result temp; temp.baudrate=m_baudrate2; temp.id=a; temp.product_class_id=read_one(a,7); get_serialnumber(temp.serialnumber,temp.id ); temp.hardware_version=read_one(temp.id ,8); m_binary_search_networkcontroller_background_thread.push_back(temp); if(read_one(a,7)==NET_WORK_CONT_PRODUCT_MODEL)//net work controller keep_back_mac_address(a); #endif */ binary_search_result temp; temp.baudrate=m_baudrate2; unsigned short SerialNum[9]; memset(SerialNum,0,sizeof(SerialNum)); int nRet=0; temp.id=a; nRet=Read_Multi(temp.id,&SerialNum[0],0,9,3); if(nRet>0) { //serial=SerialNum[0]&0x00ff+(SerialNum[0]&0xff00>>8)*256+(SerialNum[1]&0x00ff)*65536 // +(SerialNum[1]&0xff00>>8)*16777216; if(SerialNum[0]==255&&SerialNum[1]==255&&SerialNum[2]==255&&SerialNum[3]==255) { srand((unsigned)time(NULL)); SerialNum[0]=rand()%255; SerialNum[1]=rand()%255; SerialNum[2]=rand()%255; SerialNum[3]=rand()%255; write_one(temp.id,0,SerialNum[0]); write_one(temp.id,1,SerialNum[1]); write_one(temp.id,2,SerialNum[2]); write_one(temp.id,3,SerialNum[3]); } temp.serialnumber=SerialNum[0]+SerialNum[1]*256+SerialNum[2]*256*256+SerialNum[3]*256*256*256; temp.product_class_id=SerialNum[7]; temp.hardware_version=SerialNum[8]; float tstat_version2; tstat_version2=SerialNum[4];//tstat version if(tstat_version2 >=240 && tstat_version2 <250) tstat_version2 /=10; else { tstat_version2 = SerialNum[5]*256+SerialNum[4]; tstat_version2 /=10; }//tstat_version temp.software_version=tstat_version2; if(read_one(temp.id,185)==0) temp.baudrate=9600; else { temp.baudrate=19200; } temp.nEPsize=read_one(temp.id,326); if(temp.serialnumber>0) m_binary_search_networkcontroller_background_thread.push_back(temp); } } switch(a) { case -2: //crc error if(devLo!=devHi) { binarySearchforview_networkcontroller(devLo,(devLo+devHi)/2); binarySearchforview_networkcontroller((devLo+devHi)/2+1,devHi); } else binarySearchforview_networkcontroller(devLo,devHi); break; case -3: //more than 2 Tstat is connect if(devLo!=devHi) { binarySearchforview_networkcontroller(devLo,(devLo+devHi)/2); binarySearchforview_networkcontroller((devLo+devHi)/2+1,devHi); } else {//Two Tstat have the same ID,fewness do { Sleep(20);//////////////////////////////////for running is better char c_temp_arr[100]={'\0'}; if(Read_One(devLo,10)!=-2)//one times { CString str_temp; for(int j=254;j>=1;j--) if(j!=devLo) { if(!found_same_net_work_controller_by_mac(a)) { bool find=false;//false==no find;true==find for(int w=0;w<m_binary_search_product_background_thread.size();w++) if(j==m_binary_search_product_background_thread.at(w).id) { find=true; break; } if(find==false) { //************************change the Id // Sleep(20);//////////////////////////////////for running is better if(Write_One(devLo,10,j)>0)//sometimes write failure ,so inspect,important if(j<devLo) { /* #if 1 binary_search_result temp; temp.baudrate=m_baudrate2; temp.id=j; temp.product_class_id=read_one(j,7); get_serialnumber(temp.serialnumber,j); temp.hardware_version=read_one(j,8); m_binary_search_networkcontroller_background_thread.push_back(temp); if(read_one(j,7)==NET_WORK_CONT_PRODUCT_MODEL)//net work controller keep_back_mac_address(j); #endif */ binary_search_result temp; temp.baudrate=m_baudrate2; unsigned short SerialNum[9]; memset(SerialNum,0,sizeof(SerialNum)); int nRet=0; temp.id=j; nRet=Read_Multi(temp.id,&SerialNum[0],0,9,3); if(nRet>0) { //serial=SerialNum[0]&0x00ff+(SerialNum[0]&0xff00>>8)*256+(SerialNum[1]&0x00ff)*65536 // +(SerialNum[1]&0xff00>>8)*16777216; if(SerialNum[0]==255&&SerialNum[1]==255&&SerialNum[2]==255&&SerialNum[3]==255) { srand((unsigned)time(NULL)); SerialNum[0]=rand()%255; SerialNum[1]=rand()%255; SerialNum[2]=rand()%255; SerialNum[3]=rand()%255; write_one(temp.id,0,SerialNum[0]); write_one(temp.id,1,SerialNum[1]); write_one(temp.id,2,SerialNum[2]); write_one(temp.id,3,SerialNum[3]); } temp.serialnumber=SerialNum[0]+SerialNum[1]*256+SerialNum[2]*256*256+SerialNum[3]*256*256*256; temp.product_class_id=SerialNum[7]; temp.hardware_version=SerialNum[8]; float tstat_version2; tstat_version2=SerialNum[4];//tstat version if(tstat_version2 >=240 && tstat_version2 <250) tstat_version2 /=10; else { tstat_version2 = SerialNum[5]*256+SerialNum[4]; tstat_version2 /=10; }//tstat_version temp.software_version=tstat_version2; if(read_one(temp.id,185)==0) temp.baudrate=9600; else { temp.baudrate=19200; } temp.nEPsize=read_one(temp.id,326); if(temp.serialnumber>0) m_binary_search_networkcontroller_background_thread.push_back(temp); } } binarySearchforview_networkcontroller(devLo,devHi); return; } } else { return; } } } }while(1); } break; case -4:break; //no connection case -5:break; //the input error } }