Flightplan GenerateFlightPlan(Destination destination) { var fp = new Flightplan(); if (connector.Status == MyShipConnectorStatus.Connected) { fp.departure.matrix = connector.OtherConnector.WorldMatrix; fp.waypoints.Add(new Flightplan.Waypoint { name = "UDCK", position = connector.WorldMatrix.Translation, speed = Settings.DEPARTURE_SPEED, flags = SpaceshipFlags.Undock }); fp.waypoints.Add(new Flightplan.Waypoint { name = "DEPT", position = connector.WorldMatrix.Translation + connector.OtherConnector.WorldMatrix.Forward * Settings.ApproachHeight, speed = 10, flags = SpaceshipFlags.Enroute }); } else { fp.waypoints.Add(new Flightplan.Waypoint { name = "WPT", position = connector.WorldMatrix.Translation, speed = Settings.MAX_SPEED, flags = SpaceshipFlags.Enroute }); } fp.arrival.matrix = destination.matrix; Vector3D world_position = fp.arrival.matrix.Translation + fp.arrival.matrix.Forward * destination.size * 0.5; fp.waypoints.Add(new Flightplan.Waypoint { name = "ARVL", position = world_position + fp.arrival.matrix.Forward * Settings.ApproachHeight, speed = Settings.APPROACH_SPEED, flags = SpaceshipFlags.Approach }); fp.waypoints.Add(new Flightplan.Waypoint { name = "DCK", position = world_position, speed = Settings.DOCKING_SPEED, flags = SpaceshipFlags.Dock }); return(fp); }
// One of the methods to test different NpgSql connection string. public List <Flightplan> GetFlightplans() { List <Flightplan> flightplans = new List <Flightplan>(); using (NpgsqlConnection npgsqlConnection = DatabaseConnection.GetStaticCon()) // One of the methods to test different NpgSql connection string. { using (var cmd = new NpgsqlCommand()) { cmd.Connection = npgsqlConnection; cmd.CommandText = "SELECT id, author, created_at, \"name\" FROM public.flightplan"; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { Flightplan flightplan = new Flightplan(); flightplan.rowId = reader.GetInt32(0); flightplan.authorId = reader.GetInt32(1); flightplan.createdAt = reader.GetInt32(2); flightplan.name = reader.GetString(3); flightplans.Add(flightplan); } } } npgsqlConnection.Close(); } return(flightplans); }
protected override async Task OnInitAsync() { var connectionTask = Http.GetJsonAsync <Connection[]>("http://localhost:5000/api/connections"); var baseTask = Http.GetJsonAsync <Base[]>("http://localhost:5000/api/bases"); await Task.WhenAll(connectionTask, baseTask); (Points, Connections) = Flightplan.PrepareFlightplan(connectionTask.Result, baseTask.Result, (250d, 250d)); }
protected override async Task OnInitializedAsync() { var connectionTask = StarshipApi.GetConnectionsAsync(); var baseTask = StarshipApi.GetBasisAsync(); await Task.WhenAll(connectionTask, baseTask); (Points, Connections) = Flightplan.PrepareFlightplan(connectionTask.Result.ToArray(), baseTask.Result.ToArray(), (250d, 250d)); }
public async Task <Flightplan> askserver(server servers, string s) { Httpclientclass httpRequestClass = new Httpclientclass(); var result = await httpRequestClass.makeRequest(servers.ServerURL + s); Flightplan fl = new Flightplan(); fl = JsonConvert.DeserializeObject <Flightplan>(result); return(fl); }
public void SetFlightPlan(Flightplan fp) { flightplan = null; prev = 0; next = 0; active_waypoint = 0; if (fp != null && fp.IsValid()) { flightplan = fp; } }
public Flightplan Post(Flightplan f) { string dammyf = GenerateString(10); f.FlightPlanId = dammyf; flymanager.addflight(f); return(f); }
public void Deserialize(MemoryStream ms) { bool has_flightplan; ms.ReadBool(out has_flightplan); if (has_flightplan) { flightplan = new Flightplan(); flightplan.Deserialize(ms); } ms.ReadInt(out prev); ms.ReadInt(out next); ms.ReadInt(out active_waypoint); }
public void Delete(string id) { Flightplan p = flightplanmanager.flights.Where(x => x.FlightPlanId == id).FirstOrDefault(); if (p == null) { throw new Exception("id not found "); } else { flightplanmanager.flights.Remove(p); } }
protected override async Task OnInitializedAsync() { if (StarshipApi == null || Flightplan == null) { throw new InvalidOperationException("Properties not initialized by DI. Configuration error?"); } var connectionTask = StarshipApi.GetConnectionsAsync(); var baseTask = StarshipApi.GetBasisAsync(); await Task.WhenAll(connectionTask, baseTask); (Points, Connections) = Flightplan.PrepareFlightplan(connectionTask.Result.ToArray(), baseTask.Result.ToArray(), (250d, 250d)); }
public void cheak_id_sharefromservers() { instalationplan(); Flightplan plan = new Flightplan(); string timetotest = DateTime.Now.AddSeconds(11380 + 200).ToString(); plan = flightplancontrol.Getflight().First(); string id = plan.FlightPlanId; Flightplan planfrom_id = flightplancontrol.GetAsync(id).Result; Assert.AreEqual(planfrom_id.FlightPlanId, flightplancontrol.Getflight().First().FlightPlanId); }
public void cheakthepostofflight() { instalationplan(); Flightplan plan = new Flightplan(); string timetotest = DateTime.Now.AddSeconds(11380 + 200).ToString(); plan = flightplancontrol.Getflight().First(); string get_compamy_name; get_compamy_name = plan.company_name; Assert.AreEqual(get_compamy_name, "test"); }
void instalationplan() { var flight = new FlightsController(); Flightplan k = new Flightplan(); segments newseg = new segments(); newseg.setall(22, 22, 2000); k.company_name = "test"; k.initial_location = new InitialLocation(); DateTime tt = new DateTime(); tt = DateTime.Now; k.initial_location.setalll(22, 22, tt); k.segments = new System.Collections.Generic.List <segments>(); k.segments.Add(newseg); // flightplanmanager.flights.Add(k); flightplancontrol.Post(k); }
public Flightplan GetFlightplanInfo(string flightplanName) { Flightplan flightplan = new Flightplan(); using (var cmd = new NpgsqlCommand()) { cmd.Connection = this.npgSqlCon; cmd.CommandText = "SELECT id, \"name\", author, created_at FROM public.flightplan WHERE name=(@fpname)"; cmd.Parameters.AddWithValue("@fpname", flightplanName); using (var reader = cmd.ExecuteReader()) { reader.Read(); flightplan.rowId = reader.GetInt32(0); flightplan.name = reader.GetString(1); flightplan.authorId = reader.GetInt32(2); flightplan.createdAt = reader.GetInt32(3); } } return(flightplan); }
public async Task <Flightplan> GetAsync(string id) { if (flymanager.getbyid(id) == null) { foreach (var serverdata in iservermanager.allserverslist) { Flightplan flightPlan = new Flightplan(); string param = "/api/FlightPlan/"; flightPlan = await askserver(serverdata, param + id); if (flightPlan.company_name != null) { return(flightPlan); } } return(null); } else { return(flymanager.getbyid(id)); } }
/** * This method executes a flightplan at a RPi connection. This basically means that the method does: * Get the proper information needed, like the RPi connection object and the Flightplan object. * Then it validates that you are connected to the RPi connection. * Then it formats the classes (found below this class), so that it is readable by the RPi backend. * It then starts a flight in this system. * Then it sends the flightplan to the RPi backend. * It then asks the RPi connection to execute the flightplan. */ public bool HandFlightplanToRPiConnection(int receiverRPiConnectionId, string flightplanName, int priority) { this.rpiConDbService.DisconnectOldRPiConnections(); this.UpdateLastTouch(); Flightplan fpToSend = this.fpService.GetFlightplan(flightplanName); RPiConnection receiverRPiConnection = this.GetRPiConnection(receiverRPiConnectionId); int uid = this.GetUserId(); if (receiverRPiConnection.status == "disconnected") { Console.WriteLine("RPi not connected"); return(false); } else if (receiverRPiConnection.userId != uid) { Console.WriteLine("You have no connections!"); return(false); } FlightplanModelForJava flightplanModelForJava = new FlightplanModelForJava(); flightplanModelForJava.created_at = fpToSend.createdAt; flightplanModelForJava.priority = priority; flightplanModelForJava.commands = new List <CommandModelForJava>(); foreach (KeyValuePair <int, Command> entry in fpToSend.commands) { CommandModelForJava commandModelForJava = new CommandModelForJava(); commandModelForJava.cmd_id = entry.Value.CmdId; commandModelForJava.parameters = entry.Value.Params; flightplanModelForJava.commands.Insert(entry.Key, commandModelForJava); } // Start flight this.rpiConDbService.StartFlight(receiverRPiConnection.rowId, fpToSend.rowId, uid); string urlIpPort = "http://" + receiverRPiConnection.ip + ":" + receiverRPiConnection.port; string urlStoreFlightplan = urlIpPort + "/api/flightplan/store/"; string sendFlightplanResult = this.sendHttpService.SendPost(urlStoreFlightplan, ref flightplanModelForJava, receiverRPiConnection.password); if (!this.sendHttpService.DeserializeJsonString <bool>(sendFlightplanResult)) { throw new TimeoutException("Could not send flightplan to RPi!"); } // TODO: Log to flight that flightplan has been sent string urlExecuteFlightplan = urlIpPort + "/api/flightplan/execute/"; EmptyModel emptyModel = new EmptyModel(); string executeFlightplan = this.sendHttpService.SendPost(urlExecuteFlightplan, ref emptyModel, receiverRPiConnection.password); if (!this.sendHttpService.DeserializeJsonString <bool>(executeFlightplan)) { throw new TimeoutException("Could not execute flightplan at RPi!"); } // TODO: Log to flight that flightplan has been executed return(true); }