SympatheticHardwareControl.Controller.TSInitialize C# (CSharp) Method

TSInitialize() public method

public TSInitialize ( double acceleration, double deceleration, double distance, double velocity ) : void
acceleration double
deceleration double
distance double
velocity double
return void
        public void TSInitialize(double acceleration, double deceleration, double distance, double velocity)
        {
            try
            {
                // limits for the safe operation of the translation stage (set values in mm/s^n units) using calibration 1 step = 5 microns, 1 rev/s = 4000 steps/s = 20mm/s
                double minDistance = 0;
                double minVelocity = 0.5; //set as 0.5mm/s = 0.025 rev/s
                double minAcc = 0.5; //set as 0.5mm/s^2 = 0.025 rev/s^2
                double maxDistance = 500; //full table travel = 600 mm
                double maxVelocity = 900; //max screw speed = 54 rev/sec = 1080 mm/s
                double maxAcc = 5000; //max acceleration = 1000 rev/s^2 = 20 m/s^2 = 20000 mm/s^2

                if (distance < minDistance || distance > maxDistance || acceleration < minAcc || acceleration > maxAcc || deceleration < minAcc || deceleration > maxAcc || velocity < minVelocity || velocity > maxVelocity)
                {
                    distance = minDistance;
                    acceleration = minAcc;
                    deceleration = minAcc;
                    velocity = minVelocity;
                    throw new ArgumentOutOfRangeException();
                }
                else
                {
                    tstage.Initialize(acceleration, deceleration, distance, velocity);
                    controlWindow.WriteToConsole("Values initialized to: \n Acceleration = " + acceleration.ToString() + " mm/s^2 \n Deceleration = " + deceleration.ToString() +
                        " mm/s^2 \n Distance = " + distance.ToString() + " mm \n Velocity = " + velocity.ToString() + " mm/s");
                }
            }
            catch (ArgumentOutOfRangeException)
            {
                MessageBox.Show("Value set is out of the calibrated range! \n Try typing something more sensible.");
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("Translation stage is not connected.\nPress Connect button before initializing.");
            }
            catch (ObjectDisposedException)
            {
                MessageBox.Show("Translation stage has been disconnected.\nPress the Connect button to reconnect.");
            }
        }