示例#1
0
 private void DispatchCommand(SRV1.MotorCommand command)
 {
     if (SrvDrivingCommand != null)
     {
         SrvDrivingCommand(this, command);
     }
 }
示例#2
0
        private void srvDriverControl_SrvDrivingCommand(object sender, SRV1.MotorCommand command)
        {
            if (srv.IsConnected)
            {
                try
                {
                    if (!receivedFirstDrivingCommand)
                    {
                        // use one direct control command first
                        srv.StopMotors();
                    }

                    // send new command
                    srv.ControlMotors(command);

                    if (((command == SRV1.MotorCommand.DecreaseSpeed) ||
                         (command == SRV1.MotorCommand.IncreaseSpeed)) &&
                        (receivedFirstDrivingCommand) &&
                        (lastMotorCommand != SRV1.MotorCommand.Stop))
                    {
                        // resend last command to get effect of speed increase/decrease
                        srv.ControlMotors(lastMotorCommand);
                    }
                    else
                    {
                        receivedFirstDrivingCommand = true;
                        lastMotorCommand            = command;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("## " + ex.Message);
                }
            }
        }
示例#3
0
        private void srvDriverControl_SrvDrivingCommand( object sender, SRV1.MotorCommand command )
        {
            if ( svs.IsConnected )
            {
                try
                {
                    if ( !receivedFirstDrivingCommand )
                    {
                        // use one direct control command first
                        svs.StopMotors( );
                    }

                    // send new command
                    svs.ControlMotors( command );

                    if ( ( ( command == SRV1.MotorCommand.DecreaseSpeed ) ||
                           ( command == SRV1.MotorCommand.IncreaseSpeed ) ) &&
                           ( receivedFirstDrivingCommand ) &&
                           ( lastMotorCommand != SRV1.MotorCommand.Stop ) )
                    {
                        // resend last command to get effect of speed increase/decrease
                        svs.ControlMotors( lastMotorCommand  );
                    }
                    else
                    {
                        receivedFirstDrivingCommand = true;
                        lastMotorCommand = command;
                    }
                }
                catch ( Exception ex )
                {
                    System.Diagnostics.Debug.WriteLine( "## " + ex.Message );
                }
            }
        }
示例#4
0
文件: SVS.cs 项目: EnergonV/BestCS
 /// <summary>
 /// Control motors connected to SVS board using predefined commands.
 /// </summary>
 ///
 /// <param name="command">Motor command to send to the SVS board.</param>
 ///
 /// <remarks><para><note>Controlling SVS motors with this method is only available
 /// after at least one direct motor command is sent, which is done using <see cref="StopMotors"/> or
 /// <see cref="RunMotors"/> methods.</note></para></remarks>
 ///
 /// <exception cref="NotConnectedException">Not connected to SVS. Connect to SVS board before using
 /// this method.</exception>
 ///
 public void ControlMotors(SRV1.MotorCommand command)
 {
     SafeGetCommunicator1( ).ControlMotors(command);
 }