Exemplo n.º 1
0
        public JobData(SJob data)
        {
            UID           = data.uid;
            status        = data.status;
            packageWeight = data.packageWeight;
            packageXArea  = data.packageXarea;

            costFunction = new CostFunction(data.costFunction);

            if (data.status != JobStatus.Assigning)
            {
                created    = new TimeKeeper.Chronos(data.createdUnity).SetReadOnly();
                assignment = new TimeKeeper.Chronos(data.assignedTime).SetReadOnly();
                deadline   = new TimeKeeper.Chronos(data.deadline).SetReadOnly();
                if (data.status != JobStatus.Delivering)
                {
                    completed = new TimeKeeper.Chronos(data.completedOn).SetReadOnly();
                    pickup    = data.pickup;
                    dropoff   = data.destination;
                }
            }
            else
            {
                created  = TimeKeeper.Chronos.Get();
                deadline = TimeKeeper.Chronos.Get() + costFunction.CompleteIn;
                earnings = costFunction.GetPaid(deadline - 1f, deadline); // aproximate earnings
                Vector3 o = data.pickup;
                o.y = 0;
                Vector3 d = data.destination;
                d.y = 0;

                pickup  = LandingZoneIdentifier.Reposition(o);
                dropoff = LandingZoneIdentifier.Reposition(d);
            }
        }
Exemplo n.º 2
0
 public RetiredDroneData(Drone drone)
 {
     isDroneCollision = false;
     UID           = drone.UID;
     job           = drone.GetJob().UID;
     hub           = drone.GetHub()?.Name;
     completedJobs = drone.JobHistory;
     drone.StopCoroutine(drone.GetBattery().ChargeBattery());
     batteryCharge     = drone.GetBattery().Charge;
     waypoint          = drone.Waypoint;
     destroyedTime     = TimeKeeper.Chronos.Get();
     collisionLocation = drone.transform.position;
     packageWorth      = job == 0 ? 0 : -drone.GetJob().Loss;
     otherDrone        = "Retired";
 }
Exemplo n.º 3
0
        private IEnumerator StartTimer()
        {
            _active = true;
            _time   = TimeKeeper.Chronos.Get();
            yield return(_WaitForUnpause);

            while (_active)
            {
                _time.Now();
                yield return(_wait);

                var dt = _time.Timer();
                AssignedDrone.UpdateAudible(dt);
            }
        }
Exemplo n.º 4
0
        public JobData(Hub pickup, Vector3 dropoff)
        {
            UID = ++_count;

            Hub           = pickup.UID;
            Status        = JobStatus.Assigning;
            Pickup        = pickup.Position;
            Dropoff       = LandingZoneIdentifier.Reposition(dropoff);
            PackageWeight = Random.Range(0.1f, 2.5f);

            Cost             = new CostFunction(WeightToRev(Pricing.US, PackageWeight));
            ExpectedDuration = (LateralManhattan() + LateralEuclidean()) / (2 * DroneMovementJob.HorizontalSpeed) + (Pickup.y - dropoff.y) / DroneMovementJob.VerticalSpeed;
            StDevDuration    = LateralManhattan() / DroneMovementJob.HorizontalSpeed - ExpectedDuration + (Pickup.y - Dropoff.y) / DroneMovementJob.VerticalSpeed;

            Deadline = Cost.Start + Cost.Guarantee;
        }
Exemplo n.º 5
0
 public void SetData(SimulationData data, TimeKeeper.Chronos time)
 {
     _simulationData[0]  = DateTime.Now.ToString(CultureInfo.InvariantCulture);
     _simulationData[1]  = time.ToCsvFormat();
     _simulationData[2]  = data.drones.Count.ToString();
     _simulationData[3]  = Objects.Drone.ActiveDrones.childCount.ToString();
     _simulationData[4]  = data.crashes.ToString();
     _simulationData[5]  = data.queuedJobs.ToString();
     _simulationData[6]  = data.inQueueDelayed.ToString();
     _simulationData[7]  = data.completedCount.ToString();
     _simulationData[8]  = data.delayedJobs.ToString();
     _simulationData[9]  = data.failedJobs.ToString();
     _simulationData[10] = data.revenue.ToString("0.00");
     _simulationData[11] = (data.totalDelay / data.completedCount).ToString("0.00");
     _simulationData[12] = data.totalAudible.ToString("0.00");
     _simulationData[13] = UnitConverter.Convert(Energy.kWh, data.totalEnergy);
 }
Exemplo n.º 6
0
        private IEnumerator StartTimer()
        {
            _Active = true;
            if (_Time == null)
            {
                _Time = TimeKeeper.Chronos.Get();
            }
            while (_Active)
            {
                _Time.Now();
                yield return(_Wait);

                float dt = _Time.Timer();
                AssignedDrone.UpdateAudible(dt);
                SimManager.UpdateAudible(dt);
            }
            yield break;
        }
Exemplo n.º 7
0
 public RetiredDroneData(Drone drone, Collider other)
 {
     UID           = drone.UID;
     job           = drone.GetJob().UID;
     hub           = drone.GetHub()?.Name;
     completedJobs = drone.JobHistory;
     drone.StopCoroutine(drone.GetBattery().ChargeBattery());
     batteryCharge = drone.GetBattery().Charge;
     if (other.CompareTag("Drone"))
     {
         var collidee = other.GetComponent <Drone>();
         isDroneCollision = true;
         otherDrone       = collidee.Name;
         otherUID         = collidee.UID;
     }
     waypoint          = drone.Waypoint;
     destroyedTime     = TimeKeeper.Chronos.Get();
     collisionLocation = drone.transform.position;
     packageWorth      = job == 0 ? 0 : -drone.GetJob().Loss;
 }
Exemplo n.º 8
0
        public void SetData(HubData data, TimeKeeper.Chronos time)
        {
            var hub = (Objects.Hub)SimManager.AllHubs[data.UID];

            _hubData[0]  = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            _hubData[1]  = time.ToCsvFormat();
            _hubData[2]  = data.drones.Count.ToString();
            _hubData[3]  = data.ActiveDroneCount.ToString();
            _hubData[4]  = data.NumberOfDroneCrashes.ToString();
            _hubData[5]  = data.batteries.Count.ToString();
            _hubData[6]  = hub.GetChargingBatteryCount().ToString();
            _hubData[7]  = data.NumberOfJobsInQueue.ToString();
            _hubData[8]  = data.NumberOfJobsDelayedInQueue.ToString();
            _hubData[9]  = data.CompletedJobCount.ToString();
            _hubData[10] = data.DelayedCompletedJobs.ToString();
            _hubData[11] = data.FailedJobs.ToString();
            _hubData[12] = data.Earnings.ToString("0.00");
            _hubData[13] = (data.TotalDelayOfCompletedJobs / data.CompletedJobCount).ToString("0.00");
            _hubData[14] = data.AudibleDuration.ToString("0.00");
            _hubData[15] = UnitConverter.Convert(Energy.kWh, data.EnergyConsumption);
        }
Exemplo n.º 9
0
 public RetiredDroneData(SRetiredDrone data)
 {
     UID = data.uid;
     isDroneCollision = data.isDroneCollision;
     hub               = data.hub;
     packageWorth      = data.packageworth;
     destroyedTime     = new TimeKeeper.Chronos(data.destroyed);
     collisionLocation = data.location;
     waypoint          = data.waypoint;
     otherUID          = data.otherUID;
     otherDrone        = data.otherDroneName;
     batteryCharge     = data.charge;
     job               = data.assignedJob;
     completedJobs     = new SecureSortedSet <uint, IDataSource>((x, y) => (((Job)x).CompletedOn >= ((Job)y).CompletedOn) ? -1 : 1)
     {
         MemberCondition = (IDataSource obj) => { return(obj is Job); }
     };
     foreach (uint j in data.completedJobs)
     {
         completedJobs.Add(j, AllCompleteJobs[j]);
     }
 }
Exemplo n.º 10
0
        public float GetPaid(TimeKeeper.Chronos complete, TimeKeeper.Chronos deadline)
        {
            float dt = complete - deadline;

            return(Reward * Step(dt, deadline - deadline));
        }
Exemplo n.º 11
0
 public void GetData(DataLogger logger, TimeKeeper.Chronos time) => logger.SetData(_data, time);