
templates.norms.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of phat-generator Show documentation
Show all versions of phat-generator Show documentation
SociAALML to PHAT generator
The newest version!
@@@program xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"@@@ @@@repeat id="normsmust"@@@ @@@saveto@@@ @@@file overwrite="yes"@@@ @@@v@@@output@@@/v@@@/sociaal/norms/@@@v@@@normname@@@/v@@@.java@@@/file@@@ @@@text@@@ package sociaal.norms; import sociaal.PunishmentNorm; public class @@@v@@@normname@@@/v@@@ extends PunishmentNorm { public @@@v@@@normname@@@/v@@@(String name, String responsible,long time, org.drools.core.spi.KnowledgeHelper kb) { super(name,responsible,time, kb); // TODO Auto-generated constructor stub } @Override public boolean shouldPunish(long currentSimtime) { // TODO Auto-generated method stub return (currentSimtime-getTime())%3==0 && currentSimtime>getTime(); // every three seconds since violation time } @Override public void performPunishment() { } public String toString(){ return "@@@v@@@normname@@@/v@@@("+this.getResponsible()+","+this.getTime()+")"; } } @@@/text@@@ @@@/saveto@@@ @@@/repeat@@@ @@@repeat id="normsmustnot"@@@ @@@saveto@@@ @@@file overwrite="yes"@@@ @@@v@@@output@@@/v@@@/sociaal/norms/@@@v@@@normname@@@/v@@@.java@@@/file@@@ @@@text@@@ package sociaal.norms; import sociaal.PunishmentNorm; public class @@@v@@@normname@@@/v@@@ extends PunishmentNorm { public @@@v@@@normname@@@/v@@@(String name, String responsible,long time,org.drools.core.spi.KnowledgeHelper kb) { super(name,responsible, time,kb); // TODO Auto-generated constructor stub } @Override public boolean shouldPunish(long currentSimtime) { return (currentSimtime-getTime())%3==0 && currentSimtime>getTime(); // every three seconds since violation time } @Override public void performPunishment() { } public String toString(){ return "@@@v@@@normname@@@/v@@@("+this.getResponsible()+","+this.getTime()+")"; } } @@@/text@@@ @@@/saveto@@@ @@@/repeat@@@ @@@saveto@@@ @@@file overwrite="yes"@@@ @@@v@@@output@@@/v@@@/rules.drl@@@/file@@@ @@@text@@@ package sociaal; dialect "mvel" import jade.lang.acl.ACLMessage; import jade.domain.introspection.Event; import phat.agents.AgentPHATEvent; import phat.body.BodyUtils.BodyPosture; import phat.world.MonitorEventQueue; import phat.world.MonitorEventQueueImp; import phat.world.PHATCalendar; import sociaal.*; import sociaal.ontology.*; import sociaal.*; import sociaal.norms.*; /*******************************************************/ // Norm violation detection /*******************************************************/ @@@repeat id="normsmustnot"@@@ rule "violation detected: @@@v@@@normname@@@/v@@@" when @@@repeat id="normscondition"@@@ $ap1: ActionPerformed(responsible=="@@@v@@@normrolecondition@@@/v@@@",actionType=="@@@v@@@normactioncondition@@@/v@@@") @@@/repeat@@@ $ap2: ActionPerformed(responsible=="@@@v@@@normrole@@@/v@@@",actionType=="@@@v@@@normdeonticaction@@@/v@@@") not (ActionPerformed(responsible=="@@@v@@@normrolecondition@@@/v@@@", actionType!="WaitTask" && actionType!="SayTask" && actionType!="WaitForBodyClose" , getTime()>$ap1.getTime()))// filtered tasks happen at the same sim time not (ActionPerformed(responsible=="@@@v@@@normrole@@@/v@@@", actionType!="WaitTask" && actionType!="SayTask" && actionType!="WaitForBodyClose", getTime()>$ap2.getTime() && getTime()>$ap1.getTime() && getTime()-$ap1.getTime()<=@@@v@@@normtimewindow@@@/v@@@))// filtered tasks happen at the same sim time then insertLogical(new @@@v@@@normname@@@/v@@@("Violated@@@v@@@normname@@@/v@@@","@@@v@@@normrole@@@/v@@@",NormativeSystem.getElapsedSimTimeSeconds(),this)); end // "violation restored: @@@v@@@normname@@@/v@@@" is automatic when there is a new action @@@/repeat@@@ @@@repeat id="normsmust"@@@ rule "violation detected: @@@v@@@normname@@@/v@@@" when @@@repeat id="normscondition"@@@ $ap1: ActionPerformed(responsible=="@@@v@@@normrolecondition@@@/v@@@",actionType=="@@@v@@@normactioncondition@@@/v@@@") @@@/repeat@@@ not (ActionPerformed(responsible=="@@@v@@@normrolecondition@@@/v@@@", actionType!="WaitTask" && actionType!="SayTask" && actionType!="WaitForBodyClose" , getTime()>$ap1.getTime()))// filtered tasks happen at the same sim time not (ActionPerformed(responsible=="@@@v@@@normrole@@@/v@@@",actionType=="@@@v@@@normdeonticaction@@@/v@@@", getTime()>$ap1.getTime() && getTime()-$ap1.getTime()<@@@v@@@normtimewindow@@@/v@@@)) exists (CurrentTime(getTime()>=$ap1.getTime() && getTime()-$ap1.getTime()>=@@@v@@@normtimewindow@@@/v@@@)) then insertLogical(new @@@v@@@normname@@@/v@@@("Violated@@@v@@@normname@@@/v@@@","@@@v@@@normrole@@@/v@@@",NormativeSystem.getElapsedSimTimeSeconds(),this)); end rule "violation restored: @@@v@@@normname@@@/v@@@" when $v: @@@v@@@normname@@@/v@@@(name=="Violated@@@v@@@normname@@@/v@@@",responsible=="@@@v@@@normrole@@@/v@@@") ActionPerformed(responsible=="@@@v@@@normrole@@@/v@@@",actionType=="@@@v@@@normdeonticaction@@@/v@@@", getTime()>$v.getTime()) then retract($v); end @@@/repeat@@@ @@@/text@@@ @@@/saveto@@@ @@@/program@@@
© 2015 - 2025 Weber Informatics LLC | Privacy Policy