From af64207aefaaaccdad4fe2fe3ce8893e3c2c7103 Mon Sep 17 00:00:00 2001 From: ft-Demo <fischertechnik-team@fischer.de> Date: Mon, 7 Nov 2022 15:31:59 +0000 Subject: [PATCH] commit by robo pro coding --- lib/SLD.blockly | 1022 ++++++++++++++++++++++++++++------------------- lib/SLD.py | 75 +++- 2 files changed, 661 insertions(+), 436 deletions(-) diff --git a/lib/SLD.blockly b/lib/SLD.blockly index bb125d0..985b545 100644 --- a/lib/SLD.blockly +++ b/lib/SLD.blockly @@ -9,6 +9,9 @@ <variable id="[V))lfBm^j7t@3LJVWGf">state_active</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="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</variable> + <variable id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</variable> + <variable id="u~VUTh^5;XCqV.t^iE,B">calibvalue_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> @@ -54,498 +57,683 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="]$}!d~iPi$faCfYn-,02" x="0" y="383"> + <block type="procedures_defreturn" id="qn64~^UH=QV4|-w^OiX3" x="0" y="383"> + <field name="NAME">get_thresh_list</field> + <value name="RETURN"> + <block type="lists_create_with" id="?W6`HZcED/e(AP1BFbYr"> + <mutation items="2"/> + <value name="ADD0"> + <block type="variables_get" id="m1@Y1bkb,1*Dg+eexmKl"> + <field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field> + </block> + </value> + <value name="ADD1"> + <block type="variables_get" id="a^.?2Q=ibO,1}0)/Gzic"> + <field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field> + </block> + </value> + </block> + </value> + </block> + <block type="procedures_defnoreturn" id="]HGe}R8RwUwfQdy0ms1)" x="0" y="533"> + <field name="NAME">calculate_thresh</field> + <statement name="STACK"> + <block type="variables_set" id="N:HH93LfZOGlsAZG*0jY"> + <field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field> + <value name="VALUE"> + <block type="math_arithmetic" id="[kHN2Ju34-JM]=ZC}~f?"> + <field name="OP">DIVIDE</field> + <value name="A"> + <block type="math_arithmetic" id="Fr%[L18*%c*+$xkRRmm`"> + <field name="OP">ADD</field> + <value name="A"> + <block type="variables_get" id="RSPH{qq0p*_4E(i!EK*8"> + <field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="5*`ipxd4{J+n1q|w{zP|"> + <field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="math_number" id="LtL_9k`{^Y-{qpG{QxgS"> + <field name="NUM">2</field> + </block> + </value> + </block> + </value> + <next> + <block type="variables_set" id="3S~xH!-(5jp{N@[Pb]w;"> + <field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field> + <value name="VALUE"> + <block type="math_arithmetic" id="w,QV?:Z:8I@CqD-ihD0C"> + <field name="OP">DIVIDE</field> + <value name="A"> + <block type="math_arithmetic" id="wmEObo)Jdr;sB0A=s3aF"> + <field name="OP">ADD</field> + <value name="A"> + <block type="variables_get" id="]vb#C}h4E[V$hzr5g55@"> + <field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field> + </block> + </value> + <value name="B"> + <block type="variables_get" id="IbH+K4}=A;gbp*8R,31%"> + <field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field> + </block> + </value> + </block> + </value> + <value name="B"> + <block type="math_number" id="h(o(_rZpB6ZmzlHuM9V}"> + <field name="NUM">2</field> + </block> + </value> + </block> + </value> + </block> + </next> + </block> + </statement> + </block> + <block type="procedures_defreturn" id="9Cj-Yafy$tg0`VH?3)S=" x="0" y="713"> + <field name="NAME">get_calibvalue_list</field> + <value name="RETURN"> + <block type="lists_create_with" id="Wj)6C/61+mbvY6}p$eoh"> + <mutation items="3"/> + <value name="ADD0"> + <block type="variables_get" id="5v3ziq5pvqDqT/9ZVwP,"> + <field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field> + </block> + </value> + <value name="ADD1"> + <block type="variables_get" id="jWM[pB(F5IbtNLP-Bpb."> + <field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field> + </block> + </value> + <value name="ADD2"> + <block type="variables_get" id="Z@i#@^B6DW,*;PXxhc$4"> + <field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field> + </block> + </value> + </block> + </value> + </block> + <block type="procedures_defnoreturn" id="~J*0~mN(wH1HdQ6+g*8O" x="0" y="892"> + <mutation> + <arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="I@B?}jt30*H/Nrzr)p2."/> + </mutation> + <field name="NAME">set_calibvalue_white</field> + <field name="I@B?}jt30*H/Nrzr)p2.">v</field> + <statement name="STACK"> + <block type="variables_set" id="u,NtKTmx-[!KhZUdvkHW"> + <field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field> + <value name="VALUE"> + <block type="variables_get" id="2c{|eTtuT+eA#t@SrFza"> + <field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field> + </block> + </value> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="uiAN]3!dL*HgM2PpP/Mr" x="0" y="1032"> + <mutation> + <arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="`,@l)KD{{wbrC!|u;.cC"/> + </mutation> + <field name="NAME">set_calibvalue_red</field> + <field name="`,@l)KD{{wbrC!|u;.cC">v</field> + <statement name="STACK"> + <block type="variables_set" id="rAVx5ZwsP~^Ist#lCB4Q"> + <field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field> + <value name="VALUE"> + <block type="variables_get" id="h~F1rD.B2[TwE|gC@qJh"> + <field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field> + </block> + </value> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="9]2A$:IB|S6O$D~zhA=2" x="0" y="1172"> + <mutation> + <arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="|#3L}sF}`~w2aK|mn7._"/> + </mutation> + <field name="NAME">set_calibvalue_blue</field> + <field name="|#3L}sF}`~w2aK|mn7._">v</field> + <statement name="STACK"> + <block type="variables_set" id="QtVj+{4OkTrFB5EM^Ye@"> + <field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field> + <value name="VALUE"> + <block type="variables_get" id="|0z?+.gMKUwLyinAgUEX"> + <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="1312"> <field name="NAME">thread_SLD</field> <statement name="STACK"> <block type="util_python" id="or=tulIX]{S?#ofKV+]h" inline="true"> <field name="value">logging.log(logging.TRACE, '-')</field> <next> - <block type="variables_set" id="[c@.poi;J+,t;%MX-h)V"> - <field name="VAR" id="?]F?rtn:F#wq@5Ag|9yE">thresh_white_red_defaults</field> + <block type="variables_set" id="l!)l(ic4rXH/Ks9NLlO2"> + <field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field> <value name="VALUE"> - <block type="math_number" id="_Q5JwkrPuEM#+R/5oEG*"> - <field name="NUM">1150</field> + <block type="math_number" id="az0%gohkle?@IpRTY`=R"> + <field name="NUM">0</field> </block> </value> <next> - <block type="variables_set" id=":*U%Yl[CmePTgEsjdb{6"> - <field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field> + <block type="variables_set" id="`#qDeNA1zOaZm|uv$h@b"> + <field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field> <value name="VALUE"> - <block type="variables_get" id="N^w~1k_]qE}9Jwq.mb|p"> - <field name="VAR" id="?]F?rtn:F#wq@5Ag|9yE">thresh_white_red_defaults</field> + <block type="math_number" id="t*4f|r}=V7ZxUuFt}Y^0"> + <field name="NUM">0</field> </block> </value> <next> - <block type="variables_set" id="bqYP1:Ggci%},kna7%_@"> - <field name="VAR" id="Krv1?O$_~Yha=/]3-u{i">thresh_red_blue_defaults</field> + <block type="variables_set" id=";ucm/6TxzxOB}L,=6V0|"> + <field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field> <value name="VALUE"> - <block type="math_number" id="~O=H7IkEjk2PEcX*q9zH"> - <field name="NUM">1600</field> + <block type="math_number" id="ixAZB)F$Ynj)2QU^`Z9?"> + <field name="NUM">0</field> </block> </value> <next> - <block type="variables_set" id="gK1ky@Q;4_}Xt$@cd*BW"> - <field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field> + <block type="variables_set" id="[c@.poi;J+,t;%MX-h)V"> + <field name="VAR" id="?]F?rtn:F#wq@5Ag|9yE">thresh_white_red_defaults</field> <value name="VALUE"> - <block type="variables_get" id="I.3Q0|C4i35Sx)2|P{[$"> - <field name="VAR" id="Krv1?O$_~Yha=/]3-u{i">thresh_red_blue_defaults</field> + <block type="math_number" id="_Q5JwkrPuEM#+R/5oEG*"> + <field name="NUM">1150</field> </block> </value> <next> - <block type="procedures_callnoreturn" id="6`Jd3ABVNCzCdkyill$]" inline="true"> - <mutation name="_set_state_SLD"> - <arg name="_code"/> - <arg name="_active"/> - </mutation> - <value name="ARG0"> - <block type="math_number" id="rr7u?aoq/Hcx9)LX(Jv$"> - <field name="NUM">1</field> - </block> - </value> - <value name="ARG1"> - <block type="math_number" id="qJb1sEu!T/cW+mqH|6Oc"> - <field name="NUM">0</field> + <block type="variables_set" id=":*U%Yl[CmePTgEsjdb{6"> + <field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field> + <value name="VALUE"> + <block type="variables_get" id="N^w~1k_]qE}9Jwq.mb|p"> + <field name="VAR" id="?]F?rtn:F#wq@5Ag|9yE">thresh_white_red_defaults</field> </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> + <block type="variables_set" id="bqYP1:Ggci%},kna7%_@"> + <field name="VAR" id="Krv1?O$_~Yha=/]3-u{i">thresh_red_blue_defaults</field> + <value name="VALUE"> + <block type="math_number" id="~O=H7IkEjk2PEcX*q9zH"> + <field name="NUM">1600</field> + </block> + </value> + <next> + <block type="variables_set" id="gK1ky@Q;4_}Xt$@cd*BW"> + <field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field> + <value name="VALUE"> + <block type="variables_get" id="I.3Q0|C4i35Sx)2|P{[$"> + <field name="VAR" id="Krv1?O$_~Yha=/]3-u{i">thresh_red_blue_defaults</field> + </block> + </value> <next> - <block type="procedures_callnoreturn" id="p,0#!:*0*c~lmV%gtaQ`" inline="true"> + <block type="procedures_callnoreturn" id="6`Jd3ABVNCzCdkyill$]" 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 type="math_number" id="rr7u?aoq/Hcx9)LX(Jv$"> + <field name="NUM">1</field> </block> </value> <value name="ARG1"> - <block type="math_number" id="g8Lk_tA34OsX@!]LiC73"> - <field name="NUM">1</field> + <block type="math_number" id="qJb1sEu!T/cW+mqH|6Oc"> + <field name="NUM">0</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> - <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> + <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="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="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="DO"> - <block type="variables_set" id="[sz4{]_4m6cHGqtK{PO+"> - <field name="VAR" id="?Hi+81vv*K@yZim!8fD_">lastColorValue</field> + <value name="ARG1"> + <block type="math_number" id="g8Lk_tA34OsX@!]LiC73"> + <field name="NUM">1</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="procedures_callreturn" id="UcL=Uv7S99ju,3n:Y0-7"> - <mutation name="readColorValue"/> + <block type="math_number" id="7dq9UhKYcF?CH.:+!OrJ"> + <field name="NUM">3000</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="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> - <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> + <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> </value> - </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> - <next> - <block type="util_python" id="r;?8M|)NMD`GAg2sSWt8" inline="true"> - <field name="value">logging.log(logging.DEBUG, 'check counter')</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="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 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> - <next> - <block type="variables_set" id="^Ku:~)-Palwl:g+NfSj1"> - <field name="VAR" id="Cb}mUgnt@Vc|BuR6[;{s">lastStateCounterSwitch</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="input_mini_switch_get_state" id="Lu/Xqez`AYH(xvU~bo1E"> - <field name="instance_name">TXT_SLD_E5_C1_mini_switch</field> + <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> + <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> <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> - <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> + <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="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> @@ -566,13 +754,13 @@ </block> </next> </block> - </next> + </statement> </block> </next> </block> </next> </block> - </statement> + </next> </block> </next> </block> @@ -588,7 +776,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="x=/1p3KO=Q%QK7t2K5l%" x="0" y="2279"> + <block type="procedures_defreturn" id="x=/1p3KO=Q%QK7t2K5l%" x="0" y="3295"> <field name="NAME">get_calib_data_SLD_defaults</field> <statement name="STACK"> <block type="util_python" id="cO!#.ICg79WkS?A?cG[j" inline="true"> @@ -611,7 +799,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="b|1;0mU=wNNO2Ry{f6,Z" x="0" y="2444"> + <block type="procedures_defreturn" id="b|1;0mU=wNNO2Ry{f6,Z" x="0" y="3460"> <field name="NAME">get_calib_data_SLD</field> <statement name="STACK"> <block type="util_python" id="t;Zg(`vb3R)aQZ])LhpC" inline="true"> @@ -634,7 +822,7 @@ </block> </value> </block> - <block type="procedures_defnoreturn" id="3Qf0~|~$oG8z5tP{6Km;" x="0" y="2609"> + <block type="procedures_defnoreturn" id="3Qf0~|~$oG8z5tP{6Km;" x="0" y="3625"> <mutation> <arg name="_data" varid="$E/GDp,,dwQrGbs7N*=C" argid="^}Z*XZLpIfstV5L7ggN|"/> </mutation> @@ -690,7 +878,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="gsD|}/@_.f.D_8KfM;**" x="0" y="2833"> + <block type="procedures_defnoreturn" id="gsD|}/@_.f.D_8KfM;**" x="0" y="3849"> <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%"/> @@ -773,7 +961,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="eO[xQ[akMe*EVjm,{7m0" x="0" y="3187"> + <block type="procedures_defreturn" id="eO[xQ[akMe*EVjm,{7m0" x="0" y="4203"> <field name="NAME">get_state_code_SLD</field> <statement name="STACK"> <block type="util_python" id="(HOmJd*Bw@nwPNCHY0mu" inline="true"> @@ -786,7 +974,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="wpN6M:c*2cKgK+MM+G.W" x="0" y="3323"> + <block type="procedures_defreturn" id="wpN6M:c*2cKgK+MM+G.W" x="0" y="4339"> <field name="NAME">get_state_active_SLD</field> <statement name="STACK"> <block type="util_python" id="Ht%%JB`?HUum}h9K*t-9" inline="true"> @@ -799,7 +987,7 @@ </block> </value> </block> - <block type="procedures_defnoreturn" id="%z2U,T)U0wd2S}!Lot[s" x="0" y="3459"> + <block type="procedures_defnoreturn" id="%z2U,T)U0wd2S}!Lot[s" x="0" y="4475"> <mutation> <arg name="speed" varid="1X|m)*QO^oo}EfHf=nBO" argid="pePpK@*+w{Ry]Ltz(Z95"/> </mutation> @@ -825,7 +1013,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="IKFw+yZgK[}QgIvIQk]A" x="0" y="3634"> + <block type="procedures_defnoreturn" id="IKFw+yZgK[}QgIvIQk]A" x="0" y="4650"> <field name="NAME">ejectWhite</field> <statement name="STACK"> <block type="util_python" id="L9].u`N0?,H+tU)=o?Me" inline="true"> @@ -901,7 +1089,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="M^8-tj!Sv{KHcQSAS;$K" x="0" y="4011"> + <block type="procedures_defnoreturn" id="M^8-tj!Sv{KHcQSAS;$K" x="0" y="5027"> <field name="NAME">ejectRed</field> <statement name="STACK"> <block type="util_python" id="?:UCrMJUl%q(jYcN8(IE" inline="true"> @@ -977,7 +1165,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="YLSy9_KOy{GM#LBmqJ8x" x="0" y="4388"> + <block type="procedures_defnoreturn" id="YLSy9_KOy{GM#LBmqJ8x" x="0" y="5404"> <field name="NAME">ejectBlue</field> <statement name="STACK"> <block type="util_python" id="n-s%L0Ie7qkf@WU-[H8o" inline="true"> @@ -1053,7 +1241,7 @@ </block> </statement> </block> - <block type="procedures_defreturn" id="0.,m:~DVx{zBe-|XxpG-" x="0" y="4765"> + <block type="procedures_defreturn" id="0.,m:~DVx{zBe-|XxpG-" x="0" y="5781"> <field name="NAME">isColorSensorTriggered</field> <statement name="STACK"> <block type="util_python" id="23n|f!bBfO#m?@_HlHB}" inline="true"> @@ -1067,7 +1255,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="}*yI=aY}$^7875;e4Wo_" x="0" y="4901"> + <block type="procedures_defreturn" id="}*yI=aY}$^7875;e4Wo_" x="0" y="5917"> <field name="NAME">isEjectionTriggered</field> <statement name="STACK"> <block type="util_python" id="wrT1c1;%@kF-Riy28O;." inline="true"> @@ -1081,7 +1269,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="Fys9OK!K-FNH-W0o}@h," x="0" y="5037"> + <block type="procedures_defreturn" id="Fys9OK!K-FNH-W0o}@h," x="0" y="6053"> <field name="NAME">isWhite</field> <statement name="STACK"> <block type="util_python" id="h?(Tr@S1VYchJ5e6())[" inline="true"> @@ -1095,7 +1283,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="iE@eN47vK?la`*X4EQ-8" x="0" y="5173"> + <block type="procedures_defreturn" id="iE@eN47vK?la`*X4EQ-8" x="0" y="6189"> <field name="NAME">isRed</field> <statement name="STACK"> <block type="util_python" id="fN{]~9g]|*Kx,bpmy_i$" inline="true"> @@ -1109,7 +1297,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="w|KTmb#01-L]2ZG4mz)b" x="0" y="5309"> + <block type="procedures_defreturn" id="w|KTmb#01-L]2ZG4mz)b" x="0" y="6325"> <field name="NAME">isBlue</field> <statement name="STACK"> <block type="util_python" id="U(Y(8WN=vCJzgw~oLdbs" inline="true"> @@ -1123,7 +1311,7 @@ </block> </value> </block> - <block type="procedures_defreturn" id="$]uSxm9]*Qu3iZl~w~MW" x="0" y="5445"> + <block type="procedures_defreturn" id="$]uSxm9]*Qu3iZl~w~MW" x="0" y="6461"> <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 cff8ce1..7825af8 100644 --- a/lib/SLD.py +++ b/lib/SLD.py @@ -13,6 +13,9 @@ _active = None speed = None thresh_white_red = None thresh_red_blue = None +calibvalue_white = None +calibvalue_red = None +calibvalue_blue = None state_code = None state_active = None thresh_white_red_defaults = None @@ -25,18 +28,52 @@ 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 + global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 + global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch thresh_red_blue = v +def get_thresh_list(): + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + return [thresh_white_red, thresh_red_blue] + + +def calculate_thresh(): + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + thresh_white_red = (calibvalue_white + calibvalue_red) / 2 + thresh_red_blue = (calibvalue_red + calibvalue_blue) / 2 + + +def get_calibvalue_list(): + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + return [calibvalue_white, calibvalue_red, calibvalue_blue] + + +def set_calibvalue_white(v): + global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + calibvalue_white = v + + +def set_calibvalue_red(v): + global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + calibvalue_red = v + + +def set_calibvalue_blue(v): + global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch + calibvalue_blue = v + + def thread_SLD(): - 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch logging.log(logging.TRACE, '-') + calibvalue_white = 0 + calibvalue_red = 0 + calibvalue_blue = 0 thresh_white_red_defaults = 1150 thresh_white_red = thresh_white_red_defaults thresh_red_blue_defaults = 1600 @@ -89,26 +126,26 @@ def thread_SLD(): def get_calib_data_SLD_defaults(): - 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 _set_state_SLD(_code, _active): - 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 + global v, _data, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 @@ -117,26 +154,26 @@ def _set_state_SLD(_code, _active): def get_state_code_SLD(): - 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _data, _code, _active, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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) @@ -150,7 +187,7 @@ def ejectWhite(): def ejectRed(): - 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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) @@ -164,7 +201,7 @@ def ejectRed(): def ejectBlue(): - 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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) @@ -178,37 +215,37 @@ def ejectBlue(): def isColorSensorTriggered(): - 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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 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 + global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_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() -- GitLab