public bool ExecuteMessage(IOIOProtocolOutgoing outBound) { outBound.setPinDigitalOut(this.PwmDef.PinSpec.Pin, false, this.PwmDef.PinSpec.Mode); outBound.setPinPwm(this.PwmDef.PinSpec.Pin, this.PwmDef.PwmNumber, this.Enable); IPwmOutputUpdateCommand updateCommand; // this should accepted periodUSec also if (!float.IsNaN(this.DutyCycle)) { updateCommand = new PwmOutputUpdateDutyCycleCommand(this.PwmDef, this.RequestedFrequency, this.DutyCycle); } else { updateCommand = new PwmOutputUpdateCommand(this.PwmDef, this.RequestedFrequency); } updateCommand.ExecuteMessage(outBound); // retain any frequency change done by the update command this.PwmDef = updateCommand.PwmDef; return(true); }
public void IOIOProtocolOutgoing_ToggleLED() { 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(100); // wait for us to get the hardware ids fooOut.setPinDigitalOut(Spec.LED_PIN, false, DigitalOutputSpecMode.NORMAL); for (int i = 0; i < 8; i++) { System.Threading.Thread.Sleep(200); fooOut.setDigitalOutLevel(Spec.LED_PIN, true); System.Threading.Thread.Sleep(200); fooOut.setDigitalOutLevel(Spec.LED_PIN, false); } Assert.IsTrue(true, "there is no status to check"); }
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"); }