BUSHANDLING describes the phase during which an emergency peer (firefighter) needs a certain number of buses and, while they arrive, send them to specific destinations.
// Written by Gaia Trecarichi on 19/09/2007
//
// After having counted the number of people at the meeting point (MP) and
// evaluated the criticality (danger level at that MP) the firefighter request
// a certain number of bus (No_bus) the firefighter will then receive from its
// coordinator the quantity of buses (NB) that will arrive and a
// list of refuge centers (DCL) where the buses can go after people are loaded.
a(firefighter(MP),FF)::
request_bus(MP,No_bus) => a(firefighter_coordinator,FFC) <-
count(People) and get(Criticality) and
bus_needed(People,Criticality,No_bus) and
get_coordinator_ID(FFC) then
confirm_bus_arrival(NB,DCL) <= a(firefighter_coordinator,FFC) then
a(wait_for_bus(NB,DCL),FF) <- set_destination(DCL) then
a(firefighter(MP),FF)
// The coordinator receives the request of buses, decides how many buses
// will send (No_bus) and assigns to each of them a destination
// Then, he will send a confirmation message to the bus requester
a(firefighter_coordinator,FFC)::
request_bus(MP,Quantity) <= a(firefighter(_),FF) then
confirm_bus_arrival(No_bus,Destinations) => a(firefighter(_),FF) <-
check_for_bus(Quantity,No_bus) and assign(No_bus,Destinations)
// The bus requester enter this role after having received a confirmation of
// bus arrival from the coordinator.
// He expects buses arriving in a quantity of No_expected and has a list of
// destinations where to send each of them.
// Once a certain number (No_Bus) of buses arrives at the location (MP),
// a list (ABL) containing details for each bus is given.
// The list could merely be a list of bus identifiers.
// The firefighter will assign to the arrived buses a certain number of
// destinations (Next_DCL) taken from the list DCL and
// will start the buses (give a directive to the bus drivers ).
// He will then, wait for the other remaining buses.
a(wait_for_bus(No_expected,DCL),FF)::
( a(start_bus(ABL,Next_DCL),FF) <- DCL = [DCL_H| DCL_T] and
bus_at_location(MP, No_Bus, ABL) and
assign_dest(No_Bus,DCL,Next_DCL,Rest_DCL) then
a(wait_for_bus(No_expected - No_Bus,Rest_DCL),FF) ) or
null <- empty(DCL)
// This role is needed when the firefighter has to start the bus.
// To each bus is assigned a destination (ABL is equal to DCL in lenght)
// and once the driver of each bus is identified, a directive to him/her
// is sent.
a(start_bus(ABL,DCL),FF)::
( drive_to(DCL_H) => a(bus_driver,BD) <- ABL=[ABL_H|ABL_T] and
DCL=[DCL_H|DCL_T] and
driver_of(ABL_H,BD) then
a(start_bus(ABL_T,DCL_T),FF))
or
null <- empty(ABL)
// The bus driver, once the directive is received, get the route and
// move towards the destination.
// (here the bus_driver could jump to a "route_finder" role as defined
// in the interaction model "startFE")
a(bus_driver,BD)::
drive_to(Destination) <= a(start_bus(_,_),FF) then
a(perfom(move(Location, Destination, Path, bus)), BD) <- at(Location)
and get_route(Location,Destination,Path)
