예제 #1
0
 public void SetMotor(int value)
 {
     var channel = DeviceChannel.DcMotor;
     Log.Info("SetPwm({0},{1})", channel, value);
     var piCommand = new PwmCommand(channel, value);
     PiController.Instance.SendCommand(piCommand);
 }
예제 #2
0
 public void Command(PwmCommand pwmCommand)
 {
     Log.DebugFormat("PwmCommand received({0})!", pwmCommand);
     switch (pwmCommand.Channel)
     {
         case DeviceChannel.DcMotor:
             var percent = pwmCommand.DutyCyclePercent;
             var direction = percent > 0 ? MotorDirection.Forward : MotorDirection.Reverse;
             DcMotor.Go(Math.Abs(percent), direction);
             break;
         case DeviceChannel.Led:
             Led0.On(pwmCommand.DutyCyclePercent);
             break;
         case DeviceChannel.Servo:
             Servo.MoveTo(pwmCommand.DutyCyclePercent);
             break;
     }
 }
예제 #3
0
 public void SendCommand(PwmCommand pwmCommand)
 {
     PwmController.Command(pwmCommand);
 }
예제 #4
0
        private Task GetClawTask()
        {
            var task = new Task(() =>
            {
                Log.Info("Claw!");

                var ingestCommand = new PwmCommand {Channel = DeviceChannel.Servo, DutyCyclePercent = 10};
                PwmController.Command(ingestCommand);

                Task.Delay(TimeSpan.FromMilliseconds(750)).Wait();

                var throwCommand = new PwmCommand {Channel = DeviceChannel.Servo, DutyCyclePercent = 70};
                PwmController.Command(throwCommand);
            });

            task.WhenCompleted(ClawCompleted, ClawCompleted);

            return task;
        }
예제 #5
0
 public void SendCommand(PwmCommand command)
 {
     Clients.All.SendPwmCommand(command);
 }