Exemplo n.º 1
0
        private void CreateConfigs()
        {
            // start the device polling.
            // Polling requests a status update every specified number of milliseconds.
            this.currentMotor.StartPolling(250);

            // needs a delay so that the current enabled state can be obtained
            // ????
            Thread.Sleep(500);

            // enable the channel otherwise any move is ignored
            this.currentMotor.EnableDevice();

            // needs a delay to give time for the device to be enabled
            Thread.Sleep(500);

            // call GetMotorConfiguration on the device to initialize the DeviceUnitConverter object required for real world unit parameters
            // Sets up proper unit conversion for the correct device.  Only call this function ONCE
            MotorConfiguration motorSettings = this.currentMotor.LoadMotorConfiguration(this.serialNo);

            // Simply retrieves the "motor device settings"
            KCubeDCMotorSettings currentDeviceSettings = this.currentMotor.MotorDeviceSettings as KCubeDCMotorSettings;

            // display info about device

            // Retrieves a device info block
            DeviceInfo deviceInfo = this.currentMotor.GetDeviceInfo();

            Console.WriteLine("Device {0} = {1}", deviceInfo.SerialNumber, deviceInfo.Name);

            // Getting the homing velocity
            uint homeVel = currentMotor.GetHomingVelocity_DeviceUnit();


            // After the device is opened we want to save the velocity
            // Retrieves the "velocity parameters" in real world units
            VelocityParameters_DeviceUnit velPars = this.currentMotor.GetVelocityParams_DeviceUnit();

            // Restricts the velocity allowed to be the user-defined velocity
            decimal dVelocity = this.velocity;

            velPars.MaxVelocity = (int)(homeVel);
            this.currentMotor.SetVelocityParams_DeviceUnit(velPars);
        }