One of the problem faced in building management system is, how to constraint the creation of schedules for certain location/devices/time/device properties etc.  One can use JBOSS Drool to achieve this. I am using this by in process deployment of JBOSS Drool.

One sample rule for a invalid location and a device type


rule "Invalid Location and Device Type"
when
 $schedule: Schedule (  locationId == 11 && deviceTypeId == 32 )
then
 error(kcontext, $schedule);
end


Other Major problem while creating schedules because user might end up creating conflicting schedules. One simple matching rule can address this problem. This rule will take care that A is never matched with A itself and you do not get A= B and B = A


rule "matchingSchedules"

when
$s1: Schedule($id1:identifier,  $locId:locationId, $devTypeId:deviceTypeId, $devId: deviceId, $fDate: fromDate, $tDate: toDate)
$s2: Schedule(identifier != $id1 , locationId == $locId, deviceTypeId == $devTypeId,  deviceId == $devId, fromDate == $fDate, toDate == $tDate, eval($s1 != $s2))
then
matching(kcontext,$s1, $s2);

end

No comments:

Post a Comment