model.schedule ============== .. py:module:: model.schedule Classes ------- .. autoapisummary:: model.schedule.StopTime model.schedule.TripType model.schedule.Trip model.schedule.Rotation Functions --------- .. autoapisummary:: model.schedule.check_trip_before_commit model.schedule.check_rotation_before_commit Module Contents --------------- .. py:class:: StopTime Bases: :py:obj:`eflips.model.Base` This represents a stop time of a :class:`Trip` at a :class:`Station`. A trip is not guaranteed to have any stop times, but it either has none (with only the arrival and departure times set) or every stop (including the first and last) has a stop time. .. py:attribute:: __tablename__ :value: 'StopTime' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the battery type. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[eflips.model.Scenario] The scenario. .. py:attribute:: station_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the station. Foreign key to :attr:`Station.id`. .. py:attribute:: station :type: sqlalchemy.orm.Mapped[eflips.model.Station] The station. .. py:attribute:: trip_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the trip. Foreign key to :attr:`Trip.id`. .. py:attribute:: trip :type: sqlalchemy.orm.Mapped[Trip] The trip. .. py:attribute:: arrival_time :type: sqlalchemy.orm.Mapped[datetime.datetime] The arrival time at the station. .. py:attribute:: dwell_duration :type: sqlalchemy.orm.Mapped[datetime.timedelta] The dwell time at the station. Defaults to 0 if unspecified. .. py:attribute:: __table_args__ .. py:method:: __repr__() .. py:class:: TripType(*args, **kwds) Bases: :py:obj:`enum.Enum` The type of a trip. Used in analysis to determine schedule efficiency. .. py:attribute:: EMPTY = deadheading, vehicle if repositioning itself for passenger trip .. py:attribute:: PASSENGER Passengers may board .. py:class:: Trip Bases: :py:obj:`eflips.model.Base` A trip is a single run of a bus on a :class:`Route`. It is part of a :class:`Rotation`. .. py:attribute:: __tablename__ :value: 'Trip' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the battery type. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[eflips.model.Scenario] The scenario. .. py:attribute:: route_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the route. Foreign key to :attr:`Route.id`. .. py:attribute:: route :type: sqlalchemy.orm.Mapped[eflips.model.Route] The route. .. py:attribute:: rotation_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the rotation. Foreign key to :attr:`Rotation.id`. .. py:attribute:: rotation :type: sqlalchemy.orm.Mapped[Rotation] The rotation. .. py:attribute:: departure_time :type: sqlalchemy.orm.Mapped[datetime.datetime] The departure time at the first station. This must be specified as full seconds, e.g. the "microseconds" part of the datetime must be 0. This is done because lots of later parts of the code assume that the departure time is a full second. .. py:attribute:: arrival_time :type: sqlalchemy.orm.Mapped[datetime.datetime] The arrival time at the last station. This must be specified as full seconds, e.g. the "microseconds" part of the datetime must be 0. This is done because lots of later parts of the code assume that the departure time is a full second .. py:attribute:: trip_type The type of the trip. Either `EMPTY` or `PASSENGER`. .. py:attribute:: loaded_mass The level of load on the bus in kg. .. py:attribute:: stop_times :type: sqlalchemy.orm.Mapped[List[StopTime]] .. py:attribute:: stations The stations of the trip. .. py:attribute:: events :type: sqlalchemy.orm.Mapped[List[eflips.model.Event]] .. py:attribute:: __table_args__ .. py:method:: __repr__() .. py:function:: check_trip_before_commit(_, __, target) 1) Check if the arrival or departure time is not a full second, warn the user if it is not. 2) Before a trip is flushed to the database, if it has stop times: - Ensure that the arrival time of the first stop time is the departure time of the trip - Ensure that the arrival time of the last stop time is the arrival time of the trip - Ensure that the first stop time is the first stop of the route - Ensure that the last stop time is the last stop of the route :param target: a trip :return: Nothing. Raises an exception if something is wrong. .. py:class:: Rotation Bases: :py:obj:`eflips.model.Base` A rotation is a sequence of trips that are performed by a bus in a single day. .. py:attribute:: __tablename__ :value: 'Rotation' .. py:attribute:: id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the battery type. Auto-incremented. .. py:attribute:: scenario_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the scenario. Foreign key to :attr:`Scenario.id`. .. py:attribute:: scenario :type: sqlalchemy.orm.Mapped[eflips.model.Scenario] The scenario. .. py:attribute:: vehicle_type_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the vehicle type. Foreign key to :attr:`VehicleType.id`. .. py:attribute:: vehicle_type :type: sqlalchemy.orm.Mapped[eflips.model.VehicleType] The vehicle type. .. py:attribute:: vehicle_id :type: sqlalchemy.orm.Mapped[int] The unique identifier of the vehicle. Foreign key to :attr:`Vehicle.id`. .. py:attribute:: vehicle :type: sqlalchemy.orm.Mapped[eflips.model.Vehicle] .. py:attribute:: allow_opportunity_charging :type: sqlalchemy.orm.Mapped[bool] Whether opportunity charging is permitted. To actually charge, the vehicle type must support opportunity charging. .. py:attribute:: name :type: sqlalchemy.orm.Mapped[str] The name of the rotation. .. py:attribute:: trips :type: sqlalchemy.orm.Mapped[List[Trip]] A list of trips. .. py:method:: __repr__() .. py:function:: check_rotation_before_commit(_, __, target) A Rotation needs to be contiguous in time and space - the end station of a trip must be the start station of the next trip - the departure time of a trip must be after the arrival time of the previous trip :param target: A Rotation object :return: Nothing. Raises an exception if something is wrong.