Exemple #1
0
void T332AI::InitialDialog(){
	
	CString strTemp;
	strTemp.Format(_T("%d"),product_register_value[MODBUS_ID]);
	GetDlgItem(IDC_EDIT_T3ADDRESS)->SetWindowText(strTemp);
	int temp;
	temp=product_register_value[SN_LOW]+product_register_value[SN_LOW+1]*256+product_register_value[SN_HI]*256*256+product_register_value[SN_HI+1]*256*256*256;
	m_sn=temp;
	strTemp.Format(_T("%d"),temp);
	GetDlgItem(IDC_EDIT_T3SERIAL)->SetWindowText(strTemp);

	GetDlgItem(IDC_EDIT_T3MODEL)->SetWindowText(_T("T3-32AI"));
	strTemp.Format(_T("%d"),product_register_value[FIRMWARE_VER_NUMBER]);
	GetDlgItem(IDC_EDIT_T3FIRMWARE)->SetWindowText(strTemp);
	strTemp.Format(_T("%d"),product_register_value[HARDWARE_VER_NUMBER]);
	GetDlgItem(IDC_EDIT_T3HARDWARE)->SetWindowText(strTemp);
	strTemp.Format(_T("%d"),product_register_value[PIC_VER_NUMBER]);
	GetDlgItem(IDC_EDIT_T3PICVERSION)->SetWindowText(strTemp);
    strTemp.Format(_T("%d"),product_register_value[RESPONSE_DELAY]);
    GetDlgItem(IDC_EDIT_RESPONSE_DELAY)->SetWindowText(strTemp);
	// Input
	CString strresult;
	int regValue;
	for(int i = 1;i<=32;i++)
	{  
	    strresult=Get_Table_Name(m_sn,_T("Input"),i);
		m_msflexgrid_input.put_TextMatrix(i,0,strresult);
		if (0==product_register_value[Range1+i-1])
		{
			strresult=_T("RAW DATA");

		} 
		else if (1==product_register_value[Range1+i-1])
		{
			strresult=_T("10K C");
		}
		else if (2==product_register_value[Range1+i-1])
		{
			strresult=_T("10K F");
		}
		else if (3==product_register_value[Range1+i-1])
		{
			strresult=_T("0-100%");
		}
		else if (4==product_register_value[Range1+i-1])
		{
			strresult=_T("ON/OFF");
		}
		else if (5==product_register_value[Range1+i-1])
		{
			strresult=_T("OFF/ON");
		}
		else if (6==product_register_value[Range1+i-1])
		{
			strresult=_T("Pulse Input");
		}
		else if (7==product_register_value[Range1+i-1])
		{
			strresult=_T("Lighting Control");
		}
		else if (8==product_register_value[Range1+i-1])
		{
			strresult=_T("TYPE3 10K C");
		}
		else if (9==product_register_value[Range1+i-1])
		{
			strresult=_T("TYPE3 10K F");
		}
		else if (10==product_register_value[Range1+i-1])
		{
			strresult=_T("NO USE");
		}
		else if (11==product_register_value[Range1+i-1])
		{
			strresult=_T("0-5V");
		}
		else if (12==product_register_value[Range1+i-1])
		{
			strresult=_T("0-10V");
		}
		else if (13==product_register_value[Range1+i-1])
		{
			strresult=_T("0-20ma");
		}

		m_msflexgrid_input.put_TextMatrix(i,1,strresult);


		regValue=(short)product_register_value[INPUT1+i-1];
		//regValue=(short)product_register_value[INPUT1_PULSE_COUNT_LOW+2*(i-1)];

		if (0==product_register_value[Range1+i-1])
		{
			strresult.Format(_T("%d"),regValue);

		} 
		else if (1==product_register_value[Range1+i-1])
		{
			strresult.Format(_T("%.1f C"),(float)regValue/10.0);
		}
		else if (2==product_register_value[Range1+i-1])
		{
			strresult=_T("10K F");
			strresult.Format(_T("%.1f F"),(float)regValue/10.0);
		}
		else if (3==product_register_value[Range1+i-1])
		{

			strresult.Format(_T("%.1f"),(float)regValue);
			strresult+=_T("%");
		}
		else if (4==product_register_value[Range1+i-1])
		{
			//strresult.Format(_T("%.1f F"),(float)regValue/10.0);
			if (regValue==0)
			{
				strresult=_T("OFF");
			} 
			else
			{
				strresult=_T("ON");
			}
		}
		else if (5==product_register_value[Range1+i-1])
		{
			if (regValue==0)
			{
				strresult=_T("ON");
			} 
			else
			{
				strresult=_T("OFF");
			}
		}
		else if (6==product_register_value[Range1+i-1])
		{
			strresult.Format(_T("%d"),regValue);
		}
		else if (7==product_register_value[Range1+i-1])
		{
			strresult.Format(_T("%d"),regValue);
		}
		else if (8==product_register_value[Range1+i-1])
		{
			//strresult=_T("TYPE3 10K C");
			strresult.Format(_T("%0.1f C"),(float)regValue/10.0);
		}
		else if (9==product_register_value[Range1+i-1])
		{
			/*strresult=_T("TYPE3 10K F");*/
			strresult.Format(_T("%0.1f F"),(float)regValue/10.0);
		}
		else if (10==product_register_value[Range1+i-1])
		{
			strresult=_T("0");
			//strresult.Format(_T("%0.1f C"),(float)regValue/10.0);
		}
		else if (11==product_register_value[Range1+i-1])
		{
			//strresult=_T("0-5V");
			strresult.Format(_T("%0.1f V"),(float)regValue/1000.0);
		}
		else if (12==product_register_value[Range1+i-1])
		{
			//strresult=_T("0-10V");
			strresult.Format(_T("%0.1f V"),(float)regValue/1000.0);
		}
		else if (13==product_register_value[Range1+i-1])
		{
			//strresult=_T("0-20I");
			strresult.Format(_T("%0.1f ma"),(float)regValue/1000.0);
		}
		m_msflexgrid_input.put_TextMatrix(i,2,strresult);

		strresult.Format(_T("%d"),product_register_value[Filter1+i-1]);
		m_msflexgrid_input.put_TextMatrix(i,3,strresult);
	}

}
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
}