void Cconfigure::OnEnKillfocusEdit1()
{
	CString strText;
	m_edit.GetWindowText(strText); 
	m_edit.ShowWindow(SW_HIDE);
	if (strText.CompareNoCase(m_oldname)==0)
	{
	return;
	}
	int Value=_wtoi(strText);
	if (5==m_CurCol)
	{
		
		write_one(g_tstat_id,14535+m_CurRow,Value);  
	} 
	else
	{
	   write_one(g_tstat_id,251+m_CurRow,Value);
	}
	
	 

	  OnInitDialog(); 

}
void change_com_port_and_net_work_controller_baudrate(int new_baudrate)
{
	TRACE("%d\n",new_baudrate);
	static int now_baudrate=0;
	if(now_baudrate!=new_baudrate)
		now_baudrate=new_baudrate;
	else
		return;
	showing_text=T3000VIEW_SCAN_CHANGE_NET_WORK_BAUDRATE;//for showing 
	int baudrate=19200;
	if(new_baudrate!=19200)
		baudrate=9600;
	bool found=false;
	for(int i=0;i<m_binary_search_product_background_thread.size();i++)
	{
		if(NET_WORK_CONT_PRODUCT_MODEL==m_binary_search_product_background_thread.at(i).product_class_id)
		{
			found=true;

			//Change_BaudRate(m_binary_search_product_background_thread.at(i).baudrate);/////////change to same baudrate,so next step ,read,write
			if(baudrate==9600)
				write_one(m_binary_search_product_background_thread.at(i).id,128,0);
			else
				write_one(m_binary_search_product_background_thread.at(i).id,128,1);
			write_one(m_binary_search_product_background_thread.at(i).id,131,1);/////////save nemo
		}
	}
	Change_BaudRate(baudrate);
	if(found==true)
		Sleep(4000);//////////it 's better for next step
	else
		now_baudrate=0;///////////for no net work controller
	showing_text="";//for showing 
}
Beispiel #3
0
int set_color(int led, int intensity, int r, int g, int b) {
	uint16_t color = ((r)+((g)<<4)+((b)<<8));
	int i;
	write_begin();
	for (i=6; i; i--, (led <<= 1)) {
		if (led&(1<<5)) {
			write_one();
		} else {
			write_zero();
		}
	}
	for (i=8; i; i--, (intensity<<=1)) {
		if (intensity&(1<<7)) {
			write_one();
		} else {
			write_zero();
		}
	}
	for (i=12; i; i--, (color<<=1)) {
		if (color&(1<<11)) {
			write_one();
		} else {
			write_zero();
		}
	}
	write_end();
	return 0;
}
// Write one cv::Mat to file
bool write_one(FILE * file, const cv::Mat & data)
{
	bool okay = true;
	okay &= write_one(file, int32_t(data.rows));
	okay &= write_one(file, int32_t(data.cols));
	okay &= write_one(file, uint32_t(data.type()));

	// If matrix memory is continuous, we can reshape the matrix
	int rows = data.rows, cols = data.cols;
	if (data.isContinuous()) {
		cols = rows*cols;
		rows = 1;
	}

	// Currently only supports float/double matrices!
	assert(data.depth() == CV_32F || data.depth() == CV_64F);
	if (data.depth() == CV_32F)
		for (int r = 0; r < rows; ++r)
			okay &= write_n(file, data.ptr<float>(r), cols);
	else if (data.depth() == CV_64F)
		for (int r = 0; r < rows; ++r)
			okay &= write_n(file, data.ptr<double>(r), cols);
	else
		return false;

	return okay;
}
void CCO2_View::Check_HourTime()
{
	CTime temp_time;
	int chour,cmin,csec;
	m_co2_time_picker.GetTime(temp_time);
	chour = temp_time.GetHour();
	cmin = temp_time.GetMinute();
	csec = temp_time.GetSecond();

	if(chour != product_register_value[CO2_485_MODBUS_RTC_HOUR])
	{
		if(write_one(g_tstat_id,CO2_485_MODBUS_RTC_HOUR,chour,3)<0)
		{
			MessageBox(_T("Operate failure,Please try again"));
			return;
		}
	}

	if(cmin != product_register_value[CO2_485_MODBUS_RTC_MIN])
	{
		if(write_one(g_tstat_id,CO2_485_MODBUS_RTC_MIN,cmin,3)<0)
		{
			MessageBox(_T("Operate failure,Please try again"));
			return;
		}
	}
}
DWORD WINAPI _Batch_Flash_SN(LPVOID pParam)
{
    CBatchSNDlg* pView=(CBatchSNDlg*)(pParam);
   
    for (int i = 0;i<pView->m_modbus_IDs.size();i++)
    {
        int IntSN=pView->GetNewSerialNumber();
                write_one(pView->m_modbus_IDs.at(i).ModbusID,2026,123,5);
        int ret=write_one(pView->m_modbus_IDs.at(i).ModbusID,2027,IntSN,5);
        if (ret>0)
        {
              pView->WriteSerialNumber(IntSN);
              pView->m_modbus_IDs.at(i).SN = IntSN;
              pView->m_modbus_IDs.at(i).Result = TRUE; 
        } 
        else
        {    
             pView->m_modbus_IDs.at(i).SN = -1;
             pView->m_modbus_IDs.at(i).Result = FALSE;
        } 
        SendMessage(g_hwnd_now,WM_REFRESH_BAC_INPUT_LIST,2,i);
    }
     //PostMessage(g_hwnd_now,WM_REFRESH_BAC_INPUT_LIST,0,0);
    return 1;
}
void T3000_Default_MainView::OnEnKillfocusEditBacnetDeviceId()
{
    // TODO: 在此添加控件通知处理程序代码
    CString strText;
    GetDlgItemText(IDC_EDIT_BACNET_DEVICE_ID, strText);
    int nValue = _wtoi(strText);
    
    unsigned int temp_device_id = 0;
    temp_device_id = product_register_value[992] * 65536 + product_register_value[991];
    if (temp_device_id == nValue)	//Add this to judge weather this value need to change.
        return;

    unsigned short temp_device_low;
    unsigned short temp_device_high;
    temp_device_low = nValue % 65536;
    temp_device_high = nValue / 65536;

    int nret_1 = write_one(g_tstat_id, 991, temp_device_low, 6);

    int nret_2 = write_one(g_tstat_id, 992, temp_device_high, 6);

    if ((nret_1 >= 0) && (nret_2 >= 0))
    {
        product_register_value[991] = temp_device_low;
        product_register_value[992] = temp_device_high;
        SetPaneString(BAC_SHOW_MISSION_RESULTS, _T("Change bacnet device id success"));
    }
    else
    {
        MessageBox(_T("Change bacnet device id failed!"));
    }

}
Beispiel #8
0
stat_value Stat::add(const std::string & key, const std::string & player, stat_value value) {
	//errorstream<<"stat adding: "<<key<< " player="<<player<<" = "<< value<<std::endl;
	stat_value ret = write_one("total|" + key, value);
	write_one("day|"+ key + "|" + day , value);
	write_one("week|"+ key + "|" + week, value);
	write_one("month|"+ key + "|" + month, value);
	if (!player.empty())
		ret = write_one("player|" + key  + "|" + player, value);
	return ret;
}
void Cconfigure::OnCbnSelchangeRangecombo()
{
  int Item=m_controlcombo.GetCurSel();
  int RegValue,Value;
  if (1==m_CurCol)
  {
    RegValue=read_one(g_tstat_id,200+m_CurRow);
	if (RegValue<0)
	{
	RegValue=0;
	}
    if (0==Item)
    {
	  Value=1;
    }
	else if (1==Item)
	{
	Value=2;
	}
	else if (2==Item)
	{
	Value=4;
	}
	RegValue&=0xF0;
	RegValue+=Value;
    write_one(g_tstat_id,200+m_CurRow,RegValue);
  }
  else if (3==m_CurCol)
  {
    RegValue=read_one(g_tstat_id,200+m_CurRow);
	if (RegValue<0)
	{
		RegValue=0;
	}
	if (0==Item)
	{
		Value=16;
	}
	else if (1==Item)
	{
		Value=32;
	}
	RegValue&=0x0F;//留底位,去高位
	RegValue+=Value;//置高位
	write_one(g_tstat_id,200+m_CurRow,RegValue);


  }
  else if (4==m_CurCol)
  {
      write_one(g_tstat_id,4171+m_CurRow,Item);
  }
  OnInitDialog();
}
Beispiel #10
0
void T332AI::OnEnKillfocusEditName()
{
	CString strTemp;
	GetDlgItem(IDC_EDIT_NAME)->GetWindowText(strTemp);
	unsigned short Value=_wtoi(strTemp);
	if (strTemp.Compare(m_oldname)==0)
	{
		return;
	}
	if (m_curcol==0)
	{
		Insert_Update_Table_Name(m_sn,_T("Input"),m_currow,strTemp);
		m_msflexgrid_input.put_TextMatrix(m_currow,m_curcol,strTemp);
	}
	else if (m_curcol==2)
	{

		unsigned short regvalue=product_register_value[Range1+m_currow-1];
		if (regvalue>13)
		{
			regvalue=0;
		}
		Value=Value*Get_Unit_Process(Range_Unit_T332AI[regvalue]);

	      if (Value!= product_register_value[INPUT1+m_currow-1])
	      {
		    int ret=write_one(g_tstat_id,INPUT1+m_currow-1,Value,10);
			if (ret>0)
			{
			product_register_value[INPUT1+m_currow-1]=Value;
			InitialDialog();
			}
			else
			{
			AfxMessageBox(_T("Write Fail"));
			}
	      }
		 
	}
	else if (m_curcol==3)
	{
		int regvalue=product_register_value[Filter1+m_currow-1];
		if (Value!=regvalue)
		{
			int ret1=write_one(g_tstat_id,Filter1+m_currow-1,Value);
			if (ret1>0)
			{
				product_register_value[Filter1+m_currow-1]=Value;
				InitialDialog();
			}
		}
	}
}
void CReg_ControlDlg::OnBnClickedBtnDeviceIdWrite()
{
	// TODO: Add your control notification handler code here
	CString temp_id;
	CString temp_on_time;
	CString temp_cycle;
	int i_id;
	int i_time;
	int i_cycle;
	m_reg_id.GetWindowTextW(temp_id);
	m_reg_on_time.GetWindowTextW(temp_on_time);
	m_reg_cycle.GetWindowTextW(temp_cycle);
	i_id = _wtoi(temp_id);
	i_time = _wtoi(temp_on_time);
	i_cycle = _wtoi(temp_cycle);

	if(write_one(255,6,i_id)<0)
	{
		MessageBox(_T("дÈëʧ°Ü£¬ÇëÖØÊÔ"));
		return;
	}

	if(write_one(255,104,i_time)<0)
	{
		MessageBox(_T("дÈëʧ°Ü£¬ÇëÖØÊÔ"));
		return;
	}

	if(write_one(255,105,i_cycle)<0)
	{
		MessageBox(_T("дÈëʧ°Ü£¬ÇëÖØÊÔ"));
		return;
	}
	MessageBox(_T("дÈë³É¹¦£¡"));

	int id_read=0;
	int time_read=0;
	int cycle_read=0;
	CString temp_read_id;
	CString temp_read_time;
	CString temp_read_cycle;
	id_read=read_one(i_id,6,3);
	time_read=read_one(i_id,104,3);
	cycle_read=read_one(i_id,105,3);
	temp_read_id.Format(_T("%d"),id_read);
	temp_read_time.Format(_T("%d"),time_read);
	temp_read_cycle.Format(_T("%d"),cycle_read);
	GetDlgItem(IDC_STATIC_ID)->SetWindowText(temp_read_id);
	GetDlgItem(IDC_STATIC_TIME)->SetWindowText(temp_read_time);
	GetDlgItem(IDC_STATIC_CYCLE)->SetWindowText(temp_read_cycle);

}
void CCO2_NodeView::OnCbnSelchangeComboCo2NodeProtocol()
{
    // TODO: 在此添加控件通知处理程序代码
    CString temp_string;
    int nSel = ((CComboBox *)GetDlgItem(IDC_COMBO_CO2_NODE_PROTOCOL))->GetCurSel();
    ((CComboBox *)GetDlgItem(IDC_COMBO_CO2_NODE_PROTOCOL))->GetLBText(nSel, temp_string);
    int temp_protocol = product_register_value[21];
    for (int i = 0;i<sizeof(CO2_Node_Protocol) / sizeof(CO2_Node_Protocol[0]);i++)
    {
        if (temp_string.CompareNoCase(CO2_Node_Protocol[i]) == 0)
        {
            temp_protocol = i;
            break;
        }
    }

    int nret = write_one(g_tstat_id, 21, temp_protocol);
    if (nret <= 0)
    {
        SetPaneString(BAC_SHOW_MISSION_RESULTS, _T("Change protocol failed!"));
        PostMessage(WM_CO2_NODE_THREAD_READ, NULL, NULL);
    }
    else
    {
        SetPaneString(BAC_SHOW_MISSION_RESULTS, _T("Operation Done!"));
    }
    ((CButton *)GetDlgItem(IDC_BUTTON_OK))->SetFocus();
}
void CNetworkControllView::OnBnClickedRebootbtn()
{
	if(g_NetWorkLevel==1)
		return;
	write_one(g_tstat_id,133,1);
	// TODO: Add your control notification handler code here
}
void CRegisterWriteValueDlg::OnBnClickedOk()
{
   if (m_col==0)
   {
	   if (!m_CanWrite)
	   {
		   AfxMessageBox(_T("The register can't be written.\nBecause it is read-only."));
		   return;
	   }
	   m_valueEdit.GetWindowText(m_value);
	   int value=_wtoi(m_value);
	   int Add=_wtoi(m_no);
	   int ret=write_one(g_tstat_id,Add,value);
	   if (ret<0)
	   {
		   AfxMessageBox(_T("Write Fail"));
		   return;
	   }

	   product_register_value[Add]=value;
	   AfxMessageBox(_T("Write OK"));
   } 
   else
   {
   CADO ado;

   AfxMessageBox(_T("Save OK"));
   }
	
  
}
static bool
perform_tests(void *data)
{
    char command[128];
    int n;

    sol_memmap_add_map(&_memmap0);
    sol_memmap_add_map(&_memmap1);

    n = snprintf(command, sizeof(command), "truncate -s0 %s && truncate -s128 %s",
        _memmap0.path, _memmap0.path);
    ASSERT(n > 0 && (size_t)n < sizeof(command));

    n = system(command);
    ASSERT(!n);

    n = snprintf(command, sizeof(command), "truncate -s0 %s && truncate -s128 %s",
        _memmap1.path, _memmap1.path);
    ASSERT(n > 0 && (size_t)n < sizeof(command));

    n = system(command);
    ASSERT(!n);

    write_one();
    read_one(); /* This one should happen before actually writing data */
    sol_timeout_add(0, read_one_after_mainloop, NULL); /* This one should be after a main loop */
    sol_timeout_add(50, write_two_timeout, NULL); /* This, much after */
    sol_timeout_add(1000, read_two_after, NULL); /* Even later */

    sol_timeout_add(2000, write_cancelled_timeout, NULL);

    return false;
}
void CWriteSingleRegDlg::OnBnClickedOk()
{
	
	//CDialogEx::OnOK();
	UpdateData(TRUE);
	int ret=write_one(g_tstat_id,m_address,m_value);
	if (ret>0)
	{
	  product_register_value[m_address]=m_value;
	  AfxMessageBox(_T("Write OK"));

	} 
	else
	{
// 	 int value_ret=read_one(g_tstat_id,m_address,7);
// 	 if (value_ret==m_value)
// 	 {
// 	 multi_register_value[m_address]=m_value;
// 	 AfxMessageBox(_T("Write OK"));
// 	 	UpdateData(FALSE);
// 		return;
// 	 }
// 	 m_value=multi_register_value[m_address];
// 	 AfxMessageBox(_T("Write Fail"));
	}

}
void T3000_Default_MainView::OnEnKillfocusEditNodeid()
{
	CString strTemp;
	m_Edit_NodeID.GetWindowTextW(strTemp);
	int newid = _wtoi(strTemp);
	write_one(g_tstat_id, 609, newid);
}
void CCO2_NodeView::OnCbnSelchangeComboCo2NodeTemperatureUnit()
{
    // TODO: 在此添加控件通知处理程序代码

    CString temp_cs;
    int nSel = ((CComboBox *)GetDlgItem(IDC_COMBO_CO2_NODE_TEMPERATURE_UNIT))->GetCurSel();
    ((CComboBox *)GetDlgItem(IDC_COMBO_CO2_NODE_TEMPERATURE_UNIT))->GetLBText(nSel, temp_cs);

    int temp_value = product_register_value[125];
    if (temp_cs.CompareNoCase(_T("Deg.C")) == 0)
    {
        temp_value = 0;
    }
    else if (temp_cs.CompareNoCase(_T("Deg.F")) == 0)
    {
        temp_value = 1;
    }

    int nret = write_one(g_tstat_id, 125, temp_value);
    if (nret <= 0)
    {
        SetPaneString(BAC_SHOW_MISSION_RESULTS, _T("Change Deg.C or Deg.F failed!"));
        PostMessage(WM_CO2_NODE_THREAD_READ, NULL, NULL);
    }
    else
    {
        SetPaneString(BAC_SHOW_MISSION_RESULTS, _T("Operation Done!"));
    }

    ((CButton *)GetDlgItem(IDC_BUTTON_OK))->SetFocus();
}
void CNetworkControllView::OnBnClickedFarcallipBtn()
{
	if(g_NetWorkLevel==1)
		return;
	write_one(g_tstat_id,130,1);
	Sleep(5000);//Sleep because network controller is busy now 
}
void T38AI8AO::OnCbnSelchangeRangecombo()
{
bPauseMultiRead=TRUE;
	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[RANGE_INPUT1+lRow-1]==sel)
	{
		return;
	}
	int ret=write_one(g_tstat_id,RANGE_INPUT1+lRow-1,sel);
	if (ret>0)
	{
		product_register_value[RANGE_INPUT1+lRow-1]=sel;
	}
	else
	{
		AfxMessageBox(_T("Fail"));
	}
	InitialDialog();
	EndWaitCursor();
	bPauseMultiRead=FALSE;
}
void CFreeCoolDlg::OnBnClickedRadio1()
{
	
	CButton* pNCRadio=((CButton*)GetDlgItem(IDC_RADIO1));
	CButton* pLocalRadio=((CButton*)GetDlgItem(IDC_RADIO2));

	pNCRadio->SetCheck(BST_CHECKED);
	pLocalRadio->SetCheck(BST_UNCHECKED);



	short nValue=-1;
	nValue =read_one(g_tstat_id,350);
	if(nValue<0)
		return;
	nValue=nValue|0x2;
	//	nValue=nValue&0xFD;
	nValue =write_one(g_tstat_id,350,nValue);


	if(nValue&0x10)
	{
		//((CButton*)GetDlgItem(IDC_CHECK4))->SetCheck(BST_CHECKED);
		((CButton*)GetDlgItem(IDC_STATUSSTATIC))->SetWindowText(_T("OK"));
	}
	else
	{
		//((CButton*)GetDlgItem(IDC_CHECK4))->SetCheck(BST_UNCHECKED);
		((CButton*)GetDlgItem(IDC_STATUSSTATIC))->SetWindowText(_T("FAIL"));
	}

}
void T38AI8AO::OnCbnSelchangeBrandrate()
{   bPauseMultiRead=TRUE;
	int sel=m_brandratebombox.GetCurSel();
	if (product_register_value[BAUDRATE]!=sel)
	{
		int ret=write_one(g_tstat_id,BAUDRATE,sel);
		if (ret>0)
		{  
		 if (sel==0)
		{
		Change_BaudRate(9600);
		} 
		else
		{
		Change_BaudRate(19200);
		}
		    
			product_register_value[BAUDRATE]=sel;
			InitialDialog();
		
		}
		else
		{
		  AfxMessageBox(_T("Fail"));
		}
	} 
	 
	bPauseMultiRead=FALSE;
}
void CFreeCoolDlg::OnEnKillfocusAiredit()
{
	CString strTemp; 
	GetDlgItem(IDC_AIREDIT)->GetWindowText(strTemp);
	int nValue=_wtoi(strTemp);
	write_one(g_tstat_id,369,nValue);
	
}
Beispiel #24
0
void CZigbeeInformationDlg::OnBnClickedButtonZigbeeReboot()
{
	int ret = write_one(g_tstat_id, 34, 1);
	if (ret < 0)
	{
		AfxMessageBox(_T("Reboot it ,again"));
	}
}
void COutsidDailog::OnEnKillfocusEdit2()
{
	CString strTemp;
	GetDlgItem(IDC_EDIT2)->GetWindowText(strTemp);
	int nValue=_wtoi(strTemp);
	write_one(g_tstat_id,371,127+nValue);
	Refresh();
}
Beispiel #26
0
static void test_istream_unix_server(int fd)
{
	struct istream *input;
	const unsigned char *data;
	size_t size;

	input = i_stream_create_unix(fd, 1024);
	/* 1) simple read */
	test_server_read_nofd(input, 1);
	write_one(fd);

	/* 2) fd was sent but we won't get it */
	test_server_read_nofd(input, 2);
	/* we still shouldn't have the fd */
	fd_set_nonblock(fd, TRUE);
	i_stream_unix_set_read_fd(input);
	test_assert(i_stream_read_data(input, &data, &size, 0) == 0);
	test_assert(i_stream_unix_get_read_fd(input) == -1);
	fd_set_nonblock(fd, FALSE);
	write_one(fd);

	/* 3) the previous fd should be lost now */
	test_server_read_nofd(input, 3);
	write_one(fd);

	/* 4) we should get the fd now */
	test_server_read_fd(input, send_fd2, 4);
	write_one(fd);

	/* 5) the previous fd shouldn't be returned anymore */
	i_stream_unix_set_read_fd(input);
	test_server_read_nofd(input, 5);
	write_one(fd);

	/* 6) with i_stream_unix_unset_read_fd() we shouldn't get fd anymore */
	i_stream_unix_unset_read_fd(input);
	test_server_read_nofd(input, 6);
	write_one(fd);

	/* 7-8) two fds were sent, but we'll get only the first one */
	i_stream_unix_set_read_fd(input);
	test_server_read_fd(input, send_fd, 7);
	test_server_read_nofd(input, 8);
	write_one(fd);

	/* 9-10) two fds were sent, and we'll get them both */
	i_stream_unix_set_read_fd(input);
	test_server_read_fd(input, send_fd, 9);
	i_stream_unix_set_read_fd(input);
	test_server_read_fd(input, send_fd2, 10);
	write_one(fd);

	i_stream_destroy(&input);
	i_close_fd(&fd);
}
Beispiel #27
0
static void test_istream_unix_client(int fd)
{
	/* 1) */
	write_one(fd);
	read_one(fd);

	/* 2) */
	if (fd_send(fd, send_fd, "1", 1) < 0)
		i_fatal("fd_send() failed: %m");
	read_one(fd);

	/* 3) */
	write_one(fd);
	read_one(fd);

	/* 4) */
	if (fd_send(fd, send_fd2, "1", 1) < 0)
		i_fatal("fd_send() failed: %m");
	read_one(fd);

	/* 5) */
	write_one(fd);
	read_one(fd);

	/* 6) */
	if (fd_send(fd, send_fd, "1", 1) < 0)
		i_fatal("fd_send() failed: %m");
	read_one(fd);

	/* 7-8) */
	if (fd_send(fd, send_fd, "1", 1) < 0)
		i_fatal("fd_send() failed: %m");
	if (fd_send(fd, send_fd2, "1", 1) < 0)
		i_fatal("fd_send() failed: %m");
	read_one(fd);

	/* 9-10) */
	if (fd_send(fd, send_fd, "1", 1) < 0)
		i_fatal("fd_send() failed: %m");
	if (fd_send(fd, send_fd2, "1", 1) < 0)
		i_fatal("fd_send() failed: %m");
	read_one(fd);

	i_close_fd(&fd);
}
// Save binary IntraFace model file
bool save_binary_model_file(
		const char * fn,
		int iteration, int points,
		const cv::Mat & mean_shape, const cv::Mat & w, double wb,
		const std::vector<cv::Mat> & R, const std::vector<cv::Mat> & b)
{
	FILE * file = fopen(fn, "wb");
	if (!file) {
		fprintf(stderr, "Cannot open model file \"%s\" for writing!\n", fn);
		return false;
	}

	bool okay = true;

	okay &= write_one(file, uint32_t(iteration));
	okay &= write_one(file, uint32_t(points));

	okay &= write_one(file, mean_shape);
	okay &= write_one(file, w);
	okay &= write_one(file, wb);

	assert(R.size() == iteration);
	assert(b.size() == iteration);
	for (int i = 0; i < iteration; ++i) {
		okay &= write_one(file, R[i]);
		okay &= write_one(file, b[i]);
	}

	fclose(file);

	if (!okay)
		fprintf(stderr, "Error writing model file \"%s\"!\n", fn);

	return okay;
}
void CAirflowSettingDlg::OnEnKillfocusEditPid2offsetpoint5()
{
	CString temp;
	GetDlgItem(IDC_EDIT_PID2OFFSETPOINT5)->GetWindowText(temp);

	if (is_have_AVASensor)
	{
		int Val=(int)(_wtof(temp)*10);
		if (Val==product_register_value[MODBUS_MIN_AIRFLOW])
		{
			return;
		}
		int ret=write_one(g_tstat_id,MODBUS_MIN_AIRFLOW,Val);
		if (ret>0)
		{
			product_register_value[MODBUS_MIN_AIRFLOW]=Val;

		} 
		else
		{
			AfxMessageBox(_T("Write Fail"));
		}	
	}
	else
	{
		int Val=_wtoi(temp);
		if (Val==product_register_value[MODBUS_MIN_AIRFLOW])
		{
			return;
		}
		int ret=write_one(g_tstat_id,MODBUS_MIN_AIRFLOW,Val);
		if (ret>0)
		{
			product_register_value[MODBUS_MIN_AIRFLOW]=Val;
			 
		} 
		else
		{
			AfxMessageBox(_T("Write Fail"));
		}	
	}
	
	Fresh(); 
}
void T3000_Default_MainView::OnCbnSelchangeComboMrd()
{
	int sel = m_combox_mrd.GetCurSel();
	int write_Value = 0;
	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)
		)
	{

		if (sel == 0)
		{
			write_Value = product_register_value[109] & 0xffef;
		}
		else
		{
			write_Value = product_register_value[109] | 0x10;
		}
		int ret = write_one(g_tstat_id, 109, write_Value);
		if (ret > 0)
		{
			product_register_value[109] = write_Value;
		}
	}
	else
	{
		if (sel == 0)
		{
			write_Value = product_register_value[184] & 0xffef;
		}
		else
		{
			write_Value = product_register_value[184] | 0x10;
		}

		int ret = write_one(g_tstat_id, 184, write_Value);
		if (ret > 0)
		{
			product_register_value[184] = write_Value;
		}
	}
}