示例#1
0
        public void Disconnect()
        {
            if (_deviceHandle != Avaspec.INVALID_AVS_HANDLE_VALUE)
            {
                int l_Res = (int)Avaspec.AVS_StopMeasure((IntPtr)_deviceHandle);

                if (Avaspec.ERR_SUCCESS != l_Res)
                {
                    //MessageBox.Show("Error in AVS_StopMeasure, code: " + l_Res.ToString(), "Avantes",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Avaspec.AVS_Done();
        }
示例#2
0
        public bool Connect()
        {
            bool connected = false;

            int l_Port = Avaspec.AVS_Init(0);

            if (l_Port > 0)
            {
                uint l_Size         = 0;
                uint l_RequiredSize = 0;
                int  l_NrDevices    = 0;

                l_NrDevices = Avaspec.AVS_GetNrOfDevices();
                Avaspec.AvsIdentityType[] l_Id = new Avaspec.AvsIdentityType[l_NrDevices];
                l_RequiredSize = ((uint)l_NrDevices) * (uint)Marshal.SizeOf(typeof(Avaspec.AvsIdentityType));

                if (l_RequiredSize > 0)
                {
                    l_Size      = l_RequiredSize;
                    l_NrDevices = Avaspec.AVS_GetList(l_Size, ref l_RequiredSize, l_Id);
                    long l_hDevice = (long)Avaspec.AVS_Activate(ref l_Id[0]);
                    if (Avaspec.INVALID_AVS_HANDLE_VALUE != l_hDevice)
                    {
                        _deviceHandle = l_hDevice;
                        SerialNumber  = l_Id[0].m_SerialNumber;
                        Name          = l_Id[0].m_UserFriendlyName;
                        connected     = true;
                    }

                    if (Avaspec.AVS_UseHighResAdc((IntPtr)l_hDevice, true) != Avaspec.ERR_SUCCESS)
                    {
                        App.Current.Dispatcher.Invoke(new Action(() =>
                                                                 System.Windows.MessageBox.Show("Could not set to use 16 bit resolution", "Maximum count will be 16383")));
                    }
                }
            }

            if (!connected)
            {
                Avaspec.AVS_Done();
            }

            return(connected);
        }