예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <c>ServoMotorController</c> class.
 /// </summary>
 public ServoMotorController()
 {
     commJob = new DelegateCommunicationJob(delegate()
     {
         return(String.Format("servo {0}:{1}", (ushort)ServoMotorId, position));
     });
 }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <c>PwmDCMotorController</c> class.
        /// </summary>
        public PwmDCMotorController()
        {
            commJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("pwm r:{0} {1}:{2}", _rampingRate, (ushort)DCMotorId, Speed));
            });

            velCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("vel {0}", (ushort)DCMotorId));
            });
        }
        /// <summary>
        /// Initializes a new instance of the <c>BipolarStepperMotorController</c> class.
        /// </summary>
        public BipolarStepperMotorController()
        {
            stepCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("step {0}:{1}:{2}", _direction, _speed, _steps));
            });

            sweepCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("sweep {0}:{1}", _speed, _steps));
            });

            stopCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("stop"));
            });
        }
        /// <summary>
        /// Initializes a new instance of the <c>PwmDCMotorController</c> class.
        /// </summary>
        public DifferentialMotorController()
        {
            Enabled = false;
            commJob = new DelegateCommunicationJob(delegate()
            {
                string cmd = String.Format("pwm {0}:{1} {2}:{3}", (ushort)_rightMotorId, _rightMotorSpeed, (ushort)_leftMotorId, _leftMotorSpeed);
                //Debug.WriteLine("Command: " + cmd);
                return(cmd);
            });

            rampCommJob = new DelegateCommunicationJob(delegate()
            {
                string cmd = String.Format("pwm r:{0} {1}:{2} {3}:{4}", _rampingRate, (ushort)_rightMotorId, _rightMotorSpeed, (ushort)_leftMotorId, _leftMotorSpeed);
                //Debug.WriteLine("Command: " + cmd);
                return(cmd);
            });
        }
예제 #5
0
        private const double TrackCircumferenceDefault = 22.777;  // track * pi -- used for rotational calcs
        #endregion

        #region CTORS

        /// <summary>
        /// Initializes a new instance of the <c>PidDCMotorController</c> class.
        /// </summary>
        public PIDMotorController()
        {
            vPidCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format(
                           "vpid {0}:{1}:{2}:{3}", vProp, vInteg, vDeriv, vLoop));
            });

            stopCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("stop"));
            });

            dPidCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format(
                           "dpid {0}:{1}:{2}:{3}", dProp, dInteg, dDeriv, dAccel));
            });

            dPidDBCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format(
                           "dpid {0}:{1}:{2}:{3}:{4}", dProp, dInteg, dDeriv, dAccel, dDeadband));
            });

            mogoCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("mogo 1:{0} 2:{1}", motor1Velocity, motor2Velocity));
            });

            digoCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("digo 1:{0}:{1} 2:{2}:{3}", motor1Distance, motor1Velocity, motor2Distance, motor2Velocity));
            });

            stingerPidCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("rpid s"));
            });

            traxsterPidCommJob = new DelegateCommunicationJob(delegate()
            {
                return(String.Format("rpid t"));
            });
        }
예제 #6
0
파일: GpioPin.cs 프로젝트: sycomix/Win10Bot
        /// <summary>
        /// Initializes a new instance of the <c>GpioPin</c> class.
        /// </summary>
        public GpioPin()
        {
            commJob = new DelegateCommunicationJob(delegate
            {
                int p = 0;

                if (pin == GpioPinId.Pin0)
                {
                    p = 0;
                }
                else if (pin == GpioPinId.Pin1)
                {
                    p = 1;
                }
                else if (pin == GpioPinId.Pin2)
                {
                    p = 2;
                }
                else if (pin == GpioPinId.Pin3)
                {
                    p = 3;
                }
                else if (pin == GpioPinId.Pin4)
                {
                    p = 4;
                }
                else if (pin == GpioPinId.Pin5)
                {
                    p = 5;
                }
                else if (pin == GpioPinId.Pin6)
                {
                    p = 6;
                }
                else if (pin == GpioPinId.Pin7)
                {
                    p = 7;
                }
                else if (pin == GpioPinId.Pin8)
                {
                    p = 8;
                }
                else if (pin == GpioPinId.Pin9)
                {
                    p = 9;
                }
                else if (pin == GpioPinId.PinHB)
                {
                    p = 10;
                }
                else if (pin == GpioPinId.PinSCL)
                {
                    p = 11;
                }
                else if (pin == GpioPinId.PinSDA)
                {
                    p = 12;
                }
                //else if (pin == GpioPinId.PinRTS)
                //    p = 13;
                //else if (pin == GpioPinId.PinCTS)
                //    p = 14;

                if (state == false)
                {
                    return(String.Format("setio {0}:0", p));
                }
                else
                {
                    return(String.Format("setio {0}:1", p));
                }
            });
        }