23.08.2015 Views

Here - Agents Lab - University of Nottingham

Here - Agents Lab - University of Nottingham

Here - Agents Lab - University of Nottingham

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1 artifact ACMEConditioner implements Conditioner {2 nTimesUsed : int ;34 init (){5 isCooling = false ; isHeating = true ; nTimesUsed = 0;6 }78 startCooling ( speed : double ){9 nTimesUsed ++;10 isCooling = true ; isHeating = false ;11 ...12 }1314 startHeating ( speed : double ){...}1516 stop (){17 isCooling = false ; isHeating = false ;18 ...19 }20 }Fig. 4. Definition <strong>of</strong> an artifact template in simpAL. Artifact templates are used likeclasses in OOP, i.e. as templates to create instances <strong>of</strong> artifacts, defining then theirinternal structure and behavior. This figure shows the implementation <strong>of</strong> the toyACMEConditioner artifact, implementing the Conditioner interface. The definition <strong>of</strong>a template includes the name <strong>of</strong> the template, the explicit declaration <strong>of</strong> the interfacesimplemented by the template and then a body containing the declaration <strong>of</strong> the instancetyped state variables <strong>of</strong> the artifact (e.g. nTimesUsed, line 2) – which are hidden,not observable – and the definition <strong>of</strong> operations’ behavior. An operation is defined by aname (e.g. startCooling) (line 8), a set <strong>of</strong> keyword based parameters (e.g. speed) anda body. The body is very similar to the one found in imperative OO languages – Javain this case is taken as main reference – so it is a block with a sequence <strong>of</strong> statements,including local variable declarations, control-flow statements, object related statements(object creation, method invocation, etc) and some pre-defined statements related toartifact functioning, that allow, for instance, for suspending the execution <strong>of</strong> the operationuntil some specified condition is met, or to terminate with a failure the operationexecution.– the action rule must appear in an action rule block (or in any <strong>of</strong> its parentblock) where T arget has been explicitly listed among the artifact used bythe agent through the using: attribute.Examples <strong>of</strong> checks, given a fragment <strong>of</strong> a script with e.g. a belief cond:Conditioner:/* compilation ok */startCooling (speed: 0.75) on cond/* error: unknown operation switchOn */switchOn () on cond/* error: unknown parameter time: in startCooling operation */startCooling (speed: 0.75 time: 10) on cond143

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!