コード例 #1
0
ファイル: Walker.cs プロジェクト: darkthing41/SE_Drive_Walker
        private void ReadCommands()
        {
            string
                id, data;
            char
                dataType;

            //Read commands until there are none left, or hit max
            for (int i = 0; i < commandsMax; i++)
            {
                if (busCmd.ReadNext(out id, out dataType, out data))
                {
                    switch (dataType)
                    {
                    case CommandBus.dataTypeString:

                        break;

                    case CommandBus.dataTypeFloat:
                        if (id == busIdRpmLeft)
                        {
                            if (ParseRpm(data, ref status.rpmLeft))
                            {
                                Echo("Left RPM set.");
                            }
                        }
                        else if (id == busIdRpmRight)
                        {
                            if (ParseRpm(data, ref status.rpmRight))
                            {
                                Echo("Right RPM set.");
                            }
                        }
                        else
                        {
                            break;
                        }
                        continue;

                    default:
                        break;
                    }
                    //If we exited without 'continue', the command was unrecognised.
                    Echo("WARNING: Unrecognised command \"" + id + "\" type '" + dataType + "'");
                }
                else
                {
                    Echo("All commands read.");
                    return;
                }
            }

            Echo("Not reading further commands.");
        }
コード例 #2
0
        private void ReadCommands()
        {
            string
                id, data;
            char
                dataType;

            //Read commands until there are none left, or hit max
            for (int i = 0; i < commandsMax; i++)
            {
                if (busCommand.ReadNext(out id, out dataType, out data))
                {
                    switch (dataType)
                    {
                    case CommandBus.dataTypeString:
                        if (id == busId_GearUp)
                        {
                            Echo("Received command: Gear up.");
                            if (data != "")
                            {
                                Echo("WARNING: Unexpected command data \"" + data + "\"");
                            }
                            Cmd_GearUp();
                        }
                        else if (id == busId_GearDown)
                        {
                            Echo("Received command: Gear down.");
                            if (data != "")
                            {
                                Echo("WARNING: Unexpected command data \"" + data + "\"");
                            }
                            Cmd_GearDown();
                        }
                        else if (id == busId_GearAutoToggle)
                        {
                            Echo("Received command: Switch gearbox mode.");
                            if (data != "")
                            {
                                Echo("WARNING: Unexpected command data \"" + data + "\"");
                            }
                            Cmd_GearAutoToggle();
                        }
                        else
                        {
                            break;
                        }
                        continue;

                    default:
                        break;
                    }
                    //If we exited without 'continue', the command was unrecognised.
                    Echo("WARNING: Unrecognised command \"" + id + "\" type '" + dataType + "'");
                }
                else
                {
                    Echo("All commands read.");
                    return;
                }
            }

            Echo("Not reading further commands.");
        }