/// <summary> /// Gets the Input Value from the DigitalInput /// </summary> /// <returns>Boolean</returns> public override double Get() { #if USE_LOCKING lock (din) #endif { var input = Convert.ToDouble(din.Get()); if (Math.Abs(previousInput - input) > Constants.EPSILON_MIN) { onValueChanged(new VirtualControlEventArgs(input, InUse)); } previousInput = input; return(input); } }
public void insert(bool button) { if (button == true) { Left.Set(-0.25); Right.Set(0.25); } if (ShooterBallSensor.Get() == false) { stop(true); } }
public void TestSolenoid() { Reset(); using (Solenoid solenoid1 = new Solenoid(0)) using (Solenoid solenoid2 = new Solenoid(1)) { NotifyCallback solenoid1Callback = null; NotifyCallback solenoid2Callback = null; int callback1Id = -1; int callback2Id = -1; if (RobotBase.IsSimulation) { solenoid1Callback = (string s, HAL_Value val) => { SimData.DIO[12].SetValue(!val.GetBoolean()); }; callback1Id = SimData.PCM[0].RegisterSolenoidOutputCallback(0, solenoid1Callback, false); solenoid2Callback = (s, o) => { SimData.DIO[13].SetValue(!o.GetBoolean()); }; callback2Id = SimData.PCM[0].RegisterSolenoidOutputCallback(1, solenoid2Callback); } solenoid1.Set(false); solenoid2.Set(false); Timer.Delay(SolenoidDelayTime); Assert.That(fakeSolenoid1.Get()); Assert.That(fakeSolenoid2.Get()); Assert.That(!solenoid1.Get()); Assert.That(!solenoid2.Get()); solenoid1.Set(true); solenoid2.Set(false); Timer.Delay(SolenoidDelayTime); Assert.That(!fakeSolenoid1.Get()); Assert.That(fakeSolenoid2.Get()); Assert.That(solenoid1.Get()); Assert.That(!solenoid2.Get()); solenoid1.Set(false); solenoid2.Set(true); Timer.Delay(SolenoidDelayTime); Assert.That(fakeSolenoid1.Get()); Assert.That(!fakeSolenoid2.Get()); Assert.That(!solenoid1.Get()); Assert.That(solenoid2.Get()); solenoid1.Set(true); solenoid2.Set(true); Timer.Delay(SolenoidDelayTime); Assert.That(!fakeSolenoid1.Get()); Assert.That(!fakeSolenoid2.Get()); Assert.That(solenoid1.Get()); Assert.That(solenoid2.Get()); if (RobotBase.IsSimulation) { SimData.PCM[0].CancelSolenoidOutputCallback(0, callback1Id); SimData.PCM[0].CancelSolenoidOutputCallback(1, callback2Id); } } }