public async Task <DroneFlight> GenerateFlight()
        {
            using (FlightProcessorConnection cn = new FlightProcessorConnection()) {
                var Query = from d in cn.DroneFlight
                            where d.BBFlightID == _BBFlightID &&
                            d.DroneID == _DroneID
                            select d;
                if (await Query.AnyAsync())
                {
                    _DroneFlight = await Query.FirstAsync();

                    _FlightMapData.FlightID = _FlightID = _DroneFlight.ID;
                    await LoadFlightDetails();
                }
                else
                {
                    //Load information about the flight from
                    await SetFlightInformation();

                    //Add flight information to database
                    cn.DroneFlight.Add(_DroneFlight);
                    await cn.SaveChangesAsync();

                    _FlightMapData.FlightID = _FlightID = _DroneFlight.ID;
                }//if(await Query.AnyAsync())
                _ExtDroneFlight = new ExtDroneFight(_DroneFlight);
            }

            //Load Approvals for the Flight
            await LoadFlightApprovals();
            await LoadExtDroneFlight();

            return(_DroneFlight);
        }
Beispiel #2
0
        public int CreateFlight(int DroneID)
        {
            int FlightID = 0;
            int Pilotid = 0, GSCID = 0;

            String Dt           = System.DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
            var    checkdefault = ctx.MSTR_Drone_Setup.Where(x => x.DroneId == DroneID).Select(x => x).FirstOrDefault();

            Pilotid = checkdefault.PilotUserId == null?0:Util.toInt(checkdefault.PilotUserId);
            GSCID   = checkdefault.GroundStaffUserId == null ? 0 : Util.toInt(checkdefault.GroundStaffUserId);

            DroneFlight df = new DroneFlight();

            df.DroneID    = DroneID;
            df.PilotID    = Pilotid;
            df.CreatedOn  = System.DateTime.UtcNow;
            df.FlightDate = System.DateTime.UtcNow;
            ctx.DroneFlight.Add(df);
            ctx.SaveChanges();
            DroneFlight dft = ctx.DroneFlight.Where(x => x.CreatedOn == df.CreatedOn && x.DroneID == df.DroneID).FirstOrDefault();

            if (df != null)
            {
                FlightID = df.ID;
            }

            return(FlightID);
        } //using (SqlTransaction sqlTrans)
Beispiel #3
0
 /// <summary>
 /// Standard on scene start function
 /// </summary>
 void Start()
 {
     trainingArea   = gameObject.transform.parent;
     droneRB        = GetComponent <Rigidbody2D>();
     droneInterface = GetComponent <DroneFlight>();
     target         = targetPlatform.transform;
 }
Beispiel #4
0
 public ActionResult Edit([Bind(Prefix = "ID")] int FlightID = 0) {
   if (!exLogic.User.hasAccess("FLIGHT.EDIT"))
     return RedirectToAction("NoAccess", "Home");
   ViewBag.Title = "Edit RPAS Flight";
   ExponentPortalEntities db = new ExponentPortalEntities();
   DroneFlight InitialData = db.DroneFlight.Find(FlightID);
   return View(InitialData);
 }
Beispiel #5
0
    }//GetGeoTagInfo()






    public ActionResult Create([Bind(Prefix = "ID")] int DroneID = 0) {
      if (!exLogic.User.hasAccess("FLIGHT.CREATE"))
        return RedirectToAction("NoAccess", "Home");
      ViewBag.Title = "Create RPAS Flight";
      DroneFlight InitialData = new DroneFlight();
      InitialData.DroneID = DroneID;
      return View(InitialData);
    }
Beispiel #6
0
 void Start()
 {
     player = GameObject.Find("Player");
     cargoShip = GameObject.Find("Cargo ship");
     line = gameObject.GetComponent<LineRenderer>();
     flight = gameObject.GetComponent<DroneFlight>();
     gun = gameObject.GetComponent<MachineGun>();
     target = player;
 }
Beispiel #7
0
        public JsonResult FlightInfo([Bind(Prefix = "ID")] int FlightID = 0)
        {
            DroneFlight df = new DroneFlight();

            using (ExponentPortalEntities ctx = new ExponentPortalEntities()) {
                df = (from d in ctx.DroneFlight
                      where d.ID == FlightID
                      select d).FirstOrDefault();
            }
            return(Json(df, JsonRequestBehavior.AllowGet));
        }
    void Start()
    {
        cargoShip = GameObject.Find("Cargo ship");
        line = gameObject.GetComponent<LineRenderer>();
        flight = gameObject.GetComponent<DroneFlight>();
        gun = gameObject.GetComponent<MachineGun>();

        var c = 2 * Mathf.PI * circleRadius;
        var xySpeed = Mathf.Sqrt(Mathf.Pow(flight.speed, 2) - Mathf.Pow(cargoShip.GetComponent<CargoShipAI>().speed, 2));
        radPerSec = 2 * Mathf.PI * xySpeed / c;
        this.transform.localPosition = NextCircleSpot();
    }
Beispiel #9
0
    public ActionResult Create(DroneFlight theFlight) {
      if (!exLogic.User.hasAccess("FLIGHT.CREATE"))
        return RedirectToAction("NoAccess", "Home");
      if (theFlight.DroneID < 1 || theFlight.DroneID == null)
        ModelState.AddModelError("DroneID", "You must select a Drone.");
      if (theFlight.PilotID < 1 || theFlight.PilotID == null)
        ModelState.AddModelError("PilotID", "Pilot is required for a Flight.");
      if (theFlight.GSCID < 1 || theFlight.GSCID == null)
        ModelState.AddModelError("GSCID", "A Ground Station Controller should be slected.");

      //if (Request != null)
      //{
      //    var a = Request["fileinputError"];
      //    HttpPostedFileBase file = Request.Files["fileinput"];
      //    if(file==null) ModelState.AddModelError("fileinput", "You must select a Document.");
      //}

      if (ModelState.IsValid) {
        int ID = 0;
        ExponentPortalEntities db = new ExponentPortalEntities();
        db.DroneFlight.Add(theFlight);
        db.SaveChanges();
        ID = theFlight.ID;
        db.Dispose();

        //Move the uploaded file to correct path
        if (Request["FileName"] != null)
          MoveUploadFileTo((int)theFlight.DroneID, theFlight.ID);

        //insert into log table
        string sql = "insert into MSTR_Pilot_Log(DroneId,Date,PilotId,MultiDashRotor,FlightID)values(" + theFlight.DroneID + ",'" + System.DateTime.Now.ToString("MM/dd/yyyy") + "'," + theFlight.PilotID + "," + (theFlight.FlightHours == null ? 0 : (theFlight.FlightHours / 60)) + "," + ID + ")";
        Util.doSQL(sql);

        return RedirectToAction("Detail", new { ID = ID });
      } else {
        ViewBag.Title = "Create RPAS Flight";
        return View(theFlight);
      }

    }
Beispiel #10
0
    public ActionResult Edit(DroneFlight InitialData) {
      if (!exLogic.User.hasAccess("FLIGHT.EDIT"))
        return RedirectToAction("NoAccess", "Home");

      ViewBag.Title = "Edit RPAS Flight";
      // ExponentPortalEntities db = new ExponentPortalEntities();
      // db.Entry(InitialData).State = EntityState.Modified;
      // db.SaveChanges();
      if (InitialData.PilotID == null)
        InitialData.PilotID = 0;
      if (InitialData.GSCID == null)
        InitialData.GSCID = 0;
      String SQL = @"UPDATE [DroneFlight] SET
        PilotID=" + InitialData.PilotID + @",
        GSCID=" + InitialData.GSCID + @",
        FlightDate='" + ((DateTime)InitialData.FlightDate).ToString("yyyy-MM-dd HH:mm:ss") + @"',
        DroneID=" + InitialData.DroneID + @",
        Latitude=" + Util.toDouble(InitialData.Latitude) + @",
        Longitude=" + Util.toDouble(InitialData.Longitude) + @"
      WHERE
        ID=" + InitialData.ID;
      Util.doSQL(SQL);

      //insert/update in log table
      string sqlcheck = "select Id from MSTR_Pilot_Log where FlightID=" + InitialData.ID;
      int result = Convert.ToInt32(Util.getDBInt(sqlcheck));
      if (result > 0) {
        string sql = "update MSTR_Pilot_Log set DroneId=" + InitialData.DroneID + ",PilotId=" + InitialData.PilotID + ",MultiDashRotor=" + (InitialData.FlightHours == null ? 0 : (InitialData.FlightHours / 60)) + "where FlightID=" + InitialData.ID;
        Util.doSQL(sql);
      } else {
        string sql = "insert into MSTR_Pilot_Log(DroneId,Date,PilotId,MultiDashRotor,FlightID)values(" + (InitialData.DroneID == null ? 0 : InitialData.DroneID) + ",'" + System.DateTime.Now.ToString("MM/dd/yyyy") + "'," + (InitialData.PilotID == null ? 0 : InitialData.PilotID) + "," + (InitialData.FlightHours == null ? 0 : (InitialData.FlightHours / 60)) + "," + InitialData.ID + ")";
        Util.doSQL(sql);
      }


      return RedirectToAction("Detail", new { ID = InitialData.ID });
    }
 public ExtDroneFight(DroneFlight BaseFlight)
 {
     Base = BaseFlight;
 }
Beispiel #12
0
    public List<DroneFlight> getLogFlights(List<DroneFlight> Flights, int FlightID = 0) {
      String SQL = FlightID == 0 ?
        "SELECT\n" +
        "  DroneFlight.ID,\n" +
        "  LogFrom,\n" +
        "  LogTo,\n" +
        "  Convert(Varchar, Min(FlightMapData.ReadTime), 111) as 'FlightDate(UTC)',\n" +
        "  Convert(Varchar, Min(FlightMapData.ReadTime), 108) as LogTakeOffTime,\n" +
        "  Convert(Varchar, Max(FlightMapData.ReadTime), 108) as LogLandingTime,\n" +
        "  Convert(Varchar, DATEADD(\n" +
        "     Minute,\n" +
        "     DATEDIFF(MINUTE, Min(FlightMapData.ReadTime), Max(FlightMapData.ReadTime)),\n" +
        "     '2000-01-01 00:00:00'), 108) as Duration,\n" +
        "  FlightMapData.BBFlightID,\n" +
        "  '' as LogBattery1ID,\n" +
        "  '' as   LogBattery1StartV,\n" +
        "  '' as   LogBattery1EndV,\n" +
        "  '' as   LogBattery2ID,\n" +
        "  '' as   LogBattery2StartV,\n" +
        "  '' as   LogBattery2EndV,\n" +
        "  '' as   Descrepency,\n" +
        "  '' as   ActionTaken\n" +
        "From\n" +
        "  DroneFlight\n" +
        "LEFT JOIN FlightMapData On\n" +
        "  FlightMapData.FlightID = DroneFlight.ID\n" +
        "WHERE\n" +
        "  DroneFlight.DroneID = " + DroneID.ToString() + " AND\n" +
        "    (isLogged IS NULL OR isLogged = 0)\n" +
        "GROUP BY\n" +
        "  DroneFlight.ID,\n" +
        "  DroneFlight.DroneID,\n" +
        "  FlightMapData.BBFlightID,\n" +
        "  LogFrom,\n" +
        "  LogTo\n"
        :
        "SELECT\n" +
        "  DroneFlight.ID,\n" +
        "  LogFrom,\n" +
        "  LogTo,\n" +
        "  Convert(Varchar(11), FlightDate, 111) as 'FlightDate(UTC)',\n" +
        "  Convert(Varchar, LogTakeOffTime, 108) as LogTakeOffTime,\n" +
        "  Convert(Varchar, LogLandingTime, 108) as LogLandingTime,\n" +
        "  Convert(Varchar, DATEADD(\n" +
        "     Minute,\n" +
        "     DATEDIFF(MINUTE, LogTakeOffTime, LogLandingTime),\n" +
        "     '2000-01-01 00:00:00'), 104) as Duration,\n" +
        "  LogBattery1ID,\n" +
        "  LogBattery1StartV,\n" +
        "  LogBattery1EndV,\n" +
        "  LogBattery2ID,\n" +
        "  LogBattery2StartV,\n" +
        "  LogBattery2EndV,\n" +
        "  Descrepency,\n" +
        "  ActionTaken,\n" +
        "  '0' as BBFlightID\n" +
        "From\n" +
        "  DroneFlight\n" +
        "WHERE\n" +
        "  ID=" + FlightID;

      var Rows = Util.getDBRows(SQL);
      foreach (var Row in Rows) {
        DroneFlight Flight = new DroneFlight() {
          ID = Util.toInt(Row["ID"].ToString()),
          LogFrom = Row["LogFrom"].ToString(),
          LogTo = Row["LogFrom"].ToString(),
          LogTakeOffTime = Util.toDate(Row["FlightDate"].ToString() + " " + Row["LogTakeOffTime"].ToString()),
          LogLandingTime = Util.toDate(Row["FlightDate"].ToString() + " " + Row["LogLandingTime"].ToString()),
          FlightDate = Util.toDate(Row["FlightDate"].ToString()),
          LogBattery1ID = Row["LogBattery1ID"].ToString(),
          LogBattery1StartV = Util.toDecimal(Row["LogBattery1StartV"].ToString()),
          LogBattery1EndV = Util.toDecimal(Row["LogBattery1EndV"].ToString()),
          LogBattery2ID = Row["LogBattery2ID"].ToString(),
          LogBattery2StartV = Util.toDecimal(Row["LogBattery2StartV"].ToString()),
          LogBattery2EndV = Util.toDecimal(Row["LogBattery2EndV"].ToString()),
          Descrepency = Row["Descrepency"].ToString(),
          ActionTaken = Row["ActionTaken"].ToString()
        };
        Flights.Add(Flight);
      }
      return Flights;
    }//getFlights()