madsoft.c
来自「16 relay output channels and 16 isolated」· C语言 代码 · 共 1,682 行 · 第 1/5 页
C
1,682 行
MessageBox(hMainWnd,(LPCSTR)szErrMsg,"Driver Message",MB_OK);
DRV_DeviceClose((LONG far *)&DriverHandle);
return 0;
}
//get the max channel number
uMaxSingleChannel = DevFeatures.usMaxAISiglChl;
uMaxDiffChannel = DevFeatures.usMaxAIDiffChl;
// usMaxChannel = DevFeatures.usMaxAISiglChl;
if(DevCfg.ulChanConfig == 1)
{
usMaxChannel = uMaxDiffChannel;
}
else if ( uMaxSingleChannel > uMaxDiffChannel )
{
usMaxChannel = uMaxSingleChannel;
}
else
{
usMaxChannel = uMaxDiffChannel;
}
if (usCurrentChan > usStopChan)
usCurrentChan = usStopChan;
else if (usCurrentChan < usStartChan)
usCurrentChan = usStartChan;
SetChannel(hDlg);
SetCurrentChan(hDlg, TRUE);
// if the selected channel is associated with an expansion board,
// fill in the Exp. channel listbox with the available expansion board
// channel.
if (DevCfg.usNumExpChan > 0 && DevCfg.Daughter[usCurrentChan&0xf].dwBoardID
&& usCurrentChan != DevCfg.usCjcChannel &&
DevCfg.Daughter[usCurrentChan&0xf].dwBoardID != (DWORD)BD_PCLD8115)
SetExpChan(hDlg, TRUE);
else
SetExpChan(hDlg, FALSE);
if (DevCfg.Daughter[usCurrentChan&0xf].dwBoardID == (DWORD)BD_PCLD788)
SetBoardID(hDlg,TRUE);
else
SetBoardID(hDlg,FALSE);
// third: initialize Input Range List Combobox with device features
if ((DevFeatures.usNumGain != 0) &&
(DevCfg.Daughter[usCurrentChan&0xf].dwBoardID == 0))// &&
//(DevCfg.usCjcChannel != usCurrentChan)
SetGain(hDlg, TRUE);
else
SetGain(hDlg, FALSE);
}
// fourth: close device
DRV_DeviceClose((LONG far *)&DriverHandle);
// Initialize gain table option
if (gwGainList)
{
CheckRadioButton(hDlg, IDC_OVERALLGAIN, IDC_GAINARRAY,
IDC_GAINARRAY);
EnableWindow(GetDlgItem(hDlg, IDC_INPRANGE), FALSE);
EnableWindow(GetDlgItem(hDlg, IDC_GAINLIST), TRUE);
}
else
{
CheckRadioButton(hDlg, IDC_OVERALLGAIN, IDC_GAINARRAY,
IDC_OVERALLGAIN);
EnableWindow(GetDlgItem(hDlg, IDC_INPRANGE), TRUE);
EnableWindow(GetDlgItem(hDlg, IDC_GAINLIST), FALSE);
}
return TRUE;
case WM_COMMAND :
switch (LOWORD(wParam))
{
case IDOK :
// get device selection
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_DEVICE,
CB_GETCURSEL, 0, 0)) != CB_ERR)
gwDevice = (WORD)dwIndex;
// get sub-device selection
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_MODULE,
CB_GETCURSEL, 0, 0)) != CB_ERR)
gwSubDevice = (WORD)dwIndex;
if (DevCfg.ulChanConfig == 1) // Differential and can not combine dif and sig
{
if ( usNumChan > (DevFeatures.usMaxAIDiffChl - usStartChan) )
{
MessageBox(hDlg, "Invalidate logical channel number!", "Error!!", MB_OK);
return TRUE;
}
}
if ( usNumChan > (usMaxChannel - usStartChan))
{
MessageBox(hDlg, "Invalidate logical channel number!", "Error!!", MB_OK);
return TRUE;
}
EndDialog(hDlg, 0);
return TRUE;
case IDCANCEL :
EndDialog(hDlg, 0);
return TRUE;
case IDC_STARTCHAN :
// When device selection is changed, it needs to
// re-initialize sub-device combobox and input range
// combobox.
if (HIWORD(wParam) == CBN_SELCHANGE)
{
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_STARTCHAN,
CB_GETCURSEL, 0, 0)) != CB_ERR)
usStartChan = (WORD)dwIndex;
if (usStopChan < usStartChan)
{
usStopChan = usStartChan;
SendDlgItemMessage(hDlg, IDC_STOPCHAN, CB_SETCURSEL,
usStopChan,0L);
}
if (usCurrentChan > usStopChan)
usCurrentChan = usStopChan;
else// if (usCurrentChan < usStartChan)
usCurrentChan = usStartChan;
// setting usCurrentChan
SetCurrentChan(hDlg, TRUE);
// if the selected channel is associated with an expansion board,
// fill in the Exp. channel listbox with the available expansion board
// channel.
if (DevCfg.usNumExpChan > 0 && DevCfg.Daughter[usCurrentChan&0xf].dwBoardID
&& usCurrentChan != DevCfg.usCjcChannel &&
DevCfg.Daughter[usCurrentChan&0xf].dwBoardID != (DWORD)BD_PCLD8115)
SetExpChan(hDlg, TRUE);
else
SetExpChan(hDlg, FALSE);
if (DevCfg.Daughter[usCurrentChan&0xf].dwBoardID == (DWORD)BD_PCLD788)
SetBoardID(hDlg, TRUE);
else
SetBoardID(hDlg,FALSE);
// third: initialize Input Range List Combobox with device features
if ((DevFeatures.usNumGain != 0) &&
(DevCfg.Daughter[usCurrentChan&0xf].dwBoardID == 0))// &&
//(DevCfg.usCjcChannel != usCurrentChan)
SetGain(hDlg, TRUE);
else
SetGain(hDlg, FALSE);
}
return TRUE;
case IDC_NUMCHAN:
if (HIWORD(wParam) == EN_KILLFOCUS)
{
if(SendDlgItemMessage(hDlg, IDC_NUMCHAN,
EM_GETMODIFY, 0, 0))
{
SendDlgItemMessage(hDlg, IDC_NUMCHAN,
WM_GETTEXT, 10, (LPARAM)(LPSTR)szBuffer) ;
usNumChan = (int)atol(szBuffer);
usStopChan = usStartChan + usNumChan - 1;
SendDlgItemMessage(hDlg, IDC_NUMCHAN,
EM_SETMODIFY, FALSE, 0) ;
}
if (usCurrentChan > usStopChan)
usCurrentChan = usStopChan;
else if (usCurrentChan < usStartChan)
usCurrentChan = usStartChan;
// setting usCurrentChan
SetCurrentChan(hDlg, TRUE);
// if the selected channel is associated with an expansion board,
// fill in the Exp. channel listbox with the available expansion board
// channel.
if (DevCfg.usNumExpChan > 0 && DevCfg.Daughter[usCurrentChan&0xf].dwBoardID
&& usCurrentChan != DevCfg.usCjcChannel &&
DevCfg.Daughter[usCurrentChan&0xf].dwBoardID != (DWORD)BD_PCLD8115)
SetExpChan(hDlg, TRUE);
else
SetExpChan(hDlg, FALSE);
if (DevCfg.Daughter[usCurrentChan&0xf].dwBoardID == (DWORD)BD_PCLD788)
SetBoardID(hDlg, TRUE);
else
SetBoardID(hDlg,FALSE);
// third: initialize Input Range List Combobox with device features
if ((DevFeatures.usNumGain != 0) &&
(DevCfg.Daughter[usCurrentChan&0xf].dwBoardID == 0))// &&
//(DevCfg.usCjcChannel != usCurrentChan)
SetGain(hDlg, TRUE);
else
SetGain(hDlg, FALSE);
}
case IDC_STOPCHAN :
// When device selection is changed, it needs to
// re-initialize sub-device combobox and input range
// combobox.
if (HIWORD(wParam) == CBN_SELCHANGE)
{
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_STOPCHAN,
CB_GETCURSEL, 0, 0)) != CB_ERR)
usStopChan = (WORD)dwIndex;
if (usStopChan < usStartChan)
{
usStopChan = usStartChan;
SendDlgItemMessage(hDlg, IDC_STOPCHAN, CB_SETCURSEL,
usStopChan,0L);
}
if (usCurrentChan > usStopChan)
usCurrentChan = usStopChan;
else if (usCurrentChan < usStartChan)
usCurrentChan = usStartChan;
// setting usCurrentChan
SetCurrentChan(hDlg, TRUE);
// if the selected channel is associated with an expansion board,
// fill in the Exp. channel listbox with the available expansion board
// channel.
if (DevCfg.usNumExpChan > 0 && DevCfg.Daughter[usCurrentChan&0xf].dwBoardID
&& usCurrentChan != DevCfg.usCjcChannel &&
DevCfg.Daughter[usCurrentChan&0xf].dwBoardID != (DWORD)BD_PCLD8115)
SetExpChan(hDlg, TRUE);
else
SetExpChan(hDlg, FALSE);
if (DevCfg.Daughter[usCurrentChan&0xf].dwBoardID == (DWORD)BD_PCLD788)
SetBoardID(hDlg, TRUE);
else
SetBoardID(hDlg,FALSE);
// third: initialize Input Range List Combobox with device features
if ((DevFeatures.usNumGain != 0) &&
(DevCfg.Daughter[usCurrentChan&0xf].dwBoardID == 0))// &&
//(DevCfg.usCjcChannel != usCurrentChan)
SetGain(hDlg, TRUE);
else
SetGain(hDlg, FALSE);
}
return TRUE;
case IDC_GAINARRAY :
gwGainList = 1;
EnableWindow(GetDlgItem(hDlg, IDC_INPRANGE), FALSE);
EnableWindow(GetDlgItem(hDlg, IDC_GAINLIST), TRUE);
//sSetGain(hDlg, TRUE);
return TRUE;
case IDC_OVERALLGAIN :
gwGainList = 0;
EnableWindow(GetDlgItem(hDlg, IDC_INPRANGE), TRUE);
EnableWindow(GetDlgItem(hDlg, IDC_GAINLIST), FALSE);
//SetGain(hDlg, TRUE);
return TRUE;
case IDC_GAINLIST :
DialogBox (hInst, MAKEINTRESOURCE(IDD_GAINLIST),
hDlg, lpfnGainListDlgProc);
return TRUE;
case IDC_INPRANGE :
if (HIWORD(wParam) == CBN_SELCHANGE)
{
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_INPRANGE,
CB_GETCURSEL, 0, 0)) != CB_ERR)
gwGainIndex = (WORD)dwIndex;
}
return TRUE;
case IDC_EXPCHAN :
if (HIWORD(wParam) == CBN_SELCHANGE)
{
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_EXPCHAN,
CB_GETCURSEL, 0, 0)) != CB_ERR)
usExpChan[usCurrentChan] = (WORD)dwIndex;
}
return TRUE;
case IDC_BOARDID :
if (HIWORD(wParam) == CBN_SELCHANGE)
{
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_BOARDID,
CB_GETCURSEL, 0, 0)) != CB_ERR)
usBoardID[usCurrentChan] = (WORD)dwIndex;
}
return TRUE;
case IDC_CURRENTCHAN :
if (HIWORD(wParam) == CBN_SELCHANGE)
{
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_CURRENTCHAN,
CB_GETCURSEL, 0, 0)) != CB_ERR)
usCurrentChan = (WORD)dwIndex+ usStartChan;
else
return TRUE;
// setting usCurrentChan
SetCurrentChan(hDlg, TRUE);
// if the selected channel is associated with an expansion board,
// fill in the Exp. channel listbox with the available expansion board
// channel.
if (DevCfg.usNumExpChan > 0 && DevCfg.Daughter[usCurrentChan&0xf].dwBoardID
&& usCurrentChan != DevCfg.usCjcChannel &&
DevCfg.Daughter[usCurrentChan&0xf].dwBoardID != (DWORD)BD_PCLD8115)
SetExpChan(hDlg, TRUE);
else
SetExpChan(hDlg, FALSE);
if (DevCfg.Daughter[usCurrentChan&0xf].dwBoardID == (DWORD)BD_PCLD788)
SetBoardID(hDlg, TRUE);
else
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?