public MovementCommand(string unparsedText) { if (unparsedText == null) { throw new ArgumentNullException("Null string received"); } if (IsValidIdentifier(unparsedText) == false) { throw new ArgumentException("Invalid command identifier"); } rawCommand = unparsedText; try { rightDirection = ParseRightDirection(rawCommand); rightSpeed = ParseRightSpeed(rawCommand); leftDirection = ParseLeftDirection(rawCommand); leftSpeed = ParseLeftSpeed(rawCommand); } catch (ArgumentException) { throw; } microcontroller = MicrocontrollerSingleton.Instance; }
static void SerialManager(IQueue DispatcherMessageBox, IQueue MicrocontrollerCommanderMessageBox) { MicrocontrollerSingleton microcontroller = MicrocontrollerSingleton.Instance; microcontroller.SetQueue(MicrocontrollerCommanderMessageBox); bool success = false; while (true) { while (microcontroller.IsInitialized == false) { microcontroller.Initialize(); if (microcontroller.IsInitialized == true) { Console.WriteLine("Connected to microcontroller"); // success = microcontroller.WriteMessage("test \n"); // Console.WriteLine(success.ToString()); } else { Console.WriteLine("Could not connect to microcontroller"); } Thread.Sleep(5000); } Thread.Sleep(100); } }
public TiltCommand(string unparsedCommand) { if (unparsedCommand == null) { throw new ArgumentNullException("Null string received"); } rawCommand = unparsedCommand; try { camIndex = ParseCamIndex(unparsedCommand); tiltAngle = ParseTiltAngle(unparsedCommand); } catch (ArgumentException) { throw; } microcontroller = MicrocontrollerSingleton.Instance; }
public PanCommand(string unparsedCommand) { //Extra error handling might be needed on a per-servo basis (ex: some servos are expected to do 360 degrees while others arent) if (unparsedCommand == null) { throw new ArgumentNullException("Null string received"); } rawCommand = unparsedCommand; try { camIndex = ParseCamIndex(unparsedCommand); panAngle = ParsePanAngle(unparsedCommand); } catch (ArgumentException) { throw; } microcontroller = MicrocontrollerSingleton.Instance; }