<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://gres.uninova.pt/iopt-flow/show-pf.xsl" type="text/xsl" ?>
<net name="xpto" type="iopt-flow">
  <signal id="InS" mode="input" type="boolean" x="70" y="90"/>
  <operation id="calc_IE" x="110" y="90" size="15" locked="true">
    <name text="IE" off_x="-15" off_y="-15"/>
    <input id="calc_IE.in" name="in" off_x="-15" off_y="0"/>
    <output id="calc_IE.out" name="out" off_x="15" off_y="0" type="event">
      <expression>
        <operand type="signal" idRef="in" delay="1"/>
        <operator type="less-or-equal"/>
        <operand type="literal" value="0"/>
        <operator type="and"/>
        <operand type="signal" idRef="in"/>
        <operator type="more"/>
        <operand type="literal" value="0"/>
        <text>in[-1] &lt;= 0 AND in &gt; 0</text>
      </expression>
    </output>
  </operation>
  <arc id="calc_IE-in" type="read" source="InS" target="calc_IE.in"/>
  <event id="IE" mode="internal" x="160" y="90"/>
  <arc id="calc_IE-out" type="read" source="calc_IE.out" target="IE"/>
  <signal id="O1" mode="output" type="boolean" x="710" y="120"/>
  <operation id="calc_O1" x="710" y="180" size="40">
    <name text="O1" off_x="-35" off_y="-40"/>
    <input id="calc_O1.O1" name="O1" off_x="-40" off_y="-25" type="range" dynamic="type"/>
    <input id="calc_O1.OE" name="OE" off_x="-40" off_y="25" type="event"/>
    <output id="calc_O1.out" name="out" off_x="40" off_y="0" type="range" min="0" max="1">
      <expression>
        <operand type="signal" idRef="O1" delay="1"/>
        <operator type="add"/>
        <operand type="literal" value="1"/>
        <operator type="when"/>
        <operand type="signal" idRef="OE"/>
        <text>O1[-1] + 1 WHEN (OE)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="O1" delay="1"/>
        <operator type="otherwise"/>
        <text>O1[-1] OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="O1_drv" type="read" source="calc_O1.out" target="O1"/>
  <arc id="O1_out" type="read" target="calc_O1.O1" source="O1"/>
  <arc id="calc_O1_1" type="read" source="OE" target="calc_O1.OE"/>
  <signal id="O2" mode="output" type="boolean" x="710" y="370"/>
  <operation id="SO2P11" x="540" y="390" size="30">
    <name text="O2" off_x="-30" off_y="-30"/>
    <input id="SO2P11.P11" name="P11" type="range" dynamic="type" off_x="-30" off_y="-20"/>
    <output id="SO2P11.out" name="out" off_x="30" off_y="0" type="range" min="0" max="1">
      <expression>
        <operand type="literal" value="1"/>
        <operator type="when"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="P11"/>
        </operand>
        <text>1 WHEN (P11)</text>
      </expression>
      <expression>
        <operand type="literal" value="0"/>
        <operator type="otherwise"/>
        <text>0 OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="S_O2P11" type="read" source="p_11" target="SO2P11.P11"/>
  <arc id="S_O2P11_out" type="read" source="SO2P11.out" target="O2" view="xsymbolic"/>
  <signal id="O3" mode="output" type="boolean" x="710" y="450"/>
  <operation id="SO3P2" x="240" y="200" size="30">
    <name text="O3" off_x="-30" off_y="-30"/>
    <input id="SO3P2.P2" name="P2" type="range" dynamic="type" off_x="-30" off_y="-20"/>
    <output id="SO3P2.out" name="out" off_x="30" off_y="0" type="range" min="0" max="1">
      <expression>
        <operand type="literal" value="3"/>
        <operator type="when"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="P2"/>
        </operand>
        <text>3 WHEN (P2)</text>
      </expression>
      <expression>
        <operand type="literal" value="0"/>
        <operator type="otherwise"/>
        <text>0 OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="S_O3P2" type="read" source="p_2" target="SO3P2.P2"/>
  <operation id="SO3P3" x="240" y="380" size="30">
    <name text="O3" off_x="-30" off_y="-30"/>
    <input id="SO3P3.P3" name="P3" type="range" dynamic="type" off_x="-30" off_y="-20"/>
    <output id="SO3P3.out" name="out" off_x="30" off_y="0" type="range" min="0" max="1">
      <expression>
        <operand type="literal" value="1"/>
        <operator type="when"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="P3"/>
        </operand>
        <text>1 WHEN (P3)</text>
      </expression>
      <expression>
        <operand type="literal" value="0"/>
        <operator type="otherwise"/>
        <text>0 OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="S_O3P3" type="read" source="p_3" target="SO3P3.P3"/>
  <operation id="max_O3" size="30" x="660" y="450">
    <name text="max(O3)" off_x="-30" off_y="-30"/>
    <input id="max_O3.P2" name="P2" type="range" dynamic="type" off_x="-30" off_y="-8.333333333333332"/>
    <input id="max_O3.P3" name="P3" type="range" dynamic="type" off_x="-30" off_y="8.333333333333336"/>
    <output id="max_O3.out" name="out" off_x="30" off_y="0" type="range" min="0" max="1">
      <expression>
        <operand type="signal" idRef="P2"/>
        <operator type="when"/>
        <operand type="sub-expression">
          <operand type="signal" idRef="P2"/>
          <operator type="more-or-equal"/>
          <operand type="signal" idRef="P3"/>
        </operand>
        <text>P2 WHEN (P2 &gt;= P3)</text>
      </expression>
      <expression>
        <operand type="signal" idRef="P3"/>
        <operator type="otherwise"/>
        <text>P3 OTHERWISE</text>
      </expression>
    </output>
  </operation>
  <arc id="max_O3_out" type="read" source="max_O3.out" target="O3"/>
  <arc id="max_O3_in1" type="read" source="SO3P2.out" target="max_O3.P2"/>
  <arc id="max_O3_in2" type="read" source="SO3P3.out" target="max_O3.P3"/>
  <event id="OE" mode="internal" x="630" y="120"/>
  <arc id="OE_in_evt" type="read" source="t_13" target="OE" view="symbolic"/>
  <place id="p_2" x="190" y="200" init_marking="1">
    <name text="pl_2" off_x="-10" off_y="20"/>
    <comment text="" off_x="-30" off_y="20"/>
  </place>
  <place id="p_3" x="190" y="380" init_marking="0">
    <name text="pl_3" off_x="-10" off_y="20"/>
    <comment text="" off_x="-30" off_y="20"/>
  </place>
  <place id="p_10" x="490" y="210" init_marking="1">
    <name text="pl_10" off_x="-10" off_y="20"/>
    <comment text="" off_x="-30" off_y="20"/>
  </place>
  <place id="p_11" x="490" y="390" init_marking="0">
    <name text="pl_11" off_x="-10" off_y="20"/>
    <comment text="" off_x="-30" off_y="20"/>
  </place>
  <transition id="t_4" x="100" y="290" priority="1">
    <name text="tr_4" off_x="-10" off_y="20"/>
    <comment text="" off_x="-30" off_y="20"/>
  </transition>
  <operation id="t_4_guard" size="25" x="75" y="330">
    <name text="Guard" off_x="-20" off_y="-22"/>
    <input id="t_4_guard.InS" name="InS" type="range" dynamic="type" off_x="-25" off_y="0"/>
    <output id="t_4_guard.C" name="C" off_x="25" off_y="0" type="boolean">
      <expression>
        <operand type="signal" idRef="InS"/>
        <operator type="equal"/>
        <operand type="literal" value="1"/>
        <text>InS = 1</text>
      </expression>
    </output>
  </operation>
  <arc id="t_4_gc" type="read" source="t_4_guard.C" target="t_4"/>
  <arc id="t_4_guard_in1" type="read" source="InS" target="t_4_guard.InS" view="symbolic"/>
  <transition id="t_5" x="280" y="290" priority="1">
    <name text="tr_5" off_x="-10" off_y="20"/>
    <comment text="" off_x="-30" off_y="20"/>
  </transition>
  <operation id="t_5_guard" size="25" x="255" y="330">
    <name text="Guard" off_x="-20" off_y="-22"/>
    <input id="t_5_guard.InS" name="InS" type="range" dynamic="type" off_x="-25" off_y="0"/>
    <output id="t_5_guard.C" name="C" off_x="25" off_y="0" type="boolean">
      <expression>
        <operand type="signal" idRef="InS"/>
        <operator type="diff"/>
        <operand type="literal" value="1"/>
        <text>InS &lt;&gt; 1</text>
      </expression>
    </output>
  </operation>
  <arc id="t_5_gc" type="read" source="t_5_guard.C" target="t_5"/>
  <arc id="t_5_guard_in1" type="read" source="InS" target="t_5_guard.InS" view="symbolic"/>
  <transition id="t_12" x="390" y="300" priority="1">
    <name text="tr_12" off_x="-10" off_y="20"/>
    <comment text="" off_x="-30" off_y="20"/>
  </transition>
  <arc id="12_ie_1" type="read" source="IE" target="t_12" view="symbolic"/>
  <transition id="t_13" x="580" y="300" priority="1">
    <name text="tr_13" off_x="-10" off_y="20"/>
    <comment text="" off_x="-30" off_y="20"/>
  </transition>
  <arc id="6" source="t_4" target="p_2" type="normal"/>
  <arc id="7" source="p_2" target="t_5" type="normal"/>
  <arc id="8" source="t_5" target="p_3" type="normal"/>
  <arc id="9" source="p_3" target="t_4" type="normal"/>
  <arc id="14" source="p_10" target="t_13" type="normal"/>
  <arc id="15" source="t_13" target="p_11" type="normal"/>
  <arc id="16" source="p_11" target="t_12" type="normal"/>
  <arc id="17" source="t_12" target="p_10" type="normal"/>
</net>
