diff --git a/FactoryCalib.blockly b/FactoryCalib.blockly index de50bce5e1e41735ba2aec40ee7e522ee0efdc7b..45ae0cf3be34a99c19cce6a1a490d5f8f7f65df0 100644 --- a/FactoryCalib.blockly +++ b/FactoryCalib.blockly @@ -1,11 +1,11 @@ <xml xmlns="https://developers.google.com/blockly/xml" version="14"> - <block type="start_block" id="5r8Hf)nzFKt,AzMq]4)P" deletable="false" x="-197" y="33"> + <block type="start_block" id="5r8Hf)nzFKt,AzMq]4)P" deletable="false" x="0" y="0"> <statement name="statement"> <block type="display_set_label_text" id=":7]Mx6b@!j4P*7jD}iz["> <field name="instance_name">txt_label_version</field> <value name="value"> <shadow type="text" id="T9nyAyJIRL7l_Nn(S-rd"> - <field name="TEXT">Version 2022/11/07</field> + <field name="TEXT">Version 2022/11/08</field> </shadow> </value> <next> @@ -47,24 +47,24 @@ <field name="name">init_SSC_PTU</field> <data>!*d[^#5M)?7Uxe|zk^K}</data> <next> - <block type="import_function_noreturn" id="r*GLs}=Xdp(e$+6w?};6"> - <mutation parentId="$jNNx1Oeez9#x~eQYP}z"/> - <field name="name">initMQTTLocal</field> - <data>$jNNx1Oeez9#x~eQYP}z</data> + <block type="import_function_noreturn" id="Ej2ZS8_`0nx#j=Ld4er."> + <mutation parentId="*A(OQEg?]~%+S(TjuNW:"/> + <field name="name">loadFileFactoryCalib</field> + <data>*A(OQEg?]~%+S(TjuNW:</data> <next> - <block type="util_thread" id="($:VkQ#3?EHT|;iZ9W9u"> - <field name="dropdown_event">R4vMowGJ0I?IYs_!-IwU</field> + <block type="import_function_noreturn" id="r*GLs}=Xdp(e$+6w?};6"> + <mutation parentId="$jNNx1Oeez9#x~eQYP}z"/> + <field name="name">initMQTTLocal</field> + <data>$jNNx1Oeez9#x~eQYP}z</data> <next> - <block type="util_thread" id="8L?y2Z0!5om5((y`Hug6"> - <field name="dropdown_event">]$}!d~iPi$faCfYn-,02</field> + <block type="util_thread" id="($:VkQ#3?EHT|;iZ9W9u"> + <field name="dropdown_event">R4vMowGJ0I?IYs_!-IwU</field> <next> - <block type="util_thread" id="siHp)M|Kla=_B|-564Z;"> + <block type="util_thread" id="etqX=L0t.x_7Gv^0b5U,"> <field name="dropdown_event">2)S|Q)oZ/N[cbwDZy~z}</field> <next> - <block type="import_function_noreturn" id="}gpVySQp9RlQ0;T=H|T?"> - <mutation parentId="*A(OQEg?]~%+S(TjuNW:"/> - <field name="name">loadFileFactoryCalib</field> - <data>*A(OQEg?]~%+S(TjuNW:</data> + <block type="util_thread" id="{yc__LanX27NtUTm3P*)"> + <field name="dropdown_event">]$}!d~iPi$faCfYn-,02</field> <next> <block type="loop_endless" id="^hpJo7DFR.KJ9Xs2RAx,"/> </next> diff --git a/FactoryCalib.py b/FactoryCalib.py index 4de245b08c6e396bc6fa973efaad4942bd92ecdc..2edbfbc21957427400a24eebe6af653d6b64570f 100644 --- a/FactoryCalib.py +++ b/FactoryCalib.py @@ -24,7 +24,7 @@ from lib.VGR_Axes1Ref import * from lib.VGR_NodeRED import * -display.set_attr("txt_label_version.text", str('Version 2022/11/07')) +display.set_attr("txt_label_version.text", str('Version 2022/11/08')) initlib_log(5) threading.Thread(target=thread_lights, daemon=True).start() initlib_Axes1Ref() @@ -32,10 +32,10 @@ initlib_Axes2Ref() init_VGR() init_HBW() init_SSC_PTU() +loadFileFactoryCalib() initMQTTLocal() threading.Thread(target=thread_MQTTLocal, daemon=True).start() -threading.Thread(target=thread_SLD, daemon=True).start() threading.Thread(target=thread_DPS, daemon=True).start() -loadFileFactoryCalib() +threading.Thread(target=thread_SLD, daemon=True).start() while True: pass diff --git a/lib/NodeRED.blockly b/lib/NodeRED.blockly index 9ee9d23e86bf3b172b146cf10ebb856e04165029..d7c5dc4e067713c6823c5b5dd5e588bd149c7560 100644 --- a/lib/NodeRED.blockly +++ b/lib/NodeRED.blockly @@ -18,9 +18,9 @@ <variable id=")(=M[8QEW5[mGL@9Axsu">gtyp_Setup_w_Actual_ColorValue</variable> <variable id="aQ:d%c!ilWYQz|GZ5N0~">gtyp_Setup_w_Threshold_White_Red</variable> <variable id="A{`)A3~(6e.5r^y~X;S1">gtyp_Setup_w_Threshold_Red_Blue</variable> - <variable id="TZ7zEdrg=Q,vG9XutiCF">gtyp_SSC_w_Threshold_Red_Blue</variable> <variable id="1R^uniMizt=l7#?^bm$c">gtyp_Setup_di_Pos_Rotate</variable> <variable id="z}xxgCaN^$Fn.vEFUV}F">gtyp_SLD_w_Threshold_Red_Blue</variable> + <variable id="TZ7zEdrg=Q,vG9XutiCF">gtyp_SSC_w_Threshold_Red_Blue</variable> <variable id="x43W3)orCB:l1qw2dLN`">gtyp_SLD_w_Threshold_White_Red</variable> <variable id="-XOZ;@M!{qgTA%xgUef-">gtyp_SSC_w_Threshold_White_Red</variable> <variable id="mvCEZ!N=009NymF/qM7c">gtyp_Setup_di_Pos_Vertical</variable> @@ -41,10 +41,10 @@ <field name="Hbe2WDx-@,*Wg@:(`|^.">m_decode</field> <statement name="STACK"> <block type="util_python" id="G*Cyx6_G`O1FJ;t;|hrQ" inline="true"> - <field name="value">logging.log(logging.TRACE, '%s %s', topic, m_decode)</field> + <field name="value">logging.log(logging.TRACE0, '%s %s', topic, m_decode)</field> <next> <block type="controls_if" id=":Pd7[hKJ5a7hsE}Cfr($"> - <mutation elseif="13" else="1"/> + <mutation elseif="14" else="1"/> <value name="IF0"> <block type="logic_compare" id="68yi{8vrr(As?~twnx3:"> <field name="OP">EQ</field> @@ -1260,6 +1260,340 @@ <field name="BOOL">FALSE</field> </shadow> </value> + <next> + <block type="controls_if" id="c7sHjnceoH.mo|,.i)!i"> + <mutation elseif="1" else="1"/> + <value name="IF0"> + <block type="logic_compare" id="FkOwcEo2?}OUrCaO!`V4"> + <field name="OP">EQ</field> + <value name="A"> + <block type="variables_get" id="q5rjy+:qAR[VhkC$-lb*"> + <field name="VAR" id=")XfA{xXx7sN)MA=qSY=H">gtyp_Setup_i_Color_Sensor_Selection</field> + </block> + </value> + <value name="B"> + <block type="math_number" id="_[^Ljw9w5Akdky*gn86H"> + <field name="NUM">1</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="util_python" id="soiv=1GYGk1x%q@maBVQ" inline="true"> + <field name="value">logging.debug('1')</field> + <next> + <block type="import_function_noreturn" id="M[HH9m7FQXc%HGGy.8WI" inline="true"> + <mutation parentId="3Qf0~|~$oG8z5tP{6Km;"/> + <field name="name">set_calib_data_SLD</field> + <data>3Qf0~|~$oG8z5tP{6Km;</data> + <value name="_data"> + <block type="import_function_return" id="(5oQM![;])v/u0pcD6MD"> + <mutation parentId="b|1;0mU=wNNO2Ry{f6,Z"/> + <field name="name">get_calib_data_SLD</field> + <data>b|1;0mU=wNNO2Ry{f6,Z</data> + </block> + </value> + <next> + <block type="variables_set" id="WAf,+!7J@v2-:Q$D}WRy"> + <field name="VAR" id=")(=M[8QEW5[mGL@9Axsu">gtyp_Setup_w_Actual_ColorValue</field> + <value name="VALUE"> + <block type="math_convert" id="2A;=5MiWV;K=vSUi=Py|"> + <mutation option="TO_INT"/> + <field name="OP">TO_INT</field> + <field name="BASE">10</field> + <value name="NUM"> + <block type="import_function_return" id="lBF}3ws,,6TpfF}C;_a%"> + <mutation parentId="$]uSxm9]*Qu3iZl~w~MW"/> + <field name="name">readColorValue</field> + <data>$]uSxm9]*Qu3iZl~w~MW</data> + </block> + </value> + </block> + </value> + <next> + <block type="variables_set" id="A;mMGOnf}=G4)(mUTBXB"> + <field name="VAR" id="z}xxgCaN^$Fn.vEFUV}F">gtyp_SLD_w_Threshold_Red_Blue</field> + <value name="VALUE"> + <block type="lists_getIndex" id="l8(^@0LFn@VRt!9bbB@y"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="import_function_return" id="[.lX-%{ZA`0XE/8@wh;6"> + <mutation parentId="b|1;0mU=wNNO2Ry{f6,Z"/> + <field name="name">get_calib_data_SLD</field> + <data>b|1;0mU=wNNO2Ry{f6,Z</data> + </block> + </value> + <value name="AT"> + <block type="math_number" id="#RosQS*Pqqky0x=BGHqe"> + <field name="NUM">1</field> + </block> + </value> + </block> + </value> + <next> + <block type="variables_set" id="V$q[G}}_EqKbXxUdXZ?y"> + <field name="VAR" id="x43W3)orCB:l1qw2dLN`">gtyp_SLD_w_Threshold_White_Red</field> + <value name="VALUE"> + <block type="lists_getIndex" id="-dw.:I!+I-1Z}iqg+9wq"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="import_function_return" id="BynbVL(FDhK[^6E+Y]|%"> + <mutation parentId="b|1;0mU=wNNO2Ry{f6,Z"/> + <field name="name">get_calib_data_SLD</field> + <data>b|1;0mU=wNNO2Ry{f6,Z</data> + </block> + </value> + <value name="AT"> + <block type="math_number" id="xKD0g;L20Gs#1K{x-1;t"> + <field name="NUM">2</field> + </block> + </value> + </block> + </value> + <next> + <block type="mqtt_publish" id="6fC(-bBrwzAL(!f*ENq9"> + <value name="name"> + <block type="variables_get" id="!8D6PQ)C0:iovvEj~?6f"> + <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> + </block> + </value> + <value name="topic"> + <shadow type="text" id="h2D6M*w}QakoV=9S]vcz"> + <field name="TEXT">gtyp_SLD/w_Threshold_White_Red</field> + </shadow> + </value> + <value name="value"> + <shadow type="logic_null"/> + <block type="variables_get" id="10DmxbPw;Kh6~X?xC^@="> + <field name="VAR" id="x43W3)orCB:l1qw2dLN`">gtyp_SLD_w_Threshold_White_Red</field> + </block> + </value> + <value name="qos"> + <shadow type="math_number" id="f=LX{[z|sxhgBKhzMc7@"> + <field name="NUM">2</field> + </shadow> + </value> + <value name="retain"> + <shadow type="logic_boolean" id="CZ4g*FL?4Mk=lj62[*yr"> + <field name="BOOL">FALSE</field> + </shadow> + </value> + <next> + <block type="mqtt_publish" id="StL0d;=/[ck2._O_Id.("> + <value name="name"> + <block type="variables_get" id="N]59T`b2jIc;_qGW2?hE"> + <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> + </block> + </value> + <value name="topic"> + <shadow type="text" id="9W@f;@ZG8JRhbU#pQb%V"> + <field name="TEXT">gtyp_SLD/w_Threshold_Red_Blue</field> + </shadow> + </value> + <value name="value"> + <shadow type="logic_null"/> + <block type="variables_get" id=".$OApgnU$;Ks5QCN7=.?"> + <field name="VAR" id="z}xxgCaN^$Fn.vEFUV}F">gtyp_SLD_w_Threshold_Red_Blue</field> + </block> + </value> + <value name="qos"> + <shadow type="math_number" id="P@?U|z5SZY6k/NQSSaLr"> + <field name="NUM">2</field> + </shadow> + </value> + <value name="retain"> + <shadow type="logic_boolean" id=",B[1dxL!]ME%M)JCM)@^"> + <field name="BOOL">FALSE</field> + </shadow> + </value> + <next> + <block type="import_function_noreturn" id="c{=w9)lmtKb$uKpfh|f1"> + <mutation parentId="g=6%Ka9Y1qYH|_c:bu9]"/> + <field name="name">startSLD</field> + <data>g=6%Ka9Y1qYH|_c:bu9]</data> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </statement> + <value name="IF1"> + <block type="logic_compare" id="l6F{zxuH,.$dsdXP%x/d"> + <field name="OP">EQ</field> + <value name="A"> + <block type="variables_get" id="b`/+Km:.+3G=FF=mC~aL"> + <field name="VAR" id=")XfA{xXx7sN)MA=qSY=H">gtyp_Setup_i_Color_Sensor_Selection</field> + </block> + </value> + <value name="B"> + <block type="math_number" id="2-p5g+`e%-5K5h,)ge-g"> + <field name="NUM">2</field> + </block> + </value> + </block> + </value> + <statement name="DO1"> + <block type="util_python" id="x0s]$+:+=z@PJ!naMKFJ" inline="true"> + <field name="value">logging.debug('2')</field> + <next> + <block type="import_function_noreturn" id="mYNNZg)WPJlr:~$ufsec" inline="true"> + <mutation parentId=":J%zX-c=Y4mZAR)aLyUn"/> + <field name="name">set_calib_data_DPS</field> + <data>:J%zX-c=Y4mZAR)aLyUn</data> + <value name="_data"> + <block type="import_function_return" id="@;JC1=}]#34K48sx$z:f"> + <mutation parentId="Q9p7dhe-|x*[t`L^}||B"/> + <field name="name">get_calib_data_DPS</field> + <data>Q9p7dhe-|x*[t`L^}||B</data> + </block> + </value> + <next> + <block type="variables_set" id="]U{J=*zkyz1_tdI~ahab"> + <field name="VAR" id=")(=M[8QEW5[mGL@9Axsu">gtyp_Setup_w_Actual_ColorValue</field> + <value name="VALUE"> + <block type="math_convert" id="KxHe9y`eYq8M.q;u3Qf9"> + <mutation option="TO_INT"/> + <field name="OP">TO_INT</field> + <field name="BASE">10</field> + <value name="NUM"> + <block type="import_function_return" id="@L.Vk]qUp2Qx=/=#/mf;"> + <mutation parentId="![`j=,+%Mnlx`Drv~HID"/> + <field name="name">readDPSColorValue</field> + <data>![`j=,+%Mnlx`Drv~HID</data> + </block> + </value> + </block> + </value> + <next> + <block type="variables_set" id="#qTi4fJvDN/gHpGR,QZL"> + <field name="VAR" id="TZ7zEdrg=Q,vG9XutiCF">gtyp_SSC_w_Threshold_Red_Blue</field> + <value name="VALUE"> + <block type="lists_getIndex" id="XHjGd8WI?lk^D`I(D#b="> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="import_function_return" id="sY?[vd+tT0Nu7cz+s-nI"> + <mutation parentId="Q9p7dhe-|x*[t`L^}||B"/> + <field name="name">get_calib_data_DPS</field> + <data>Q9p7dhe-|x*[t`L^}||B</data> + </block> + </value> + <value name="AT"> + <block type="math_number" id="0*d]I4B_:$fDgz,^vuWz"> + <field name="NUM">1</field> + </block> + </value> + </block> + </value> + <next> + <block type="variables_set" id="D:=f2wh[w8ZBWyd[g(7}"> + <field name="VAR" id="-XOZ;@M!{qgTA%xgUef-">gtyp_SSC_w_Threshold_White_Red</field> + <value name="VALUE"> + <block type="lists_getIndex" id="wdG`|Kmg=qcF]7y]s%/Y"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="import_function_return" id="nkoTt5*j.7AKXq.ht:mP"> + <mutation parentId="Q9p7dhe-|x*[t`L^}||B"/> + <field name="name">get_calib_data_DPS</field> + <data>Q9p7dhe-|x*[t`L^}||B</data> + </block> + </value> + <value name="AT"> + <block type="math_number" id="{2;D6h`S7C3wQ-4YG}9K"> + <field name="NUM">2</field> + </block> + </value> + </block> + </value> + <next> + <block type="mqtt_publish" id="q*l)lLvQ+gq071=B?@^C"> + <value name="name"> + <block type="variables_get" id="F,Y)cUZYs0lOI-L0=p.l"> + <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> + </block> + </value> + <value name="topic"> + <shadow type="text" id=")`awz#27RX.sH,6*)B6)"> + <field name="TEXT">gtyp_SSC/w_Threshold_White_Red</field> + </shadow> + </value> + <value name="value"> + <shadow type="logic_null"/> + <block type="variables_get" id="SGGyieKA!!R@(D$b/RSW"> + <field name="VAR" id="-XOZ;@M!{qgTA%xgUef-">gtyp_SSC_w_Threshold_White_Red</field> + </block> + </value> + <value name="qos"> + <shadow type="math_number" id="8{srU/E?AVvW$Dd[(}l]"> + <field name="NUM">2</field> + </shadow> + </value> + <value name="retain"> + <shadow type="logic_boolean" id="vXK,eAojF*2ouQ1Jd#tp"> + <field name="BOOL">FALSE</field> + </shadow> + </value> + <next> + <block type="mqtt_publish" id="E#Pgwk-H%6WI!+Zg@xS)"> + <value name="name"> + <block type="variables_get" id="R3n.;F-Yx`_%3T(IqW~h"> + <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> + </block> + </value> + <value name="topic"> + <shadow type="text" id="E`^{fo{,)eHSu{:O/6.V"> + <field name="TEXT">gtyp_SSC/w_Threshold_Red_Blue</field> + </shadow> + </value> + <value name="value"> + <shadow type="logic_null"/> + <block type="variables_get" id="jQ}sKf~Op2Pr:-kx:TM#"> + <field name="VAR" id="TZ7zEdrg=Q,vG9XutiCF">gtyp_SSC_w_Threshold_Red_Blue</field> + </block> + </value> + <value name="qos"> + <shadow type="math_number" id="J#pZ^?|%;:t7Amwb9W(W"> + <field name="NUM">2</field> + </shadow> + </value> + <value name="retain"> + <shadow type="logic_boolean" id="_dEw,Az-T1[gzI?|=7f*"> + <field name="BOOL">FALSE</field> + </shadow> + </value> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </statement> + </block> + </next> </block> </next> </block> @@ -1434,9 +1768,10 @@ <block type="variables_set" id="BPg6vOMOI?;C`6A+QJsT"> <field name="VAR" id=")(=M[8QEW5[mGL@9Axsu">gtyp_Setup_w_Actual_ColorValue</field> <value name="VALUE"> - <block type="math_round" id="5Z4z]JtJXR~%c^j)XFcq"> - <field name="OP">ROUND</field> - <field name="DECIMALS">0</field> + <block type="math_convert" id="$0(^:}~o#8BHH)}4$Y!`"> + <mutation option="TO_INT"/> + <field name="OP">TO_INT</field> + <field name="BASE">10</field> <value name="NUM"> <block type="import_function_return" id="oJ7BxBI@76/r%%ru?)v}"> <mutation parentId="$]uSxm9]*Qu3iZl~w~MW"/> @@ -1520,10 +1855,17 @@ <block type="variables_set" id="9*`+]6N]2vvRh5r{)qUZ"> <field name="VAR" id=")(=M[8QEW5[mGL@9Axsu">gtyp_Setup_w_Actual_ColorValue</field> <value name="VALUE"> - <block type="import_function_return" id="dcG_(9Wi^pI2:{/h0uN?"> - <mutation parentId="![`j=,+%Mnlx`Drv~HID"/> - <field name="name">readDPSColorValue</field> - <data>![`j=,+%Mnlx`Drv~HID</data> + <block type="math_convert" id="m#f}yT6yg[=rg4z7l}r!"> + <mutation option="TO_INT"/> + <field name="OP">TO_INT</field> + <field name="BASE">10</field> + <value name="NUM"> + <block type="import_function_return" id="dcG_(9Wi^pI2:{/h0uN?"> + <mutation parentId="![`j=,+%Mnlx`Drv~HID"/> + <field name="name">readDPSColorValue</field> + <data>![`j=,+%Mnlx`Drv~HID</data> + </block> + </value> </block> </value> <next> @@ -1582,45 +1924,81 @@ <block type="util_python" id="rWWm)}Q.WvYJz$62-AC:" inline="true"> <field name="value">logging.debug('none')</field> <next> - <block type="variables_set" id="9x5:lZLpAx9wmr9(j=_s"> - <field name="VAR" id="TZ7zEdrg=Q,vG9XutiCF">gtyp_SSC_w_Threshold_Red_Blue</field> + <block type="variables_set" id="g)-8V^Z,Zx{V:R_f]i_."> + <field name="VAR" id=")(=M[8QEW5[mGL@9Axsu">gtyp_Setup_w_Actual_ColorValue</field> <value name="VALUE"> - <block type="math_number" id="gz]b+,C1~FgTaNK~=r,5"> + <block type="math_number" id="Gof8u):q_v1H]SGYCc7y"> <field name="NUM">0</field> </block> </value> <next> - <block type="variables_set" id="S2G]dx)f~jgzuW0k^kNp"> - <field name="VAR" id="-XOZ;@M!{qgTA%xgUef-">gtyp_SSC_w_Threshold_White_Red</field> - <value name="VALUE"> - <block type="math_number" id="C=d/[ap2uVxKy:e^MI:Z"> + <block type="import_function_noreturn" id="pP}9%Bs)9]$fD$H/@=As" inline="true"> + <mutation parentId="VSmATTY?.L[C{f,=c#1:"/> + <field name="name">set_calibvalue_white</field> + <data>VSmATTY?.L[C{f,=c#1:</data> + <value name="v"> + <block type="math_number" id="tb{pe]#KLCojOWWR,]P4"> <field name="NUM">0</field> </block> </value> <next> - <block type="variables_set" id="K8LkNm#7hFX|dJ!z6$7i"> - <field name="VAR" id="z}xxgCaN^$Fn.vEFUV}F">gtyp_SLD_w_Threshold_Red_Blue</field> - <value name="VALUE"> - <block type="math_number" id="ke^5kEWYDF/S$ln@)=%_"> + <block type="import_function_noreturn" id="T[KPPJTp(uGcU!,C^YIz" inline="true"> + <mutation parentId="(h]YqJ@0g{:(ai*WF@?!"/> + <field name="name">set_calibvalue_red</field> + <data>(h]YqJ@0g{:(ai*WF@?!</data> + <value name="v"> + <block type="math_number" id="4`yo3W2#s*iwoL6aXidC"> <field name="NUM">0</field> </block> </value> <next> - <block type="variables_set" id="=~039uS6s1=!E3E6zijO"> - <field name="VAR" id="x43W3)orCB:l1qw2dLN`">gtyp_SLD_w_Threshold_White_Red</field> - <value name="VALUE"> - <block type="math_number" id="s(Z7II`Fld+4)J.OPb9T"> + <block type="import_function_noreturn" id="hUp?s=y@zf/dV9Kdg3fJ" inline="true"> + <mutation parentId="VSmATTY?.L[C{f,=c#1:"/> + <field name="name">set_calibvalue_white</field> + <data>VSmATTY?.L[C{f,=c#1:</data> + <value name="v"> + <block type="math_number" id="D]m:m}L4P~4,ZKK%6,4b"> <field name="NUM">0</field> </block> </value> <next> - <block type="variables_set" id="g)-8V^Z,Zx{V:R_f]i_."> - <field name="VAR" id=")(=M[8QEW5[mGL@9Axsu">gtyp_Setup_w_Actual_ColorValue</field> + <block type="variables_set" id="9x5:lZLpAx9wmr9(j=_s"> + <field name="VAR" id="TZ7zEdrg=Q,vG9XutiCF">gtyp_SSC_w_Threshold_Red_Blue</field> <value name="VALUE"> - <block type="math_number" id="Gof8u):q_v1H]SGYCc7y"> + <block type="math_number" id="gz]b+,C1~FgTaNK~=r,5"> <field name="NUM">0</field> </block> </value> + <next> + <block type="variables_set" id="S2G]dx)f~jgzuW0k^kNp"> + <field name="VAR" id="-XOZ;@M!{qgTA%xgUef-">gtyp_SSC_w_Threshold_White_Red</field> + <value name="VALUE"> + <block type="math_number" id="C=d/[ap2uVxKy:e^MI:Z"> + <field name="NUM">0</field> + </block> + </value> + <next> + <block type="variables_set" id="K8LkNm#7hFX|dJ!z6$7i"> + <field name="VAR" id="z}xxgCaN^$Fn.vEFUV}F">gtyp_SLD_w_Threshold_Red_Blue</field> + <value name="VALUE"> + <block type="math_number" id="ke^5kEWYDF/S$ln@)=%_"> + <field name="NUM">0</field> + </block> + </value> + <next> + <block type="variables_set" id="=~039uS6s1=!E3E6zijO"> + <field name="VAR" id="x43W3)orCB:l1qw2dLN`">gtyp_SLD_w_Threshold_White_Red</field> + <value name="VALUE"> + <block type="math_number" id="s(Z7II`Fld+4)J.OPb9T"> + <field name="NUM">0</field> + </block> + </value> + </block> + </next> + </block> + </next> + </block> + </next> </block> </next> </block> @@ -1662,117 +2040,249 @@ </shadow> </value> <next> - <block type="mqtt_publish" id="Tr6*L5MmGUw.AvHyamY1"> + <block type="mqtt_publish" id="C0H}e^9yo]hxUOeBc2*#"> <value name="name"> - <block type="variables_get" id="WCtWefm``a=@t.FvV6Ac"> + <block type="variables_get" id="p0X8sj!EoEpI#(j?rjDK"> <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> </block> </value> <value name="topic"> - <shadow type="text" id="F]G-gNlf!`e_U_qdumeE"> - <field name="TEXT">gtyp_SLD/w_Threshold_White_Red</field> + <shadow type="text" id="z:c)5vp$ci1uAFGaHp9@"> + <field name="TEXT">gtyp_Setup/w_Calib_ColorValue_White</field> </shadow> </value> <value name="value"> <shadow type="logic_null"/> - <block type="variables_get" id="CA*7dY|3*S+0`O#yh$UV"> - <field name="VAR" id="x43W3)orCB:l1qw2dLN`">gtyp_SLD_w_Threshold_White_Red</field> + <block type="lists_getIndex" id="l.X3$reE0r0jh;[~pmK?"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="import_function_return" id="p!Jl7zNx)|e~9Fftb3Aq"> + <mutation parentId="cYBcy|]-F?s-:oG+Ch0Q"/> + <field name="name">get_calibvalue_list</field> + <data>cYBcy|]-F?s-:oG+Ch0Q</data> + </block> + </value> + <value name="AT"> + <block type="math_number" id=")W:^5ed^eR@S*e*lYCoR"> + <field name="NUM">1</field> + </block> + </value> </block> </value> <value name="qos"> - <shadow type="math_number" id="V-RWpnm?!B]u{GqNJAg$"> + <shadow type="math_number" id="pJrgZ-rCs|Ad-4CQ5p)|"> <field name="NUM">2</field> </shadow> </value> <value name="retain"> - <shadow type="logic_boolean" id="=RK^F}d7d^E_mU*W(1}S"> + <shadow type="logic_boolean" id="M0DD;M,Hob1i8$@!sGQ^"> <field name="BOOL">FALSE</field> </shadow> </value> <next> - <block type="mqtt_publish" id="E=2htASUa2V7[.Oh1Z~g"> + <block type="mqtt_publish" id="6(}h+sRHy(m_(J]gH)GR"> <value name="name"> - <block type="variables_get" id="E=].S3E:1;mEJj~=9fb+"> + <block type="variables_get" id="xY;/XLdNbXQ3;tu*QM56"> <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> </block> </value> <value name="topic"> - <shadow type="text" id="1=udhKnD|L.;~2$e^_#_"> - <field name="TEXT">gtyp_SLD/w_Threshold_Red_Blue</field> + <shadow type="text" id="rnI=(fq~]rAZ*GJ^Nsbe"> + <field name="TEXT">gtyp_Setup/w_Calib_ColorValue_Red</field> </shadow> </value> <value name="value"> <shadow type="logic_null"/> - <block type="variables_get" id="~}pnCIq5Q%wF4(fA0fsq"> - <field name="VAR" id="z}xxgCaN^$Fn.vEFUV}F">gtyp_SLD_w_Threshold_Red_Blue</field> + <block type="lists_getIndex" id="B[0R|c2aW8}-ekM%I*R+"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="import_function_return" id="n5}84DJyLkX[AcIKKqOG"> + <mutation parentId="cYBcy|]-F?s-:oG+Ch0Q"/> + <field name="name">get_calibvalue_list</field> + <data>cYBcy|]-F?s-:oG+Ch0Q</data> + </block> + </value> + <value name="AT"> + <block type="math_number" id="^0d1L4TeD^3v$Qkg(`G!"> + <field name="NUM">2</field> + </block> + </value> </block> </value> <value name="qos"> - <shadow type="math_number" id="E4b)TY}~jy~SgWRG28:A"> + <shadow type="math_number" id="jwypWoaA/Ms?!x#.s`W}"> <field name="NUM">2</field> </shadow> </value> <value name="retain"> - <shadow type="logic_boolean" id="pQnV]dxl4;W):A3rbTA4"> + <shadow type="logic_boolean" id="Lkx1trZNK~vbYT|gFqYX"> <field name="BOOL">FALSE</field> </shadow> </value> <next> - <block type="mqtt_publish" id="]+EFhfc|)bE:M?s~.ngZ"> + <block type="mqtt_publish" id="1MYf1lFc}Jj5_67cwb(U"> <value name="name"> - <block type="variables_get" id="/rhX}@]}|@N.dEfulb@p"> + <block type="variables_get" id="3HZ3;JzBOh~iIC0^5miG"> <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> </block> </value> <value name="topic"> - <shadow type="text" id=";//4DTrS)DM6*idO;]QU"> - <field name="TEXT">gtyp_SSC/w_Threshold_White_Red</field> + <shadow type="text" id="o2M46gBb@/`+9y).JjYt"> + <field name="TEXT">gtyp_Setup/w_Calib_ColorValue_Blue</field> </shadow> </value> <value name="value"> <shadow type="logic_null"/> - <block type="variables_get" id="PJ+D)]FK6=D!^WDu/Z|5"> - <field name="VAR" id="-XOZ;@M!{qgTA%xgUef-">gtyp_SSC_w_Threshold_White_Red</field> + <block type="lists_getIndex" id="@LQUgWD|$gN;t$G[,s=T"> + <mutation statement="false" at="true"/> + <field name="MODE">GET</field> + <field name="WHERE">FROM_START</field> + <value name="VALUE"> + <block type="import_function_return" id="KGR)MXzy7LpO6Dhskvr;"> + <mutation parentId="cYBcy|]-F?s-:oG+Ch0Q"/> + <field name="name">get_calibvalue_list</field> + <data>cYBcy|]-F?s-:oG+Ch0Q</data> + </block> + </value> + <value name="AT"> + <block type="math_number" id="g_4bY$Uhq@X1lktX(%Nl"> + <field name="NUM">3</field> + </block> + </value> </block> </value> <value name="qos"> - <shadow type="math_number" id="XROfsH:uPwEr;=?ZA2BH"> + <shadow type="math_number" id="uZqL9;3W0@^a@,kryyS{"> <field name="NUM">2</field> </shadow> </value> <value name="retain"> - <shadow type="logic_boolean" id="60}wRHbBKjeDf|]~O*k`"> + <shadow type="logic_boolean" id="sF:XBpP20BdY^@UwskAj"> <field name="BOOL">FALSE</field> </shadow> </value> <next> - <block type="mqtt_publish" id="FME^shM?U!h!^!cby}W+"> + <block type="mqtt_publish" id="Tr6*L5MmGUw.AvHyamY1"> <value name="name"> - <block type="variables_get" id="SWRJBMR,KRCD#rU;5]k_"> + <block type="variables_get" id="WCtWefm``a=@t.FvV6Ac"> <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> </block> </value> <value name="topic"> - <shadow type="text" id="7H2q)ld@nos)0D@g-ST{"> - <field name="TEXT">gtyp_SSC/w_Threshold_Red_Blue</field> + <shadow type="text" id="F]G-gNlf!`e_U_qdumeE"> + <field name="TEXT">gtyp_SLD/w_Threshold_White_Red</field> </shadow> </value> <value name="value"> <shadow type="logic_null"/> - <block type="variables_get" id="M30M^ylqg=LNn8:gZP/N"> - <field name="VAR" id="TZ7zEdrg=Q,vG9XutiCF">gtyp_SSC_w_Threshold_Red_Blue</field> + <block type="variables_get" id="CA*7dY|3*S+0`O#yh$UV"> + <field name="VAR" id="x43W3)orCB:l1qw2dLN`">gtyp_SLD_w_Threshold_White_Red</field> </block> </value> <value name="qos"> - <shadow type="math_number" id="SsA_tZ`x^1+}(_zKjKRu"> + <shadow type="math_number" id="V-RWpnm?!B]u{GqNJAg$"> <field name="NUM">2</field> </shadow> </value> <value name="retain"> - <shadow type="logic_boolean" id="!*}`Y.znZ+z.oXK--9c-"> + <shadow type="logic_boolean" id="=RK^F}d7d^E_mU*W(1}S"> <field name="BOOL">FALSE</field> </shadow> </value> + <next> + <block type="mqtt_publish" id="E=2htASUa2V7[.Oh1Z~g"> + <value name="name"> + <block type="variables_get" id="E=].S3E:1;mEJj~=9fb+"> + <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> + </block> + </value> + <value name="topic"> + <shadow type="text" id="1=udhKnD|L.;~2$e^_#_"> + <field name="TEXT">gtyp_SLD/w_Threshold_Red_Blue</field> + </shadow> + </value> + <value name="value"> + <shadow type="logic_null"/> + <block type="variables_get" id="~}pnCIq5Q%wF4(fA0fsq"> + <field name="VAR" id="z}xxgCaN^$Fn.vEFUV}F">gtyp_SLD_w_Threshold_Red_Blue</field> + </block> + </value> + <value name="qos"> + <shadow type="math_number" id="E4b)TY}~jy~SgWRG28:A"> + <field name="NUM">2</field> + </shadow> + </value> + <value name="retain"> + <shadow type="logic_boolean" id="pQnV]dxl4;W):A3rbTA4"> + <field name="BOOL">FALSE</field> + </shadow> + </value> + <next> + <block type="mqtt_publish" id="]+EFhfc|)bE:M?s~.ngZ"> + <value name="name"> + <block type="variables_get" id="/rhX}@]}|@N.dEfulb@p"> + <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> + </block> + </value> + <value name="topic"> + <shadow type="text" id=";//4DTrS)DM6*idO;]QU"> + <field name="TEXT">gtyp_SSC/w_Threshold_White_Red</field> + </shadow> + </value> + <value name="value"> + <shadow type="logic_null"/> + <block type="variables_get" id="PJ+D)]FK6=D!^WDu/Z|5"> + <field name="VAR" id="-XOZ;@M!{qgTA%xgUef-">gtyp_SSC_w_Threshold_White_Red</field> + </block> + </value> + <value name="qos"> + <shadow type="math_number" id="XROfsH:uPwEr;=?ZA2BH"> + <field name="NUM">2</field> + </shadow> + </value> + <value name="retain"> + <shadow type="logic_boolean" id="60}wRHbBKjeDf|]~O*k`"> + <field name="BOOL">FALSE</field> + </shadow> + </value> + <next> + <block type="mqtt_publish" id="FME^shM?U!h!^!cby}W+"> + <value name="name"> + <block type="variables_get" id="SWRJBMR,KRCD#rU;5]k_"> + <field name="VAR" id="d2.J:01W*;j`8R0B1!GX">client</field> + </block> + </value> + <value name="topic"> + <shadow type="text" id="7H2q)ld@nos)0D@g-ST{"> + <field name="TEXT">gtyp_SSC/w_Threshold_Red_Blue</field> + </shadow> + </value> + <value name="value"> + <shadow type="logic_null"/> + <block type="variables_get" id="M30M^ylqg=LNn8:gZP/N"> + <field name="VAR" id="TZ7zEdrg=Q,vG9XutiCF">gtyp_SSC_w_Threshold_Red_Blue</field> + </block> + </value> + <value name="qos"> + <shadow type="math_number" id="SsA_tZ`x^1+}(_zKjKRu"> + <field name="NUM">2</field> + </shadow> + </value> + <value name="retain"> + <shadow type="logic_boolean" id="!*}`Y.znZ+z.oXK--9c-"> + <field name="BOOL">FALSE</field> + </shadow> + </value> + </block> + </next> + </block> + </next> + </block> + </next> </block> </next> </block> @@ -1829,6 +2339,26 @@ <field name="value">logging.debug('set')</field> </block> </statement> + <value name="IF14"> + <block type="logic_compare" id="}DyHn{d4Dl`b)k`G^W1b"> + <field name="OP">EQ</field> + <value name="A"> + <block type="variables_get" id="v(%}vA4qP{Nx`4{T`a~]"> + <field name="VAR" id="J0n.(S2c_J^ul.Ya```o">topic</field> + </block> + </value> + <value name="B"> + <block type="text" id="n(9:|J#;6mfidf4p[#SP"> + <field name="TEXT">TXTGUINotification</field> + </block> + </value> + </block> + </value> + <statement name="DO14"> + <block type="util_python" id="?ZarOgz$fO:y^4.NXQFp" inline="true"> + <field name="value">pass&#10;#ignore GUI topics</field> + </block> + </statement> <statement name="ELSE"> <block type="util_python" id="fo^~-S;M`X:Li[AK5|qW" inline="true"> <field name="value">logging.debug('else')</field> @@ -1955,7 +2485,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="$jNNx1Oeez9#x~eQYP}z" x="0" y="6063"> + <block type="procedures_defnoreturn" id="$jNNx1Oeez9#x~eQYP}z" x="0" y="7118"> <field name="NAME">initMQTTLocal</field> <statement name="STACK"> <block type="variables_set" id="_C*fQdBXqrGb1uUWi?_1"> @@ -2051,7 +2581,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="R4vMowGJ0I?IYs_!-IwU" x="0" y="6638"> + <block type="procedures_defnoreturn" id="R4vMowGJ0I?IYs_!-IwU" x="0" y="7693"> <field name="NAME">thread_MQTTLocal</field> <statement name="STACK"> <block type="util_python" id="IiRVsU4_~OPjE]@(VC;/" inline="true"> @@ -2067,7 +2597,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="8u`{W^33E#gAnZ}n#.-h" x="0" y="6898"> + <block type="procedures_defnoreturn" id="8u`{W^33E#gAnZ}n#.-h" x="0" y="7953"> <mutation> <arg name="client" varid="d2.J:01W*;j`8R0B1!GX" argid="_4Lef8L=}Do}$CNf.$X3"/> <arg name="userdata" varid="3^jP4hL~~1UKs+hYG]M=" argid=".~Cx#%[dpU*oKQFZ*1}G"/> @@ -2280,7 +2810,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="_OzPkP~3{!(`00$xIV+e" x="0" y="7688"> + <block type="procedures_defnoreturn" id="_OzPkP~3{!(`00$xIV+e" x="0" y="8743"> <mutation> <arg name="client" varid="d2.J:01W*;j`8R0B1!GX" argid="_4Lef8L=}Do}$CNf.$X3"/> <arg name="userdata" varid="3^jP4hL~~1UKs+hYG]M=" argid=".~Cx#%[dpU*oKQFZ*1}G"/> @@ -2296,7 +2826,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="W9;^Y=ye_P7SI[QLip%+" x="0" y="7908"> + <block type="procedures_defnoreturn" id="W9;^Y=ye_P7SI[QLip%+" x="0" y="8963"> <mutation> <arg name="client" varid="d2.J:01W*;j`8R0B1!GX" argid="_4Lef8L=}Do}$CNf.$X3"/> <arg name="userdata" varid="3^jP4hL~~1UKs+hYG]M=" argid=".~Cx#%[dpU*oKQFZ*1}G"/> @@ -2312,7 +2842,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="}B,U]C!V!/l^kl:ZS,ly" x="0" y="8107"> + <block type="procedures_defnoreturn" id="}B,U]C!V!/l^kl:ZS,ly" x="0" y="9162"> <mutation> <arg name="client" varid="d2.J:01W*;j`8R0B1!GX" argid="_4Lef8L=}Do}$CNf.$X3"/> <arg name="userdata" varid="3^jP4hL~~1UKs+hYG]M=" argid=".~Cx#%[dpU*oKQFZ*1}G"/> @@ -2330,7 +2860,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="a]0!I}Zd7AawL:mU%,P1" x="0" y="8334"> + <block type="procedures_defnoreturn" id="a]0!I}Zd7AawL:mU%,P1" x="0" y="9389"> <mutation> <arg name="client" varid="d2.J:01W*;j`8R0B1!GX" argid="`n4M@;+Y^Ab44Gi.YYy-"/> <arg name="userdata" varid="3^jP4hL~~1UKs+hYG]M=" argid="]gLOm[vhCT0;N+Cp[1?5"/> diff --git a/lib/NodeRED.py b/lib/NodeRED.py index 8106b12145940a7f53bcefc4398ee9639b8d8d63..6b42e7fa513d39fb7d6a5d6a40e506035712e044 100644 --- a/lib/NodeRED.py +++ b/lib/NodeRED.py @@ -1,6 +1,5 @@ import json import logging -import math import paho.mqtt.client as mqtt from datetime import datetime @@ -37,11 +36,11 @@ gtyp_Setup_i_Color_Sensor_Selection = None gtyp_Setup_w_Actual_ColorValue = None gtyp_Setup_w_Threshold_White_Red = None gtyp_Setup_w_Threshold_Red_Blue = None -gtyp_SSC_w_Threshold_Red_Blue = None gtyp_Setup_di_Pos_Rotate = None gtyp_SLD_w_Threshold_Red_Blue = None -gtyp_SSC_w_Threshold_White_Red = None +gtyp_SSC_w_Threshold_Red_Blue = None gtyp_SLD_w_Threshold_White_Red = None +gtyp_SSC_w_Threshold_White_Red = None gtyp_Setup_di_Pos_Vertical = None ts = None controller_name = None @@ -49,8 +48,8 @@ gtyp_Setup_di_Pos_Horizontal = None def processReceivedMessage(topic, m_decode): - global client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal - logging.log(logging.TRACE, '%s %s', topic, m_decode) + global client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_SLD_w_Threshold_White_Red, gtyp_SSC_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal + logging.log(logging.TRACE0, '%s %s', topic, m_decode) if topic == 'gtyp_Setup/x_Set_Pos_Activ': logging.debug('activate') gtyp_Setup_x_Set_Pos_Activ = m_decode @@ -149,6 +148,25 @@ def processReceivedMessage(topic, m_decode): gtyp_Setup_w_Threshold_Red_Blue = (get_thresh_list())[1] client.publish(topic='gtyp_Setup/w_Threshold_White_Red', payload=gtyp_Setup_w_Threshold_White_Red, qos=2, retain=False) client.publish(topic='gtyp_Setup/w_Threshold_Red_Blue', payload=gtyp_Setup_w_Threshold_Red_Blue, qos=2, retain=False) + if gtyp_Setup_i_Color_Sensor_Selection == 1: + logging.debug('1') + set_calib_data_SLD(get_calib_data_SLD()) + gtyp_Setup_w_Actual_ColorValue = int(readColorValue(), 10) + gtyp_SLD_w_Threshold_Red_Blue = (get_calib_data_SLD())[0] + gtyp_SLD_w_Threshold_White_Red = (get_calib_data_SLD())[1] + client.publish(topic='gtyp_SLD/w_Threshold_White_Red', payload=gtyp_SLD_w_Threshold_White_Red, qos=2, retain=False) + client.publish(topic='gtyp_SLD/w_Threshold_Red_Blue', payload=gtyp_SLD_w_Threshold_Red_Blue, qos=2, retain=False) + startSLD() + elif gtyp_Setup_i_Color_Sensor_Selection == 2: + logging.debug('2') + set_calib_data_DPS(get_calib_data_DPS()) + gtyp_Setup_w_Actual_ColorValue = int(readDPSColorValue(), 10) + gtyp_SSC_w_Threshold_Red_Blue = (get_calib_data_DPS())[0] + gtyp_SSC_w_Threshold_White_Red = (get_calib_data_DPS())[1] + client.publish(topic='gtyp_SSC/w_Threshold_White_Red', payload=gtyp_SSC_w_Threshold_White_Red, qos=2, retain=False) + client.publish(topic='gtyp_SSC/w_Threshold_Red_Blue', payload=gtyp_SSC_w_Threshold_Red_Blue, qos=2, retain=False) + else: + pass elif topic == 'gtyp_Setup/x_Color_Sensor_Calibration': logging.debug('calibrate color sensor') gtyp_Setup_x_Color_Sensor_Calibration = m_decode @@ -164,22 +182,28 @@ def processReceivedMessage(topic, m_decode): gtyp_Setup_i_Color_Sensor_Selection = int(m_decode, 10) if gtyp_Setup_i_Color_Sensor_Selection == 1: logging.debug('1') - gtyp_Setup_w_Actual_ColorValue = round(readColorValue()) + gtyp_Setup_w_Actual_ColorValue = int(readColorValue(), 10) gtyp_SLD_w_Threshold_Red_Blue = (get_calib_data_SLD())[0] gtyp_SLD_w_Threshold_White_Red = (get_calib_data_SLD())[1] elif gtyp_Setup_i_Color_Sensor_Selection == 2: logging.debug('2') - gtyp_Setup_w_Actual_ColorValue = readDPSColorValue() + gtyp_Setup_w_Actual_ColorValue = int(readDPSColorValue(), 10) gtyp_SSC_w_Threshold_Red_Blue = (get_calib_data_DPS())[0] gtyp_SSC_w_Threshold_White_Red = (get_calib_data_DPS())[1] else: logging.debug('none') + gtyp_Setup_w_Actual_ColorValue = 0 + set_calibvalue_white(0) + set_calibvalue_red(0) + set_calibvalue_white(0) gtyp_SSC_w_Threshold_Red_Blue = 0 gtyp_SSC_w_Threshold_White_Red = 0 gtyp_SLD_w_Threshold_Red_Blue = 0 gtyp_SLD_w_Threshold_White_Red = 0 - gtyp_Setup_w_Actual_ColorValue = 0 client.publish(topic='gtyp_Setup/w_Actual_ColorValue', payload=gtyp_Setup_w_Actual_ColorValue, qos=2, retain=False) + client.publish(topic='gtyp_Setup/w_Calib_ColorValue_White', payload=(get_calibvalue_list())[0], qos=2, retain=False) + client.publish(topic='gtyp_Setup/w_Calib_ColorValue_Red', payload=(get_calibvalue_list())[1], qos=2, retain=False) + client.publish(topic='gtyp_Setup/w_Calib_ColorValue_Blue', payload=(get_calibvalue_list())[2], qos=2, retain=False) client.publish(topic='gtyp_SLD/w_Threshold_White_Red', payload=gtyp_SLD_w_Threshold_White_Red, qos=2, retain=False) client.publish(topic='gtyp_SLD/w_Threshold_Red_Blue', payload=gtyp_SLD_w_Threshold_Red_Blue, qos=2, retain=False) client.publish(topic='gtyp_SSC/w_Threshold_White_Red', payload=gtyp_SSC_w_Threshold_White_Red, qos=2, retain=False) @@ -188,6 +212,9 @@ def processReceivedMessage(topic, m_decode): logging.debug('calibrate push out') elif topic == 'gtyp_Setup/x_Set_CounterValues': logging.debug('set') + elif topic == 'TXTGUINotification': + pass + #ignore GUI topics else: logging.debug('else') if not (apply_SetupPosition_VGR(topic, int(m_decode, 10))): @@ -201,7 +228,7 @@ def processReceivedMessage(topic, m_decode): def initMQTTLocal(): - global topic, m_decode, client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal + global topic, m_decode, client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_SLD_w_Threshold_White_Red, gtyp_SSC_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal gtyp_Setup_x_Set_Pos_Activ = 0 gtyp_Setup_i_Pos_Selection = 0 gtyp_Setup_x_Color_Sensor_Calibration = 0 @@ -222,7 +249,7 @@ def initMQTTLocal(): def thread_MQTTLocal(): - global topic, m_decode, client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal + global topic, m_decode, client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_SLD_w_Threshold_White_Red, gtyp_SSC_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal logging.debug('-') #client.loop_forever() client.loop_start() @@ -231,7 +258,7 @@ def thread_MQTTLocal(): def on_connect(client, userdata, flags, rc): - global topic, m_decode, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal + global topic, m_decode, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_SLD_w_Threshold_White_Red, gtyp_SSC_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal print("Connection returned result: "+mqtt.connack_string(rc)) client.subscribe("#") #client.subscribe("$SYS/#") @@ -248,23 +275,23 @@ def on_connect(client, userdata, flags, rc): def on_disconnect(client, userdata, rc): - global topic, m_decode, flags, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal + global topic, m_decode, flags, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_SLD_w_Threshold_White_Red, gtyp_SSC_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal if rc != 0: print("Unexpected disconnection.") def on_publish(client, userdata, mid): - global topic, m_decode, flags, rc, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal + global topic, m_decode, flags, rc, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_SLD_w_Threshold_White_Red, gtyp_SSC_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal #print("on_publish") def on_subscribe(client, userdata, mid, granted_qos): - global topic, m_decode, flags, rc, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal + global topic, m_decode, flags, rc, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_SLD_w_Threshold_White_Red, gtyp_SSC_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal print("on_subscribe") def on_message(client, userdata, msg): - global topic, m_decode, flags, rc, mid, granted_qos, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal + global topic, m_decode, flags, rc, mid, granted_qos, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_SLD_w_Threshold_White_Red, gtyp_SSC_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal print("Received message '" + str(msg.payload) + "' on topic '" + msg.topic + "' with QoS " + str(msg.qos)) diff --git a/lib/SLD.blockly b/lib/SLD.blockly index ef0e83d0eab1f7bb13c54557d4fdfe9eb92254da..d67a47a54d4f7ad4a08a27b330f680cca738c1c9 100644 --- a/lib/SLD.blockly +++ b/lib/SLD.blockly @@ -6,6 +6,7 @@ <variable id="1X|m)*QO^oo}EfHf=nBO">speed</variable> <variable id="78bW9521)(I[oMydfNIz">state_code</variable> <variable id="[V))lfBm^j7t@3LJVWGf">state_active</variable> + <variable id="ey.@ye[RiHweS+e|GIKG">started</variable> <variable id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</variable> <variable id="?]F?rtn:F#wq@5Ag|9yE">thresh_white_red_defaults</variable> <variable id="Krv1?O$_~Yha=/]3-u{i">thresh_red_blue_defaults</variable> @@ -22,7 +23,20 @@ <block type="util_python_imports" id=".e$$DS-W;QA]vq3]8xZ(" x="0" y="0"> <field name="value">import logging</field> </block> - <block type="procedures_defnoreturn" id="]$}!d~iPi$faCfYn-,02" x="0" y="101"> + <block type="procedures_defnoreturn" id="g=6%Ka9Y1qYH|_c:bu9]" x="0" y="101"> + <field name="NAME">startSLD</field> + <statement name="STACK"> + <block type="variables_set" id="-.GkGb!x[Oe6-:E#s|fT"> + <field name="VAR" id="ey.@ye[RiHweS+e|GIKG">started</field> + <value name="VALUE"> + <block type="logic_boolean" id="N=zgn;4ci4-EO=n5:RW-"> + <field name="BOOL">TRUE</field> + </block> + </value> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="]$}!d~iPi$faCfYn-,02" x="0" y="210"> <field name="NAME">thread_SLD</field> <statement name="STACK"> <block type="util_python" id="or=tulIX]{S?#ofKV+]h" inline="true"> @@ -100,444 +114,473 @@ </block> </value> <next> - <block type="loop_endless" id="??ZH|RLC1U|c~MVe9I${"> - <statement name="DO"> - <block type="util_python" id="9:U=/@,Hc3J70C9Na;o," inline="true"> - <field name="value">logging.log(logging.DEBUG, 'start')</field> - <next> - <block type="procedures_callnoreturn" id="p,0#!:*0*c~lmV%gtaQ`" inline="true"> - <mutation name="_set_state_SLD"> - <arg name="_code"/> - <arg name="_active"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="L%*,:(HtlgK(_/a7WcP("> - <field name="NUM">2</field> - </block> - </value> - <value name="ARG1"> - <block type="math_number" id="g8Lk_tA34OsX@!]LiC73"> - <field name="NUM">1</field> + <block type="variables_set" id="qfACgepBJ)Hpg)-U%/+)"> + <field name="VAR" id="ey.@ye[RiHweS+e|GIKG">started</field> + <value name="VALUE"> + <block type="logic_boolean" id="1%y]9zHav|=dwFmHLl^W"> + <field name="BOOL">FALSE</field> + </block> + </value> + <next> + <block type="loop_endless" id="??ZH|RLC1U|c~MVe9I${"> + <statement name="DO"> + <block type="controls_if" id="9VM2@@QI`l2,@ERs#d$Z"> + <value name="IF0"> + <block type="variables_get" id="BBJojQPff-aLn+TzcB9v"> + <field name="VAR" id="ey.@ye[RiHweS+e|GIKG">started</field> </block> </value> - <next> - <block type="variables_set" id="4Z?[|d:[z0zGF-MAuDV["> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - <value name="VALUE"> - <block type="math_number" id="7dq9UhKYcF?CH.:+!OrJ"> - <field name="NUM">3000</field> - </block> - </value> + <statement name="DO0"> + <block type="util_python" id="9:U=/@,Hc3J70C9Na;o," inline="true"> + <field name="value">logging.log(logging.DEBUG, 'start')</field> <next> - <block type="procedures_callnoreturn" id="3lR3C/Xv:^zlf/_JBvY^" inline="true"> - <mutation name="setConvBeltSpeedSLD"> - <arg name="speed"/> + <block type="procedures_callnoreturn" id="p,0#!:*0*c~lmV%gtaQ`" inline="true"> + <mutation name="_set_state_SLD"> + <arg name="_code"/> + <arg name="_active"/> </mutation> <value name="ARG0"> - <block type="math_number" id="l5c-VK(61=0/J@T38dRO"> - <field name="NUM">512</field> + <block type="math_number" id="L%*,:(HtlgK(_/a7WcP("> + <field name="NUM">2</field> + </block> + </value> + <value name="ARG1"> + <block type="math_number" id="g8Lk_tA34OsX@!]LiC73"> + <field name="NUM">1</field> </block> </value> <next> - <block type="controls_whileUntil" id="Y3)fnloS|8,DEOQG{n2-"> - <field name="MODE">UNTIL</field> - <value name="BOOL"> - <block type="procedures_callreturn" id="mewh8q@GplOPE!2od1f?"> - <mutation name="isEjectionTriggered"/> + <block type="variables_set" id="4Z?[|d:[z0zGF-MAuDV["> + <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + <value name="VALUE"> + <block type="math_number" id="7dq9UhKYcF?CH.:+!OrJ"> + <field name="NUM">3000</field> </block> </value> - <statement name="DO"> - <block type="variables_set" id="[sz4{]_4m6cHGqtK{PO+"> - <field name="VAR" id="?Hi+81vv*K@yZim!8fD_">lastColorValue</field> - <value name="VALUE"> - <block type="procedures_callreturn" id="UcL=Uv7S99ju,3n:Y0-7"> - <mutation name="readColorValue"/> + <next> + <block type="procedures_callnoreturn" id="3lR3C/Xv:^zlf/_JBvY^" inline="true"> + <mutation name="setConvBeltSpeedSLD"> + <arg name="speed"/> + </mutation> + <value name="ARG0"> + <block type="math_number" id="l5c-VK(61=0/J@T38dRO"> + <field name="NUM">512</field> </block> </value> <next> - <block type="controls_if" id="qyW_y}R$-,jF[q1v?Q/p"> - <value name="IF0"> - <block type="logic_compare" id="jW1YS6O$PmDf{zaOQ]oc"> - <field name="OP">LT</field> - <value name="A"> - <block type="variables_get" id="D#aHaqrz_p7^q/~LW7Y]"> - <field name="VAR" id="?Hi+81vv*K@yZim!8fD_">lastColorValue</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="0Aj9O:QXUr$yIykb^nIN"> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - </block> - </value> + <block type="controls_whileUntil" id="Y3)fnloS|8,DEOQG{n2-"> + <field name="MODE">UNTIL</field> + <value name="BOOL"> + <block type="procedures_callreturn" id="mewh8q@GplOPE!2od1f?"> + <mutation name="isEjectionTriggered"/> </block> </value> - <statement name="DO0"> - <block type="variables_set" id="vpyrCX)b0b8(5Q)/CE$7"> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + <statement name="DO"> + <block type="variables_set" id="[sz4{]_4m6cHGqtK{PO+"> + <field name="VAR" id="?Hi+81vv*K@yZim!8fD_">lastColorValue</field> <value name="VALUE"> - <block type="variables_get" id="#9q1($D*Zqbur;(szG#u"> - <field name="VAR" id="?Hi+81vv*K@yZim!8fD_">lastColorValue</field> + <block type="procedures_callreturn" id="UcL=Uv7S99ju,3n:Y0-7"> + <mutation name="readColorValue"/> </block> </value> + <next> + <block type="controls_if" id="qyW_y}R$-,jF[q1v?Q/p"> + <value name="IF0"> + <block type="logic_compare" id="jW1YS6O$PmDf{zaOQ]oc"> + <field name="OP">LT</field> + <value name="A"> + <block type="variables_get" id="D#aHaqrz_p7^q/~LW7Y]"> + <field name="VAR" id="?Hi+81vv*K@yZim!8fD_">lastColorValue</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="0Aj9O:QXUr$yIykb^nIN"> + <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="variables_set" id="vpyrCX)b0b8(5Q)/CE$7"> + <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + <value name="VALUE"> + <block type="variables_get" id="#9q1($D*Zqbur;(szG#u"> + <field name="VAR" id="?Hi+81vv*K@yZim!8fD_">lastColorValue</field> + </block> + </value> + </block> + </statement> + </block> + </next> </block> </statement> - </block> - </next> - </block> - </statement> - <next> - <block type="procedures_callnoreturn" id="dBj`=^uA2PbPQQR)%wCI" inline="true"> - <mutation name="setConvBeltSpeedSLD"> - <arg name="speed"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="@vOXIdm1`/*0?9GK?%k!"> - <field name="NUM">0</field> - </block> - </value> - <next> - <block type="util_python" id="RTDnf9zEhD_)dv}a{N1h" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue)</field> <next> - <block type="output_compressor_toggle_state" id="fWq}q)%ocS`?nbbfG?zH"> - <field name="instance_name">TXT_SLD_E5_O8_compressor</field> - <field name="property_name">on</field> + <block type="variables_set" id=":31NfxPPR[nrT/Rj+u(~"> + <field name="VAR" id="ey.@ye[RiHweS+e|GIKG">started</field> + <value name="VALUE"> + <block type="logic_boolean" id="adN9XE$j.3!9TmgN3wKu"> + <field name="BOOL">FALSE</field> + </block> + </value> <next> - <block type="util_python" id="r;?8M|)NMD`GAg2sSWt8" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'check counter')</field> + <block type="procedures_callnoreturn" id="dBj`=^uA2PbPQQR)%wCI" inline="true"> + <mutation name="setConvBeltSpeedSLD"> + <arg name="speed"/> + </mutation> + <value name="ARG0"> + <block type="math_number" id="@vOXIdm1`/*0?9GK?%k!"> + <field name="NUM">0</field> + </block> + </value> <next> - <block type="variables_set" id="}a!#}^wyf8QJuRLL;bQq"> - <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> - <value name="VALUE"> - <block type="math_number" id="DLeT,8FCW_Fi(rjPFKZt"> - <field name="NUM">0</field> - </block> - </value> + <block type="util_python" id="RTDnf9zEhD_)dv}a{N1h" inline="true"> + <field name="value">logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue)</field> <next> - <block type="variables_set" id="^Ku:~)-Palwl:g+NfSj1"> - <field name="VAR" id="Cb}mUgnt@Vc|BuR6[;{s">lastStateCounterSwitch</field> - <value name="VALUE"> - <block type="input_mini_switch_get_state" id="Lu/Xqez`AYH(xvU~bo1E"> - <field name="instance_name">TXT_SLD_E5_C1_mini_switch</field> - </block> - </value> + <block type="output_compressor_toggle_state" id="fWq}q)%ocS`?nbbfG?zH"> + <field name="instance_name">TXT_SLD_E5_O8_compressor</field> + <field name="property_name">on</field> <next> - <block type="motor_set_speed" id="zkY?|Osg#~$*`Qr8u{uI"> - <field name="instance_name">TXT_SLD_E5_M1_encodermotor</field> - <field name="direction">Motor.CW</field> - <value name="speed"> - <shadow type="motor_number" id="Q~bzD*aUU/rsfp6dM,{("> - <field name="MOTOR_NUM">350</field> - </shadow> - </value> + <block type="util_python" id="r;?8M|)NMD`GAg2sSWt8" inline="true"> + <field name="value">logging.log(logging.DEBUG, 'check counter')</field> <next> - <block type="controls_whileUntil" id="O{q6_~I-KmQ}1i}%hVj?"> - <field name="MODE">WHILE</field> - <value name="BOOL"> - <block type="logic_compare" id="sU?{Uav{P@vD5{Sj-kgZ"> - <field name="OP">LTE</field> - <value name="A"> - <block type="variables_get" id="Lis}jL`_`*I$?F^O?ch`"> - <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> - </block> - </value> - <value name="B"> - <block type="math_number" id="]n/~EGON9=EwXNd2=M%h"> - <field name="NUM">29</field> - </block> - </value> + <block type="variables_set" id="}a!#}^wyf8QJuRLL;bQq"> + <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> + <value name="VALUE"> + <block type="math_number" id="DLeT,8FCW_Fi(rjPFKZt"> + <field name="NUM">0</field> </block> </value> - <statement name="DO"> - <block type="controls_if" id="`@W^kruj%p|@CI0L{q:#"> - <value name="IF0"> - <block type="logic_compare" id="@ae3R,Z*1Xk2HQpYmMbZ"> - <field name="OP">NEQ</field> - <value name="A"> - <block type="input_mini_switch_get_state" id="$}YI${saB#:;*lq})+P0"> - <field name="instance_name">TXT_SLD_E5_C1_mini_switch</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id=")8]F+QO3=p.Lob:_kihY"> - <field name="VAR" id="Cb}mUgnt@Vc|BuR6[;{s">lastStateCounterSwitch</field> - </block> - </value> + <next> + <block type="variables_set" id="^Ku:~)-Palwl:g+NfSj1"> + <field name="VAR" id="Cb}mUgnt@Vc|BuR6[;{s">lastStateCounterSwitch</field> + <value name="VALUE"> + <block type="input_mini_switch_get_state" id="Lu/Xqez`AYH(xvU~bo1E"> + <field name="instance_name">TXT_SLD_E5_C1_mini_switch</field> </block> </value> - <statement name="DO0"> - <block type="math_change" id="+!G?mN+l_~T`F7?;!kqp"> - <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> - <value name="DELTA"> - <shadow type="math_number" id="Dv~%6T9k^}Hf]%eDBbw?"> - <field name="NUM">1</field> + <next> + <block type="motor_set_speed" id="zkY?|Osg#~$*`Qr8u{uI"> + <field name="instance_name">TXT_SLD_E5_M1_encodermotor</field> + <field name="direction">Motor.CW</field> + <value name="speed"> + <shadow type="motor_number" id="Q~bzD*aUU/rsfp6dM,{("> + <field name="MOTOR_NUM">350</field> </shadow> </value> <next> - <block type="variables_set" id="rVUY6WB`cem}FiG?5U@9"> - <field name="VAR" id="Cb}mUgnt@Vc|BuR6[;{s">lastStateCounterSwitch</field> - <value name="VALUE"> - <block type="input_mini_switch_get_state" id="+JLI~]-]6:`p6F,0AM|F"> - <field name="instance_name">TXT_SLD_E5_C1_mini_switch</field> - </block> - </value> - <next> - <block type="util_python" id="s;3oKGuf4t~q|)i-o.p3" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'counter: %d', counter)</field> - <next> - <block type="util_wait_for" id=",}}{@hG+U_SU9=r~_TSW"> - <field name="format">ms</field> - <value name="value"> - <shadow type="math_number" id="xklDFBfugxb-GyKkoR,I"> - <field name="NUM">1</field> - </shadow> - </value> - </block> - </next> - </block> - </next> - </block> - </next> - </block> - </statement> - <next> - <block type="controls_if" id="%=@sT#xE/CAW7pi?{e*#"> - <mutation elseif="2" else="1"/> - <value name="IF0"> - <block type="logic_operation" id="|!dZm[p;Jkup*BTe]pPN" inline="false"> - <field name="OP">AND</field> - <value name="A"> - <block type="logic_compare" id="#xRgpUtg^E]oMU@V4T`i"> - <field name="OP">GTE</field> + <block type="controls_whileUntil" id="O{q6_~I-KmQ}1i}%hVj?"> + <field name="MODE">WHILE</field> + <value name="BOOL"> + <block type="logic_compare" id="sU?{Uav{P@vD5{Sj-kgZ"> + <field name="OP">LTE</field> <value name="A"> - <block type="variables_get" id="==O{i~i|bE.5}Xrx_JZP"> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - </block> - </value> - <value name="B"> - <block type="math_number" id="::1,wC7M::ixYbwq9eI3"> - <field name="NUM">200</field> - </block> - </value> - </block> - </value> - <value name="B"> - <block type="logic_compare" id="`):_GRc/Y8vqapW5*3kX"> - <field name="OP">LT</field> - <value name="A"> - <block type="variables_get" id="w0^1{9aXCbvFy,k__.v;"> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="`;J,uh@c|r^lW(jy6W]8"> - <field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field> - </block> - </value> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="controls_if" id="C,DeIZKYXXMwTy-|VKDb"> - <value name="IF0"> - <block type="logic_compare" id="4@i%+GywVT/eXFM[n:mG"> - <field name="OP">GT</field> - <value name="A"> - <block type="variables_get" id="E[R=0N3LxmxRCnf0_oI7"> + <block type="variables_get" id="Lis}jL`_`*I$?F^O?ch`"> <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> </block> </value> <value name="B"> - <block type="math_number" id="t1Wzji0hz}Rv$,y%b7~Z"> - <field name="NUM">5</field> + <block type="math_number" id="]n/~EGON9=EwXNd2=M%h"> + <field name="NUM">29</field> </block> </value> </block> </value> - <statement name="DO0"> - <block type="motor_stop" id="@Nxv_JCs.5z7;K$Jf8cx"> - <field name="instance_name">TXT_SLD_E5_M1_encodermotor</field> - <next> - <block type="util_python" id="P)rdQ)El,Oq~@1ue6H(e" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue)</field> - <next> - <block type="procedures_callnoreturn" id="g?crz6vB(IpG*dzi*tN*"> - <mutation name="ejectWhite"/> - <next> - <block type="controls_flow_statements" id="~WR8i~(H:4XI5UrbxdRZ"> - <field name="FLOW">BREAK</field> - </block> - </next> + <statement name="DO"> + <block type="controls_if" id="`@W^kruj%p|@CI0L{q:#"> + <value name="IF0"> + <block type="logic_compare" id="@ae3R,Z*1Xk2HQpYmMbZ"> + <field name="OP">NEQ</field> + <value name="A"> + <block type="input_mini_switch_get_state" id="$}YI${saB#:;*lq})+P0"> + <field name="instance_name">TXT_SLD_E5_C1_mini_switch</field> </block> - </next> - </block> - </next> - </block> - </statement> - </block> - </statement> - <value name="IF1"> - <block type="logic_operation" id="iNsa5o!.e;YIzvbW_wTv" inline="false"> - <field name="OP">AND</field> - <value name="A"> - <block type="logic_compare" id="e0]4]%Y_?NoA%%G(m6,~"> - <field name="OP">GTE</field> - <value name="A"> - <block type="variables_get" id="i-{^l%mMu/gl?A`U1oS;"> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="8{U:mxgMB(6G-QF,%ZYC"> - <field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field> - </block> - </value> - </block> - </value> - <value name="B"> - <block type="logic_compare" id="up.FB6`Io11NLrrLVsDs"> - <field name="OP">LT</field> - <value name="A"> - <block type="variables_get" id="8C:-+Nfc|+%LT?1P1WK}"> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="y}:.yn}a^s|p6aL-*.E*"> - <field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field> + </value> + <value name="B"> + <block type="variables_get" id=")8]F+QO3=p.Lob:_kihY"> + <field name="VAR" id="Cb}mUgnt@Vc|BuR6[;{s">lastStateCounterSwitch</field> + </block> + </value> </block> </value> - </block> - </value> - </block> - </value> - <statement name="DO1"> - <block type="controls_if" id="?{-a%bv#)`n#kx%q|]Cz"> - <value name="IF0"> - <block type="logic_compare" id="i1pvi)$d3Oys^]PI7+X:"> - <field name="OP">GT</field> - <value name="A"> - <block type="variables_get" id="=vx{)D5sb}T$+=K9*l7L"> + <statement name="DO0"> + <block type="math_change" id="+!G?mN+l_~T`F7?;!kqp"> <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> - </block> - </value> - <value name="B"> - <block type="math_number" id="$m1Gf69JGF5p?/Ui~a@c"> - <field name="NUM">14</field> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="motor_stop" id="x,Hw0K?Oo{A`!:]XO,GN"> - <field name="instance_name">TXT_SLD_E5_M1_encodermotor</field> - <next> - <block type="util_python" id="KjmL^-U4EG5T*#B,q3v1" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue)</field> + <value name="DELTA"> + <shadow type="math_number" id="Dv~%6T9k^}Hf]%eDBbw?"> + <field name="NUM">1</field> + </shadow> + </value> <next> - <block type="procedures_callnoreturn" id="cL]:Qu_iLYtB@^AS:fC2"> - <mutation name="ejectRed"/> + <block type="variables_set" id="rVUY6WB`cem}FiG?5U@9"> + <field name="VAR" id="Cb}mUgnt@Vc|BuR6[;{s">lastStateCounterSwitch</field> + <value name="VALUE"> + <block type="input_mini_switch_get_state" id="+JLI~]-]6:`p6F,0AM|F"> + <field name="instance_name">TXT_SLD_E5_C1_mini_switch</field> + </block> + </value> <next> - <block type="controls_flow_statements" id=".~.zxr`^*Gcw^7BX`TG6"> - <field name="FLOW">BREAK</field> + <block type="util_python" id="s;3oKGuf4t~q|)i-o.p3" inline="true"> + <field name="value">logging.log(logging.DEBUG, 'counter: %d', counter)</field> + <next> + <block type="util_wait_for" id=",}}{@hG+U_SU9=r~_TSW"> + <field name="format">ms</field> + <value name="value"> + <shadow type="math_number" id="xklDFBfugxb-GyKkoR,I"> + <field name="NUM">1</field> + </shadow> + </value> + </block> + </next> </block> </next> </block> </next> </block> - </next> - </block> - </statement> - </block> - </statement> - <value name="IF2"> - <block type="logic_operation" id="Elsy}a$4e*xBUg`8eL:f" inline="false"> - <field name="OP">AND</field> - <value name="A"> - <block type="logic_compare" id="s9|uTTT_y0LPHxIx@b]R"> - <field name="OP">GTE</field> - <value name="A"> - <block type="variables_get" id="QQ%r_Nd368,qw}$0/KFm"> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="y)s`tKA^Cy++r-gsGqFD"> - <field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field> - </block> - </value> - </block> - </value> - <value name="B"> - <block type="logic_compare" id="8h].$besY~Tc]TBp*UPQ"> - <field name="OP">LT</field> - <value name="A"> - <block type="variables_get" id="/^cTiAWo7z7rq.pu,t#J"> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - </block> - </value> - <value name="B"> - <block type="math_number" id="va`hEl#rZ9[sPG`(COsp"> - <field name="NUM">2000</field> - </block> - </value> - </block> - </value> - </block> - </value> - <statement name="DO2"> - <block type="controls_if" id="@IT7YzVF(Zh;X*C-T*xs"> - <value name="IF0"> - <block type="logic_compare" id="Fa3_6txQs*L35z]0FIpl"> - <field name="OP">GT</field> - <value name="A"> - <block type="variables_get" id="l1ANb09JI#!q!R8=AKLD"> - <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> - </block> - </value> - <value name="B"> - <block type="math_number" id="y~:??=(1r/zsX?WM=mub"> - <field name="NUM">25</field> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="motor_stop" id="Vp2M3gw;YRD~2SPd:ijZ"> - <field name="instance_name">TXT_SLD_E5_M1_encodermotor</field> + </statement> <next> - <block type="util_python" id="306U;Vh=uzU#3HX6D.aR" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue)</field> - <next> - <block type="procedures_callnoreturn" id="ThSO,:]IQ-1.G_c;8$4`"> - <mutation name="ejectBlue"/> - <next> - <block type="controls_flow_statements" id="*4m_zPA@WtM_dmS!6lO."> - <field name="FLOW">BREAK</field> + <block type="controls_if" id="%=@sT#xE/CAW7pi?{e*#"> + <mutation elseif="2" else="1"/> + <value name="IF0"> + <block type="logic_operation" id="|!dZm[p;Jkup*BTe]pPN" inline="false"> + <field name="OP">AND</field> + <value name="A"> + <block type="logic_compare" id="#xRgpUtg^E]oMU@V4T`i"> + <field name="OP">GTE</field> + <value name="A"> + <block type="variables_get" id="==O{i~i|bE.5}Xrx_JZP"> + <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + </block> + </value> + <value name="B"> + <block type="math_number" id="::1,wC7M::ixYbwq9eI3"> + <field name="NUM">200</field> + </block> + </value> </block> - </next> + </value> + <value name="B"> + <block type="logic_compare" id="`):_GRc/Y8vqapW5*3kX"> + <field name="OP">LT</field> + <value name="A"> + <block type="variables_get" id="w0^1{9aXCbvFy,k__.v;"> + <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="`;J,uh@c|r^lW(jy6W]8"> + <field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field> + </block> + </value> + </block> + </value> </block> - </next> + </value> + <statement name="DO0"> + <block type="controls_if" id="C,DeIZKYXXMwTy-|VKDb"> + <value name="IF0"> + <block type="logic_compare" id="4@i%+GywVT/eXFM[n:mG"> + <field name="OP">GT</field> + <value name="A"> + <block type="variables_get" id="E[R=0N3LxmxRCnf0_oI7"> + <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> + </block> + </value> + <value name="B"> + <block type="math_number" id="t1Wzji0hz}Rv$,y%b7~Z"> + <field name="NUM">5</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="motor_stop" id="@Nxv_JCs.5z7;K$Jf8cx"> + <field name="instance_name">TXT_SLD_E5_M1_encodermotor</field> + <next> + <block type="util_python" id="P)rdQ)El,Oq~@1ue6H(e" inline="true"> + <field name="value">logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue)</field> + <next> + <block type="procedures_callnoreturn" id="g?crz6vB(IpG*dzi*tN*"> + <mutation name="ejectWhite"/> + <next> + <block type="controls_flow_statements" id="~WR8i~(H:4XI5UrbxdRZ"> + <field name="FLOW">BREAK</field> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </statement> + </block> + </statement> + <value name="IF1"> + <block type="logic_operation" id="iNsa5o!.e;YIzvbW_wTv" inline="false"> + <field name="OP">AND</field> + <value name="A"> + <block type="logic_compare" id="e0]4]%Y_?NoA%%G(m6,~"> + <field name="OP">GTE</field> + <value name="A"> + <block type="variables_get" id="i-{^l%mMu/gl?A`U1oS;"> + <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="8{U:mxgMB(6G-QF,%ZYC"> + <field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="logic_compare" id="up.FB6`Io11NLrrLVsDs"> + <field name="OP">LT</field> + <value name="A"> + <block type="variables_get" id="8C:-+Nfc|+%LT?1P1WK}"> + <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="y}:.yn}a^s|p6aL-*.E*"> + <field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field> + </block> + </value> + </block> + </value> + </block> + </value> + <statement name="DO1"> + <block type="controls_if" id="?{-a%bv#)`n#kx%q|]Cz"> + <value name="IF0"> + <block type="logic_compare" id="i1pvi)$d3Oys^]PI7+X:"> + <field name="OP">GT</field> + <value name="A"> + <block type="variables_get" id="=vx{)D5sb}T$+=K9*l7L"> + <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> + </block> + </value> + <value name="B"> + <block type="math_number" id="$m1Gf69JGF5p?/Ui~a@c"> + <field name="NUM">14</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="motor_stop" id="x,Hw0K?Oo{A`!:]XO,GN"> + <field name="instance_name">TXT_SLD_E5_M1_encodermotor</field> + <next> + <block type="util_python" id="KjmL^-U4EG5T*#B,q3v1" inline="true"> + <field name="value">logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue)</field> + <next> + <block type="procedures_callnoreturn" id="cL]:Qu_iLYtB@^AS:fC2"> + <mutation name="ejectRed"/> + <next> + <block type="controls_flow_statements" id=".~.zxr`^*Gcw^7BX`TG6"> + <field name="FLOW">BREAK</field> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </statement> + </block> + </statement> + <value name="IF2"> + <block type="logic_operation" id="Elsy}a$4e*xBUg`8eL:f" inline="false"> + <field name="OP">AND</field> + <value name="A"> + <block type="logic_compare" id="s9|uTTT_y0LPHxIx@b]R"> + <field name="OP">GTE</field> + <value name="A"> + <block type="variables_get" id="QQ%r_Nd368,qw}$0/KFm"> + <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="y)s`tKA^Cy++r-gsGqFD"> + <field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="logic_compare" id="8h].$besY~Tc]TBp*UPQ"> + <field name="OP">LT</field> + <value name="A"> + <block type="variables_get" id="/^cTiAWo7z7rq.pu,t#J"> + <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> + </block> + </value> + <value name="B"> + <block type="math_number" id="va`hEl#rZ9[sPG`(COsp"> + <field name="NUM">2000</field> + </block> + </value> + </block> + </value> + </block> + </value> + <statement name="DO2"> + <block type="controls_if" id="@IT7YzVF(Zh;X*C-T*xs"> + <value name="IF0"> + <block type="logic_compare" id="Fa3_6txQs*L35z]0FIpl"> + <field name="OP">GT</field> + <value name="A"> + <block type="variables_get" id="l1ANb09JI#!q!R8=AKLD"> + <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> + </block> + </value> + <value name="B"> + <block type="math_number" id="y~:??=(1r/zsX?WM=mub"> + <field name="NUM">25</field> + </block> + </value> + </block> + </value> + <statement name="DO0"> + <block type="motor_stop" id="Vp2M3gw;YRD~2SPd:ijZ"> + <field name="instance_name">TXT_SLD_E5_M1_encodermotor</field> + <next> + <block type="util_python" id="306U;Vh=uzU#3HX6D.aR" inline="true"> + <field name="value">logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue)</field> + <next> + <block type="procedures_callnoreturn" id="ThSO,:]IQ-1.G_c;8$4`"> + <mutation name="ejectBlue"/> + <next> + <block type="controls_flow_statements" id="*4m_zPA@WtM_dmS!6lO."> + <field name="FLOW">BREAK</field> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </statement> + </block> + </statement> </block> </next> </block> </statement> + <next> + <block type="util_wait_for" id="x6/]Zl3-?BK17)M_Y;7O"> + <field name="format">ms</field> + <value name="value"> + <shadow type="math_number" id="Y|(QX~;eqSh42`H}AOb["> + <field name="NUM">500</field> + </shadow> + </value> + </block> + </next> </block> - </statement> + </next> </block> </next> </block> - </statement> - <next> - <block type="util_wait_for" id="x6/]Zl3-?BK17)M_Y;7O"> - <field name="format">ms</field> - <value name="value"> - <shadow type="math_number" id="Y|(QX~;eqSh42`H}AOb["> - <field name="NUM">500</field> - </shadow> - </value> - </block> </next> </block> </next> @@ -560,11 +603,11 @@ </block> </next> </block> - </next> + </statement> </block> - </next> + </statement> </block> - </statement> + </next> </block> </next> </block> @@ -586,7 +629,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="x=/1p3KO=Q%QK7t2K5l%" x="0" y="2030"> + <block type="procedures_defreturn" id="x=/1p3KO=Q%QK7t2K5l%" x="0" y="2237"> <field name="NAME">get_calib_data_SLD_defaults</field> <statement name="STACK"> <block type="util_python" id="cO!#.ICg79WkS?A?cG[j" inline="true"> @@ -609,7 +652,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="b|1;0mU=wNNO2Ry{f6,Z" x="0" y="2191"> + <block type="procedures_defreturn" id="b|1;0mU=wNNO2Ry{f6,Z" x="0" y="2398"> <field name="NAME">get_calib_data_SLD</field> <statement name="STACK"> <block type="util_python" id="t;Zg(`vb3R)aQZ])LhpC" inline="true"> @@ -632,7 +675,7 @@ </block> </value> </block> - <block type="procedures_defnoreturn" id="3Qf0~|~$oG8z5tP{6Km;" x="0" y="2352"> + <block type="procedures_defnoreturn" id="3Qf0~|~$oG8z5tP{6Km;" x="0" y="2559"> <mutation> <arg name="_data" varid="$E/GDp,,dwQrGbs7N*=C" argid="^}Z*XZLpIfstV5L7ggN|"/> </mutation> @@ -688,7 +731,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="gsD|}/@_.f.D_8KfM;**" x="0" y="2571"> + <block type="procedures_defnoreturn" id="gsD|}/@_.f.D_8KfM;**" x="0" y="2778"> <mutation> <arg name="_code" varid="x?rbx}Z!7+Jx9E.L=:pX" argid=",ZCb|vi(m3g0A4u*(!{`"/> <arg name="_active" varid="Hq*BSR/(QEo9c0kQRW{y" argid="mqa@Al(.5xeP*B]Jl`8%"/> @@ -771,7 +814,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="eO[xQ[akMe*EVjm,{7m0" x="0" y="2916"> + <block type="procedures_defreturn" id="eO[xQ[akMe*EVjm,{7m0" x="0" y="3123"> <field name="NAME">get_state_code_SLD</field> <statement name="STACK"> <block type="util_python" id="(HOmJd*Bw@nwPNCHY0mu" inline="true"> @@ -784,7 +827,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="wpN6M:c*2cKgK+MM+G.W" x="0" y="3049"> + <block type="procedures_defreturn" id="wpN6M:c*2cKgK+MM+G.W" x="0" y="3256"> <field name="NAME">get_state_active_SLD</field> <statement name="STACK"> <block type="util_python" id="Ht%%JB`?HUum}h9K*t-9" inline="true"> @@ -797,7 +840,7 @@ </block> </value> </block> - <block type="procedures_defnoreturn" id="%z2U,T)U0wd2S}!Lot[s" x="0" y="3182"> + <block type="procedures_defnoreturn" id="%z2U,T)U0wd2S}!Lot[s" x="0" y="3389"> <mutation> <arg name="speed" varid="1X|m)*QO^oo}EfHf=nBO" argid="pePpK@*+w{Ry]Ltz(Z95"/> </mutation> @@ -823,7 +866,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="IKFw+yZgK[}QgIvIQk]A" x="0" y="3353"> + <block type="procedures_defnoreturn" id="IKFw+yZgK[}QgIvIQk]A" x="0" y="3560"> <field name="NAME">ejectWhite</field> <statement name="STACK"> <block type="util_python" id="L9].u`N0?,H+tU)=o?Me" inline="true"> @@ -899,7 +942,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="M^8-tj!Sv{KHcQSAS;$K" x="0" y="3720"> + <block type="procedures_defnoreturn" id="M^8-tj!Sv{KHcQSAS;$K" x="0" y="3927"> <field name="NAME">ejectRed</field> <statement name="STACK"> <block type="util_python" id="?:UCrMJUl%q(jYcN8(IE" inline="true"> @@ -975,7 +1018,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="YLSy9_KOy{GM#LBmqJ8x" x="0" y="4087"> + <block type="procedures_defnoreturn" id="YLSy9_KOy{GM#LBmqJ8x" x="0" y="4294"> <field name="NAME">ejectBlue</field> <statement name="STACK"> <block type="util_python" id="n-s%L0Ie7qkf@WU-[H8o" inline="true"> @@ -1051,7 +1094,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="0.,m:~DVx{zBe-|XxpG-" x="0" y="4454"> + <block type="procedures_defreturn" id="0.,m:~DVx{zBe-|XxpG-" x="0" y="4661"> <field name="NAME">isColorSensorTriggered</field> <statement name="STACK"> <block type="util_python" id="23n|f!bBfO#m?@_HlHB}" inline="true"> @@ -1065,7 +1108,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="}*yI=aY}$^7875;e4Wo_" x="0" y="4587"> + <block type="procedures_defreturn" id="}*yI=aY}$^7875;e4Wo_" x="0" y="4794"> <field name="NAME">isEjectionTriggered</field> <statement name="STACK"> <block type="util_python" id="wrT1c1;%@kF-Riy28O;." inline="true"> @@ -1079,7 +1122,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="Fys9OK!K-FNH-W0o}@h," x="0" y="4720"> + <block type="procedures_defreturn" id="Fys9OK!K-FNH-W0o}@h," x="0" y="4927"> <field name="NAME">isWhite</field> <statement name="STACK"> <block type="util_python" id="h?(Tr@S1VYchJ5e6())[" inline="true"> @@ -1093,7 +1136,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="iE@eN47vK?la`*X4EQ-8" x="0" y="4853"> + <block type="procedures_defreturn" id="iE@eN47vK?la`*X4EQ-8" x="0" y="5060"> <field name="NAME">isRed</field> <statement name="STACK"> <block type="util_python" id="fN{]~9g]|*Kx,bpmy_i$" inline="true"> @@ -1107,7 +1150,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="w|KTmb#01-L]2ZG4mz)b" x="0" y="4986"> + <block type="procedures_defreturn" id="w|KTmb#01-L]2ZG4mz)b" x="0" y="5193"> <field name="NAME">isBlue</field> <statement name="STACK"> <block type="util_python" id="U(Y(8WN=vCJzgw~oLdbs" inline="true"> @@ -1121,7 +1164,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="$]uSxm9]*Qu3iZl~w~MW" x="0" y="5119"> + <block type="procedures_defreturn" id="$]uSxm9]*Qu3iZl~w~MW" x="0" y="5326"> <field name="NAME">readColorValue</field> <statement name="STACK"> <block type="util_python" id="JSm|]EZ0cs6:5)g-C23(" inline="true"> diff --git a/lib/SLD.py b/lib/SLD.py index 262e9207633cf4487890937a64c49367dc1a496a..917b934518d2961ed13b4999b6dca5cc92c206de 100644 --- a/lib/SLD.py +++ b/lib/SLD.py @@ -10,6 +10,7 @@ _data = None _code = None _active = None speed = None +started = None state_code = None state_active = None calibvalue_white = None @@ -26,8 +27,13 @@ counter = None lastStateCounterSwitch = None +def startSLD(): + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + started = True + + def thread_SLD(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') calibvalue_white = 0 calibvalue_red = 0 @@ -37,73 +43,76 @@ def thread_SLD(): thresh_red_blue_defaults = 1600 thresh_red_blue = thresh_red_blue_defaults _set_state_SLD(1, 0) + started = False while True: - logging.log(logging.DEBUG, 'start') - _set_state_SLD(2, 1) - detectedColorValue = 3000 - setConvBeltSpeedSLD(512) - while not isEjectionTriggered(): - lastColorValue = readColorValue() - if lastColorValue < detectedColorValue: - detectedColorValue = lastColorValue - setConvBeltSpeedSLD(0) - logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue) - TXT_SLD_E5_O8_compressor.on() - logging.log(logging.DEBUG, 'check counter') - counter = 0 - lastStateCounterSwitch = TXT_SLD_E5_C1_mini_switch.get_state() - TXT_SLD_E5_M1_encodermotor.set_speed(int(350), Motor.CW) - TXT_SLD_E5_M1_encodermotor.start() - while counter <= 29: - if (TXT_SLD_E5_C1_mini_switch.get_state()) != lastStateCounterSwitch: - counter = (counter if isinstance(counter, Number) else 0) + 1 - lastStateCounterSwitch = TXT_SLD_E5_C1_mini_switch.get_state() - logging.log(logging.DEBUG, 'counter: %d', counter) - time.sleep(0.001) - if detectedColorValue >= 200 and detectedColorValue < thresh_white_red: - if counter > 5: - TXT_SLD_E5_M1_encodermotor.stop() - logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue) - ejectWhite() - break - elif detectedColorValue >= thresh_white_red and detectedColorValue < thresh_red_blue: - if counter > 14: - TXT_SLD_E5_M1_encodermotor.stop() - logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue) - ejectRed() - break - elif detectedColorValue >= thresh_red_blue and detectedColorValue < 2000: - if counter > 25: - TXT_SLD_E5_M1_encodermotor.stop() - logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue) - ejectBlue() - break - else: - pass - time.sleep(0.5) + if started: + logging.log(logging.DEBUG, 'start') + _set_state_SLD(2, 1) + detectedColorValue = 3000 + setConvBeltSpeedSLD(512) + while not isEjectionTriggered(): + lastColorValue = readColorValue() + if lastColorValue < detectedColorValue: + detectedColorValue = lastColorValue + started = False + setConvBeltSpeedSLD(0) + logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue) + TXT_SLD_E5_O8_compressor.on() + logging.log(logging.DEBUG, 'check counter') + counter = 0 + lastStateCounterSwitch = TXT_SLD_E5_C1_mini_switch.get_state() + TXT_SLD_E5_M1_encodermotor.set_speed(int(350), Motor.CW) + TXT_SLD_E5_M1_encodermotor.start() + while counter <= 29: + if (TXT_SLD_E5_C1_mini_switch.get_state()) != lastStateCounterSwitch: + counter = (counter if isinstance(counter, Number) else 0) + 1 + lastStateCounterSwitch = TXT_SLD_E5_C1_mini_switch.get_state() + logging.log(logging.DEBUG, 'counter: %d', counter) + time.sleep(0.001) + if detectedColorValue >= 200 and detectedColorValue < thresh_white_red: + if counter > 5: + TXT_SLD_E5_M1_encodermotor.stop() + logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue) + ejectWhite() + break + elif detectedColorValue >= thresh_white_red and detectedColorValue < thresh_red_blue: + if counter > 14: + TXT_SLD_E5_M1_encodermotor.stop() + logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue) + ejectRed() + break + elif detectedColorValue >= thresh_red_blue and detectedColorValue < 2000: + if counter > 25: + TXT_SLD_E5_M1_encodermotor.stop() + logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue) + ejectBlue() + break + else: + pass + time.sleep(0.5) def get_calib_data_SLD_defaults(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') return [thresh_white_red_defaults, thresh_red_blue_defaults] def get_calib_data_SLD(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') return [thresh_white_red, thresh_red_blue] def set_calib_data_SLD(_data): - global _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, _data) thresh_white_red = _data[0] thresh_red_blue = _data[1] def _set_state_SLD(_code, _active): - global _data, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') if state_code != _code or state_active != _active: _ts_state = 0 @@ -112,26 +121,26 @@ def _set_state_SLD(_code, _active): def get_state_code_SLD(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return state_code def get_state_active_SLD(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return state_active def setConvBeltSpeedSLD(speed): - global _data, _code, _active, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, 'speed: %d', speed) TXT_SLD_E5_M1_encodermotor.set_speed(int(speed), Motor.CW) TXT_SLD_E5_M1_encodermotor.start() def ejectWhite(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') TXT_SLD_E5_O5_magnetic_valve.on() time.sleep(0.5) @@ -145,7 +154,7 @@ def ejectWhite(): def ejectRed(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') TXT_SLD_E5_O6_magnetic_valve.on() time.sleep(0.5) @@ -159,7 +168,7 @@ def ejectRed(): def ejectBlue(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') TXT_SLD_E5_O7_magnetic_valve.on() time.sleep(0.5) @@ -173,37 +182,37 @@ def ejectBlue(): def isColorSensorTriggered(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return TXT_SLD_E5_I1_photo_transistor.is_dark() def isEjectionTriggered(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return TXT_SLD_E5_I3_photo_transistor.is_dark() def isWhite(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return TXT_SLD_E5_I6_photo_transistor.is_dark() def isRed(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return TXT_SLD_E5_I7_photo_transistor.is_dark() def isBlue(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return TXT_SLD_E5_I8_photo_transistor.is_dark() def readColorValue(): - global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global _data, _code, _active, speed, started, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return TXT_SLD_E5_I2_color_sensor.get_voltage()