Esempio n. 1
0
        // ----------------------------------------------------------------------
        // Stage
        // ----------------------------------------------------------------------

        private void buttonConnect_Click(object sender, RoutedEventArgs e)
        {
            //PosX = 100.999;
            //return;

            if (m_deviceX != null)
            {
                return;
            }

            if (m_xbox != null)
            {
                FindXBoxController();
            }

            // Try to create synthetic stages (but Create will fail!)d
            //var sx = DeviceManagerCLI.RegisterSimulation(xAxisID, typeID, "X axis");
            //var sy = DeviceManagerCLI.RegisterSimulation(yAxisID, typeID, "Y axis");

            DeviceManagerCLI.BuildDeviceList();
            List <string> serialNumbers = DeviceManagerCLI.GetDeviceList(LongTravelStage.DevicePrefix);

            // X axis -------------------------------------------------------
            m_deviceX = LongTravelStage.CreateLongTravelStage(m_xAxisID);
            m_deviceX.Connect(m_xAxisID);
            var diX = m_deviceX.GetDeviceInfo();

            // wait for the device settings to initialize
            if (!m_deviceX.IsSettingsInitialized())
            {
                m_deviceX.WaitForSettingsInitialized(5000);
            }

            // start the device polling
            m_deviceX.StartPolling(250);
            m_deviceX.EnableDevice();

            // Y axis -------------------------------------------------------
            m_deviceY = LongTravelStage.CreateLongTravelStage(m_yAxisID);
            m_deviceY.Connect(m_xAxisID);
            var diY = m_deviceY.GetDeviceInfo();

            // wait for the device settings to initialize
            if (!m_deviceY.IsSettingsInitialized())
            {
                m_deviceY.WaitForSettingsInitialized(5000);
            }

            // start the device polling
            m_deviceY.StartPolling(250);
            m_deviceY.EnableDevice();

            StageInitialized = true;
        }
Esempio n. 2
0
        private void buttonDisconnect_Click(object sender, RoutedEventArgs e)
        {
            if (m_deviceX == null)
            {
                return;
            }

            m_deviceX.StopPolling();
            m_deviceX.Disconnect();
            m_deviceX = null;

            if (m_xbox != null)
            {
                m_xbox = null;
            }
            StageInitialized = false;
        }
Esempio n. 3
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            if (_longTravelStage != null)
            {
                MessageBox.Show("Device already connected");
                return;
            }

            const string serialNumber = "45848872";

            // All of this operation has been placed inside a single "catch-all"
            // exception handler. This is to reduce the size of the example code.
            // Normally you would have a try...catch per API call and catch the
            // specific exceptions that could be thrown (details of which can be
            // found in the Kinesis .NET API document).
            try
            {
                // Instructs the DeviceManager to build and maintain the list of
                // devices connected.
                DeviceManagerCLI.BuildDeviceList();

                _longTravelStage = LongTravelStage.CreateLongTravelStage(serialNumber);

                // Establish a connection with the device.
                _longTravelStage.Connect(serialNumber);

                // Wait for the device settings to initialize. We ask the device to
                // throw an exception if this takes more than 5000ms (5s) to complete.
                _longTravelStage.WaitForSettingsInitialized(5000);

                // Initialize the DeviceUnitConverter object required for real world
                // unit parameters.
                _longTravelStage.GetMotorConfiguration(serialNumber);

                // This starts polling the device at intervals of 250ms (0.25s).
                _longTravelStage.StartPolling(250);

                // We are now able to enable the device for commands.
                _longTravelStage.EnableDevice();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to connect to device\n" + ex);
            }
        }
Esempio n. 4
0
        private void buttonDisconnect_Click(object sender, EventArgs e)
        {
            if (_longTravelStage == null)
            {
                MessageBox.Show("Not connected to device");
                return;
            }

            // All of this operation has been placed inside a "catch-all" exception
            // handler. Normally you would catch the more specific exceptions that
            // the API call might throw (details of which can be found in the
            // Kinesis .NET API document).
            try
            {
                // Shuts down this device and frees any resources it is using.
                _longTravelStage.ShutDown();

                _longTravelStage = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to disconnect from device\n" + ex);
            }
        }