Ejemplo n.º 1
0
        public void IOIOProtocolOutgoing_DigitalLoopbackOut31In32()
        {
            IOIOConnection ourConn = this.CreateGoodSerialConnection();

            this.CreateCaptureLogHandlerSet();
            LOG.Debug("Setup Complete");

            IOIOProtocolIncoming fooIn  = new IOIOProtocolIncoming(ourConn.GetInputStream(), HandlerObservable_);
            IOIOProtocolOutgoing fooOut = new IOIOProtocolOutgoing(ourConn.GetOutputStream());

            System.Threading.Thread.Sleep(50); // receive the HW ID
            LOG.Info("This test requires Pin 31 and 32 be shorted together");
            fooOut.setPinDigitalIn(31, DigitalInputSpecMode.FLOATING);
            // request to be told of state change.  system will acknowledge this
            fooOut.setChangeNotify(31, true);
            // first change that will be captured...
            fooOut.setPinDigitalOut(32, false, DigitalOutputSpecMode.NORMAL);
            // second change that is captured
            fooOut.setDigitalOutLevel(32, true);
            // we could wait until our acknowledgements are received
            System.Threading.Thread.Sleep(300);
            // all log  methods contain method name which is in the interface so this is reasonably safe
            // we get one change event as soon as the Pin input Pin is configured + 2 changes in test
            int matchingLogs = this.CapturedLogs_.CapturedLogs_.Count(s => s.Contains(typeof(ReportDigitalInStatusFrom).Name));

            // sometimes we get 3 and sometimes 4 (!?)
            Assert.IsTrue(3 == matchingLogs || 4 == matchingLogs, "Should have captured 3 or 4 input changes, not " + matchingLogs + ".  Are pins 31 and 32 shorted together");
            // verify the system acknowledged our request to be notified of state change
            Assert.AreEqual(1, this.CapturedSingleQueueAllType_
                            .OfType <ISetChangeNotifyMessageFrom>().Where(m => m.Pin == 31).Count()
                            , "Unexpected count for IReportDigitalInStatusFrom");
            // verify we got Pin state changes for 31
            Assert.AreEqual(3, this.CapturedSingleQueueAllType_
                            .OfType <IReportDigitalInStatusFrom>().Where(m => m.Pin == 31).Count()
                            , "Unexpected count for IReportDigitalInStatusFrom");
        }
Ejemplo n.º 2
0
 public bool ExecuteMessage(IOIOProtocolOutgoing outBound)
 {
     outBound.setPinDigitalIn(BoundPin, DigitalInputSpecMode.FLOATING);
     return(true);
 }