Ejemplo n.º 1
0
 public void TestCreateUpperLimit()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         var p = new DoubleSolenoid(m_module, SolenoidChannels, SolenoidChannels + 1);
     });
 }
Ejemplo n.º 2
0
 public void TestDoubleSolenoidModuleOverLimit()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         var s = new DoubleSolenoid(SolenoidModules, 0, 1);
     });
 }
Ejemplo n.º 3
0
 public void TestSmartDashboardType()
 {
     using (DoubleSolenoid s = NewDoubleSolenoid())
     {
         Assert.That(s.SmartDashboardType, Is.EqualTo("Double Solenoid"));
     }
 }
Ejemplo n.º 4
0
 public void TestCreateLowerLimit()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         var p = new DoubleSolenoid(m_module, -2, -1);
     });
 }
Ejemplo n.º 5
0
 public void TestDoubleSolenoidModuleOverLimit()
 {
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         var s = new DoubleSolenoid(SolenoidModules, 0, 1);
     });
 }
Ejemplo n.º 6
0
 public void TestBlackList()
 {
     using (DoubleSolenoid ds = NewDoubleSolenoid())
     {
         Assert.IsFalse(ds.FwdSolenoidBlackListed);
         Assert.IsFalse(ds.RevSolenoidBlackListed);
     }
 }
Ejemplo n.º 7
0
 public void TestDoubleSolenoidCreate()
 {
     using (DoubleSolenoid s = NewDoubleSolenoid())
     {
         Assert.IsTrue(GetSolenoids().GetSolenoidInitialized(0));
         Assert.IsTrue(GetSolenoids().GetSolenoidInitialized(1));
     }
 }
Ejemplo n.º 8
0
 /// <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);
 }
Ejemplo n.º 9
0
 public void TestSolenoidSetOff()
 {
     using (DoubleSolenoid ds = NewDoubleSolenoid())
     {
         ds.Set(DoubleSolenoid.Value.Off);
         Assert.IsFalse(GetSolenoids().GetSolenoidOutput(1));
         Assert.IsFalse(GetSolenoids().GetSolenoidOutput(0));
     }
 }
Ejemplo n.º 10
0
 public void TestSolenoidSetReverse()
 {
     using (DoubleSolenoid ds = NewDoubleSolenoid())
     {
         ds.Set(DoubleSolenoid.Value.Reverse);
         Assert.IsTrue(GetSolenoids().GetSolenoidOutput(1));
         Assert.IsFalse(GetSolenoids().GetSolenoidOutput(0));
     }
 }
Ejemplo n.º 11
0
        public void TestSolenoidGetOff()
        {
            using (DoubleSolenoid ds = NewDoubleSolenoid())
            {
                GetSolenoids().SetSolenoidOutput(0, false);
                GetSolenoids().SetSolenoidOutput(1, false);

                Assert.AreEqual(DoubleSolenoid.Value.Off, ds.Get());
            }
        }
Ejemplo n.º 12
0
        public void TestSolenoidGetReverse()
        {
            using (DoubleSolenoid ds = NewDoubleSolenoid())
            {
                GetSolenoids().SetSolenoidOutput(1, true);
                GetSolenoids().SetSolenoidOutput(0, false);

                Assert.AreEqual(DoubleSolenoid.Value.Reverse, ds.Get());
            }
        }
Ejemplo n.º 13
0
 public void TestStopLiveWindowMode()
 {
     using (DoubleSolenoid s = NewDoubleSolenoid())
     {
         Assert.DoesNotThrow(() =>
         {
             s.StopLiveWindowMode();
         });
     }
 }
Ejemplo n.º 14
0
 public void TestUpdateTableNull()
 {
     using (DoubleSolenoid s = NewDoubleSolenoid())
     {
         Assert.DoesNotThrow(() =>
         {
             s.UpdateTable();
         });
     }
 }
Ejemplo n.º 15
0
 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);
 }
Ejemplo n.º 16
0
 public void TestMultipleAllocation()
 {
     using (DoubleSolenoid ds = NewDoubleSolenoid())
     {
         Assert.Throws(typeof(AllocationException), () =>
         {
             var p = NewDoubleSolenoid();
         });
     }
 }
Ejemplo n.º 17
0
 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);
 }
Ejemplo n.º 18
0
 public void TestInitTable()
 {
     using (DoubleSolenoid s = NewDoubleSolenoid())
     {
         ITable table = new MockNetworkTable();
         Assert.DoesNotThrow(() =>
         {
             s.InitTable(table);
         });
         Assert.That(s.Table, Is.EqualTo(table));
     }
 }
Ejemplo n.º 19
0
        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);
                }
            }
        }
Ejemplo n.º 20
0
 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));
     }
 }
Ejemplo n.º 21
0
        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);
                }
            }
        }
Ejemplo n.º 22
0
 public void TestCreateUpperLimit()
 {
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         var p = new DoubleSolenoid(m_module, SolenoidChannels, SolenoidChannels + 1);
     });
 }
Ejemplo n.º 23
0
 public void TestCreateLowerLimit()
 {
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         var p = new DoubleSolenoid(m_module, -2, -1);
     });
 }