public int initialize()
        {
            int nRetVal = 0;

            try
            {
                string strChannel = _channel.ToString("00");

                // Set the motor parameters.

                HelixGenModel theModel = ((HelixGen.App)(App.Current)).Model;

                int nResult = initializeMotorParams(_channel, theModel.Config.m_R2Piston_Configuration);
                if (nResult != 0)
                {
                    // Initialization failed.

                    logger.Debug("deviceR2Piston::initialize failed.");
                }
                else
                {
                    HelixGenModel _theModel  = ((HelixGen.App)(App.Current)).Model;
                    clsAMB        controller = _theModel.getMotorBoard(_controllerId);

                    // Move the pump to the initial position.
                    //RNNosition = 89000;

                    controller.SetDirectionPolarity(strChannel, "0");
                    controller.MoveHome(strChannel);
                    controller.WaitForCompletion(strChannel);

                    /*
                     * controller.SetDirectionPolarity(strChannel, "0");
                     * controller.MoveRelativePositive(strChannel, "2580");
                     * controller.WaitForCompletion(strChannel);*/
                    /*
                     * controller.SetDirectionPolarity(strChannel, "0");
                     * controller.MoveRelativePositive(strChannel, "50064");
                     * controller.WaitForCompletion(strChannel);*/


                    controller.SetResolution(theModel.Config.m_R2Piston_Configuration.m_nMotorChannel.ToString("00"),
                                             theModel.Config.m_R2Piston_Configuration.m_uiMotorResolution.ToString());

                    // Position = 3;
                    // RNPosition = 50000;//9.9mm
                    // RNNosition = 89000;
                }
            }
            catch (Exception)
            {
                nRetVal = 1;
            }

            return(nRetVal);
        }
Exemple #2
0
        public int initialize()
        {
            int nRetVal = 0;

            try
            {
                string strChannel = _channel.ToString("00");

                // Set the motor parameters.

                HelixGenModel theModel = ((HelixGen.App)(App.Current)).Model;

                int nResult = initializeMotorParams(_channel, theModel.Config.m_ChassisPiston_Configuration);
                if (nResult != 0)
                {
                    // Initialization failed.

                    logger.Debug("deviceChassisPiston::initialize failed.");
                }
                else
                {
                    clsAMB controller = theModel.getMotorBoard(theModel.Config.m_ChassisPiston_Configuration.m_strControllerName);

                    // Move the pump to the initial position.

                    /*
                     * controller.SetDirectionPolarity(strChannel, "0");
                     * controller.MoveRelativePositive(strChannel, "2700");
                     * controller.WaitForCompletion(strChannel);*/

                    // controller.SetDirectionPolarity(strChannel, "0");
                    controller.MoveHome(strChannel);
                    controller.WaitForCompletion(strChannel);

                    /*
                     * controller.SetDirectionPolarity(strChannel, "0");
                     * controller.MoveRelativePositive(strChannel, "5000");
                     * controller.WaitForCompletion(strChannel);
                     */
                    controller.SetResolution(theModel.Config.m_ChassisPiston_Configuration.m_nMotorChannel.ToString("00"),
                                             theModel.Config.m_ChassisPiston_Configuration.m_uiMotorResolution.ToString());

                    //Position = 1;
                }
            }
            catch (Exception ex)
            {
                logger.Debug("deviceChassisPiston::initialize() Caught an exception: {0}", ex.Message);

                nRetVal = 1;
            }

            return(nRetVal);
        }
Exemple #3
0
        public void ZeroOptic()
        {
            HelixGenModel theModel = ((HelixGen.App)(App.Current)).Model;

            clsAMB controller = theModel.getMotorBoard(_controllerId);
            string strChannel = _channel.ToString("00");

            /*
             * for (int nLED = 0; nLED < 6; nLED++)
             * {
             *  theModel.OpticsModel.SetLedCurrent(nLED + 1, 0.75);
             *  //theModel.OpticsModel.SetLedCurrent(nLED + 1, 0);
             * }*/

            // theModel.DeviceOpticsMotor.Position = 5;
            controller.MoveHome(strChannel);
            controller.WaitForCompletion(strChannel);

            // double[,] allReadings = new double[6, 4];
            // double[] baselines = new double[4];
            for (int i = 0; i < 15; i++)
            {
                for (int Position = 2; Position < 6; Position++)
                {
                    theModel.DeviceOpticsMotor.Position = Position;
                    double[] readings = theModel.opticsBoard.ReadPhotodetector();
                    if (i == 14)
                    {
                        theModel.optic_zero[Position - 2] = readings[2];
                    }

                    // for (int nCartridge = 0; nCartridge < 6; nCartridge++)
                    // allReadings[nCartridge, Position - 2] = readings[nCartridge];

                    //Thread.Sleep(3000);
                }
                controller.MoveHome(strChannel);
                controller.WaitForCompletion(strChannel);
            }

            /*
             * for (int nLED = 0; nLED < 6; nLED++)
             * {
             *  theModel.OpticsModel.SetLedCurrent(nLED + 1, 0);
             *  //theModel.OpticsModel.SetLedCurrent(nLED + 1, 0);
             * }*/
            controller.MoveHome(strChannel);
            controller.WaitForCompletion(strChannel);
        }
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                _motorBoard = null;

                disposedValue = true;
            }
        }
        public int initialize1()
        {
            int nRetVal = 0;

            try
            {
                string strChannel = _channel.ToString("00");

                // Set the motor parameters.

                HelixGenModel theModel = ((HelixGen.App)(App.Current)).Model;


                HelixGenModel _theModel  = ((HelixGen.App)(App.Current)).Model;
                clsAMB        controller = _theModel.getMotorBoard(_controllerId);

                // Move the pump to the initial position.
                //RNNosition = 89000;



                controller.SetDirectionPolarity(strChannel, "0");
                controller.MoveRelativePositive(strChannel, "12080");
                controller.WaitForCompletion(strChannel);

                /*
                 * controller.SetDirectionPolarity(strChannel, "0");
                 * controller.MoveRelativePositive(strChannel, "68100");
                 * controller.WaitForCompletion(strChannel);*/


                controller.SetResolution(theModel.Config.m_R2Piston_Configuration.m_nMotorChannel.ToString("00"),
                                         theModel.Config.m_R2Piston_Configuration.m_uiMotorResolution.ToString());

                // Position = 3;
                // RNPosition = 50000;//9.9mm
                // RNNosition = 89000;
            }
            catch (Exception)
            {
                nRetVal = 1;
            }

            return(nRetVal);
        }
Exemple #6
0
        public devicePump(motorBoardModel motorBoardIn, int diochannel)
        {
            _motorBoard = motorBoardIn.board;
            _diochannel = diochannel;

            // The Motorboard value cannot be null.

            if (motorBoardIn == null)
            {
                throw new Exception("Error; devicePump::devicePump the value motorBoardIn cannot be null.");
            }

            // Check the range values on the channel argument.

            if (diochannel < 1 || diochannel > 8)
            {
                throw new Exception(string.Format("Error; devicePump::devicePump the value for diochannel ({0}) must be between 1 and 8 (inclusive).",
                                                  diochannel.ToString()));
            }
        }
Exemple #7
0
        protected int initializeMotorParams(int axis, Configuration.CSystem_MotorBoardConfigurationItem configIn)
        {
            HelixGenModel _theModel = ((HelixGen.App)(App.Current)).Model;

            clsAMB controller = _theModel.getMotorBoard(_controllerId);

            int nRetVal = 0;

            // Set the parameters for the board on this axis.

            int iaxis = axis - 1;

            controller.axisparams_current[iaxis].strStartSpeed                         = configIn.m_uiMotorStartSpeed.ToString();
            controller.axisparams_current[iaxis].strMaxSpeed                           = configIn.m_uiMotorMaxSpeed.ToString();
            controller.axisparams_current[iaxis].strAcceleration                       = configIn.m_uiMotorAccel.ToString();
            controller.axisparams_current[iaxis].strDeceleration                       = configIn.m_uiMotorDecel.ToString();
            controller.axisparams_current[iaxis].strJerk                               = configIn.m_uiMotorJerk.ToString();
            controller.axisparams_current[iaxis].strMoveCurrent                        = configIn.m_uiMotorMoveCurrent.ToString();
            controller.axisparams_current[iaxis].strHoldCurrent                        = configIn.m_uiMotorHoldCurrent.ToString();
            controller.axisparams_current[iaxis].strResolution                         = configIn.m_uiMotorResolution.ToString();
            controller.axisparams_current[iaxis].strDirectionPolarity                  = configIn.m_uiMotorDirection.ToString();
            controller.axisparams_current[iaxis].strHomeTimeout                        = configIn.m_uiMotorHomeTimeout.ToString();
            controller.axisparams_current[iaxis].strProfileMode                        = configIn.m_uiMotorProfileMode.ToString();
            controller.axisparams_current[iaxis].strEncoderPresent                     = configIn.m_bEncoderEnabled ? "1" : "0";
            controller.axisparams_current[iaxis].strEncoderEncoderMonitorTimer_ms      = configIn.m_uiEncoderMonitorTimer_ms.ToString();
            controller.axisparams_current[iaxis].strEncoderMonitorPulseChangeThreshold = configIn.m_uiEncoderMonitorPulseChangeThreshold.ToString();
            controller.axisparams_current[iaxis].strEncoderMonitorErrorCountThreshold  = configIn.m_uiEncoderMonitorErrorCountThreshold.ToString();
            controller.axisparams_current[iaxis].strEncoderDirectionPolarity           = configIn.m_uiEncoderDirectionPolarity.ToString();
            controller.axisparams_current[iaxis].strLostStepsLimit                     = configIn.m_uiMotorMaxNumLostSteps.ToString();
            controller.axisparams_current[iaxis].strEncoderStartOffset                 = configIn.m_iEncoderStartOffset.ToString();
            controller.axisparams_current[iaxis].strEncoderControllerConversionFactor  = configIn.m_fEncoderScalingFactor.ToString();

            // Kick the parameters in.

            controller.LoadParametersIntoController(axis.ToString("00"));

            return(nRetVal);
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="motorBoardIn">A reference to the corresponding motor board.</param>
        /// <param name="channel">The channel number on the motorboard.  Should be 1...4 (inclusive)</param>
        /// <param name="positions">An array of absolute positions that correspond to the pump positions.</param>
        /// <param name="npositions">The number of positions used for this pump.  Note that this should be the
        /// size of the positions array.</param>
        public devicePistonPump(clsAMB motorBoardIn, int channel, int[] positions, string controllerId)
        {
            _motorBoard   = motorBoardIn;
            _channel      = channel;
            _positions    = positions;
            _npositions   = positions.Count();
            _controllerId = controllerId;

            // The Motorboard value cannot be null.

            if (motorBoardIn == null)
            {
                throw new Exception("Error; devicePistonPump::devicePistonPump the value motorBoardIn cannot be null.");
            }

            // Check the range values on the channel argument.

            if (channel < 1 || channel > 4)
            {
                throw new Exception(string.Format("Error; devicePistonPump::devicePistonPump the value for channel ({0}) must be between 1 and 4 (inclusive).",
                                                  channel.ToString()));
            }
        }
Exemple #9
0
        public int initialize()
        {
            int nRetVal = 0;

            try
            {
                string strChannel = _channel.ToString("00");


                // Set the motor parameters.

                HelixGenModel theModel = ((HelixGen.App)(App.Current)).Model;

                int nResult = initializeMotorParams(_channel, theModel.Config.m_Slider_Configuration);
                if (nResult != 0)
                {
                    // Initialization failed.

                    logger.Debug("deviceSlider::initialize failed.");
                }
                else
                {
                    clsAMB controller = theModel.getMotorBoard(_controllerId);

                    // Move the pump to the initial position.
                    controller.SetDirectionPolarity(strChannel, "0");
                    controller.MoveHome(strChannel);
                    controller.WaitForCompletion(strChannel);



                    controller.MoveRelativePositive(strChannel, "4510");

                    controller.WaitForCompletion(strChannel);

                    /*
                     * //controller.SetDirectionPolarity(strChannel, "0");
                     * controller.MoveRelativePositive(strChannel, "9500");
                     * controller.WaitForCompletion(strChannel);
                     *
                     *
                     * controller.SetDirectionPolarity(strChannel, "1");
                     * //controller.MoveRelativePositive(strChannel, "6156");
                     * controller.MoveRelativePositive(strChannel, "5800");
                     * controller.WaitForCompletion(strChannel);
                     *
                     *       controller.MoveRelativePositive(strChannel, "4300");
                     * controller.WaitForCompletion(strChannel);
                     *
                     * controller.SetDirectionPolarity(strChannel, "0");
                     */
                    /* controller.MoveToAbsolutePosition(strChannel,
                     *       "11114");
                     * controller.WaitForCompletion(strChannel);*/
                    //controller.SetDirectionPolarity(strChannel, "1");

                    controller.SetResolution(theModel.Config.m_Slider_Configuration.m_nMotorChannel.ToString("00"),
                                             theModel.Config.m_Slider_Configuration.m_uiMotorResolution.ToString());

                    //Position = 2;
                    // Position = 1;
                    //RNPosition = 9614;
                    //RNNosition = 6307;
                    //RNNosition = 3307;
                }
            }
            catch (Exception ex)
            {
                logger.Debug("deviceSlider::initialize() Caught an exception: {0}", ex.Message);
                nRetVal = 1;
            }

            return(nRetVal);
        }
Exemple #10
0
        public int initialize()
        {
            int nRetVal = 0;

            try
            {
                string strChannel = _channel.ToString("00");

                // Set the motor parameters.

                HelixGenModel theModel = ((HelixGen.App)(App.Current)).Model;

                int nResult = initializeMotorParams(_channel, theModel.Config.m_OpticsMotor_Configuration);
                if (nResult != 0)
                {
                    // Initialization failed.

                    logger.Debug("deviceOpticsMotor::initialize failed.");
                }
                else
                {
                    clsAMB controller = theModel.getMotorBoard(_controllerId);

                    // Move the pump to the initial position.
                    string value;
                    controller.GetHomeSwitchStatus(strChannel, out value);

                    if (Int32.Parse(value) == 0)
                    {
                        controller.MoveHome(strChannel);
                        controller.WaitForCompletion(strChannel);
                    }

                    // theModel.DeviceOpticsMotor.Position = 4;

                    /*
                     * for (int nLED = 0; nLED < 6; nLED++)
                     * {
                     *   theModel.OpticsModel.SetLedCurrent(nLED + 1, 0.75);
                     *   //theModel.OpticsModel.SetLedCurrent(nLED + 1, 0);
                     * }
                     */
                    // controller.SetStartSpeed(strChannel, "400");//200,400
                    // controller.SetMaxSpeed(strChannel, "1200");//200,1600

                    /*
                     * controller.SetDirectionPolarity(strChannel, "0");
                     * controller.MoveRelativePositive(strChannel, "100000000");
                     * controller.WaitForCompletion(strChannel);
                     * controller.MoveRelativeNegative(strChannel, "0");
                     * controller.WaitForCompletion(strChannel);
                     */
                    controller.SetResolution(theModel.Config.m_OpticsMotor_Configuration.m_nMotorChannel.ToString("00"),
                                             theModel.Config.m_OpticsMotor_Configuration.m_uiMotorResolution.ToString());



                    //if(isFirstIn)
                    //ZeroOptic();
                    isFirstIn = false;
                    // theModel.OpticsModel.TriggerPhotodetector();
                    // Position = 1;

                    /*
                     * controller.MoveToAbsolutePosition(strChannel,
                     *       "132");
                     * controller.WaitForCompletion(strChannel);*/
                }
            }
            catch (Exception)
            {
                nRetVal = 1;
            }

            return(nRetVal);
        }
 public motorBoardModel2(HelixGenModel modelIn)
 {
     _model      = modelIn;
     _motorBoard = new clsAMB();
 }