public void NewHaltEventTest() { goalComs.SetStream(haltInputStream); INaoEvent result = NaoEventFactory.NewEvent( (byte)EventCode.Halt); Assert.IsInstanceOf(typeof(HaltEvent), result); }
public void NewPickupEventTest() { goalComs.SetStream(pickupInputStream); INaoEvent result = NaoEventFactory.NewEvent( (byte)EventCode.Pickup); Assert.IsInstanceOf(typeof(PickupEvent), result); }
public void NewGoToEventTest() { goalComs.SetStream(goToInputStream); INaoEvent result = NaoEventFactory.NewEvent( (byte)EventCode.GoTo); Assert.IsInstanceOf(typeof(GoToEvent), result); }
/// <summary> /// Attempts to read incoming data from the server. /// </summary> private void ReceiveData() { if (!Running) { return; } byte code = 0; try { code = communicationStream.ReadByte(); if (!Running) { return; } INaoEvent naoEvent = NaoEventFactory.NewEvent(code); EventQueue.Nao.Post(naoEvent); } catch (InvalidEventCodeException e) { Logger.Except(e); Logger.Log(this, "Invalid event code received: " + code); INaoEvent failureEvent = new FailureEvent(code); EventQueue.Goal.Post(failureEvent); } catch (Exception e) { if (e is InvalidOperationException || e is IOException) { Logger.Log(this, "Communication stream got closed."); communicationStream.Open = false; } else { Logger.Log(this, "Unexpected exception occurred while processing incoming data: " + e); } } }
public void NewInvalidEventTest() { goalComs.SetStream(invalidInputStream); INaoEvent result = NaoEventFactory.NewEvent( invalidEventCode); }