Beispiel #1
0
        public Flight startFlight(String aircraft, double lat, double lon, Aircraft currentAircraft)
        {
            XmlDocument result;

            result = call("startFlight", "aircraft", aircraft, "lat", lat, "lon", lon);

            String            registration   = getTextNode(result.DocumentElement, "registration");
            String            fuel           = getTextNode(result.DocumentElement, "fuel");
            String            leaseExpires   = getTextNode(result.DocumentElement, "leaseExpires");
            bool              isTacho        = getTextNode(result.DocumentElement, "accounting") == "tacho";
            TimeSpan          leaseTime      = new TimeSpan(0, 0, Int32.Parse(leaseExpires));
            fuelStruct        startFuel      = new fuelStruct(fuel);
            bool              rentedDry      = getTextNode(result.DocumentElement, "rentedDry") == "true";
            float             rentalPrice    = float.Parse(getTextNode(result.DocumentElement, "rentalPrice"));
            int               payloadWeight  = Int32.Parse(getTextNode(result.DocumentElement, "payloadWeight"));
            List <assignment> assignmentList = new List <assignment>();

            foreach (XmlNode node in result.GetElementsByTagName("assignment"))
            {
                assignmentList.Add(new assignment(
                                       getTextNode((XmlElement)node, "from"),
                                       getTextNode((XmlElement)node, "to"),
                                       getTextNode((XmlElement)node, "cargo"),
                                       getTextNode((XmlElement)node, "comment")
                                       ));
            }
            return(new Flight(currentAircraft, registration, startFuel, leaseTime, rentedDry, rentalPrice, isTacho, payloadWeight, assignmentList));
        }
Beispiel #2
0
        void finishFlight(SIMCONNECT_RECV_SIMOBJECT_DATA data)
        {
            fuelStruct fuel       = (fuelStruct)data.dwData[0];
            String     parameters = currentFlight.getUrlParameters();

            parameters += String.Format("&lat={0:f}&lon={1:f}", currentAircraft.latestInfo.lat, currentAircraft.latestInfo.lon);
            parameters += "&" + fuel.getUrlParameters();
            using (SubmitForm dialog = new SubmitForm(parameters))
            {
                dialog.ShowDialog();
            }

            disposeFlight();
            updateFunction();
            currentAircraft.invalidatePosition();
        }
 public Flight(Aircraft aircraft, String registration, fuelStruct fuelState, TimeSpan leaseTime, bool rentedDry, float rentalPrice, bool isTacho, int payloadWeight, List <webRequest.assignment> assignmentList)
 {
     this.aircraft       = aircraft;
     this.registration   = registration;
     this.fuelState      = fuelState;
     this.leaseTime      = leaseTime;
     this.rentedDry      = rentedDry;
     this.rentalPrice    = rentalPrice;
     this.isTacho        = isTacho;
     this.payloadWeight  = payloadWeight;
     this.fuelPrice      = aircraft.latestProbeData.currentAirport.fuelPrice;
     this.assignmentList = assignmentList;
     this.started        = DateTime.UtcNow;
     engines             = new engine[aircraft.specifications.numEngines];
     for (int c = 0; c < engines.Length; c++)
     {
         engines[c] = new engine(c + 1);
     }
 }