예제 #1
0
파일: AgentBase.cs 프로젝트: pecen/Reco3
        public bool QueueJob(SimulationJob job)
        {
            try
            {
                /*
                 * if (DbAgent.Registered == false)
                 *  return false;
                 *
                 * using (var db = new DatabaseContext())
                 * {
                 *  var balance = (from sim in db.Simulation
                 *          join agent in db.Agent on sim.AgentId equals agent.AgentId
                 *          where agent.AgentId == '1'
                 *          select sim.SimulationId)
                 *      .SingleOrDefault();
                 *
                 *
                 *
                 * }
                 * return true;
                 */
            }
            catch
            {
            }

            return(false);
        }
예제 #2
0
    protected override void ThreadFunction()
    {
        try
        {
            bool running = true;

            List <SimulateAreaJob> jobs = new List <SimulateAreaJob>();

            jobs.Clear();

            uint totalDevisions = _worldSimulationState.SimulationDevisions;
            uint stepsCompleted = 0;

            for (uint i = 0; i < totalDevisions; i++)
            {
                jobs.Add(SimulateStep(i, totalDevisions, () =>
                {
                    if (++stepsCompleted >= jobs.Count)
                    {
                        //TODO SImulate again
                        _worldSimulationState.StepSimulationState();
                        _worldSimulationStateService.SaveState(_worldSimulationState, _persistentDataPath);

                        SimulationJob _job = new SimulationJob(_worldDataAccess, _worldSimulationState, _worldSimulationStateService, _persistentDataPath);
                        _job.Start();
                    }
                }));
            }
        }
        catch (Exception e)
        {
            Debug.LogError("There was an error running SimulationJob \n" + e);
        }
    }
예제 #3
0
파일: AgentBase.cs 프로젝트: pecen/Reco3
        public bool DeleteSimulationJob(SimulationJob job, bool bDeleteVehicleXMLs)
        {
            try
            {
                /*
                 * using (var db = new DatabaseContext())
                 * {
                 *  using (var dbContextTransaction = db.Database.BeginTransaction())
                 *  {
                 *      try
                 *      {
                 *          List<Simulation> sims = db.Simulation.Where(x => x.SimulationJobId == job.SimulationJobId).ToList();
                 *
                 *          db.SaveChanges();
                 *          dbContextTransaction.Commit();
                 *      }
                 *      catch (Exception ex)
                 *      {
                 *          dbContextTransaction.Rollback();
                 *      }
                 *  }
                 * }
                 */
            }
            catch
            {
            }

            return(false);
        }
예제 #4
0
 private void OnDestroy()
 {
     if (_job != null)
     {
         _job.Abort();
         _job = null;
     }
 }
예제 #5
0
        public ActionResult Edit(SimulationJob job)
        {
            AgentBase ABase = new AgentBase();

            if (ModelState.IsValid)
            {
                ABase.GetContext().Entry(job).State = EntityState.Modified;
                ABase.GetContext().SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(job));
        }
예제 #6
0
    private IEnumerator SimulationCoroutine()
    {
        yield return(0);

        bool simulating = true;

        _job = new SimulationJob(_worldDataAccess, _state, _worldSimulationStateService, Application.persistentDataPath);
        _job.Start();

        while (!_job.IsDone)
        {
            yield return(0);
        }
    }
예제 #7
0
파일: AgentBase.cs 프로젝트: pecen/Reco3
        //public List<Simulation> GetSimulationList(SimulationJob job)
        public object GetSimulationList(SimulationJob job)
        {
            try
            {
                using (var db = new DatabaseContext())
                {
                    /*
                     * var query = (from sim in db.Simulation
                     *  join vehicle in db.Vehicle on sim.VehicleId equals vehicle.VehicleId
                     *  where sim.SimulationJobId == job.SimulationJobId
                     *  select new
                     *  {
                     *      vehicle.VIN,
                     *      sim.AgentId
                     *
                     *  }).ToList();
                     */
                    /*
                     * var query = (from sim in db.Simulation
                     *           join vehicle in db.vehicle on sim.VehicleId equals vehicle.VehicleId
                     *           where sim.SimulationJobId == job.SimulationJobId
                     *           select sim).ToList();
                     */

                    /*
                     * select Sim.AgentId,
                     * SimJob.OwnerSss,
                     * SimJob.SimulationJobName,
                     * vehicle.VIN
                     * from [BugsBunny].[dbo].[Simulation] as Sim
                     * inner join [BugsBunny].[dbo].[vehicle] as vehicle  on vehicle.[VehicleId] = Sim.[VehicleId]
                     * inner join [BugsBunny].[dbo].[SimulationJob] As SimJob on SimJob.SimulationJobId = Sim.SimulationJobId
                     */

                    //ar query = (from p in db.Simulation where p.SimulationJobId == job.SimulationJobId select p).ToList();

                    // return query;
                }
            }
            catch
            {
            }

            return(null);
        }
예제 #8
0
        public ActionResult SaveSimulation(string SimulationName, string SimulationJobId)
        {
            try
            {
                AgentBase     ABase = new AgentBase();
                SimulationJob job   = ABase.CreateNewSimulationJob(SimulationName, SimulationJobId);
                if (job != null)
                {
                    return(Json(new { success = true, message = "Simulation successfully created.", jobid = job.SimulationJobId }, JsonRequestBehavior.AllowGet));
                }
                return(Json(new { success = false, message = "Failed to create simulation." }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(Json(new { success = false, message = e.Message }, JsonRequestBehavior.AllowGet));
            }


            //return RedirectToAction("Index");
        }