<div class="section" id="add-a-meter">
<span id="add-meter"></span><span id="index-0"></span>
<div class="line-block">
<div class="line">A <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-meter"><em class="xref std std-term">meter</em></a> is very similar to an <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-event"><em class="xref std std-term">event</em></a>.</div>
<div class="line">Instead of being a boolean value (on/off), it can take a range of integer values.</div>
<div class="line">Other tasks are then triggered when the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-meter"><em class="xref std std-term">meter</em></a> reaches a certain value.</div>
<div class="line">Like events, <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-meter"><em class="xref std std-term">meter</em></a>‘s have names and a <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-task"><em >task</em></class="xref std std-term">task</em></a> can have several of them.</div>
</div>
<div class="highlight-python"><pre># Definition of the suite test.
suite test
edit ECF_INCLUDE "$HOME/course"
edit ECF_HOME "$HOME/course"
family f1
edit SLEEP 20
task t1
meter progress 1 100 90
task t2
trigger t1 eq complete
event a
event b
task t3
trigger t2:a
task t4
trigger t2 eq complete
complete t2:b
task t5
trigger t1:progress ge 30
task t6
trigger t1:progress ge 60
task t7
trigger t1:progress ge 90
endfamily
endsuite</pre>
</div>
<p>In python this would be:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/env python2.5</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">ecflow</span>
<span class="k">def</span> <span class="nf">create_family_f1</span><span class="p">():</span>
<span class="n">f1</span> <span class="o">=</span> <span class="n">ecflow</span><span class="o">.</span><span class="n">Family</span><span class="p">(</span><span class="s">"f1"</span><span class="p">)</span>
<span class="n">f1</span><span >.class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"SLEEP"</span><span class="p">,</span><span class="mi">20</span><span class="p">)</span>
<span class="n">t1</span> <span class="o">=</span> <span class="n">f1</span><span class="o">.</span><span >add_class="n">add_task</span><span class="p">(</span><span class="s">"t1"</span><span class="p">)</span>
<span class="n">t1</span><span class="o">.</span><span class="n">add_meter</span><span class="p">(</span><span class="s">"progress"</span><span class="p">,</span><span class="mi">1</span><span >,class="p">,</span><span class="mi">100</span><span class="p">,</span><span class="mi">90</span><span class="p">)</span>
<span class="n">t2</span> <span class="o">=</span> <span class="n">f1</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span >&class="s">"t2"</span><span class="p">)</span>
<span class="n">t2</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"t1 eq complete"</span><span class="p">)</span>
<span class="n">t2</span><span class="o">.</span><span class="n">add_event</span><span >(class="p">(</span><span class="s">"a"</span><span class="p">)</span>
<span class="n">t2</span><span class="o">.</span><span class="n">add_event</span><span class="p">(</span><span class="s">"b"</span><span class="p">)</span>
<span class="n">t3</span> <span class="o">=</span> <span >f1</class="n">f1</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"t3"</span><span class="p">)</span>
<span class="n">t3</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"t2:a"</span><span >)class="p">)</span>
<span class="n">t4</span> <span class="o">=</span> <span class="n">f1</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"t4"</span><span class="p">)</span>
<span class="n">t4</span><span class="o">.</span><span >add_class="n">add_trigger</span><span class="p">(</span><span class="s">"t2 eq complete"</span><span class="p">)</span>
<span class="n">t4</span><span class="o">.</span><span class="n">add_complete</span><span class="p">(</span><span class="s">"t2:b"</span><span class="p">)</span>
<span class="n">t5</span> <span >=<class="o">=</span> <span class="n">f1</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"t5"</span><span class="p">)</span>
<span class="n">t5</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span >&class="s">"t1:progress ge 30"</span><span class="p">)</span>
<span class="n">t6</span> <span class="o">=</span> <span class="n">f1</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">"t6"</span><span class="p">)</span>
<span class="n">t6</span><span >.class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"t1:progress ge 60"</span><span class="p">)</span>
<span class="n">t7</span> <span class="o">=</span> <span class="n">f1</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span >&class="s">"t7"</span><span class="p">)</span>
<span class="n">t7</span><span class="o">.</span><span class="n">add_trigger</span><span class="p">(</span><span class="s">"t1:progress ge 90"</span><span class="p">)</span>
<span class="k">return</span> <span class="n">f1</span>
<span class="n">defs</span> <span >=<class="o">=</span> <span class="n">ecflow</span><span class="o">.</span><span class="n">Defs</span><span >(</span><span >"test.def"</span><span >class="p">()</span>
<span class="n">suite</span> <span class="o">=</span> <span class="n">defs</span><span class="o">.</span><span class="n">add_suite</span><span class="p">(</span><span class="s">"test"</span><span span><span class="p">)</span>
<span class="n">suite</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"ECF_INCLUDE"</span><span class="p">,</span><span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span span><span class="s">"HOME"</span><span class="p">)</span> <span class="o">+</span> <span class="s">"/course"</span><span class="p">)</span>
<span class="n">suite</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">"ECF_HOME "</span><span class="p">,</span><span span><span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s">"HOME"</span><span class="p">)</span> <span class="o">+</span> <span class="s">"/course"</span><span class="p">)</span>
<span class="n">suite</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span> <span class="n">create_family_f1</span><span class="p">()</span> <span class="p">)</span>
</pre></div>
</div>
<div class="line-block">
<div class="line">To notify <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-ecfecflow-server"><em >ecfclass="xref std std-term">ecflow_server</em></a>, the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-task"><em class="xref std std-term">task</em></a> <strong>t1</strong> must call the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-ecfecflow-client"><em >ecfclass="xref std std-term">ecflow_client</em></a> –meter.</div>
<div class="line">This is also one of the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-child-command"><em -child-command"><em class="xref std std-term">child command</em></a>‘s</div>
</div>
<div class="highlight-python"><pre>%include <head.h>
echo "I will now sleep for %SLEEP% seconds"
sleep %SLEEP%
n=1
while [[ $n -le 100 ]] # Loop 100 times
do
sleep 1 # Wait a short time
ecfecflow_client --meter progress $n # Notify ecFlow
(( n = $n + 1 ))
done
%include <tail.h></pre>
</div>
<p>What to do:</p>
<ol class="arabic simple">
<li>Edit the definition file or python to add the modifications.</li>
<li>Edit <tt class="file docutils literal"><span class="pre">t1.ecf</span></tt> to call <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-ecf-client"><em >ecf-ecflow-client"><em class="xref std std-term">ecflow_client</em></a> –meter</li>
<li>Copy <tt class="file docutils literal"><span class="pre">t4.ecf</span></tt> to <tt class="file docutils literal"><span class="pre">t5.ecf</span></tt>, <tt class="file docutils literal"><span class="pre">t6.ecf</span></tt> and <tt ><span and <tt class="file docutils literal"><span class="pre">t7.ecf</span></tt></li>
<li>Load the definition again.</li>
<li>Observe the tasks in <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-ecflowview"><em >ecFlowview<class="xref std std-term">ecflowview</em></a>.</li>
<li>See the triggers by selecting progress and clicking on the Triggers icon.</li>
<li>Move the mouse pointer over <img alt="progress" src="../wiki../download../attachments_images/7373012/progress.jpg" /> then with the right mouse button, choose <strong>Edit...</strong></li>
<li>Modify the value of the meter and click on the Apply icon <img alt="apply" src="../wiki../download/attachments/7373012../_images/apply.jpg" /></li>
</ol>
</div>
|