public void TestSolenoidGet() { using (Solenoid s = NewSolenoid()) { s.Set(true); Assert.IsTrue(s.Get()); s.Set(false); Assert.IsFalse(s.Get()); } }
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); } } }
public void TestSolenoid() { Reset(); using (Solenoid solenoid1 = new Solenoid(0)) using (Solenoid solenoid2 = new Solenoid(1)) { Action<string, dynamic> solenoid1Callback = null; Action<string, dynamic> solenoid2Callback = null; if (RobotBase.IsSimulation) { solenoid1Callback = (s, o) => { SimData.DIO[12].Value = !o; }; SimData.GetPCM(0).Solenoids[0].Register("Value", solenoid1Callback); solenoid2Callback = (s, o) => { SimData.DIO[13].Value = !o; }; SimData.GetPCM(0).Solenoids[1].Register("Value", 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.GetPCM(0).Solenoids[0].Cancel("Value", solenoid1Callback); SimData.GetPCM(0).Solenoids[1].Cancel("Value", solenoid2Callback); } } }