public void TestCreateUpperLimit() { Assert.Throws <ArgumentOutOfRangeException>(() => { var p = new DoubleSolenoid(m_module, SolenoidChannels, SolenoidChannels + 1); }); }
public void TestDoubleSolenoidModuleOverLimit() { Assert.Throws <ArgumentOutOfRangeException>(() => { var s = new DoubleSolenoid(SolenoidModules, 0, 1); }); }
public void TestSmartDashboardType() { using (DoubleSolenoid s = NewDoubleSolenoid()) { Assert.That(s.SmartDashboardType, Is.EqualTo("Double Solenoid")); } }
public void TestCreateLowerLimit() { Assert.Throws <ArgumentOutOfRangeException>(() => { var p = new DoubleSolenoid(m_module, -2, -1); }); }
public void TestDoubleSolenoidModuleOverLimit() { Assert.Throws<ArgumentOutOfRangeException>(() => { var s = new DoubleSolenoid(SolenoidModules, 0, 1); }); }
public void TestBlackList() { using (DoubleSolenoid ds = NewDoubleSolenoid()) { Assert.IsFalse(ds.FwdSolenoidBlackListed); Assert.IsFalse(ds.RevSolenoidBlackListed); } }
public void TestDoubleSolenoidCreate() { using (DoubleSolenoid s = NewDoubleSolenoid()) { Assert.IsTrue(GetSolenoids().GetSolenoidInitialized(0)); Assert.IsTrue(GetSolenoids().GetSolenoidInitialized(1)); } }
/// <summary> /// Constructor /// </summary> /// <param name="commonName">CommonName the DoubleSolenoid will have</param> /// <param name="forwardChannel">The forward channel number on the PCM [0..7]</param> /// <param name="reverseChannel">The reverse channel number on the PCM [0..7]</param> /// <param name="_default">Default position for when the Robot is initialized</param> /// <param name="reversed">If the output is reversed for the forward and reversed states</param> public DoubleSolenoidItem(string commonName, int forwardChannel, int reverseChannel, DoubleSolenoid.Value _default, bool reversed = false) { solenoid = new DoubleSolenoid(forwardChannel, reverseChannel); Name = commonName; Default = _default; IsReversed = reversed; solenoid.Set(_default); }
public void TestSolenoidSetOff() { using (DoubleSolenoid ds = NewDoubleSolenoid()) { ds.Set(DoubleSolenoid.Value.Off); Assert.IsFalse(GetSolenoids().GetSolenoidOutput(1)); Assert.IsFalse(GetSolenoids().GetSolenoidOutput(0)); } }
public void TestSolenoidSetReverse() { using (DoubleSolenoid ds = NewDoubleSolenoid()) { ds.Set(DoubleSolenoid.Value.Reverse); Assert.IsTrue(GetSolenoids().GetSolenoidOutput(1)); Assert.IsFalse(GetSolenoids().GetSolenoidOutput(0)); } }
public void TestSolenoidGetOff() { using (DoubleSolenoid ds = NewDoubleSolenoid()) { GetSolenoids().SetSolenoidOutput(0, false); GetSolenoids().SetSolenoidOutput(1, false); Assert.AreEqual(DoubleSolenoid.Value.Off, ds.Get()); } }
public void TestSolenoidGetReverse() { using (DoubleSolenoid ds = NewDoubleSolenoid()) { GetSolenoids().SetSolenoidOutput(1, true); GetSolenoids().SetSolenoidOutput(0, false); Assert.AreEqual(DoubleSolenoid.Value.Reverse, ds.Get()); } }
public void TestStopLiveWindowMode() { using (DoubleSolenoid s = NewDoubleSolenoid()) { Assert.DoesNotThrow(() => { s.StopLiveWindowMode(); }); } }
public void TestUpdateTableNull() { using (DoubleSolenoid s = NewDoubleSolenoid()) { Assert.DoesNotThrow(() => { s.UpdateTable(); }); } }
public void TestDoubleSolenoidCreateDefaultModule() { using (DoubleSolenoid s = new DoubleSolenoid(0, 1)) { Assert.IsTrue(SimData.GetPCM(0).Solenoids[0].Initialized); Assert.IsTrue(SimData.GetPCM(0).Solenoids[1].Initialized); } Assert.That(SimData.GetPCM(0).Solenoids[0].Initialized, Is.False); Assert.That(SimData.GetPCM(0).Solenoids[1].Initialized, Is.False); }
public void TestMultipleAllocation() { using (DoubleSolenoid ds = NewDoubleSolenoid()) { Assert.Throws(typeof(AllocationException), () => { var p = NewDoubleSolenoid(); }); } }
public void TestDoubleSolenoidCreateDefaultModule() { using (DoubleSolenoid s = new DoubleSolenoid(0, 1)) { Assert.IsTrue(SimData.PCM[0].GetSolenoidInitialized(0)); Assert.IsTrue(SimData.PCM[0].GetSolenoidInitialized(1)); } Assert.That(SimData.PCM[0].GetSolenoidInitialized(0), Is.False); Assert.That(SimData.PCM[0].GetSolenoidInitialized(1), Is.False); }
public void TestInitTable() { using (DoubleSolenoid s = NewDoubleSolenoid()) { ITable table = new MockNetworkTable(); Assert.DoesNotThrow(() => { s.InitTable(table); }); Assert.That(s.Table, Is.EqualTo(table)); } }
public void TestDoubleSolenoid() { using (DoubleSolenoid solenoid = new DoubleSolenoid(0, 1)) { NotifyCallback solenoid1Callback = null; NotifyCallback solenoid2Callback = null; int callback1Id = -1; int callback2Id = -1; if (RobotBase.IsSimulation) { solenoid1Callback = (s, o) => { SimData.DIO[12].SetValue(!o.GetBoolean()); }; callback1Id = SimData.PCM[0].RegisterSolenoidOutputCallback(0, solenoid1Callback); solenoid2Callback = (s, o) => { SimData.DIO[13].SetValue(!o.GetBoolean()); }; callback2Id = SimData.PCM[0].RegisterSolenoidOutputCallback(1, solenoid2Callback); } solenoid.Set(DoubleSolenoid.Value.Off); Timer.Delay(SolenoidDelayTime); Assert.That(fakeSolenoid1.Get()); Assert.That(fakeSolenoid2.Get()); Assert.That(solenoid.Get(), Is.EqualTo(DoubleSolenoid.Value.Off)); solenoid.Set(DoubleSolenoid.Value.Forward); Timer.Delay(SolenoidDelayTime); Assert.That(!fakeSolenoid1.Get()); Assert.That(fakeSolenoid2.Get()); Assert.That(solenoid.Get(), Is.EqualTo(DoubleSolenoid.Value.Forward)); solenoid.Set(DoubleSolenoid.Value.Reverse); Timer.Delay(SolenoidDelayTime); Assert.That(fakeSolenoid1.Get()); Assert.That(!fakeSolenoid2.Get()); Assert.That(solenoid.Get(), Is.EqualTo(DoubleSolenoid.Value.Reverse)); if (RobotBase.IsSimulation) { SimData.PCM[0].CancelSolenoidOutputCallback(0, callback1Id); SimData.PCM[0].CancelSolenoidOutputCallback(1, callback2Id); } } }
public void TestValueChanged() { using (DoubleSolenoid s = NewDoubleSolenoid()) { s.Set(DoubleSolenoid.Value.Forward); Assert.That(s.Get(), Is.EqualTo(Value.Forward)); s.ValueChanged(null, null, NetworkTables.Value.MakeString("Reverse"), NetworkTables.NotifyFlags.NotifyLocal); Assert.That(s.Get, Is.EqualTo(Value.Reverse)); s.ValueChanged(null, null, NetworkTables.Value.MakeString("Garbage"), NetworkTables.NotifyFlags.NotifyLocal); Assert.That(s.Get, Is.EqualTo(Value.Off)); s.ValueChanged(null, null, NetworkTables.Value.MakeString("Forward"), NetworkTables.NotifyFlags.NotifyLocal); Assert.That(s.Get, Is.EqualTo(Value.Forward)); } }
public void TestDoubleSolenoid() { using (DoubleSolenoid solenoid = new DoubleSolenoid(0, 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); } solenoid.Set(DoubleSolenoid.Value.Off); Timer.Delay(SolenoidDelayTime); Assert.That(fakeSolenoid1.Get()); Assert.That(fakeSolenoid2.Get()); Assert.That(solenoid.Get(), Is.EqualTo(DoubleSolenoid.Value.Off)); solenoid.Set(DoubleSolenoid.Value.Forward); Timer.Delay(SolenoidDelayTime); Assert.That(!fakeSolenoid1.Get()); Assert.That(fakeSolenoid2.Get()); Assert.That(solenoid.Get(), Is.EqualTo(DoubleSolenoid.Value.Forward)); solenoid.Set(DoubleSolenoid.Value.Reverse); Timer.Delay(SolenoidDelayTime); Assert.That(fakeSolenoid1.Get()); Assert.That(!fakeSolenoid2.Get()); Assert.That(solenoid.Get(), Is.EqualTo(DoubleSolenoid.Value.Reverse)); if (RobotBase.IsSimulation) { SimData.GetPCM(0).Solenoids[0].Cancel("Value", solenoid1Callback); SimData.GetPCM(0).Solenoids[1].Cancel("Value", solenoid2Callback); } } }
public void TestCreateUpperLimit() { Assert.Throws<ArgumentOutOfRangeException>(() => { var p = new DoubleSolenoid(m_module, SolenoidChannels, SolenoidChannels + 1); }); }
public void TestCreateLowerLimit() { Assert.Throws<ArgumentOutOfRangeException>(() => { var p = new DoubleSolenoid(m_module, -2, -1); }); }