<xml xmlns="http://www.w3.org/1999/xhtml">
  <block type="cubelets_setup" id="2" deletable="false" x="-287" y="-37">
    <statement name="setup_do">
      <block type="variables_set" id="s/wq#`waqT1`2?gwqT90">
        <field name="VAR">STATE_OFF</field>
        <value name="VALUE">
          <block type="math_number" id="+Fe-)_*toUXOG^x#^lJl">
            <field name="NUM">0</field>
          </block>
        </value>
        <next>
          <block type="variables_set" id="Fm={/1-f_,4qiV7i;:ly">
            <field name="VAR">STATE_ON</field>
            <value name="VALUE">
              <block type="math_number" id="4{PaRrUakL!1H76g6zJ0">
                <field name="NUM">1</field>
              </block>
            </value>
            <next>
              <block type="variables_set" id="aYBYw^ua2IE_Jm`?bpsl">
                <field name="VAR">STATE_WAITING</field>
                <value name="VALUE">
                  <block type="math_number" id="B.!20?y%L^,7p^p=}B2w">
                    <field name="NUM">3</field>
                  </block>
                </value>
                <next>
                  <block type="variables_set" id=",2hCHl1(3kdo-*]!/85e">
                    <field name="VAR">LATCH_ON_BV</field>
                    <value name="VALUE">
                      <block type="math_number" id="mv2HZAbX0dS|-Jvxs`c@">
                        <field name="NUM">255</field>
                      </block>
                    </value>
                    <next>
                      <block type="variables_set" id="nr{6k2`MP))n}3zoygQ7">
                        <field name="VAR">LATCH_OFF_BV</field>
                        <value name="VALUE">
                          <block type="math_number" id="e[;0wsu2@a^/){f(C9ey">
                            <field name="NUM">0</field>
                          </block>
                        </value>
                        <next>
                          <block type="variables_set" id="Fako88d|4,d5).#lghz.">
                            <field name="VAR">LATCH_THRESHOLD</field>
                            <value name="VALUE">
                              <block type="math_number" id="Oe|sMsjzkZh6s_!*EM?[">
                                <field name="NUM">127</field>
                              </block>
                            </value>
                            <next>
                              <block type="variables_set" id="J4TBa0L(,F2i0m:Q8rDq">
                                <field name="VAR">state</field>
                                <value name="VALUE">
                                  <block type="variables_get" id="@lgc:*rxas(KpU6b;_[E">
                                    <field name="VAR">STATE_OFF</field>
                                  </block>
                                </value>
                              </block>
                            </next>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </next>
      </block>
    </statement>
  </block>
  <block type="cubelets_loop" id="5" deletable="false" x="-286" y="195">
    <statement name="loop_do">
      <block type="controls_if" id="=r?Jap;0=e+~}.!9i.mN">
        <mutation elseif="1"></mutation>
        <value name="IF0">
          <block type="logic_operation" id="Oi5yb-BB_!=v#r#@;,dm">
            <field name="OP">AND</field>
            <value name="A">
              <block type="logic_compare" id="H(q|=rcO%PDz2G?NGL`~">
                <field name="OP">EQ</field>
                <value name="A">
                  <block type="variables_get" id="K*@aWhECZn`O=ut1YCv+">
                    <field name="VAR">state</field>
                  </block>
                </value>
                <value name="B">
                  <block type="variables_get" id="HA*hKodij_6lw)/dY9@8">
                    <field name="VAR">STATE_OFF</field>
                  </block>
                </value>
              </block>
            </value>
            <value name="B">
              <block type="logic_compare" id="/31t|dU^bK`-~Pr))Su=">
                <field name="OP">GT</field>
                <value name="A">
                  <block type="get_sensor_value" id="X/^IpG78|i%SVtN@YG#1"></block>
                </value>
                <value name="B">
                  <block type="variables_get" id="FWLf)tIe{i%BG#EZ)yqP">
                    <field name="VAR">LATCH_THRESHOLD</field>
                  </block>
                </value>
              </block>
            </value>
          </block>
        </value>
        <statement name="DO0">
          <block type="variables_set" id="|RiZJ5+h(G0,l%j2|sLh">
            <field name="VAR">state</field>
            <value name="VALUE">
              <block type="variables_get" id="9cZP09p=mdG3CvZ~`_vi">
                <field name="VAR">STATE_WAITING</field>
              </block>
            </value>
            <next>
              <block type="variables_set" id="%D;20O%@(_kNMgifLCt*">
                <field name="VAR">block_value</field>
                <value name="VALUE">
                  <block type="variables_get" id="+L?yhFZT:fGr~Sk7i5Pj">
                    <field name="VAR">LATCH_ON_BV</field>
                  </block>
                </value>
                <next>
                  <block type="set_timeout" id="!^ga_^o-!FxD?fWYJiQR">
                    <field name="time_interval">300</field>
                    <field name="callback_name">set_state_on</field>
                    <statement name="callback_do">
                      <block type="variables_set" id="!-m[ZZ305enK!`TI)i+:">
                        <field name="VAR">state</field>
                        <value name="VALUE">
                          <block type="variables_get" id="6-P3iI0D?~B9pTcB#Nt:">
                            <field name="VAR">STATE_ON</field>
                          </block>
                        </value>
                      </block>
                    </statement>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </statement>
        <value name="IF1">
          <block type="logic_operation" id="RL)6k|~`@heICJe;QBnY">
            <field name="OP">AND</field>
            <value name="A">
              <block type="logic_compare" id="lx22.!s{[B`{(8Xh/n}{">
                <field name="OP">EQ</field>
                <value name="A">
                  <block type="variables_get" id="lDqcuo{S%QLx{]x8i+nr">
                    <field name="VAR">state</field>
                  </block>
                </value>
                <value name="B">
                  <block type="variables_get" id="wWYNy1kj=,2%zMPTR!iW">
                    <field name="VAR">STATE_ON</field>
                  </block>
                </value>
              </block>
            </value>
            <value name="B">
              <block type="logic_compare" id="_xy9xBr?ut~E5ngl{]g4">
                <field name="OP">GT</field>
                <value name="A">
                  <block type="get_sensor_value" id="}G^AM?/kur]S7Wp3!YNj"></block>
                </value>
                <value name="B">
                  <block type="variables_get" id="e%qpG%H*{-I1[hkw#N9z">
                    <field name="VAR">LATCH_THRESHOLD</field>
                  </block>
                </value>
              </block>
            </value>
          </block>
        </value>
        <statement name="DO1">
          <block type="variables_set" id="{O:?iE^7(kO`W%iOq.5!">
            <field name="VAR">state</field>
            <value name="VALUE">
              <block type="variables_get" id="U7,aEPgN8P:IA%`s]O]H">
                <field name="VAR">STATE_WAITING</field>
              </block>
            </value>
            <next>
              <block type="variables_set" id="JVLRvvX59)-:#=BB2s`N">
                <field name="VAR">block_value</field>
                <value name="VALUE">
                  <block type="variables_get" id="y@?A|},bq,%ob[pX/WgX">
                    <field name="VAR">LATCH_OFF_BV</field>
                  </block>
                </value>
                <next>
                  <block type="set_timeout" id="k#i_Q/~%J;k16i`6:S1d">
                    <field name="time_interval">300</field>
                    <field name="callback_name">set_state_off</field>
                    <statement name="callback_do">
                      <block type="variables_set" id="31S0D[tm9jG.^F_]vzek">
                        <field name="VAR">state</field>
                        <value name="VALUE">
                          <block type="variables_get" id="HE?[*2W]C[=%+BG!Q(rU">
                            <field name="VAR">STATE_OFF</field>
                          </block>
                        </value>
                      </block>
                    </statement>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </statement>
      </block>
    </statement>
  </block>
</xml>