<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href='http://gres.uninova.pt/iopt-flow/show-pf.xsl' type='text/xsl' ?>
<net name="sample" type="iopt-flow">
  <signal id="btn1" mode="input" type="boolean" x="185" y="66"/>
  <signal id="btn2" mode="input" type="boolean" x="156" y="88"/>
  <signal id="in1" mode="input" type="range" min="0" max="100" x="125" y="108"/>
  <signal id="in2" mode="input" type="range" min="0" max="100" x="70" y="291"/>
  <signal id="in3" mode="input" type="range" min="0" max="100" x="90" y="307"/>
  <signal id="in4" mode="input" type="range" min="0" max="100" x="107" y="324"/>
  <event id="ev1" mode="input" x="100" y="500"/>
  <signal id="led1" mode="output" type="boolean" x="648" y="396"/>
  <signal id="led2" mode="output" type="boolean" x="800" y="600"/>
  <signal id="led3" mode="output" type="boolean" x="649" y="301"/>
  <signal id="res" mode="output" type="range" min="0" max="100" x="780" y="69"/>
  <event id="ev2" mode="output" x="800" y="500"/>
  <event id="ev3" mode="output" x="823" y="50"/>
  <operation id="op1" x="200" y="300" rot="0" shape="arrow" size="40">
    <name text="OP1" off_x="-10" off_y="5"/>
    <input id="op1.i1" name="i1" type="range" min="0" max="100" off_x="-40" off_y="-24" frac="0" dynamic="name"/>
    <input id="op1.i2" name="i2" type="range" min="0" max="100" off_x="-40" off_y="-8"/>
    <input id="op1.i3" name="i3" type="range" min="0" max="100" off_x="-40" off_y="8"/>
    <input id="op1.i4" name="i4" type="range" min="0" max="100" off_x="-40" off_y="24"/>
    <output id="op1.out" name="out" type="range" min="0" max="100" off_x="40" off_y="0">
      <expression>
        <text>i1 + i2 + i3 + i4</text>
        <operand type="signal" idRef="i1"/>
        <operator type="add"/>
        <operand type="signal" idRef="i2"/>
        <operator type="add"/>
        <operand type="signal" idRef="i3"/>
        <operator type="add"/>
        <operand type="signal" idRef="i4"/>
      </expression>
    </output>
  </operation>
  <arc type="read" id="a1" source="in1" target="op1.i1" c2_x="-20" c2_y="-26" c1_x="0" c1_y="0"/>
  <arc type="read" id="a2" source="in2" target="op1.i2"/>
  <arc type="read" id="a3" source="in3" target="op1.i3"/>
  <arc type="read" id="a4" source="in4" target="op1.i4"/>
  <operation id="op2" x="350" y="300" rot="0" shape="arrow" size="20">
    <name text="OP2" off_x="-10" off_y="12"/>
    <input id="op2.i" name="i" type="range" min="0" max="100" off_x="-20" off_y="0"/>
    <output id="op2.out" name="out" type="boolean" off_x="20" off_y="0">
      <expression>
        <text>i &gt;= 50</text>
        <operand type="signal" idRef="i"/>
        <operator type="more"/>
        <operand type="literal" value="50"/>
      </expression>
    </output>
  </operation>
  <arc type="read" id="a5" source="op1.out" target="op2.i"/>
  <operation id="op3" x="275" y="180" rot="0" shape="arrow" size="30">
    <name text="OP3" off_x="-15" off_y="5"/>
    <input id="op3.i" name="i" type="range" min="0" max="100" off_x="-30" off_y="0" dynamic="all"/>
    <output id="op3.out" name="out" type="event" off_x="30" off_y="0">
      <expression>
        <text>i &gt; 50 AND i[-1] &lt;= 50</text>
        <operand type="signal" idRef="i"/>
        <operator type="more"/>
        <operand type="literal" value="50"/>
        <operator type="and"/>
        <operand type="signal" idRef="i" delay="1"/>
        <operator type="less-or-equal"/>
        <operand type="literal" value="50"/>
      </expression>
    </output>
  </operation>
  <arc type="read" id="a6" source="in1" target="op3.i" c2_x="-45" c2_y="0" c1_x="0" c1_y="0"/>
  <place id="p1" bound="10" init_marking="1" x="300" y="400">
    <name text="PL1" off_x="10" off_y="10"/>
    <comment text="abcdxpto" off_x="10" off_y="10"/>
  </place>
  <transition id="t1" priority="1" x="200" y="500">
    <name text="Tr1" off_x="10" off_y="10"/>
    <comment text="asdf" off_x="10" off_y="10"/>
  </transition>
  <place id="p2" bound="10" init_marking="0" x="305" y="600">
    <name text="PL2" off_x="10" off_y="10"/>
  </place>
  <transition id="t2" priority="1" x="400" y="500">
    <name text="Tr2" off_x="10" off_y="10"/>
  </transition>
  <arc type="normal" id="a7" source="p1" target="t1" c2_x="0" c2_y="-50" c1_x="0" c1_y="0"/>
  <arc type="normal" id="a8" source="t1" target="p2" c2_x="-55" c2_y="0" c1_x="0" c1_y="0"/>
  <arc type="normal" id="a9" source="p2" target="t2" c2_x="-5" c2_y="50" c1_x="0" c1_y="0"/>
  <arc type="normal" id="a10" source="t2" target="p1" c2_x="50" c2_y="0" c1_x="0" c1_y="0"/>
  <arc type="read" id="a11" source="op3.out" target="t1"/>
  <arc type="read" id="a12" source="op2.out" target="t2" c2_x="0" c2_y="-90" c1_x="0" c1_y="0"/>
  <arc type="read" id="a13" source="ev1" target="t1"/>
  <arc type="read" id="a14" source="p1" target="led1"/>
  <arc type="read" id="a15" source="p2" target="led2"/>
  <operation id="op4" x="504" y="299" rot="0" shape="arrow" size="30">
    <name text="MAX" off_x="-15" off_y="5"/>
    <input id="op4.i1" name="i1" type="boolean" off_x="-30" off_y="-10"/>
    <input id="op4.i2" name="i2" type="boolean" off_x="-30" off_y="10"/>
    <output id="op4.out" name="out" type="boolean" off_x="30" off_y="0">
      <expression>
        <text>i1 WHEN (i1 &gt; i2)</text>
        <operand type="signal" idRef="i1"/>
        <operator type="when"/>
        <operand type="signal" idRef="i1"/>
        <operator type="more"/>
        <operand type="signal" idRef="i2"/>
      </expression>
      <expression>
        <text>i2 OTHERWISE</text>
        <operand type="signal" idRef="i2"/>
      </expression>
    </output>
  </operation>
  <arc type="read" id="a16" source="p1" target="op4.i1"/>
  <arc type="read" id="a17" source="p2" target="op4.i2"/>
  <arc type="read" id="a18" source="op4.out" target="led3"/>
  <arc type="read" id="a19" source="t2" target="ev2"/>
  <component id="cp1" class="io/encoder" x="495" y="110" width="100" height="150">
    <name text="Comp1" off_x="-40" off_y="-80"/>
    <input id="cp1.start" name="start" type="event" off_x="-50" off_y="-60"/>
    <input id="cp1.enable" name="enable" type="boolean" off_x="-50" off_y="-40"/>
    <input id="cp1.mode" name="mode" type="boolean" off_x="-50" off_y="-20"/>
    <input id="cp1.in_value" name="in_value" type="range" min="0" max="100" off_x="-50" off_y="0"/>
    <output id="cp1.done" name="done" type="event" off_x="50" off_y="-60"/>
    <output id="cp1.result" name="result" type="range" min="0" max="1000" off_x="50" off_y="-40"/>
  </component>
  <arc type="read" id="a20" source="t2" target="cp1.start"/>
  <arc type="read" id="a21" source="btn1" target="cp1.enable"/>
  <arc type="read" id="a22" source="in1" target="cp1.in_value"/>
  <arc type="read" id="a23" source="btn2" target="cp1.mode"/>
  <arc type="read" id="a24" source="cp1.done" target="ev3"/>
  <arc type="read" id="a25" source="cp1.result" target="res"/>
  <place id="p0" x="960" y="225" init_marking="0">
    <name off_x="-10" off_y="-10" text="p0"/>
    <comment off_x="-10" off_y="20" text="-"/>
  </place>
  <transition id="t3" x="1031" y="289" priority="0">
    <name off_x="-10" off_y="-10" text="t3"/>
    <comment off_x="-10" off_y="20" text="-"/>
  </transition>
  <transition id="t4" x="889" y="292" priority="0">
    <name off_x="-10" off_y="-10" text="t4"/>
    <comment off_x="-10" off_y="20" text="-"/>
  </transition>
  <place id="p5" x="963" y="357" init_marking="0">
    <name off_x="-10" off_y="-10" text="p5"/>
    <comment off_x="-10" off_y="20" text="-"/>
  </place>
  <place id="p6" x="961" y="79" init_marking="1">
    <name off_x="-10" off_y="-10" text="p6"/>
    <comment off_x="-10" off_y="20" text="-"/>
  </place>
  <transition id="t7" x="961" y="147" priority="0">
    <name off_x="-10" off_y="-10" text="t7"/>
    <comment off_x="-10" off_y="20" text="-"/>
  </transition>
  <arc id="a26" type="normal" source="p6" target="t7"/>
  <arc id="a27" type="normal" source="t7" target="p0"/>
  <arc id="a28" type="normal" source="t4" target="p0"/>
  <arc id="a29" type="normal" source="t3" target="p5"/>
  <arc id="a30" type="normal" source="p5" target="t4"/>
  <arc id="a31" type="read" source="p0" target="t3"/>
  <operation id="Lc0" x="1175" y="597" rot="0" shape="rect" size="30">
    <name text="---|/|---" off_x="-20" off_y="0"/>
    <input id="Lc0.in" name="in" type="boolean" off_x="-30" off_y="0"/>
    <input id="Lc0.gate" name="gate" type="boolean" off_x="0" off_y="25"/>
    <output id="Lc0.out" name="out" type="boolean" off_x="30" off_y="0">
      <expression>
        <text>in AND (gate = 0)</text>
        <operand type="signal" idRef="in"/>
        <operator type="and"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="gate"/>
          <operator type="equal"/>
          <operand type="literal" value="0"/>
        </operand>
      </expression>
    </output>
  </operation>
  <operation id="Lc1" x="1317" y="595" rot="0" shape="rect" size="30">
    <name text="---| |---" off_x="-20" off_y="0"/>
    <input id="Lc1.in" name="in" type="boolean" off_x="-30" off_y="0"/>
    <input id="Lc1.gate" name="gate" type="boolean" off_x="0" off_y="25"/>
    <output id="Lc1.out" name="out" type="boolean" off_x="30" off_y="0">
      <expression>
        <text>in AND gate</text>
        <operand type="signal" idRef="in"/>
        <operator type="and"/>
        <operand type="signal" idRef="gate"/>
      </expression>
    </output>
  </operation>
  <arc id="a32" type="read" source="Lc0.out" target="Lc1.in"/>
  <signal id="s33" x="1030" y="595" mode="input" type="boolean" min="0" max="1"/>
  <arc id="a34" type="read" source="s33" target="Lc0.in"/>
  <operation id="Lc35" x="1163" y="754" rot="0" shape="rect" size="30">
    <name text="---|/|---" off_x="-20" off_y="0"/>
    <input id="Lc35.in" name="in" type="boolean" off_x="-30" off_y="0"/>
    <input id="Lc35.gate" name="gate" type="boolean" off_x="0" off_y="25"/>
    <output id="Lc35.out" name="out" type="boolean" off_x="30" off_y="0">
      <expression>
        <text>in AND (gate = 0)</text>
        <operand type="signal" idRef="in"/>
        <operator type="and"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="gate"/>
          <operator type="equal"/>
          <operand type="literal" value="0"/>
        </operand>
      </expression>
    </output>
  </operation>
  <arc id="a36" type="read" source="s33" target="Lc35.in" c2_x="-68" c2_y="-24" c1_x="0" c1_y="0"/>
  <signal id="s40" x="1562" y="595" mode="output" type="boolean" min="0" max="1"/>
  <signal id="s42" x="1177" y="685" mode="input" type="boolean" min="0" max="1"/>
  <arc id="a43" type="read" source="s42" target="Lc0.gate"/>
  <signal id="s44" x="1315" y="683" mode="input" type="boolean" min="0" max="1"/>
  <arc id="a46" type="read" source="s44" target="Lc1.gate"/>
  <component id="Lc49" class="control/pid" x="1232" y="282" width="100" height="160">
    <name text="LinCtrl0" off_x="-40" off_y="-80"/>
    <input id="Lc49.reset" name="reset" type="event" off_x="-50" off_y="-60"/>
    <input id="Lc49.enable" name="enable" type="boolean" off_x="-50" off_y="-40"/>
    <input id="Lc49.Kp" name="Kp" type="range" min="0" max="100" off_x="-50" off_y="-20"/>
    <input id="Lc49.Ki" name="Ki" type="range" min="0" max="100" off_x="-50" off_y="0"/>
    <input id="Lc49.Kd" name="Kd" type="range" min="0" max="100" off_x="-50" off_y="20"/>
    <input id="Lc49.ref_pos" name="ref_pos" type="range" min="0" max="1023" off_x="-50" off_y="40"/>
    <input id="Lc49.sens_pos" name="sens_pos" type="range" min="0" max="1023" off_x="-50" off_y="60"/>
    <output id="Lc49.value" name="value" type="range" min="0" max="1023" off_x="50" off_y="-60"/>
    <output id="Lc49.signal" name="signal" type="boolean" off_x="50" off_y="-40"/>
    <output id="Lc49.count" name="count" type="range" min="0" max="1023" off_x="50" off_y="-40"/>
  </component>
  <arc id="a50" type="read" source="t3" target="Lc49.reset"/>
  <signal id="s51" x="1164" y="855" mode="input" type="boolean" min="0" max="1"/>
  <arc id="a52" type="read" source="s51" target="Lc35.gate"/>
  <operation id="o1" x="1341" y="755" rot="0" shape="rect" size="30">
    <name text="---| |---" off_x="-20" off_y="0"/>
    <input id="o1.in" name="in" type="boolean" off_x="-30" off_y="0"/>
    <input id="o1.gate" name="gate" type="boolean" off_x="0" off_y="25"/>
    <output id="o1.out" name="out" type="boolean" off_x="30" off_y="0">
      <expression>
        <text>in AND gate</text>
        <operand type="signal" idRef="in"/>
        <operator type="and"/>
        <operand type="signal" idRef="gate"/>
      </expression>
    </output>
  </operation>
  <arc id="a33" type="read" source="Lc35.out" target="o1.in"/>
  <operation id="o36" x="1300" y="845" rot="0" shape="rect" size="20">
    <name text="TRUE" off_x="-15" off_y="0"/>
    <output id="o36.out" name="out" type="boolean" off_x="20" off_y="0">
      <expression>
        <text>true</text>
        <operand type="literal" value="1"/>
      </expression>
    </output>
  </operation>
  <arc id="a37" type="read" source="o36.out" target="o1.gate" c2_x="-1" c2_y="35" c1_x="0" c1_y="0"/>
  <signal id="s1" x="840" y="135" mode="output" type="boolean" min="0" max="1"/>
  <operation id="o2" x="1098" y="483" rot="0" shape="rect" size="20">
    <name text="TRUE" off_x="-15" off_y="0"/>
    <output id="o2.out" name="out" type="boolean" off_x="20" off_y="0">
      <expression>
        <text>true</text>
        <operand type="literal" value="1"/>
      </expression>
    </output>
  </operation>
  <operation id="o3" x="1319" y="482" rot="0" shape="rect" size="30">
    <name text="---|/|---" off_x="-20" off_y="0"/>
    <input id="o3.in" name="in" type="boolean" off_x="-30" off_y="0"/>
    <input id="o3.gate" name="gate" type="boolean" off_x="0" off_y="30"/>
    <output id="o3.out" name="out" type="boolean" off_x="30" off_y="0">
      <expression>
        <text>in AND (gate = 0)</text>
        <operand type="signal" idRef="in"/>
        <operator type="and"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="gate"/>
          <operator type="equal"/>
          <operand type="literal" value="0"/>
        </operand>
      </expression>
    </output>
  </operation>
  <operation id="o4" x="1460" y="595" rot="0" shape="circle" size="22">
    <name text="OR" off_x="-10" off_y="-6"/>
    <input id="o4.in1" name="in1" type="boolean" off_x="-22" off_y="0"/>
    <input id="o4.in2" name="in2" type="boolean" off_x="0" off_y="20"/>
    <input id="o4.in3" name="in3" type="boolean" off_x="0" off_y="-20"/>
    <output id="o4.out" name="out" type="boolean" off_x="22" off_y="0">
      <expression>
        <text>in1 OR in2 OR In3</text>
        <operand type="signal" idRef="in"/>
        <operator type="or"/>
        <operand type="signal" idRef="in2"/>
        <operator type="or"/>
        <operand type="signal" idRef="in3"/>
      </expression>
    </output>
  </operation>
  <arc id="a35" type="read" source="o2.out" target="o3.in"/>
  <arc id="a38" type="read" source="Lc0.out" target="o3.gate" c2_x="-19" c2_y="33" c1_x="30" c1_y="-7"/>
  <arc id="a39" type="read" source="o3.out" target="o4.in3" c2_x="0" c2_y="-50" c1_x="0" c1_y="0"/>
  <arc id="a40" type="read" source="Lc1.out" target="o4.in1"/>
  <arc id="a41" type="read" source="o1.out" target="o4.in2" c2_x="5" c2_y="70" c1_x="0" c1_y="0"/>
  <arc id="a42" type="read" source="o4.out" target="s40"/>
  <component id="c2" class="timers/tON" x="728" y="165" width="60" height="80">
    <name text="tON" off_x="-30" off_y="-42"/>
    <input id="c2.in" name="in" type="boolean" off_x="-30" off_y="-30"/>
    <input id="c2.delay" name="delay" type="range" min="0" max="16384" off_x="-30" off_y="-10"/>
    <output id="c2.out" name="out" type="boolean" off_x="30" off_y="-30"/>
  </component>
  <signal id="s3" x="612" y="135" mode="input" type="boolean" min="0" max="1"/>
  <arc id="a44" type="read" source="s3" target="c2.in"/>
  <arc id="a45" type="read" source="c2.out" target="s1"/>
  <operation id="o46" x="741" y="345" rot="0" shape="arrow" size="25">
    <name text="&gt;" off_x="-10" off_y="3"/>
    <input id="o46.i1" name="i1" type="range" min="0" max="1024" off_x="-25" off_y="-10"/>
    <input id="o46.i2" name="i2" type="range" min="0" max="1024" off_x="-25" off_y="10"/>
    <output id="o46.out" name="out" type="boolean" off_x="25" off_y="0">
      <expression>
        <text>i1 &gt; i2</text>
        <operand type="signal" idRef="i1"/>
        <operator type="more"/>
        <operand type="signal" idRef="i2"/>
      </expression>
    </output>
  </operation>
  <arc id="a47" type="read" source="led3" target="o46.i1"/>
  <arc id="a48" type="read" source="led1" target="o46.i2"/>
  <arc id="a49" type="read" source="o46.out" target="t4"/>
</net>
