|
Listing 2: Access Control and Safety/Security Rules
|
[..setup and import omitted..]
declare SensorFailureEvent
@idroom: int
@idsensor: int
end
rule “If there are NOT pending alarm forward PDP access response”
no-loop true
salience 1
dialect “java”
when
$aEvent:PdpAccessRequest();
$bEvent:PdpAccessResponse(this.isConsumed == false,
this.isException == false,
this.getIdRequest == $aEvent.getIdRequest,
($bEvent.getResponse == “Permit” || “Deny”),this after $aEvent);
not(SensorFailureEvent(this.isConsumed == false,
this.isException == false,this.idRoom == $aEvent.idRoom,
this.idSensor == $aEvent.idSensor));
then
Actuators.ManageAccess($aEvent.getIdSensor(),
$aEvent.getIdroom(),$bEvent.getResponse()));
end
rule “If there are failures take countermeasures”
no-loop true
salience 1
dialect “java”
when
$aEvent:SensorFailureEvent();
then
Alarm.NotifyToOwners($aEvent.idsensor, $aEvent.idroom);
//or take direct countermeasure through actuator
end
rule “If there are pending alarm check accesses to the resource”
no-loop true
salience 1
dialect “java”
when
$aEvent:PdpAccessRequest();
$bEvent:PdpAccessResponse(this.isConsumed == false,
this.isException == false,
this.getIdRequest == $aEvent.getIdRequest,
($bEvent.getResponse == “Permit” || “Deny”),this after $aEvent);
$cEvent:SensorFailureEvent(this.isConsumed == false,
this.isException == false,this.idRoom == $aEvent.idRoom);
then
Actuators.ManageAccess($aEvent.getIdSensor(),$aEvent.getIdroom(),
OwnersDatabase.NotificationToParentsCheck($aEvent.getIdUser));
end
|