예제 #1
0
    def emptyServices(self, drivers, vehicles):
        """Creates an accessory ServicesList to be used in the first working period,
        after attribution of vehicles to the available drivers.


        Requires: drivers and vehicles are collections of drivers and vehicles, respectively.
        Ensures: A ServicesList regarding the working period prior to the first of the day (ie 0709).
        This will be useful if one considers the first working period of the day (0911),
        where vehicles are not attributed to drivers and no service List is available.
        Thus, vehicles, lexicographic sorted by plate, are attributed to drivers
        according to their entry hour (and name, in case of tie). All the service-related information is
        set as a "no service" (_no_client_, _no_circuit_, service kms = 0), Arrival and Departure
        hours are set as the Driver's entry hour and being ready to work,
        drivers' status is standby, of course!
        """

        # sort drivers for the 1st period (0911) according to Drivers' EntryHour
        # and in case of tie, Drivers' name
        d = sorted(drivers.values())
        v = sorted(vehicles.keys())

        j = 0
        for i in d:
            driverName = i.getDriverName()
            vehiclePlate = v[j]
            serv = Service(driverName, vehiclePlate, "", i.getDriverEntryHour(), i.getDriverEntryHour(), "", "", "")
            serv.noService()
            self.append(serv)
            j += 1