madsoft.c
来自「16 relay output channels and 16 isolated」· C语言 代码 · 共 1,682 行 · 第 1/5 页
C
1,682 行
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_DEVICE :
//
// 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_DEVICE,
CB_GETCURSEL, 0, 0)) != CB_ERR)
gwDevice = (WORD)dwIndex;
else
return TRUE;
// ------------------------------------------------------
// Initialize Module Combobox for COM port or CAN devices
// ------------------------------------------------------
// check any device attached on this COM port or CAN
gnNumOfSubdevices = DeviceList[gwDevice].nNumOfSubdevices;
if (gnNumOfSubdevices > MAX_DEVICES)
gnNumOfSubdevices = MAX_DEVICES;
// retrieve the information of all installed devices
if (gnNumOfSubdevices != 0)
{
if ((ErrCde = DRV_DeviceGetSubList(
(DWORD)DeviceList[gwDevice].dwDeviceNum,
(DEVLIST far *)&SubDeviceList[0],
(SHORT)gnNumOfSubdevices,
(SHORT far *)&nOutEntries)) != (LONG)SUCCESS)
{
DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
MessageBox(hMainWnd, (LPCSTR)szErrMsg,
"Driver Message", MB_OK);
return TRUE;
}
// initialize the Module List Combobox with the
// retrieved information
EnableWindow(GetDlgItem(hDlg, IDC_MODULE), TRUE);
SendDlgItemMessage(hDlg, IDC_MODULE, CB_RESETCONTENT,
0, (LPARAM)((LPSTR)0));
for (i = 0; i < (USHORT)gnNumOfSubdevices; i++)
SendDlgItemMessage(hDlg, IDC_MODULE, CB_ADDSTRING, 0,
(LPARAM)((LPSTR)SubDeviceList[i].szDeviceName));
gwSubDevice = 0;
SendDlgItemMessage(hDlg, IDC_MODULE, CB_SETCURSEL,
(WPARAM)gwSubDevice, (LPARAM)0);
}
else
{
EnableWindow(GetDlgItem(hDlg, IDC_MODULE), FALSE);
SendDlgItemMessage(hDlg, IDC_MODULE, CB_RESETCONTENT,
0, (LPARAM)((LPSTR)0));
}
// -------------------------------------------------
// Initialize Input Range List Combobox, it needs to
// get device features for gain list
// -------------------------------------------------
// first : Open Device
// for non COM port or CAN device
if (gnNumOfSubdevices == 0)
{
ErrCde = DRV_DeviceOpen(
DeviceList[gwDevice].dwDeviceNum,
(LONG far *)&DriverHandle);
}
// for COM port or CAN device
else
{
ErrCde = DRV_DeviceOpen(
SubDeviceList[gwSubDevice].dwDeviceNum,
(LONG far *)&DriverHandle);
}
if (ErrCde != SUCCESS)
{
strcpy(szErrMsg,"Device open error !");
MessageBox(hMainWnd, (LPCSTR)szErrMsg,
"Driver Message", MB_OK);
return 0;
}
// second: get device features
ptDevFeatures.buffer = (LPDEVFEATURES)&DevFeatures;
ptDevFeatures.size = sizeof(DEVFEATURES);
if ((ErrCde = DRV_DeviceGetFeatures(DriverHandle,
(LPT_DeviceGetFeatures)&ptDevFeatures)) != SUCCESS)
{
DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
MessageBox(hMainWnd, (LPCSTR)szErrMsg, "Driver Message",
MB_OK);
DRV_DeviceClose((LONG far *)&DriverHandle);
return 0;
}
// Have AI function support ?
if ((DevFeatures.usMaxAIDiffChl == 0) &&
(DevFeatures.usMaxAISiglChl == 0))
AllWindows(hDlg);
else
{
ptAIGetConfig.buffer = (LPDEVCONFIG_AI)&DevCfg;
ptAIGetConfig.size = sizeof(DEVCONFIG_AI);
// call AIGetConfig
if ((ErrCde = DRV_AIGetConfig(DriverHandle,
(LPT_AIGetConfig)&ptAIGetConfig)) != SUCCESS)
{
DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
MessageBox(hMainWnd,(LPCSTR)szErrMsg,"Driver Message",MB_OK);
DRV_DeviceClose((LONG far *)&DriverHandle);
return 0;
}
//mining modify 12/20/2005
if (DevCfg.ulChanConfig == 1)
{
usMaxChannel = DevFeatures.usMaxAIDiffChl;
}
else
usMaxChannel = (DevFeatures.usMaxAISiglChl >= DevFeatures.usMaxAIDiffChl)?DevFeatures.usMaxAISiglChl:DevFeatures.usMaxAIDiffChl;
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
&& (int)usCurrentChan != (int)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);
}
return TRUE;
case IDC_MODULE:
{
if (HIWORD(wParam) == CBN_SELCHANGE)
{
if ((dwIndex = SendDlgItemMessage(hDlg, IDC_MODULE,
CB_GETCURSEL, 0, 0)) != CB_ERR)
gwSubDevice = (WORD)dwIndex;
else
return TRUE;
// for non COM port or CAN device
if (gnNumOfSubdevices == 0)
{
ErrCde = DRV_DeviceOpen(
DeviceList[gwDevice].dwDeviceNum,
(LONG far *)&DriverHandle);
}
// for COM port or CAN device
else
{
ErrCde = DRV_DeviceOpen(
SubDeviceList[gwSubDevice].dwDeviceNum,
(LONG far *)&DriverHandle);
}
if (ErrCde != SUCCESS)
{
strcpy(szErrMsg,"Device open error !");
MessageBox(hMainWnd, (LPCSTR)szErrMsg,
"Driver Message", MB_OK);
return 0;
}
// second: get device features
ptDevFeatures.buffer = (LPDEVFEATURES)&DevFeatures;
ptDevFeatures.size = sizeof(DEVFEATURES);
if ((ErrCde = DRV_DeviceGetFeatures(DriverHandle,
(LPT_DeviceGetFeatures)&ptDevFeatures)) != SUCCESS)
{
DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
MessageBox(hMainWnd, (LPCSTR)szErrMsg, "Driver Message",
MB_OK);
DRV_DeviceClose((LONG far *)&DriverHandle);
return 0;
}
// Have AI function support ?
if ((DevFeatures.usMaxAIDiffChl == 0) &&
(DevFeatures.usMaxAISiglChl == 0))
AllWindows(hDlg);
else
{
ptAIGetConfig.buffer = (LPDEVCONFIG_AI)&DevCfg;
ptAIGetConfig.size = sizeof(DEVCONFIG_AI);
// call AIGetConfig
if ((ErrCde = DRV_AIGetConfig(DriverHandle,
(LPT_AIGetConfig)&ptAIGetConfig)) != SUCCESS)
{
DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
MessageBox(hMainWnd,(LPCSTR)szErrMsg,"Driver Message",MB_OK);
DRV_DeviceClose((LONG far *)&DriverHandle);
return 0;
}
//mining modify 12/20/2005
if (DevCfg.ulChanConfig == 1)
{
usMaxChannel = DevFeatures.usMaxAIDiffChl;
}
else
usMaxChannel = (DevFeatures.usMaxAISiglChl >= DevFeatures.usMaxAIDiffChl)?DevFeatures.usMaxAISiglChl:DevFeatures.usMaxAIDiffChl;
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
&& (int)usCurrentChan != (int)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);
return TRUE;
}
}
}
break;
}
return FALSE ;
}
/***************************************************************************
FUNCTION: ScanDlgProc(HWND, unsigned, WPARAM, LPARAM)
PURPOSE: Processes dialog box messages for scan time settings
****************************************************************************/
BOOL FTYPE ScanDlgProc
(
HWND hDlg, // window handle
unsigned message, // type of message
WPARAM wParam, // additional information
LPARAM lParam // additional information
)
{
char szBuffer[40];
switch (message)
{
case WM_INITDIALOG :
// ---------------------------------------------------
// Initialize Scan Time Edit, Maximum accuracy: 40 ms
// ---------------------------------------------------
itoa(gwScanTime, szBuffer, 10);
SendDlgItemMessage(hDlg, IDC_SCAN, EM_REPLACESEL, 0,
(LPARAM)((LPSTR)szBuffer));
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?