Example #1
0
void CTdaemonSimDlg::process()
{
	double SP = m_aStep[m_nCurrentStep];
	CString s;
	static time_t st;

	if (abs(m_fPV - SP) < 1.0) {		// 온도가 맞음
		if (m_bStable) {
			if (time(NULL) > st + m_nDuration) {	// duration까지 stable 구간 유지
				m_nCurrentStep++;
				if (m_nCurrentStep >= m_aStep.size()) {	
					if (m_bContinue) {				// 처음부터 다시 시작

						if (m_bGSTECH) {
							s.Format("%s789.0F\r", m_sPrefix1);	// end signal
							m_cli.send(s);

							m_fPV = 25.0;
							s.Format("%s456.0F\r", m_sPrefix1);	// start signal
							m_cli.send(s);
						}

						m_nCurrentStep = 0;
						return;
					}
					else {
						OnBnClickedButtonStart();	// click stop
					}
				}
			}
		}
		else {					// stable 구간 시작
			m_bStable = true;
			st = time(NULL);
		}
	}
	else if (m_fPV > SP) {			// 현재 온도가 설정 온도보다 큼. 온도 내림
		m_fPV -= m_fTf;
		m_bStable = false;
	}
	else if (m_fPV < SP) {			// 현재 온도가 설정 온도보다 작음. 온도 올림
		m_fPV += m_fTr;
		m_bStable = false;
	}

	// 온도에 약간의 변화를 줌.
	double tol = (rand() % 100)/ 100.0 * m_fTolerance - (m_fTolerance / 2.0);

	s.Format("%s%05.1fF\r", m_sPrefix1, m_fPV + tol);
	m_cli.send(s);

}
Example #2
0
LRESULT CDlgPanel::OnOrderRun(WPARAM wparam, LPARAM lparam)
{
	OnBnClickedButtonStart();
	return 0;
}