BOOL CConfigurationDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	// create available device list.
	SetControlWinText(0);
	SetControlText(3202, 2) ;
   InstantDiCtrl * instantDiCtrl = AdxInstantDiCtrlCreate();
   ICollection<DeviceTreeNode>* sptedDevices = instantDiCtrl->getSupportedDevices();

   if (sptedDevices->getCount() == 0)
   {
      GetDlgItem(IDOK)->EnableWindow(FALSE);
      GetDlgItem(IDCANCEL)->EnableWindow(FALSE);
      AfxMessageBox(_T("No device to support the currently demonstrated function!"));
      return FALSE;
   }else{
      for (int i = 0; i < sptedDevices->getCount(); ++i)
      {
         DeviceTreeNode const & node = sptedDevices->getItem(i);
         TRACE("%d, %s\n", node.DeviceNumber, node.Description);
         TCHAR des[MAX_DEVICE_DESC_LEN];
         m_comboBox_Device.AddString(WCHAR_TO_TCHAR(node.Description,des));
         m_comboBox_Device.SetItemData(i,node.DeviceNumber);
      }
      sptedDevices->Dispose();
   }
   instantDiCtrl->Dispose();
   m_comboBox_Device.SetCurSel(0);

	return TRUE;
}
Example #2
0
bool Motion::init()
{
	int cardno = 0;
	int tmp = 0;

	m_instantDiCtrl = AdxInstantDiCtrlCreate();
	m_instantDoCtrl = AdxInstantDoCtrlCreate();
	if ((m_instantDiCtrl != NULL) && (NULL != m_instantDoCtrl))
	{
		cardno++;
		isInitOK = true;

		int deviceNum = 0;
		DeviceInformation devInfo(deviceNum);

		ErrorCode errorCode = m_instantDiCtrl->setSelectedDevice(devInfo);
		if (errorCode != Success)
		{
			//CheckError(errorCode);
			return false;
		}
		m_instantDiCtrl->getSelectedDevice(devInfo);
		errorCode = m_instantDoCtrl->setSelectedDevice(devInfo);
		if (errorCode != Success)
			return false;//CheckError(errorCode);
		m_instantDoCtrl->getSelectedDevice(devInfo);

		m_IportCount = m_instantDiCtrl->getFeatures()->getPortCount();
		m_portData = new byte[m_IportCount];
		memset(m_portData, 0, m_IportCount);


		int portcount = m_instantDoCtrl->getFeatures()->getPortCount();
		errorCode = m_instantDiCtrl->setSelectedDevice(devInfo);
		if (errorCode != Success)
		{
			return false;
		}
		m_instantDiCtrl->getSelectedDevice(devInfo);
		errorCode = m_instantDoCtrl->setSelectedDevice(devInfo);
		if (errorCode != Success)
		{
			return false;
		}
		m_instantDoCtrl->getSelectedDevice(devInfo);
	}
	else
	{
		isInitOK = false;
		return false;
	}
	if (0 == cardno) return false;
	else return true;
}
Example #3
0
ReadHardware::ReadHardware(int portNum, int bitCount)
	: m_nPortNum(portNum), m_nBitCount(bitCount)
{
	bits.resize(bitCount);
	instantDiCtrl = AdxInstantDiCtrlCreate();
}