Пример #1
0
            /// <summary>
            /// it could be better to store that in remote control gps list
            /// all arguments can be used in gps name
            /// name - 20,3.5,1,Node gps - 15934.19:-15396.17:16499.03
            /// no need to shit in ram
            /// </summary>
            void ReadRouteData()
            {
                var text = RouteData;

                if (string.IsNullOrWhiteSpace(text))
                {
                    return;
                }

                _route.Clear();

                string[] lines = text.Trim().Split('\n');
                for (int l = 0; l < lines.Length; l++)
                {
                    try
                    {
                        _route.Add(new RouteNode(lines[l]));
                    }
                    catch (Exception e)
                    {
                        ProgramInstance.Echo("Exception occured during reading route data: " + e.Message);
                    }
                }
                _routeLength = _route.Count - 1;
            }
Пример #2
0
        /// <summary>
        /// Mains entry point of the VpNet Examples.
        /// </summary>
        /// <param name="args">The args.</param>
        static void Main(string[] args)
        {
            var program = new ProgramInstance();

            Task.Run(async() =>
            {
                await program.Run();
            }).GetAwaiter().GetResult();
        }
        public IActionResult Post([FromBody] ProgramInstance programInstance)
        {
            if (programInstance == null)
            {
                return(BadRequest());
            }
            this.db.ProgramInstances.Add(programInstance);
            this.db.SaveChanges();

            return(CreatedAtRoute("GetProgramInstance", new { id = programInstance.Id }, programInstance));
        }
        public IActionResult Put(int Id, [FromBody] ProgramInstance newProgramInstance)
        {
            if (newProgramInstance == null || newProgramInstance.Id != Id)
            {
                return(BadRequest());
            }
            var currentProgramInstance = this.db.ProgramInstances.FirstOrDefault(x => x.Id == Id);

            if (currentProgramInstance == null)
            {
                return(NotFound());
            }

            currentProgramInstance.userId   = newProgramInstance.userId;
            currentProgramInstance.program  = newProgramInstance.program;
            currentProgramInstance.workouts = newProgramInstance.workouts;


            this.db.ProgramInstances.Update(currentProgramInstance);
            this.db.SaveChanges();

            return(NoContent());
        }
Пример #5
0
 public MainWindow()
 {
     InitializeComponent();
     _program         = new ProgramInstance();
     GameConsole.Text = _program.Output;
 }
Пример #6
0
            internal void Main()
            {
                ProgramInstance.Echo("Status: " + _status);
                ProgramInstance.Echo("Route length: " + _routeLength);
                ProgramInstance.Echo("Current node: " + _currentNodeNum);

                _gridCenterPosition = _controller.CubeGrid.GetPosition();
                _currentSpeed       = _controller.GetShipSpeed() * 3.7d;

                RadioInput();

                switch (_status)
                {
                case State.STANDBY:
                    if (_commands.Count != 0)
                    {
                        NextCommand();
                    }
                    break;

                case State.MOVE:
                    MovementControl(_route[_currentNodeNum].Direction);
                    break;

                case State.CLEARCOMM:
                    _commands.Clear();
                    _currentNodeNum = 0;
                    NextCommand();
                    break;

                case State.CLEARROUTE: //TODO
                    _currentNodeNum = 0;
                    _route.Clear();
                    NextCommand();
                    break;

                case State.READROUTE:
                    _currentNodeNum = 0;
                    ReadRouteData();
                    NextCommand();
                    break;

                case State.UNDOCKING:
                    if (_connector.Status == MyShipConnectorStatus.Connected)
                    {
                        _connector.Disconnect();
                        _connector.Enabled = false;
                    }
                    else
                    {
                        NextCommand();
                    }
                    break;

                case State.DOCKING:
                    GetForwardAxels();
                    float angle; double distance;
                    CalculatePlanarAngleAndDistanceTo(_route[_currentNodeNum].Position, out angle, out distance);
                    WheelsControl(angle, 1, _route[_currentNodeNum - 1].Speed);


                    if (_currentNodeNum == _routeLength)
                    {
                        if (_connector.Status == MyShipConnectorStatus.Connectable)
                        {
                            _connector.Connect();
                        }
                        if (_connector.Status == MyShipConnectorStatus.Connected)
                        {
                            NextCommand();
                        }
                    }
                    else if (distance < _route[_currentNodeNum].CheckDistance)
                    {
                        _currentNodeNum++;
                        _connector.Enabled = false;
                        if (_currentNodeNum == _routeLength)
                        {
                            _connector.Enabled = true;
                        }
                        WriteData();
                    }

                    break;

                case State.RADIOCALL:
                    ProgramInstance.IGC.SendBroadcastMessage(_radio, "DELIVERY " + _sender + " " + _mode + " " + _recipient);
                    NextCommand();
                    break;
                }
            }
Пример #7
0
            internal void NewInstructions(string argument)
            {
                string[] lines = argument.Split('\n');

                for (int l = 0; l < lines.Length; l++)
                {
                    string[] wordPair = lines[l].Split(':');
                    try
                    {
                        switch (wordPair[0].ToUpper())
                        {
                        case "NEWSTATE":
                            if (wordPair[1].ToUpper() == "CLEARCOMM")
                            {
                                _commands.Clear();
                                _currentNodeNum = 0;
                                _status         = State.STANDBY;
                            }
                            else
                            {
                                _status = StatusEnumFromString(wordPair[1].ToUpper());
                            }
                            break;

                        case "NEWCOMMAND":
                            _commands.Add(wordPair[1].ToUpper());
                            break;

                        case "NEWSENDER":
                            _sender = string.IsNullOrWhiteSpace(wordPair[1]) ? "NULL" : wordPair[1].Trim();
                            break;

                        case "NEWRECIPIENT":
                            _recipient = string.IsNullOrWhiteSpace(wordPair[1]) ? "NULL" : wordPair[1].Trim();
                            break;

                        case "NEWMODE":
                            _mode = wordPair[1];
                            break;

                        case "NEWRADIO":
                            _radio = wordPair[1];
                            break;

                        case "CLEARROUTE": //TODO
                            _currentNodeNum = 0;
                            _route.Clear();
                            NextCommand();
                            break;

                        default:
                            break;
                        } // end switch
                    }     //end for
                    catch (Exception e)
                    {
                        ProgramInstance.Echo(e.ToString());
                        ProgramInstance.Echo(e.StackTrace);
                    }
                }
                WriteData();
            }
Пример #8
0
            void ReadData()
            {
                /*
                 * Sender: TestStation1
                 * Recipient: teststation2
                 * Mode: courier|fred
                 * Radio: teststation2
                 * Goodbay: DroRadInp23 9899994525615633
                 * State: STANDBY
                 * CurrPath: 0
                 * ConnStat: Connected
                 */
                var text = StatusData;

                _previousInput = text;
                string[] lines = text.Split('\n');

                string[] wordPair = lines[0].Split(':');
                _sender = string.IsNullOrWhiteSpace(wordPair[1]) ? "NULL" : wordPair[1].Trim();

                wordPair   = lines[1].Split(':');
                _recipient = string.IsNullOrWhiteSpace(wordPair[1]) ? "NULL" : wordPair[1].Trim();

                wordPair = lines[2].Split(':');
                _mode    = wordPair[1];

                wordPair = lines[3].Split(':');
                _radio   = wordPair[1];

                wordPair       = lines[4].Split(':');
                _goodbayTarget = wordPair[1];

                wordPair = lines[5].Split(':');
                _status  = StatusEnumFromString(wordPair[1]);

                MoveOrStop();

                wordPair        = lines[6].Split(':');
                _currentNodeNum = int.Parse(wordPair[1]);

                _commands = new List <string>();
                //7 - ConnStat
                for (int l = 8; l < lines.Length; l++)
                {
                    wordPair = lines[l].Split(':');
                    try
                    {
                        switch (wordPair[0].ToUpper())
                        {
                        case "NEXTCOMM":
                            _commands.Add(wordPair[1].ToUpper());
                            break;

                        case "NEWSTATE":
                            _status = StatusEnumFromString(wordPair[1]);
                            break;

                        case "NEWCOMMAND":
                            _commands.Add(wordPair[1].ToUpper());
                            break;

                        case "NEWSENDER":
                            _sender = wordPair[1];
                            break;

                        case "NEWRECIPIENT":
                            _recipient = wordPair[1];
                            break;

                        case "NEWMODE":
                            _mode = wordPair[1];
                            break;

                        case "NEWRADIO":
                            _radio = wordPair[1];
                            break;

                        case "NEWGOODBAY":
                            _goodbayTarget = wordPair[1];
                            break;

                        default:
                            break;
                        }
                    }
                    catch
                    (Exception e)
                    {
                        ProgramInstance.Echo("At: " + (l + 1) + "\n" + e.ToString());
                    }
                }//end for
            }