Beispiel #1
0
        internal new static TaskTravelDurationDataSet Read(StateBinaryReader reader, VehicleSchedule schedule)
        {
            TaskTravelDurationDataSet result = new TaskTravelDurationDataSet();

            result.DoRead(reader, schedule);
            return(result);
        }
            internal static Measurement Read(StateBinaryReader reader, VehicleSchedule schedule, VehicleScheduleData data)
            {
                RootTask    task   = schedule.GetTasks()[reader.ReadInt()];
                Measurement result = MeasurementSurrogate.Read(reader, data, task);

                result.DoRead(reader, schedule, data);
                return(result);
            }
        protected virtual void DoRead(StateBinaryReader reader, VehicleSchedule schedule)
        {
            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int      taskIndex = reader.ReadInt();
                RootTask task      = schedule.GetTasks()[taskIndex];
                _data.Add(task, DurationDataSet.Read(reader));
            }
        }
Beispiel #4
0
 protected override void DoRead(StateBinaryReader reader, VehicleSchedule schedule, VehicleScheduleData data)
 {
     base.DoRead(reader, schedule, data);
     _startDistance = null;
     if (ScheduleStopwatch.GetSchemaVersion(typeof(VehicleScheduleData)) >= 2)
     {
         if (reader.ReadBool())
         {
             _startDistance = reader.ReadFloat();
         }
     }
 }
Beispiel #5
0
        internal void Read(StateBinaryReader reader)
        {
            _connectedBuildings.Clear();
            _additionalDemands.Clear();
            _connectedStations.Clear();

            if (ScheduleStopwatch.GetSchemaVersion(typeof(StationDemandManager)) >= 3)
            {
                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    VehicleStation station = reader.ReadBuilding <VehicleStation>();
                    UniqueList <IStorageNetworkNode> demandList = null;
                    int countList = reader.ReadInt();
                    if (countList > 0 && station != null)
                    {
                        demandList = GetOrCreateDemandsList(station);
                    }

                    for (int j = 0; j < countList; j++)
                    {
                        IStorageNetworkNode node = reader.ReadBuilding <Building>() as IStorageNetworkNode;
                        if (demandList != null && node != null)
                        {
                            demandList.Add(node);
                            _connectedBuildings.Add(node.Building);
                        }
                    }
                }

                count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    VehicleStation station = reader.ReadBuilding <VehicleStation>();
                    UniqueList <VehicleStation> stationList = null;
                    int countList = reader.ReadInt();
                    if (countList > 0 && station != null)
                    {
                        stationList = GetOrCreateConnectedStationsList(station);
                    }

                    for (int j = 0; j < countList; j++)
                    {
                        VehicleStation connStation = reader.ReadBuilding <VehicleStation>();
                        if (stationList != null && connStation != null)
                        {
                            stationList.Add(connStation);
                            _connectedBuildings.Add(connStation);
                        }
                    }
                }
            }
        }
        internal void Read(StateBinaryReader reader)
        {
            _vehiclesData.Clear();
            int count = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int     vehicleId = reader.ReadInt();
                Vehicle vehicle   = LazyManager <VehicleManager> .Current.FindById(vehicleId);

                _vehiclesData.Add(vehicle, VehicleScheduleData.Read(reader, vehicle));
            }
        }
Beispiel #7
0
        internal static VehicleScheduleData Read(StateBinaryReader reader, Vehicle vehicle)
        {
            VehicleScheduleData result = new VehicleScheduleData(vehicle)
            {
                _travelData         = TaskTravelDurationDataSet.Read(reader, vehicle.Schedule),
                _stationLoadingData = TaskDurationDataSet.Read(reader, vehicle.Schedule)
            };

            if (reader.ReadBool())
            {
                result._measurement = Measurement.Read(reader, vehicle.Schedule, result);
            }

            return(result);
        }
Beispiel #8
0
            internal static Measurement Read(StateBinaryReader reader, VehicleScheduleData data, RootTask task)
            {
                byte id = reader.ReadByte();

                switch (id)
                {
                case 0:
                    return(new StationLoadingMeasurement(data, task));

                case 1:
                    return(new TravelMeasurement(data, task));
                }

                throw new ArgumentException("Unknown id " + id.ToString());
            }
Beispiel #9
0
        internal static DurationDataSet Read(StateBinaryReader reader)
        {
            DurationDataSet result = new DurationDataSet();
            int             count  = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                TimeSpan span = new TimeSpan(reader.ReadLong());
                result._durationData.Put(span);
                result._runningSum += span;
            }

            result._totalCount = reader.ReadInt();
            result._totalSum   = new TimeSpan(reader.ReadLong());

            return(result);
        }
        protected override void Read(StateBinaryReader reader)
        {
            _readVersion = null;
            try
            {
                int antVersion = SchemaVersion <ScheduleStopwatch> .Get();

                if (antVersion < 3)
                {
                    _readVersion = reader.ReadByte();
                }
                VehicleScheduleDataManager.Current.Read(reader);
                LazyManager <StationDemandManager> .Current.Read(reader);
            }
            catch (Exception e)
            {
                logger.Log(UnityEngine.LogType.Error, "Error when loading ScheduleStopwatch data");
                logger.LogException(e);
            }
            _readVersion = null;
        }
Beispiel #11
0
        protected override void DoRead(StateBinaryReader reader, VehicleSchedule schedule)
        {
            base.DoRead(reader, schedule);
            if (ScheduleStopwatch.GetSchemaVersion(typeof(TaskDurationDataSet)) >= 2)
            {
                int count = reader.ReadInt();

                for (int i = 0; i < count; i++)
                {
                    int   taskIndex = reader.ReadInt();
                    float value     = reader.ReadFloat();
                    if (taskIndex > -1)
                    {
                        _distanceData.Add(schedule.GetTasks()[taskIndex], value);
                    }
                    else
                    {
                        ScheduleStopwatch.logger.Log(UnityEngine.LogType.Warning, "RootTask index = -1");
                    }
                }
            }
        }
Beispiel #12
0
 protected override void Read(StateBinaryReader reader)
 {
     OldSchoolStyleManager.Current.Enabled = reader.ReadBool();
 }
 public void Read(StateBinaryReader reader)
 {
 }
 protected virtual void DoRead(StateBinaryReader reader, VehicleSchedule schedule, VehicleScheduleData data)
 {
     startTime = new DateTime(reader.ReadLong());
 }