using System; namespace PixelHub { public enum PixelWheel { None, Left, Right, Both } /// /// Specifies a single command that is to be sent to a PixelBot. /// public class PixelCommand { /// /// The wheel(s) that should be operated upon. /// public PixelWheel Wheel { get; set; } /// /// The duration, in milliseconds, that the left wheel should turn for. /// public int DurationLeft { get; set; } /// /// The duration, in milliseconds, that the right wheel should turn for. /// /// The duration right. public int DurationRight { get; set; } /// /// The duration, in milliseconds, that the wheels should turn for. /// /// /// This property sets both the and properties. /// The getter returns the maximum of the two durations. /// public int Duration { get { return Math.Max(DurationLeft, DurationRight); } set { DurationLeft = value; DurationRight = value; } } /// /// Creates a new instance. /// /// The wheel to turn. /// The duration , in milliseconds, to turn the wheels for. public PixelCommand(PixelWheel inWheel, int inDuration) { Wheel = inWheel; Duration = inDuration; } /// /// Compiles the PixelCommand into a raw command string that cna be understood by the PixelBot. /// /// The compiled command, ready to be sent over the wire to the PixelBot. public string AsCompiledCommand() { return $"Move:L={DurationLeft},Right={DurationRight}"; } public override string ToString() { return string.Format("PixelCommand: Targets Wheel={0} for Duration={1}ms", Wheel, Duration); } } }