diff --git a/FactoryCalib.blockly b/FactoryCalib.blockly index 621baf800df0bc94c5157ad95476eabe8f0774e7..de50bce5e1e41735ba2aec40ee7e522ee0efdc7b 100644 --- a/FactoryCalib.blockly +++ b/FactoryCalib.blockly @@ -5,7 +5,7 @@ <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/04</field> + <field name="TEXT">Version 2022/11/07</field> </shadow> </value> <next> diff --git a/FactoryCalib.py b/FactoryCalib.py index 6eb2fa6ecb6d1edc8eac389d2ac32b71237ea945..ca154aa683376a1b7354ca79761263611eb3218b 100644 --- a/FactoryCalib.py +++ b/FactoryCalib.py @@ -23,7 +23,7 @@ from lib.VGR_Axes1Ref import * from lib.VGR_NodeRED import * -display.set_attr("txt_label_version.text", str('Version 2022/11/04')) +display.set_attr("txt_label_version.text", str('Version 2022/11/07')) initlib_log(5) threading.Thread(target=thread_lights, daemon=True).start() initlib_Axes1Ref() diff --git a/lib/NodeRED.blockly b/lib/NodeRED.blockly index 33bfa1ea09a5fc6a8b9bd9a649b1ba8e9b9874cb..c6cac11ca555c6d723bd7e22270aeac00d479e22 100644 --- a/lib/NodeRED.blockly +++ b/lib/NodeRED.blockly @@ -1137,7 +1137,7 @@ <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="$fas2_adI*|Cw;HQeIg5"> - <field name="VAR" id="#ZVIt[,H@%Ms3XJhPF7y">gtyp_Setup_i_Pos_Selection</field> + <field name="VAR" id=")XfA{xXx7sN)MA=qSY=H">gtyp_Setup_i_Color_Sensor_Selection</field> </block> </value> <value name="B"> diff --git a/lib/NodeRED.py b/lib/NodeRED.py index 21888cbc267fa86890ae9711c95a2a3dc4f96c8e..32a7e36ecd110dd6330d66039617527f440b5372 100644 --- a/lib/NodeRED.py +++ b/lib/NodeRED.py @@ -141,7 +141,7 @@ 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') - elif gtyp_Setup_i_Pos_Selection == 2: + elif gtyp_Setup_i_Color_Sensor_Selection == 2: logging.debug('2') else: logging.debug('none') diff --git a/lib/SLD.blockly b/lib/SLD.blockly index 53b0381a04694febedd8c0a0c21177fb1b543e5a..bb125d010d282157de5381ac384041faf49c779b 100644 --- a/lib/SLD.blockly +++ b/lib/SLD.blockly @@ -4,12 +4,13 @@ <variable id="x?rbx}Z!7+Jx9E.L=:pX">_code</variable> <variable id="Hq*BSR/(QEo9c0kQRW{y">_active</variable> <variable id="1X|m)*QO^oo}EfHf=nBO">speed</variable> + <variable id="2hXKDa]i2lK78Fcn!kS7">v</variable> <variable id="78bW9521)(I[oMydfNIz">state_code</variable> <variable id="[V))lfBm^j7t@3LJVWGf">state_active</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> <variable id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</variable> <variable id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</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> <variable id="g%%DHmT#UX~.YdQn3gcf">_ts_state</variable> <variable id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</variable> <variable id="?Hi+81vv*K@yZim!8fD_">lastColorValue</variable> @@ -19,7 +20,41 @@ <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="CpW/ole-H2rC#biYY(;s" x="0" y="103"> + <mutation> + <arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid=",],|#/r)~Xl=JL*8taHJ"/> + </mutation> + <field name="NAME">set_thresh_white_red</field> + <field name=",],|#/r)~Xl=JL*8taHJ">v</field> + <statement name="STACK"> + <block type="variables_set" id="3*3|dp7u~ki(*nK_4Ekt"> + <field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field> + <value name="VALUE"> + <block type="variables_get" id="/o6UTd6e2cy=Pj`s9)(c"> + <field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field> + </block> + </value> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="h5y$(R^WIO%kMWuCgE+;" x="0" y="243"> + <mutation> + <arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="Nz7/7d0Ek!?Vdf4NY1ae"/> + </mutation> + <field name="NAME">set_thresh_red_blue</field> + <field name="Nz7/7d0Ek!?Vdf4NY1ae">v</field> + <statement name="STACK"> + <block type="variables_set" id="eNRG|p(-%_Yz!$K``W6e"> + <field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field> + <value name="VALUE"> + <block type="variables_get" id="2|LmmIczudHT]_cFHQ(?"> + <field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field> + </block> + </value> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="]$}!d~iPi$faCfYn-,02" x="0" y="383"> <field name="NAME">thread_SLD</field> <statement name="STACK"> <block type="util_python" id="or=tulIX]{S?#ofKV+]h" inline="true"> @@ -73,254 +108,273 @@ </block> </value> <next> - <block type="util_python" id="n.p8_b8KsLuV8+Nn5|_N" inline="true"> - <field name="value">threading.Thread(target=thread_update_SLD, daemon=True).start()</field> - <next> - <block type="loop_endless" id="??ZH|RLC1U|c~MVe9I${"> - <statement name="DO"> - <block type="controls_if" id="4H`AQ+![PHR,)B9=[ZZs"> - <mutation elseif="1"/> - <value name="IF0"> - <block type="logic_compare" id="sf/MV)Uz7p2R7aQPw3Az"> - <field name="OP">EQ</field> - <value name="A"> - <block type="import_function_return" id="sfPm0O_ulXsuW13fY*h!" disabled="true"> - <mutation parentId="*Po6~DzRyM9/RWe)v-Dm"/> - <field name="name">get_factory_error_state</field> - <data>*Po6~DzRyM9/RWe)v-Dm</data> - </block> - </value> - <value name="B"> - <block type="text" id="^9RQWz)BV(S!A;c3gpgh"> - <field name="TEXT">SLD</field> - </block> - </value> + <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> - <statement name="DO0"> - <block type="procedures_callnoreturn" id="nVMc-C),14c@QNCd.(5S" inline="true"> - <mutation name="_set_state_SLD"> - <arg name="_code"/> - <arg name="_active"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="3THyKnJK}E.!w#oR6/L{"> - <field name="NUM">4</field> - </block> - </value> - <value name="ARG1"> - <block type="math_number" id=",QQX!E9Odk3H2W4VI?Nh"> - <field name="NUM">1</field> - </block> - </value> - <next> - <block type="display_set_label_text" id="-=u+bL8~=Ofog:|eNrpo"> - <field name="instance_name">txt_label_message1</field> - <value name="value"> - <shadow type="text" id="WR82C}msfCLs,r$ogw@H"> - <field name="TEXT">ERROR SLD: Please confirm with ACK button!</field> - </shadow> - </value> - </block> - </next> - </block> - </statement> - <value name="IF1"> - <block type="procedures_callreturn" id="Y%:9e@vMPRAJ!u.PDzd$"> - <mutation name="isColorSensorTriggered"/> + <value name="ARG1"> + <block type="math_number" id="g8Lk_tA34OsX@!]LiC73"> + <field name="NUM">1</field> </block> </value> - <statement name="DO1"> - <block type="util_python" id="9:U=/@,Hc3J70C9Na;o," inline="true"> - <field name="value">logging.log(logging.DEBUG, 'start')</field> + <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> <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"/> + <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="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="math_number" id="l5c-VK(61=0/J@T38dRO"> + <field name="NUM">512</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 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> - <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> + <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"/> </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="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="DO"> - <block type="variables_set" id="[sz4{]_4m6cHGqtK{PO+"> - <field name="VAR" id="?Hi+81vv*K@yZim!8fD_">lastColorValue</field> + <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="procedures_callreturn" id="UcL=Uv7S99ju,3n:Y0-7"> - <mutation name="readColorValue"/> + <block type="variables_get" id="#9q1($D*Zqbur;(szG#u"> + <field name="VAR" id="?Hi+81vv*K@yZim!8fD_">lastColorValue</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> - </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="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> + <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="util_python" id="RTDnf9zEhD_)dv}a{N1h" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'detectedColorValue: %d', detectedColorValue)</field> + <block type="util_python" id="r;?8M|)NMD`GAg2sSWt8" inline="true"> + <field name="value">logging.log(logging.DEBUG, 'check counter')</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="}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> <next> - <block type="util_python" id="r;?8M|)NMD`GAg2sSWt8" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'check counter')</field> + <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> <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> + <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="^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 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> </value> - <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> + <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> + </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> + </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_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> + <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="variables_get" id="Lis}jL`_`*I$?F^O?ch`"> - <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</field> + <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> </value> <value name="B"> - <block type="math_number" id="]n/~EGON9=EwXNd2=M%h"> - <field name="NUM">29</field> + <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="DO"> - <block type="controls_if" id="`@W^kruj%p|@CI0L{q:#"> + <statement name="DO0"> + <block type="controls_if" id="C,DeIZKYXXMwTy-|VKDb"> <value name="IF0"> - <block type="logic_compare" id="@ae3R,Z*1Xk2HQpYmMbZ"> - <field name="OP">NEQ</field> + <block type="logic_compare" id="4@i%+GywVT/eXFM[n:mG"> + <field name="OP">GT</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 type="variables_get" id="E[R=0N3LxmxRCnf0_oI7"> + <field name="VAR" id="_?QtuoxDM2ZJ#rQLHhaQ">counter</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 type="math_number" id="t1Wzji0hz}Rv$,y%b7~Z"> + <field name="NUM">5</field> </block> </value> </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> - </shadow> - </value> + <block type="motor_stop" id="@Nxv_JCs.5z7;K$Jf8cx"> + <field name="instance_name">TXT_SLD_E5_M1_encodermotor</field> <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> + <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="util_python" id="s;3oKGuf4t~q|)i-o.p3" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'counter: %d', counter)</field> + <block type="procedures_callnoreturn" id="g?crz6vB(IpG*dzi*tN*"> + <mutation name="ejectWhite"/> <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 type="controls_flow_statements" id="~WR8i~(H:4XI5UrbxdRZ"> + <field name="FLOW">BREAK</field> </block> </next> </block> @@ -329,313 +383,169 @@ </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> - <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> + </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> - <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> + <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> - </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> + </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> - <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> + <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> - </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> + </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> - <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> + <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="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 type="controls_flow_statements" id=".~.zxr`^*Gcw^7BX`TG6"> + <field name="FLOW">BREAK</field> </block> </next> </block> - </statement> + </next> </block> - </statement> + </next> </block> - </next> + </statement> </block> </statement> - <next> - <block type="controls_if" id="}{Vt#WBd0U9-/bN#%lCH"> - <mutation elseif="0" else="1"/> - <value name="IF0"> - <block type="logic_operation" id="SE,oX0aW1b%CffPm.L|Z" inline="false"> - <field name="OP">OR</field> + <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="logic_compare" id="R`A77Ja/#{2bGx+]6f3p"> - <field name="OP">LT</field> - <value name="A"> - <block type="variables_get" id="D;}:PEv4O:W54-^i2hgw"> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - </block> - </value> - <value name="B"> - <block type="math_number" id="y|UE(xv|{/3CvV|ot-K/"> - <field name="NUM">200</field> - </block> - </value> + <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="logic_compare" id="`ePuYg7l`=z0dT$O]Z^Q"> - <field name="OP">GTE</field> - <value name="A"> - <block type="variables_get" id="55qfiW0=.-B/Q(xz|hw="> - <field name="VAR" id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</field> - </block> - </value> - <value name="B"> - <block type="math_number" id="/#B:Ei=L08guFuB4cu:C"> - <field name="NUM">2000</field> - </block> - </value> + <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> - <statement name="DO0"> - <block type="import_function_noreturn" id="obocv-?We~2|A#N3SHW|" inline="true" disabled="true"> - <mutation parentId="wSoc08Sb1t[JV3?PZ4jG"/> - <field name="name">set_factory_error_state</field> - <data>wSoc08Sb1t[JV3?PZ4jG</data> - <next> - <block type="util_python" id="Nv,aaR5BQg0o5]2d?h-c" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'error: color out of bounds')</field> + <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> - </next> + </value> + <value name="B"> + <block type="math_number" id="va`hEl#rZ9[sPG`(COsp"> + <field name="NUM">2000</field> + </block> + </value> </block> - </statement> - <statement name="ELSE"> - <block type="procedures_callnoreturn" id="X.7!8r7*^P{Or{a=+E@S" inline="true"> - <mutation name="_set_state_SLD"> - <arg name="_code"/> - <arg name="_active"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="PBr.i?/R=U1Kt]J|R6Bg"> - <field name="NUM">1</field> + </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="ARG1"> - <block type="math_number" id="BG_/:/aH:t42kJ`2pYEY"> - <field name="NUM">0</field> + <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="EO=.{66=Z-)x=YE9UIRE" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'sorted')</field> + <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> - </next> + </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> </next> @@ -658,21 +568,11 @@ </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> + </statement> </block> </next> </block> @@ -688,7 +588,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="x=/1p3KO=Q%QK7t2K5l%" x="0" y="2378"> + <block type="procedures_defreturn" id="x=/1p3KO=Q%QK7t2K5l%" x="0" y="2279"> <field name="NAME">get_calib_data_SLD_defaults</field> <statement name="STACK"> <block type="util_python" id="cO!#.ICg79WkS?A?cG[j" inline="true"> @@ -711,7 +611,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="b|1;0mU=wNNO2Ry{f6,Z" x="0" y="2539"> + <block type="procedures_defreturn" id="b|1;0mU=wNNO2Ry{f6,Z" x="0" y="2444"> <field name="NAME">get_calib_data_SLD</field> <statement name="STACK"> <block type="util_python" id="t;Zg(`vb3R)aQZ])LhpC" inline="true"> @@ -734,7 +634,7 @@ </block> </value> </block> - <block type="procedures_defnoreturn" id="3Qf0~|~$oG8z5tP{6Km;" x="0" y="2700"> + <block type="procedures_defnoreturn" id="3Qf0~|~$oG8z5tP{6Km;" x="0" y="2609"> <mutation> <arg name="_data" varid="$E/GDp,,dwQrGbs7N*=C" argid="^}Z*XZLpIfstV5L7ggN|"/> </mutation> @@ -790,92 +690,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id=",nyl?Z;M8PRY0Bu|9@XY" x="0" y="2919"> - <field name="NAME">thread_update_SLD</field> - <statement name="STACK"> - <block type="util_python" id="D)[fw5QAGMWYCwwf5|$H" inline="true"> - <field name="value">logging.log(logging.TRACE, '-')</field> - <next> - <block type="variables_set" id="A!8!lWzAY|LEJw:!}[vu"> - <field name="VAR" id="g%%DHmT#UX~.YdQn3gcf">_ts_state</field> - <value name="VALUE"> - <block type="math_number" id=")Op~1Xo-jR1.hcl/8qI!"> - <field name="NUM">0</field> - </block> - </value> - <next> - <block type="loop_endless" id="^K#bV/dWnbhyByb7X~Gy"> - <statement name="DO"> - <block type="controls_if" id="paSb85/~`)/ftd/zCVER"> - <value name="IF0"> - <block type="logic_compare" id="4LV%zy(wxH*^_^Win.V)"> - <field name="OP">GT</field> - <value name="A"> - <block type="math_arithmetic" id="sH[EX[*clgp.^9mAlSDa"> - <field name="OP">MINUS</field> - <value name="A"> - <block type="util_runtime_measurement" id="pl7p|I3!nb4L2LpO=eQ$"> - <field name="TIME">MILLISECOND</field> - </block> - </value> - <value name="B"> - <block type="variables_get" id="mGDIfF?xgF67~)/NSo6f"> - <field name="VAR" id="g%%DHmT#UX~.YdQn3gcf">_ts_state</field> - </block> - </value> - </block> - </value> - <value name="B"> - <block type="math_number" id="ulg*^*h(%;+e^uRB@Ytz"> - <field name="NUM">10000</field> - </block> - </value> - </block> - </value> - <statement name="DO0"> - <block type="import_function_noreturn" id="ys|+PWnX.Qx,0J5wC.7E" inline="true" disabled="true"> - <mutation parentId="rZjuCnOSx#4%euwOJX]X"/> - <field name="name">update_display_SLD</field> - <data>rZjuCnOSx#4%euwOJX]X</data> - <next> - <block type="import_function_noreturn" id="0(o(njJj3}zEguj9aSui" inline="true" disabled="true"> - <mutation parentId="`$(l[O3$4[Vf/KP(cLR@"/> - <field name="name">publish_state_SLD</field> - <data>`$(l[O3$4[Vf/KP(cLR@</data> - <next> - <block type="variables_set" id="g#_Ae9JA~Y_VWaf,iUjd"> - <field name="VAR" id="g%%DHmT#UX~.YdQn3gcf">_ts_state</field> - <value name="VALUE"> - <block type="util_runtime_measurement" id="xjYwtP9:Z|gVtEOB.MGA"> - <field name="TIME">MILLISECOND</field> - </block> - </value> - </block> - </next> - </block> - </next> - </block> - </statement> - <next> - <block type="util_wait_for" id="BLXZ=m5u9(`{mURPH7kJ"> - <field name="format">s</field> - <value name="value"> - <shadow type="math_number" id="yhCpd4@`)g)YI18EIaO4"> - <field name="NUM">1</field> - </shadow> - </value> - </block> - </next> - </block> - </statement> - </block> - </next> - </block> - </next> - </block> - </statement> - </block> - <block type="procedures_defnoreturn" id="gsD|}/@_.f.D_8KfM;**" x="0" y="3298"> + <block type="procedures_defnoreturn" id="gsD|}/@_.f.D_8KfM;**" x="0" y="2833"> <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%"/> @@ -958,7 +773,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="eO[xQ[akMe*EVjm,{7m0" x="0" y="3643"> + <block type="procedures_defreturn" id="eO[xQ[akMe*EVjm,{7m0" x="0" y="3187"> <field name="NAME">get_state_code_SLD</field> <statement name="STACK"> <block type="util_python" id="(HOmJd*Bw@nwPNCHY0mu" inline="true"> @@ -971,7 +786,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="wpN6M:c*2cKgK+MM+G.W" x="0" y="3776"> + <block type="procedures_defreturn" id="wpN6M:c*2cKgK+MM+G.W" x="0" y="3323"> <field name="NAME">get_state_active_SLD</field> <statement name="STACK"> <block type="util_python" id="Ht%%JB`?HUum}h9K*t-9" inline="true"> @@ -984,7 +799,7 @@ </block> </value> </block> - <block type="procedures_defnoreturn" id="%z2U,T)U0wd2S}!Lot[s" x="0" y="3909"> + <block type="procedures_defnoreturn" id="%z2U,T)U0wd2S}!Lot[s" x="0" y="3459"> <mutation> <arg name="speed" varid="1X|m)*QO^oo}EfHf=nBO" argid="pePpK@*+w{Ry]Ltz(Z95"/> </mutation> @@ -1010,7 +825,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="IKFw+yZgK[}QgIvIQk]A" x="0" y="4080"> + <block type="procedures_defnoreturn" id="IKFw+yZgK[}QgIvIQk]A" x="0" y="3634"> <field name="NAME">ejectWhite</field> <statement name="STACK"> <block type="util_python" id="L9].u`N0?,H+tU)=o?Me" inline="true"> @@ -1086,7 +901,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="M^8-tj!Sv{KHcQSAS;$K" x="0" y="4447"> + <block type="procedures_defnoreturn" id="M^8-tj!Sv{KHcQSAS;$K" x="0" y="4011"> <field name="NAME">ejectRed</field> <statement name="STACK"> <block type="util_python" id="?:UCrMJUl%q(jYcN8(IE" inline="true"> @@ -1162,7 +977,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="YLSy9_KOy{GM#LBmqJ8x" x="0" y="4814"> + <block type="procedures_defnoreturn" id="YLSy9_KOy{GM#LBmqJ8x" x="0" y="4388"> <field name="NAME">ejectBlue</field> <statement name="STACK"> <block type="util_python" id="n-s%L0Ie7qkf@WU-[H8o" inline="true"> @@ -1238,7 +1053,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="0.,m:~DVx{zBe-|XxpG-" x="0" y="5181"> + <block type="procedures_defreturn" id="0.,m:~DVx{zBe-|XxpG-" x="0" y="4765"> <field name="NAME">isColorSensorTriggered</field> <statement name="STACK"> <block type="util_python" id="23n|f!bBfO#m?@_HlHB}" inline="true"> @@ -1252,7 +1067,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="}*yI=aY}$^7875;e4Wo_" x="0" y="5314"> + <block type="procedures_defreturn" id="}*yI=aY}$^7875;e4Wo_" x="0" y="4901"> <field name="NAME">isEjectionTriggered</field> <statement name="STACK"> <block type="util_python" id="wrT1c1;%@kF-Riy28O;." inline="true"> @@ -1266,7 +1081,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="Fys9OK!K-FNH-W0o}@h," x="0" y="5447"> + <block type="procedures_defreturn" id="Fys9OK!K-FNH-W0o}@h," x="0" y="5037"> <field name="NAME">isWhite</field> <statement name="STACK"> <block type="util_python" id="h?(Tr@S1VYchJ5e6())[" inline="true"> @@ -1280,7 +1095,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="iE@eN47vK?la`*X4EQ-8" x="0" y="5580"> + <block type="procedures_defreturn" id="iE@eN47vK?la`*X4EQ-8" x="0" y="5173"> <field name="NAME">isRed</field> <statement name="STACK"> <block type="util_python" id="fN{]~9g]|*Kx,bpmy_i$" inline="true"> @@ -1294,7 +1109,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="w|KTmb#01-L]2ZG4mz)b" x="0" y="5713"> + <block type="procedures_defreturn" id="w|KTmb#01-L]2ZG4mz)b" x="0" y="5309"> <field name="NAME">isBlue</field> <statement name="STACK"> <block type="util_python" id="U(Y(8WN=vCJzgw~oLdbs" inline="true"> @@ -1308,7 +1123,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="$]uSxm9]*Qu3iZl~w~MW" x="0" y="5846"> + <block type="procedures_defreturn" id="$]uSxm9]*Qu3iZl~w~MW" x="0" y="5445"> <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 9b9238152bfd5c96bc0deca648d7c67360c00ac8..cff8ce1815bc91053403df2d3734ad4d8be42b7e 100644 --- a/lib/SLD.py +++ b/lib/SLD.py @@ -3,20 +3,20 @@ import time from fischertechnik.controller.Motor import Motor from lib.controller import * -from lib.display import * from numbers import Number +v = None _data = None _code = None _active = None speed = None +thresh_white_red = None +thresh_red_blue = None state_code = None state_active = None thresh_white_red_defaults = None thresh_red_blue_defaults = None -thresh_white_red = None -thresh_red_blue = None _ts_state = None detectedColorValue = None lastColorValue = None @@ -24,101 +24,91 @@ counter = None lastStateCounterSwitch = None +def set_thresh_white_red(v): + global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + thresh_white_red = v + + +def set_thresh_red_blue(v): + global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + thresh_red_blue = v + + def thread_SLD(): - global _data, _code, _active, speed, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') thresh_white_red_defaults = 1150 thresh_white_red = thresh_white_red_defaults thresh_red_blue_defaults = 1600 thresh_red_blue = thresh_red_blue_defaults _set_state_SLD(1, 0) - threading.Thread(target=thread_update_SLD, daemon=True).start() while True: - if 0 == 'SLD': - _set_state_SLD(4, 1) - display.set_attr("txt_label_message1.text", str('ERROR SLD: Please confirm with ACK button!')) - elif isColorSensorTriggered(): - 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 - if detectedColorValue < 200 or detectedColorValue >= 2000: - logging.log(logging.DEBUG, 'error: color out of bounds') + 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: - _set_state_SLD(1, 0) - logging.log(logging.DEBUG, 'sorted') + pass time.sleep(0.5) def get_calib_data_SLD_defaults(): - global _data, _code, _active, speed, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, 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, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, 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, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, _data) thresh_white_red = _data[0] thresh_red_blue = _data[1] -def thread_update_SLD(): - global _data, _code, _active, speed, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch - logging.log(logging.TRACE, '-') - _ts_state = 0 - while True: - if (time.time() * 1000) - _ts_state > 10000: - _ts_state = (time.time() * 1000) - time.sleep(1) - - def _set_state_SLD(_code, _active): - global _data, speed, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') if state_code != _code or state_active != _active: _ts_state = 0 @@ -127,26 +117,26 @@ def _set_state_SLD(_code, _active): def get_state_code_SLD(): - global _data, _code, _active, speed, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, 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, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return state_active def setConvBeltSpeedSLD(speed): - global _data, _code, _active, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, 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, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') TXT_SLD_E5_O5_magnetic_valve.on() time.sleep(0.5) @@ -160,7 +150,7 @@ def ejectWhite(): def ejectRed(): - global _data, _code, _active, speed, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') TXT_SLD_E5_O6_magnetic_valve.on() time.sleep(0.5) @@ -174,7 +164,7 @@ def ejectRed(): def ejectBlue(): - global _data, _code, _active, speed, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') TXT_SLD_E5_O7_magnetic_valve.on() time.sleep(0.5) @@ -188,37 +178,37 @@ def ejectBlue(): def isColorSensorTriggered(): - global _data, _code, _active, speed, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, 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, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, 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, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, 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, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, 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, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, 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, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE0, '-') return TXT_SLD_E5_I2_color_sensor.get_voltage() diff --git a/lib/SLD_NodeRED.blockly b/lib/SLD_NodeRED.blockly index b84652105fca5e9954861bb5919bb3a61c07c1af..7ed973feda3dbd3ac8c1c7411d82a3ae6cf8927f 100644 --- a/lib/SLD_NodeRED.blockly +++ b/lib/SLD_NodeRED.blockly @@ -6,7 +6,7 @@ <block type="util_python_imports" id="C~t1TVK8naGZ9VcQnd!H" x="0" y="0"> <field name="value">#TXT FW 3.1.0: https://pypi.org/project/paho-mqtt/1.3.1/&#10;&#10;import paho.mqtt.client as mqtt&#10;import json&#10;from datetime import datetime&#10;import logging</field> </block> - <block type="procedures_defnoreturn" id="NR!pGTXhhcy9PF=6+]*7" x="0" y="206"> + <block type="procedures_defnoreturn" id="NR!pGTXhhcy9PF=6+]*7" x="0" y="213"> <mutation> <arg name="c" varid="C2~T0O1L[2W(C)`SXOAO" argid="8TCtm^79}dhkQZlY^WCh"/> </mutation>