コード例 #1
0
        private void ConnectDevice(string motorNO)
        {
            // unload any currently connected device if not of the desired type
            if (KDC101 != null)
            {
                if (KDC101.DeviceID == motorNO)
                {
                    return;
                }
                DisconnectDevice();
            }

            // create the new device
            KDC101 = KCubeDCServo.CreateKCubeDCServo(motorNO);

            try
            {
                KDC101.Connect(motorNO);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
                return;
            }

            // wait for settings to be initialized (on the channel)
            KDC101.WaitForSettingsInitialized(5000);

            // create user interface (WPF view) via the DeviceManager
            _contentControl.Content = KCubeDCServoUI.CreateLargeView(KDC101, DeviceConfiguration.DeviceSettingsUseOptionType.UseConfiguredSettings);
        }
コード例 #2
0
        private void DisconnectDevice()
        {
            if (KDC101 != null && KDC101.IsConnected)
            {
                KDC101.Disconnect(false);
                KDC101 = null;
            }
            // unregister devices before exit
            string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            DeviceManager.UnregisterLibrary(null, Path.Combine(path, "Thorlabs.MotionControl.KCube.DCServoUI.DLL"), "KCubeDCServoUI");
        }