Appendix c, Digital input/output control – Lanner LEC-7110 User Manual
Page 27
27
Digital Input/Output Control
Appendix C
Embedded and Industrial Computing
CString str ;
str.Format (“COM%d”, i) ;
int nIndex = m_ComPort.InsertString (-1, (LPCSTR)
str) ;
}
m_ComPort.SelectString (0, szCOM) ;
b_ComOK = Ignition_Init ( (char*) (LPCSTR)szCOM, 9600) ;
if (b_ComOK == FALSE)
MessageBox (“Com port init fail”) ;
SetTimer (0, 100, NULL) ;
return TRUE; // return TRUE unless you set the focus to a
control
}
void CIGpin_stDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code
below
// to draw the icon. For MFC applications using the document/view
model,
// this is automatically done for you by the framework.
void CIGpin_stDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
S e n d M e s s a g e ( W M _ I C O N E R A S E B K G N D ,
reinterpret_cast
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the
user drags
// the minimized window.
HCURSOR CIGpin_stDlg::OnQueryDragIcon()
{
return static_cast
}
void CIGpin_stDlg::OnCbnSelchangeComport()
{
// TODO: Add your control notification handler code here
char szCom[16] ;
m_ComPort.GetWindowText (szCom, sizeof (szCom) ) ;
b_ComOK = Ignition_Init ( (char*) (LPCSTR)szCom, 9600) ;
//57600
if (b_ComOK == FALSE) //false = 0
MessageBox (“Com port init fail”) ;
}
void CIGpin_stDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: Add your message handler code here and/or call
default
//CDialog::OnTimer(nIDEvent);
if (nIDEvent != 0)
return ;
char szBuf[128] ;
int nDout;
//int nDout = GetIGValue (“OUTPUT_STATE”);
int nDin = GetIGValue (“INPUT_STATE”);