<?xml version="1.0" encoding="utf-8"?><!DOCTYPE nta PUBLIC '-//Uppaal Team//DTD Flat System 1.1//EN' 'http://www.it.uu.se/research/group/darts/uppaal/flat-1_1.dtd'><nta><declaration>//Insert declarations of global clocks, variables, constants and channels.
const int epsilon = 20;
const int delta = 50;
const int Max = 10;
const int Wait = 2000;
const int delay = 100;
const int tolerance = 5;
const int T_react = 1;
const int latency = 5;


// IUT internal:
chan touch, starthold, endhold;
int[0,1] on;
int iutLevel, OL;

// IUT interface to adapter:
chan setGrasp, setRelease; // inputs
chan setLevel; // outputs
int adapLevel;

// Observable
chan grasp, release, level;


// Environment:
</declaration><template><name x="5" y="5">Interface</name><parameter>const int epsilon, const int delta, chan &amp;grasp, chan &amp;release</parameter><declaration>clock x;</declaration><location id="id0" x="160" y="80"><name x="150" y="50">idle</name></location><location id="id1" x="160" y="152"><name x="176" y="136">ignoring</name><label kind="invariant" x="128" y="160">x&lt;=epsilon+tolerance</label></location><location id="id2" x="160" y="232"><name x="112" y="200">touching</name><label kind="invariant" x="161" y="241">x&lt;=delta+tolerance</label></location><location id="id3" x="256" y="160"><name x="246" y="130">touched</name><label kind="invariant" x="272" y="152">x&lt;tolerance</label></location><location id="id4" x="64" y="192"><name x="32" y="160">releasing</name><label kind="invariant" x="32" y="208">x&lt;tolerance</label></location><location id="id5" x="160" y="312"><name x="176" y="304">holding</name></location><init ref="id0"/><transition><source ref="id0"/><target ref="id1"/><label kind="synchronisation" x="168" y="88">grasp?</label><label kind="assignment" x="168" y="112">x=0</label></transition><transition><source ref="id1"/><target ref="id0"/><label kind="synchronisation" x="88" y="104">release?</label><nail x="128" y="144"/><nail x="128" y="88"/></transition><transition><source ref="id2"/><target ref="id3"/><label kind="synchronisation" x="256" y="200">release?</label><label kind="assignment" x="256" y="216">x=0</label><nail x="256" y="232"/></transition><transition><source ref="id3"/><target ref="id0"/><label kind="synchronisation" x="208" y="64">touch!</label><nail x="256" y="80"/></transition><transition><source ref="id1"/><target ref="id2"/><label kind="guard" x="128" y="176">x&gt;=epsilon</label></transition><transition><source ref="id2"/><target ref="id5"/><label kind="guard" x="104" y="256">x&gt;=delta</label><label kind="synchronisation" x="104" y="272">starthold!</label></transition><transition><source ref="id5"/><target ref="id4"/><label kind="synchronisation" x="32" y="232">release?</label><label kind="assignment" x="32" y="248">x=0</label><nail x="64" y="312"/></transition><transition><source ref="id4"/><target ref="id0"/><label kind="synchronisation" x="64" y="64">endhold!</label><nail x="64" y="80"/></transition></template><template><name x="5" y="5">Dimmer</name><parameter>const int delay, chan &amp;setLevel, int&amp; L</parameter><declaration>clock x;</declaration><location id="id6" x="64" y="144"><name x="54" y="114">Up</name><label kind="invariant" x="0" y="160">x&lt;=delay+tolerance</label></location><location id="id7" x="320" y="144"><name x="310" y="114">Dn</name><label kind="invariant" x="264" y="160">x&lt;=delay+tolerance</label></location><location id="id8" x="192" y="272"><name x="208" y="264">PassiveDn</name></location><location id="id9" x="192" y="0"><name x="208" y="-8">PassiveUp</name></location><location id="id10" x="136" y="64"><committed/></location><location id="id11" x="-80" y="136"><committed/></location><location id="id12" x="464" y="152"><committed/></location><init ref="id9"/><transition><source ref="id6"/><target ref="id8"/><label kind="synchronisation" x="80" y="224">endhold?</label></transition><transition><source ref="id8"/><target ref="id7"/><label kind="synchronisation" x="256" y="208">starthold?</label><label kind="assignment" x="240" y="224">OL=L,x=0,on=1</label></transition><transition><source ref="id6"/><target ref="id11"/><label kind="guard" x="-40" y="200">L&lt;Max and x&gt;=delay</label><label kind="assignment" x="-32" y="240">L=L+1,
x=0</label><nail x="-8" y="192"/></transition><transition><source ref="id7"/><target ref="id12"/><label kind="guard" x="392" y="184">L&gt;0 and x&gt;=delay</label><label kind="assignment" x="392" y="224">L=L-1,
x=0</label><nail x="400" y="184"/></transition><transition><source ref="id9"/><target ref="id10"/><label kind="synchronisation" x="112" y="-40">starthold?</label><label kind="assignment" x="112" y="-24">L=OL,
x=0,
on=1</label></transition><transition><source ref="id7"/><target ref="id9"/><label kind="synchronisation" x="232" y="56">endhold?</label></transition><transition><source ref="id6"/><target ref="id7"/><label kind="guard" x="168" y="80">L==Max and x&gt;=delay</label><nail x="192" y="120"/></transition><transition><source ref="id7"/><target ref="id6"/><label kind="guard" x="168" y="176">L==0 and x&gt;=delay</label><nail x="192" y="176"/></transition><transition><source ref="id10"/><target ref="id6"/><label kind="synchronisation" x="56" y="72">setLevel!</label></transition><transition><source ref="id11"/><target ref="id6"/><label kind="synchronisation" x="-40" y="88">setLevel!</label><nail x="-8" y="112"/></transition><transition><source ref="id12"/><target ref="id7"/><label kind="synchronisation" x="392" y="80">setLevel!</label><nail x="408" y="112"/></transition></template><template><name x="5" y="5">Switch</name><parameter>chan &amp;setLevel, int&amp; L</parameter><location id="id13" x="192" y="98"><name x="182" y="68">idle</name></location><location id="id14" x="64" y="96"><name x="32" y="64">goingOn</name><committed/></location><location id="id15" x="328" y="96"><name x="318" y="66">goingOff</name><committed/></location><init ref="id13"/><transition><source ref="id13"/><target ref="id14"/><label kind="guard" x="104" y="96">on==0</label><label kind="synchronisation" x="104" y="112">touch?</label><label kind="assignment" x="104" y="128">L=OL,
on=1</label><nail x="160" y="128"/><nail x="96" y="128"/></transition><transition><source ref="id13"/><target ref="id15"/><label kind="guard" x="232" y="96">on==1</label><label kind="synchronisation" x="232" y="112">touch?</label><label kind="assignment" x="232" y="128">OL=L,
L=0,
on=0</label><nail x="224" y="128"/><nail x="288" y="128"/></transition><transition><source ref="id14"/><target ref="id13"/><label kind="synchronisation" x="96" y="48">setLevel!</label><nail x="96" y="64"/><nail x="160" y="64"/></transition><transition><source ref="id15"/><target ref="id13"/><label kind="synchronisation" x="224" y="48">setLevel!</label><nail x="288" y="64"/><nail x="224" y="64"/></transition></template><template><name x="5" y="5">OldAdapter</name><parameter>int&amp; outData, int&amp; L, chan &amp;showLevel</parameter><declaration>clock z;</declaration><location id="id16" x="-72" y="-256"><name x="-120" y="-264">busy</name><label kind="invariant" x="-112" y="-240">z&lt;tolerance</label></location><location id="id17" x="-72" y="-384"><name x="-82" y="-414">idle</name></location><location id="id18" x="32" y="-256"><name x="48" y="-264">ERROR</name></location><init ref="id17"/><transition><source ref="id17"/><target ref="id16"/><label kind="synchronisation" x="-64" y="-344">setLevel?</label><label kind="assignment" x="-64" y="-328">z=0,
outData=L</label></transition><transition><source ref="id16"/><target ref="id18"/><label kind="synchronisation" x="-48" y="-272">setLevel?</label></transition><transition><source ref="id16"/><target ref="id17"/><label kind="synchronisation" x="-168" y="-336">showLevel!</label><nail x="-128" y="-288"/><nail x="-128" y="-352"/></transition></template><template><name x="5" y="5">DumbUser</name><parameter>chan &amp;changeLevel, int&amp; L</parameter><declaration>clock z;</declaration><location id="id19" x="-64" y="-256"><name x="-40" y="-272">idle</name><label kind="invariant" x="-88" y="-248">z&lt;=Wait</label></location><location id="id20" x="-64" y="-96"><name x="-40" y="-96">busy</name><label kind="invariant" x="-96" y="-128">z&lt;=Wait</label></location><init ref="id19"/><transition><source ref="id20"/><target ref="id19"/><label kind="guard" x="-32" y="-200">z&gt;=T_react</label><label kind="synchronisation" x="-32" y="-184">release!</label><label kind="assignment" x="-32" y="-168">z=0</label><nail x="0" y="-128"/><nail x="0" y="-224"/></transition><transition><source ref="id19"/><target ref="id20"/><label kind="guard" x="-160" y="-200">z&gt;=T_react</label><label kind="synchronisation" x="-160" y="-184">grasp!</label><label kind="assignment" x="-160" y="-168">z=0</label><nail x="-128" y="-224"/><nail x="-128" y="-128"/></transition><transition><source ref="id19"/><target ref="id19"/><label kind="synchronisation" x="-104" y="-312">changeLevel?</label><nail x="-96" y="-288"/><nail x="-32" y="-288"/></transition><transition><source ref="id20"/><target ref="id20"/><label kind="synchronisation" x="-96" y="-64">changeLevel?</label><nail x="-96" y="-64"/><nail x="-32" y="-64"/></transition></template><template><name x="5" y="5">SampleUser</name><parameter>chan &amp;changeLevel, int&amp; newLevel</parameter><declaration>clock z;
int[0,Max] L;</declaration><location id="id21" x="-64" y="-256"><name x="-40" y="-272">idle</name><label kind="invariant" x="-104" y="-240">z&lt;=2*delay</label></location><location id="id22" x="-64" y="-96"><name x="-40" y="-96">busy</name><label kind="invariant" x="-104" y="-128">z&lt;=10*delay</label></location><init ref="id21"/><transition><source ref="id22"/><target ref="id21"/><label kind="guard" x="-56" y="-200">z&gt;=2*delay</label><label kind="synchronisation" x="-56" y="-184">release!</label><label kind="assignment" x="-56" y="-168">z=0</label><nail x="0" y="-128"/><nail x="0" y="-224"/></transition><transition><source ref="id21"/><target ref="id22"/><label kind="guard" x="-152" y="-200">z&gt;=delay</label><label kind="synchronisation" x="-152" y="-184">grasp!</label><label kind="assignment" x="-152" y="-168">z=0</label><nail x="-128" y="-224"/><nail x="-128" y="-128"/></transition><transition><source ref="id21"/><target ref="id21"/><label kind="synchronisation" x="-104" y="-320">changeLevel?</label><label kind="assignment" x="-104" y="-304">L=newLevel</label><nail x="-96" y="-288"/><nail x="-32" y="-288"/></transition><transition><source ref="id22"/><target ref="id22"/><label kind="synchronisation" x="-96" y="-64">changeLevel?</label><label kind="assignment" x="-96" y="-48">L=newLevel</label><nail x="-96" y="-64"/><nail x="-32" y="-64"/></transition><transition><source ref="id22"/><target ref="id21"/><label kind="guard" x="40" y="-200">L&gt;8 and z&lt;delta</label><label kind="synchronisation" x="40" y="-184">release!</label><label kind="assignment" x="40" y="-168">z=0</label><nail x="64" y="-128"/><nail x="64" y="-216"/></transition></template><template><name x="5" y="5">RealUser</name><parameter>chan &amp;changeLevel, int&amp; newLevel</parameter><declaration>clock z;
int[0,Max] L;</declaration><location id="id23" x="-64" y="-256"><name x="-104" y="-272">idle</name><label kind="invariant" x="-96" y="-240">z&lt;5*delay</label></location><location id="id24" x="-64" y="-96"><name x="-40" y="-96">busy</name><label kind="invariant" x="-96" y="-128">z&lt;10*delay+delta</label></location><location id="id25" x="98" y="-319"><name x="112" y="-328">off</name><label kind="invariant" x="80" y="-304">z&lt;delta</label></location><init ref="id23"/><transition><source ref="id24"/><target ref="id23"/><label kind="guard" x="-32" y="-200">z&gt;=3*delay+delta</label><label kind="synchronisation" x="-32" y="-184">release!</label><label kind="assignment" x="-32" y="-168">z=0</label><nail x="0" y="-128"/><nail x="0" y="-224"/></transition><transition><source ref="id23"/><target ref="id24"/><label kind="guard" x="-160" y="-208">L&lt;=7 and z&gt;=2*delay</label><label kind="synchronisation" x="-160" y="-176">grasp!</label><label kind="assignment" x="-160" y="-160">z=0</label><nail x="-128" y="-224"/><nail x="-128" y="-128"/></transition><transition><source ref="id23"/><target ref="id23"/><label kind="synchronisation" x="-120" y="-320">changeLevel?</label><label kind="assignment" x="-120" y="-304">L=newLevel</label><nail x="-96" y="-288"/><nail x="-32" y="-288"/></transition><transition><source ref="id24"/><target ref="id24"/><label kind="synchronisation" x="-96" y="-64">changeLevel?</label><label kind="assignment" x="-96" y="-48">L=newLevel</label><nail x="-96" y="-64"/><nail x="-32" y="-64"/></transition><transition><source ref="id23"/><target ref="id25"/><label kind="guard" x="-16" y="-336">L&gt;5 and z&gt;=3*delay</label><label kind="synchronisation" x="-16" y="-304">grasp!</label><label kind="assignment" x="-16" y="-288">z=0</label></transition><transition><source ref="id25"/><target ref="id23"/><label kind="guard" x="24" y="-272">z&gt;epsilon</label><label kind="synchronisation" x="24" y="-256">release!</label><label kind="assignment" x="24" y="-240">z=0</label><nail x="96" y="-256"/></transition><transition><source ref="id25"/><target ref="id25"/><label kind="synchronisation" x="48" y="-384">changeLevel?</label><label kind="assignment" x="48" y="-368">L=newLevel</label><nail x="64" y="-352"/><nail x="128" y="-352"/></transition></template><template><name x="5" y="5">Adapter</name><parameter>const int delay, chan &amp;inp, chan &amp;out</parameter><declaration>clock x;</declaration><location id="id26" x="256" y="128"></location><location id="id27" x="256" y="224"><label kind="invariant" x="232" y="240">x&lt;=delay</label></location><init ref="id26"/><transition><source ref="id26"/><target ref="id27"/><label kind="synchronisation" x="296" y="160">inp?</label><label kind="assignment" x="296" y="175">x=0</label><nail x="288" y="160"/><nail x="288" y="192"/></transition><transition><source ref="id27"/><target ref="id26"/><label kind="synchronisation" x="224" y="168">out!</label><nail x="224" y="192"/><nail x="224" y="160"/></transition></template><template><name x="5" y="5">IntAdapter</name><parameter>const int delay, chan &amp;inp, chan &amp;out, int&amp; inpData, int&amp; outData</parameter><declaration>clock x;</declaration><location id="id28" x="256" y="128"></location><location id="id29" x="256" y="224"><label kind="invariant" x="232" y="240">x&lt;=delay</label></location><init ref="id28"/><transition><source ref="id28"/><target ref="id29"/><label kind="synchronisation" x="296" y="160">inp?</label><label kind="assignment" x="296" y="175">x=0,
outData=inpData</label><nail x="288" y="160"/><nail x="288" y="192"/></transition><transition><source ref="id29"/><target ref="id28"/><label kind="synchronisation" x="192" y="128">out!</label><nail x="224" y="200"/><nail x="224" y="160"/></transition></template><system>// IUT part:
interface= Interface(epsilon,delta, setGrasp, setRelease);
dimmer = Dimmer(delay, setLevel, iutLevel);
switch = Switch(setLevel, iutLevel);

// Env part:
// note: SampleUser cannot detect mutant 1, but DumbUser can!
user = SampleUser(level, adapLevel);

// communication latency adapters:
graspAdapter = Adapter(latency, grasp, setGrasp);
releaseAdapter = Adapter(latency, release, setRelease);
levelAdapter = IntAdapter(latency, setLevel, level, iutLevel, adapLevel);
system 	interface, switch, dimmer,
	user,
	graspAdapter, releaseAdapter, levelAdapter;

/*
input grasp(), release();
output showLevel(envLevel);
*/</system></nta>