We provide here a collection of examples of interaction models taken from our test cases, based on areas such as bioinformatics, business and emergency response.

BUSHANDLING

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)

CENSUS

CENSUS describes the phase during which an emergency peer registers information on people present at a certain location into a database.


//  Written by Lorenzo Vaccari

r(censuscurator,initial)
r(dbcurator,necessary,1)

//   The emergency peer enters this role to obtain the info 
//  (Name Type, Location, etc. ) related to a person and to send a 
//  relative message to the dbcurator (the peer who
//  actually will store the info into the DB). 
//  A success (failure) message is received if things went well (wrong) 

a(censuscurator, ID1):: 
update(Name,Type,Location,GPS,Status,Notes) => a(dbcurator, ID2) <- 
obtain(List, Name,Type,Location,GPS,Status,Notes)
then
success(Id) <= a(dbcurator, ID2)
or
(failure(Msg) <= a(dbcurator, ID2)
then
null <- proceed(Msg))


//  The peer who stores info into a DB enters this role.

a(dbcurator, ID2)::
update(Name,Type,Location,GPS,Status,Notes) <=  a(censuscurator, ID1)
then
success(Id) => a(censuscurator, ID1) <- updateDb(Name,Type,Location,GPS,Status,Notes,Id)
or
failure(Msg) => a(censuscurator, ID1) <- lastError(Msg)

RECONNAISSANCE

RECONNAISSANCE describes the phase during which an emergency peer (firefighter) needs to close a meeting point due to the increasing level of water measured at that meeting point and its neighbourhood.


//  Written by Gaia Trecarichi on 28/06/2007 - modified on 20/12/2007

r(firefighter,initial)
r(firefighter_coordinator,necessary,1)

//  The firefighter first measures the water level (WL_local) at the 
//  meeting point (MP) and then ask its coordinator
//  to give details on the water level at the closest areas (WL_adj_nodes). 
//  Based on this info, a parameter (Criticality) is computed in order to 
//  decide if it is the case to close the meeting point or not. 
//  If the MP is closed a message is sent to the coordinator.

a(firefighter,FF)::
update&request_WL_info(MP, WL_local) => a(firefighter_coordinator,FFC) 
     <- at(MP) and measure_local_WL(MP, WL_local) and 
	get_coordinator_ID(FFC) then
emergency_WL_info(MP, WL_adj_nodes) <= a(firefighter_coordinator,FFC) then
	null <- compute(WL_local, WL_adj_nodes, Criticality) then	
(a(perfom(close(MP)),FF) <- greater(Criticality,MaxCriticality) then	
   update_on_MP_state(closed) => a(firefighter_coordinator,FFC)) or 	
a(firefighter,FF) 


//  The firefighter coordinator receives a message from the firefighter to 
//  update info on water level at meeting point MP and to send info on water 
//  levels at its adjacent points.
//  The coordinator can also receives an "update_on_MP_state(closed)" message 
//  from the firefighter.

a(firefighter_coordinator,FFC)::
((update&request_WL_info(MP, WL_local) <= a(firefighter,FF) then 
emergency_WL_info(MP, WL_adj_nodes) => a(firefighter,FF) <- 
update_WL_info(MP,WL_local) and gather_WL_adj_area(MP, WL_adj_nodes)) or 
update_on_MP_state(closed) <= a(firefighter,FF) ) then
a(firefighter_coordinator,FFC)

Egglue Powered