コード例 #1
0
ファイル: Ultrasonic.cs プロジェクト: atrimper/WPILib
        /// <summary>
        /// Destructor for the ultrasonic sensor.
        /// </summary>
        /// <remarks>Delete the instance of the ultrasonic sensor by freeing the allocated digital channels.
        /// If the system was in automatic mode (round robin), then it is stopped, then started again after
        /// this sensor is removed (provided this wasn't the last sensor).
        /// </remarks>
        public override void Dispose()
        {
            base.Dispose();
            bool previousAutoMode = s_automaticRoundRobinEnabled;

            SetAutomaticMode(false);
            lock (s_syncRoot)
            {
                s_currentSensors.Remove(this);
            }
            if (m_allocatedChannels)
            {
                m_pingChannel?.Dispose();
                m_echoChannel?.Dispose();
            }
            m_counter?.Dispose();
            m_pingChannel = null;
            m_echoChannel = null;
            m_counter     = null;
            lock (s_syncRoot)
            {
                if (!s_currentSensors.Any())
                {
                    return;
                }
            }
            SetAutomaticMode(previousAutoMode);
        }
コード例 #2
0
 public Conveyer()
 {
     conveyor = new Talon(Constants.Conveyer_Channel);
     beamBrakeIn = new DigitalInput(Constants.Conveyer_BeambrakeInChannel);
     beamBrakeOut = new DigitalInput(Constants.Conveyer_BeambrakeOutChannel);
     balls = 0;
     InState = false;
 }
コード例 #3
0
ファイル: Ultrasonic.cs プロジェクト: atrimper/WPILib
 /// <summary>
 /// Create an instance of the <see cref="Ultrasonic"/> Sensor.
 /// </summary>
 /// <remarks>This is designed to superchannel the Deventech SRF04 and
 /// Vex ultrasonic sensors.</remarks>
 /// <param name="pingChannel">The digital output channel that sends the pulse
 /// to initiate the sensor sending the ping</param>
 /// <param name="echoChannel">The digital input channel the receives the echo.
 /// The lenght of time that the echo is high represents the round trip time of
 /// the ping, and the distance/</param>
 /// <param name="units">The units returns in either <see cref="Unit.Inches">Inches</see>
 /// or <see cref="Unit.Millimeters">Millimeters</see>. Default is inches.</param>
 public Ultrasonic(int pingChannel, int echoChannel, Unit units = Unit.Inches)
 {
     m_pingChannel       = new DigitalOutput(pingChannel);
     m_echoChannel       = new DigitalInput(echoChannel);
     m_allocatedChannels = true;
     DistanceUnits       = units;
     Initialize();
 }
コード例 #4
0
ファイル: Ultrasonic.cs プロジェクト: atrimper/WPILib
 /// <summary>
 /// Create an instance of the <see cref="Ultrasonic"/> Sensor.
 /// </summary>
 /// <remarks>This is designed to superchannel the Deventech SRF04 and
 /// Vex ultrasonic sensors.</remarks>
 /// <param name="pingChannel">The <see cref="DigitalOutput"/> channel that sends the pulse
 /// to initiate the sensor sending the ping</param>
 /// <param name="echoChannel">The <see cref="DigitalInput"/> channel the receives the echo.
 /// The lenght of time that the echo is high represents the round trip time of
 /// the ping, and the distance/</param>
 /// <param name="units">The units returns in either <see cref="Unit.Inches">Inches</see>
 /// or <see cref="Unit.Millimeters">Millimeters</see></param>
 public Ultrasonic(DigitalOutput pingChannel, DigitalInput echoChannel, Unit units = Unit.Inches)
 {
     if (pingChannel == null)
     {
         throw new ArgumentNullException(nameof(pingChannel));
     }
     if (echoChannel == null)
     {
         throw new ArgumentNullException(nameof(echoChannel));
     }
     m_pingChannel       = pingChannel;
     m_echoChannel       = echoChannel;
     m_allocatedChannels = false;
     DistanceUnits       = units;
     Initialize();
 }
コード例 #5
0
 private static void AddDigitalInput(string key, DigitalInput limitSwitch)
 {
     DigitalInputKeys.Add(key);
     DigitalInputs.Add(key, limitSwitch);
 }
コード例 #6
0
ファイル: Ultrasonic.cs プロジェクト: chopshop-166/WPILib
        /// <summary>
        /// Destructor for the ultrasonic sensor.
        /// </summary>
        /// <remarks>Delete the instance of the ultrasonic sensor by freeing the allocated digital channels. 
        /// If the system was in automatic mode (round robin), then it is stopped, then started again after 
        /// this sensor is removed (provided this wasn't the last sensor).
        /// </remarks>
        public override void Dispose()
        {
            base.Dispose();
            bool previousAutoMode = s_automaticRoundRobinEnabled;
            SetAutomaticMode(false);
            lock (s_syncRoot)
            {
                s_currentSensors.Remove(this);
            }
            if (m_allocatedChannels)
            {
                m_pingChannel?.Dispose();
                m_echoChannel?.Dispose();
            }
            m_counter?.Dispose();
            m_pingChannel = null;
            m_echoChannel = null;
            m_counter = null;
            lock (s_syncRoot)
            {
                if (!s_currentSensors.Any()) return;
            }
            SetAutomaticMode(previousAutoMode);

        }
コード例 #7
0
ファイル: Ultrasonic.cs プロジェクト: chopshop-166/WPILib
 /// <summary>
 /// Create an instance of the <see cref="Ultrasonic"/> Sensor.
 /// </summary>
 /// <remarks>This is designed to superchannel the Deventech SRF04 and 
 /// Vex ultrasonic sensors.</remarks>
 /// <param name="pingChannel">The <see cref="DigitalOutput"/> channel that sends the pulse 
 /// to initiate the sensor sending the ping</param>
 /// <param name="echoChannel">The <see cref="DigitalInput"/> channel the receives the echo.
 /// The lenght of time that the echo is high represents the round trip time of 
 /// the ping, and the distance/</param>
 /// <param name="units">The units returns in either <see cref="Unit.Inches">Inches</see>
 /// or <see cref="Unit.Millimeters">Millimeters</see></param>
 public Ultrasonic(DigitalOutput pingChannel, DigitalInput echoChannel, Unit units = Unit.Inches)
 {
     if (pingChannel == null) throw new ArgumentNullException(nameof(pingChannel));
     if (echoChannel == null) throw new ArgumentNullException(nameof(echoChannel));
     m_pingChannel = pingChannel;
     m_echoChannel = echoChannel;
     m_allocatedChannels = false;
     DistanceUnits = units;
     Initialize();
 }
コード例 #8
0
ファイル: Ultrasonic.cs プロジェクト: chopshop-166/WPILib
 /// <summary>
 /// Create an instance of the <see cref="Ultrasonic"/> Sensor.
 /// </summary>
 /// <remarks>This is designed to superchannel the Deventech SRF04 and 
 /// Vex ultrasonic sensors.</remarks>
 /// <param name="pingChannel">The digital output channel that sends the pulse 
 /// to initiate the sensor sending the ping</param>
 /// <param name="echoChannel">The digital input channel the receives the echo.
 /// The lenght of time that the echo is high represents the round trip time of 
 /// the ping, and the distance/</param>
 /// <param name="units">The units returns in either <see cref="Unit.Inches">Inches</see>
 /// or <see cref="Unit.Millimeters">Millimeters</see>. Default is inches.</param>
 public Ultrasonic(int pingChannel, int echoChannel, Unit units = Unit.Inches)
 {
     m_pingChannel = new DigitalOutput(pingChannel);
     m_echoChannel = new DigitalInput(echoChannel);
     m_allocatedChannels = true;
     DistanceUnits = units;
     Initialize();
 }
コード例 #9
0
        private static void InitializeElevator()
        {
            ElevatorEncoder = new Encoder(8, 9, false, EncodingType.K1X);
            ElevatorEncoder.DistancePerPulse = 1;

            TopLimitSwitch = new DigitalInput(7);
            BottomLimitSwitch = new DigitalInput(4);

            var setpoints = new List<Setpoint>
            {
                new Setpoint(2, 0),
                new Setpoint(4, 325),
                new Setpoint(3, 750),
                new Setpoint(5, 1475),
                new Setpoint(8, 1200),
                new Setpoint(9, 2800)
            };

            Setpoints = new SetpointMapWrapper(setpoints);
        }
コード例 #10
0
        private static void InitializeAutonomous()
        {
            RightPhotoSensor = new DigitalInput(0);
            LeftPhotoSensor = new DigitalInput(1);

            Ultra = new Ultrasonic(3, 4);
            Ultrasonic.SetAutomaticMode(true);
        }