BOOL CAirflowSettingDlg::OnInitDialog()
{
	  is_have_AVASensor=product_register_value[MODBUS_VAV_CONTROL]&&2;
	Fresh();
CDialogEx::OnInitDialog();
	return TRUE;
}
Exemple #2
0
/* Подпрограмма инициализации границ 3D пространства */
void Inic() {
    int i, j, k;
    for (i = 0; i <= in; i++) {
        for (j = 0; j <= jn; j++) {
            for (k = 0; k <= kn; k++) {
                if(i && j && k && i != in && j != jn && k != kn) {
                    F[0][i][j][k] = 0;
                    F[1][i][j][k] = 0;
                } else {
                    F[0][i][j][k] = Fresh(i * hx, j * hy, k * hz);
                    F[1][i][j][k] = Fresh(i * hx, j * hy, k * hz);
                }
            }
        }
    }
}
LRESULT CRegisterValueAnalyzerDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	
	if (message==MY_FRESH_DRAW_GRAPHIC)
	{
		Fresh();
	}
	return CDialogEx::WindowProc(message, wParam, lParam);
}
LRESULT CRegisterValueAnalyzerDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	// TODO: Add your specialized code here and/or call the base class
	if (message==MY_FRESH_DRAW_GRAPHIC)
	{
		Fresh();
	}
	return CDialogEx::WindowProc(message, wParam, lParam);
}
LRESULT CCO2_View::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	// TODO: Add your specialized code here and/or call the base class
	if(MsgT3000ViewFresh==message)
	{
		if(this->IsWindowVisible())	//add by Fance ,if window not visible, it's unnecessary to fresh it;
			Fresh();
	}
	return CFormView::WindowProc(message, wParam, lParam);
}
void CNetworkControllView::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: Add your message handler code here and/or call default
	CMainFrame* pMain = (CMainFrame*)AfxGetApp()->m_pMainWnd;
	CView* pNewView = pMain->m_pViews[1];
	CView* pActiveView = pMain->GetActiveView();

	if ( pNewView != pActiveView )    // current is CM5 dialog
	{
		KillTimer(1);
		return;
	}

	Fresh();
	CFormView::OnTimer(nIDEvent);
}
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(); 
}
LRESULT  CCO2_View::DealMessage(WPARAM wParam,LPARAM lParam)
{
	int command = wParam;
	switch(command)
	{
	case REFRESH_DLG:
		Fresh();
		break;
	case ENABLE_REFRESH_BUTTON:
		GetDlgItem(IDC_BTN_CO2_REFRESH)->EnableWindow(TRUE);
		break;
	case  REFRESH_FAIL:
		if(this->IsWindowVisible())
			MessageBox(_T("Refresh failure,Please try again!"));
		break;
	default:
		break;
	}

	return 0;
}
void CAirflowSettingDlg::OnEnKillfocusMinSupply()
{
	CString temp;
	GetDlgItem(IDC_MIN_SUPPLY)->GetWindowText(temp);
	int Val=(int)(_wtof(temp)*10);
	if (Val==product_register_value[MODBUS_MIN_SUPPLY_SETPOINT])
	{
		return;
	}
	int ret=write_one(g_tstat_id,MODBUS_MIN_SUPPLY_SETPOINT,Val);
	if (ret>0)
	{
		product_register_value[MODBUS_MIN_SUPPLY_SETPOINT]=Val;
		temp.Format(_T("%d"),product_register_value[MODBUS_MIN_SUPPLY_SETPOINT]);
		GetDlgItem(IDC_MIN_SUPPLY)->SetWindowText(temp);
	} 
	else
	{
		AfxMessageBox(_T("Write Fail"));
	}	
	Fresh(); 
}
void CAirflowSettingDlg::OnEnKillfocusEditPid2offsetpoint2()
{
	CString temp;
	GetDlgItem(IDC_EDIT_PID2OFFSETPOINT2)->GetWindowText(temp);
	int Val=_wtoi(temp);
	if (Val==product_register_value[MODBUS_AIRFLOW_SETPOINT])
	{
	return;
	}
	int ret=write_one(g_tstat_id,MODBUS_AIRFLOW_SETPOINT,Val);
	if (ret>0)
	{
	 product_register_value[MODBUS_AIRFLOW_SETPOINT]=Val;
	 temp.Format(_T("%d"),product_register_value[MODBUS_AIRFLOW_SETPOINT]);
	 GetDlgItem(IDC_EDIT_PID2OFFSETPOINT2)->SetWindowText(temp);
	} 
	else
	{
	AfxMessageBox(_T("Write Fail"));
	}
	Fresh();
}
//Add 20130724  by Fance
LRESULT  CCO2_View::ResumeCO2MessageCallBack(WPARAM wParam, LPARAM lParam)
{
	UINT temp_id;
	_MessageWriteOneInfo *Write_Struct_feedback =(_MessageWriteOneInfo *)lParam;
	bool msg_result=WRITE_FAIL;
	msg_result = MKBOOL(wParam);
	vector <int>::iterator Iter;
	if(msg_result)
	{
		int indexid = -1;
		for (int i=0;i<(int)Change_Color_ID.size();i++)
		{
			if(Change_Color_ID.at(i)!=Write_Struct_feedback->CTRL_ID)
				continue;
			else
				indexid = i;
		}

		if(indexid!=-1)
		{
			Iter = Change_Color_ID.begin()+indexid;
			Change_Color_ID.erase(Iter);
		}

		CString temp;
		temp.Format(_T("Change \"%s\" value from %d to %d success!"),
			Write_Struct_feedback->Changed_Name,
			Write_Struct_feedback->old_value,
			Write_Struct_feedback->new_value);
		temp_id = Write_Struct_feedback->CTRL_ID;
		SetPaneString(1,temp);
		product_register_value[Write_Struct_feedback->address]= Write_Struct_feedback->new_value;
		if(Write_Struct_feedback!=NULL)
			delete Write_Struct_feedback;
		//MessageBox(temp);
	}
	else
	{
		CString temp;
		temp.Format(_T("Change \"%s\" value from %d to %d Fail!"),
			Write_Struct_feedback->Changed_Name,
			Write_Struct_feedback->old_value,
			Write_Struct_feedback->new_value);

		temp_id = Write_Struct_feedback->CTRL_ID;
		SetPaneString(1,temp);
		Beep(10,100);
		product_register_value[Write_Struct_feedback->address]= Write_Struct_feedback->old_value;
		//GetDlgItem(Write_Struct_feedback->CTRL_ID)->SetWindowTextW(_T(""));

		int indexid = -1;
		for (int i=0;i<(int)Change_Color_ID.size();i++)
		{
			if(Change_Color_ID.at(i)!=Write_Struct_feedback->CTRL_ID)
				continue;
			else
				indexid = i;
		}
		Iter = Change_Color_ID.begin()+indexid;
		if(indexid!=-1)
		{
			Iter = Change_Color_ID.begin()+indexid;
			Change_Color_ID.erase(Iter);
		}

		if(Write_Struct_feedback!=NULL)
		{
			delete Write_Struct_feedback;
		}
	}
	Fresh();
	GetDlgItem(temp_id)->Invalidate();

	return 0;
}
Exemple #12
0
int main() {
    double X, Y, Z;
    double max, N, t1, t2;
    double owx, owy, owz, c, e;
    double Fi, Fj, Fk, F1;

    int i, j, k, mi, mj, mk;
    int R, fl, fl1, fl2;
    int it,f, L0, L1;
    long int osdt;
    struct timeval tv1, tv2;
    it = 0;
    X = 2.0;
    Y = 2.0;
    Z = 2.0;
    e = 0.00001;
    L0 = 1;
    L1 = 0;
    /* Размеры шагов */
    hx = X / in;
    hy = Y / jn;
    hz = Z / kn;

    owx = pow(hx,2);
    owy = pow(hy,2);
    owz = pow(hz,2);
    c = 2 / owx + 2 / owy + 2 / owz + a;
    gettimeofday(&tv1, NULL);
    /* Инициализация границ пространства */
    Inic();
    /* Основной итерационный цикл */
    do {
        f = 1;
        L0 = 1 - L0;
        L1 = 1 - L1;
        for (i = 1; i < in; i++) {
            for (j = 1; j < jn; j++) {
                for(k = 1; k < kn; k++) {
                    Fi = (F[L0][i+1][j][k] + F[L0][i-1][j][k]) / owx;
                    Fj = (F[L0][i][j+1][k] + F[L0][i][j-1][k]) / owy;
                    Fk = (F[L0][i][j][k+1] + F[L0][i][j][k-1]) / owz;
                    F[L1][i][j][k] = (Fi + Fj + Fk - Ro(i*hx,j*hy,k*hz)) / c;
                    if (fabs(F[L1][i][j][k] - F[L0][i][j][k]) > e)
                        f = 0;
                }
            }
        }

        it++;
    } while (!f);

    gettimeofday(&tv2, NULL);
    osdt = (tv2.tv_sec - tv1.tv_sec)*1000000 + tv2.tv_usec - tv1.tv_usec;
    printf("in = %d ; iter = %d ; E = %f ; T = %ld\n", in, it, e, osdt);

    /* Нахождение максимального расхождения полученного приближенного решения
* и точного решения */
    max = 0.0;
    for(i = 1; i < in; i++) {
        for(j = 1; j < jn; j++) {
            for(k = 1; k < kn; k++) {
                if ( (F1 = fabs(F[L1][i][j][k] - Fresh(i*hx,j*hy,k*hz))) > max ) {
                    max = F1;
                    mi = i;
                    mj = j;
                    mk = k;
                }
            }
        }
    }

    printf("Max differ = %f\n in point(%d,%d,%d)\n", max, mi, mj, mk);

    return 0;
}
void CNetworkControllView::OnEnKillfocusIdaddressEdit()
{	
	m_nSerialNum=get_serialnumber();
	CString strSerialNum;
	strSerialNum.Format(_T("%d"), m_nSerialNum);

	CString strModbusID;
	m_idEdt.GetWindowText(strModbusID);
	strModbusID.Trim();
	if(strModbusID.IsEmpty())
		return;
	int nID=_wtoi(strModbusID);
	if(nID<=0||nID>=255)
	{
	//	AfxMessageBox(_T("Please input a correct ID!"));
		return;
	}
	if(g_tstat_id==nID)
		return;
	_ConnectionPtr m_pConTmp;
	_RecordsetPtr m_pRsTemp;
	m_pConTmp.CreateInstance("ADODB.Connection");
	m_pRsTemp.CreateInstance("ADODB.Recordset");
	m_pConTmp->Open(g_strDatabasefilepath.GetString(),"","",adModeUnknown);
	
	CString strSql;
	strSql.Format(_T("select * from ALL_NODE where Product_ID ='%s'"),strModbusID);
	m_pRsTemp->Open((_variant_t)strSql,_variant_t((IDispatch *)m_pConTmp,true),adOpenStatic,adLockOptimistic,adCmdText);
	if(m_pRsTemp->GetRecordCount()>0)
	{
		while(VARIANT_FALSE==m_pRsTemp->EndOfFile)
		{			
			CString strSID=m_pRsTemp->GetCollect("Serial_ID");
			CString strPID=m_pRsTemp->GetCollect("Product_ID");
		
			if( strSID.CompareNoCase(strSerialNum)!=0 && strPID.CompareNoCase(strModbusID)==0 )
			{
				CString strPop;
				strPop.Format(_T("There is another device(Serial#=%s) has the ID ='%s', Please input a new one!"), strSID, strModbusID);
				AfxMessageBox(strPop);
				if(m_pRsTemp->State)
					m_pRsTemp->Close();		
				return;	

			}

			m_pRsTemp->MoveNext();
		}
	}

	if(m_pRsTemp->State)
		m_pRsTemp->Close();
	int nRet=0;
	nRet=write_one(g_tstat_id, 6,nID);
	if(nRet>0)
	{
		g_tstat_id=nID;
		CString strSerial;
		strSerial.Format(_T("%d"),m_nSerialNum);
		strSerial.Trim();
		strSql.Format(_T("update ALL_NODE set Product_ID ='%s' where Serial_ID ='%s'"),strModbusID,strSerial);
		m_pConTmp->Execute(strSql.GetString(),NULL,adCmdText);
	
	}
	if(m_pConTmp->State)
		m_pConTmp->Close();
	CMainFrame* pPraent=(CMainFrame*)GetParent();
	pPraent->ScanTstatInDB();
	Fresh();

}
void CNetworkControllView::OnBnClickedApplybutton()
{
	if(!CheckSettingChanged()) // if setting changed,return TRUE
	{
		return; // unchanged, don't write register
	}

	if(g_NetWorkLevel==1)
		return;
	BeginWaitCursor();
	//m_nListenPort	
	CString strText;
	m_listenPortEdit.GetWindowText(strText);
	if(!strText.IsEmpty())
		m_nListenPort=_wtoi(strText);
	if(m_nListenPort>=12767)
	{
		AfxMessageBox(_T("The listen port number is too big, please change it."));
		return;
	}
	if(m_nListenPort<=0)
	{
		AfxMessageBox(_T("The listen port number must be greater than 0!"));
		return;
	}
	write_one(g_tstat_id,120,m_nListenPort);
	BYTE address1,address2,address3,address4;
	m_ip_addressCtrl.	GetAddress(address1,address2,address3,address4);
	int n=write_one(g_tstat_id,107,address1);
	n=write_one(g_tstat_id,108,address2);
	n=write_one(g_tstat_id,109,address3);
	n=write_one(g_tstat_id,110,address4);
	m_subnet_addressCtrl.GetAddress(address1,address2,address3,address4);
	write_one(g_tstat_id,111,address1);
	write_one(g_tstat_id,112,address2);
	write_one(g_tstat_id,113,address3);
	write_one(g_tstat_id,114,address4);
	m_gateway_addressCtrl.GetAddress(address1,address2,address3,address4);
	write_one(g_tstat_id,115,address1);
	write_one(g_tstat_id,116,address2);
	write_one(g_tstat_id,117,address3);
	write_one(g_tstat_id,118,address4);
	write_one(g_tstat_id,131,1);
	Sleep(1000);//Sleep(10000); // ???
	write_one(g_tstat_id,133,1);
	Sleep(5000);	//Sleep(5000); // wait for nc restart

	CMainFrame* pPraent=(CMainFrame*)GetParent();
	//pPraent->ReFresh();

	/*
	unsigned short variable[13]={0};
	int nRet=Read_Multi(g_tstat_id,variable,106,13,3);/////////////////////////read
	m_ipModelComBox.SetCurSel(variable[0]);
	m_ip_addressCtrl.SetAddress(variable[1],variable[2],variable[3],variable[4]);
	m_subnet_addressCtrl.SetAddress(variable[5],variable[6],variable[7],variable[8]);
	m_gateway_addressCtrl.SetAddress(variable[9],variable[10],variable[11],variable[12]);

*/
	
	CString strBuilding,strSubBuilding;
	strBuilding=pPraent->m_strCurMainBuildingName;
	strSubBuilding=pPraent->m_strCurSubBuldingName;
	CString strIP,strPort;
	strPort.Format(_T("%d"),multi_register_value[120]);
	m_ip_addressCtrl.GetAddress(address1,address2,address3,address4);
	strIP.Format(_T("%d.%d.%d.%d"),address1,address2,address3,address4);
	if(g_CommunicationType==1)//TCP
	{
		int nPort;
		nPort=_wtoi(strPort);
		//m_strIP=build_info.strIp; 
		g_CommunicationType=1;
		SetCommunicationType(g_CommunicationType);
		BOOL bOk=FALSE;
		bOk=Open_Socket2(strIP,nPort);
		CString strInfo;

		strInfo.Format((_T("Open IP:%s successful")),strIP);//prompt info;
		SetPaneString(1,strInfo);
		if(bOk)
		{
			_ConnectionPtr t_pCon;//for ado connection
			t_pCon.CreateInstance(_T("ADODB.Connection"));
			t_pCon->Open(g_strDatabasefilepath.GetString(),_T(""),_T(""),adModeUnknown);
			CString strSql;
			strSql.Format(_T("update Building set Ip_Address='%s' where Ip_Address='%s'"),strIP,pPraent->m_strIP);
			t_pCon->Execute(strSql.GetString(),NULL,adCmdText);

			// 改node
			CString strSID;
			strSID.Format(_T("%d"), m_nSerialNum);
			strSql.Format(_T("update ALL_NODE set Bautrate='%s' where Serial_ID='%s'"),strIP, strSID); //bautrate 放IP
			t_pCon->Execute(strSql.GetString(),NULL,adCmdText);




			if(t_pCon->State)
				t_pCon->Close();
			pPraent->m_strIP=strIP;
			pPraent->ScanTstatInDB();

		}
		else
		{

		}



/*
		_ConnectionPtr t_pCon;//for ado connection
		t_pCon.CreateInstance(_T("ADODB.Connection"));
		t_pCon->Open(g_strDatabasefilepath.GetString(),_T(""),_T(""),adModeUnknown);
		CString strSql;
		strSql.Format(_T("update Building set Ip_Address='%s',Ip_Port='%s' where Main_BuildingName='%s' and Building_Name='%s'"),strIP,strPort,strBuilding,strSubBuilding);
		t_pCon->Execute(strSql.GetString(),NULL,adCmdText);
		if(t_pCon->State)
			t_pCon->Close();
		pPraent->OnConnect();
		*/
	}
	//write_one(g_tstat_id,131,1);
	Fresh();
	EndWaitCursor();

}