NEWS
[Frage] Blockly zufällig im Zeitbereich
-
Danke., ändere ich.
Ich wollte eigentlich da wo ich den festen Intervall hab, was variables haben….
-
Gibt es sonst eine Möglichkeit nur mit Blockly einen zufälligen Zeitbereich zu erstellen?
Ich möchte dass nachts ein Licht 10 mal schaltet, aber jeweils im zufälligen Bereich von 0 bis 5 Minuten.
-
Gibt es sonst eine Möglichkeit nur mit Blockly einen zufälligen Zeitbereich zu erstellen?
Ich möchte dass nachts ein Licht 10 mal schaltet, aber jeweils im zufälligen Bereich von 0 bis 5 Minuten. `
Hallo lobomau
Nicht direkt. Leider läßt Blockly in vielen Bausteinen keine Variablen zu.
Aber vom Rücken, durch die Brust ins Auge könnte es gehen.
Auf die Schnelle fällt mir dazu folgende Möglichkeit ein.
Der Export:
! ````
<xml xmlns="http://www.w3.org/1999/xhtml"><block type="schedule" id="#q]X?XA6,T#oVG0~p2-k" x="-137" y="-162"><field name="SCHEDULE">/5 * * * * </field>
<statement name="STATEMENT"><block type="controls_if" id="SPb@1vaoX%#8}Ztk9|.{"><value name="IF0"><block type="logic_compare" id=")|KD~LFn0EfiYM^m@Nn"><field name="OP">NEQ</field>
<value name="A"><block type="variables_get" id="d71W,pX%pJ72;8{kfdS"><field name="VAR">TimerAktiv</field></block></value> <value name="B"><block type="logic_boolean" id="(%,AB0sDN!#y4ic_{VjS"><field name="BOOL">TRUE</field></block></value></block></value> <statement name="DO0"><block type="variables_set" id="}.-BM_s!1lz.V*hvU@AY"><field name="VAR">valZufall</field> <value name="VALUE"><block type="math_random_int" id="3Q/HHpL~EpbBr^HE~1df"><value name="FROM"><shadow type="math_number" id="A.LJ5W.UeB
qK(Tl2GvZ"><field name="NUM">1</field></shadow></value>
<value name="TO"><shadow type="math_number" id="T{/dDJqQ1%YlMESV9(Nv"><field name="NUM">3</field></shadow></value></block></value>
<next><block type="controls_if" id="kGg5uFcR8[gxXgSzVl5n"><mutation elseif="2"></mutation>
<value name="IF0"><block type="logic_compare" id="?nV9axQ.ztUS+?mvR:^v"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="eGQClh}yINaaminM]h@M"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="w)p6@Kl(M%rZZC2w[fk^"><field name="NUM">1</field></block></value></block></value>
<statement name="DO0"><block type="procedures_callnoreturn" id="K0BT]GJP:#6Le6RdwqF8"><mutation name="ZufallEins"></mutation></block></statement>
<value name="IF1"><block type="logic_compare" id="M0[QB+35R8YTEh=5Xge"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="(tpMntf[RTlhk6nXF#Xk"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="Nc.|J~M;eYEIWS|Q!J;l"><field name="NUM">2</field></block></value></block></value>
<statement name="DO1"><block type="procedures_callnoreturn" id="W87g2nl8jprwJXB]J[hw"><mutation name="ZufallZwei"></mutation></block></statement>
<value name="IF2"><block type="logic_compare" id="gj}gnPUy#/5aHdoBnr@"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="leS?FhGaeYN^U_eW=UC@"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="L+jsa(J@;}6M8Rr%a}Yd"><field name="NUM">3</field></block></value></block></value>
<statement name="DO2"><block type="procedures_callnoreturn" id="{;AN3#fKQQ0kBms}=oDy"><mutation name="ZufallDrei"></mutation></block></statement></block></next></block></statement></block></statement></block>
<block type="procedures_defnoreturn" id="]aih=G55?HS]7lpbvSc" x="538" y="-187"><field name="NAME">ZufallEins</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK"><block type="debug" id="m(8lX4Y:**J%J^9ti)M"><field name="Severity">log</field> <value name="TEXT"><shadow type="text" id="
7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow>
<block type="variables_get" id="y1Q1BFtS+I+?X!T;vdJ|"><field name="VAR">valZufall</field></block></value>
<next><block type="comment" id="UD8iI_FNE6Pa0}07og*["><field name="COMMENT">Schalte etwas ein</field>
<next><block type="variables_set" id="gc%||Eu?4a-GR[lV#V+9"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id=".f:;9;bHuW@Q8uTIM7cx"><field name="BOOL">TRUE</field></block></value>
<next><block type="timeouts_settimeout" id="KUky=Au9Hf42KvRsaZi"><field name="NAME">timeout</field>
<field name="DELAY">1000</field>
<statement name="STATEMENT"><block type="comment" id="!/W#E)^phCi/#d:rZ11M"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="45qLb@}f0E5vBYwGUs,H"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="M69l1/uK.(zT^%3mbA|@"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block>
<block type="procedures_defnoreturn" id="j6lr@jITsr]ms8yhUh0" x="538" y="63"><field name="NAME">ZufallZwei</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK"><block type="debug" id="Yj?[d2mz/jUbw6B@}i^w"><field name="Severity">log</field>
<value name="TEXT"><shadow type="text" id="7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow> <block type="variables_get" id=")6F1e[,wecN:0#OxtHo5"><field name="VAR">valZufall</field></block></value> <next><block type="comment" id="(K~gPu|WTF3rn%_]Wu|p"><field name="COMMENT">Schalte etwas ein</field> <next><block type="variables_set" id="{(kXy~N;Z
.QRt}vr3I"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="G6@Xxm=)a-dD[j{I=Yfv"><field name="BOOL">TRUE</field></block></value>
<next><block type="timeouts_settimeout" id="xefMj,DIwtkW2@Phw1Q"><field name="NAME">timeout2</field>
<field name="DELAY">2000</field>
<statement name="STATEMENT"><block type="comment" id="A[?425Oyazos+*y8;Y2:"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="W,)iWjtj;*J19I8rbs8"><field name="VAR">TimerAktiv</field> <value name="VALUE"><block type="logic_boolean" id="P=PZWs~Sdnb/7A_g1IMp"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block> <block type="procedures_defnoreturn" id=",%sXx)neL(hBuOH~l%%9" x="538" y="313"><field name="NAME">ZufallDrei</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> <statement name="STACK"><block type="debug" id="k}),=oVBLM[qL:1,0K=%"><field name="Severity">log</field> <value name="TEXT"><shadow type="text" id="
7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow>
<block type="variables_get" id="zY3NJB^6bk2C?gA/]Qa9"><field name="VAR">valZufall</field></block></value>
<next><block type="comment" id="|;jKXPh/w,O.!TE~)5y6"><field name="COMMENT">Schalte etwas ein</field>
<next><block type="variables_set" id="WDYnD=%[7Ot3b94P*cl"><field name="VAR">TimerAktiv</field> <value name="VALUE"><block type="logic_boolean" id="m{t-glCB~U:?~U6VhWvj"><field name="BOOL">TRUE</field></block></value> <next><block type="timeouts_settimeout" id="TX2ufws
26#AES|*Hmty"><field name="NAME">timeout3</field>
<field name="DELAY">3000</field>
<statement name="STATEMENT"><block type="comment" id=";6|h5I,9xy=NsXaK6Pv{"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="q7GtkJVZ!-R+JVdai^K("><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="p!%n^3t8Q}JFG!y8~NPI"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block></xml>Grüße EDIT: Die lokalen Variablem müssen vorher initialisiert werden!!! Sonst klappt es nicht.  Ist in dem Export NICHT enthalten.
-
Gibt es sonst eine Möglichkeit nur mit Blockly einen zufälligen Zeitbereich zu erstellen?
Ich möchte dass nachts ein Licht 10 mal schaltet, aber jeweils im zufälligen Bereich von 0 bis 5 Minuten. `
Hallo lobomau
Nicht direkt. Leider läßt Blockly in vielen Bausteinen keine Variablen zu.
Aber vom Rücken, durch die Brust ins Auge könnte es gehen.
Auf die Schnelle fällt mir dazu folgende Möglichkeit ein.
Blocky Zufall.png
Der Export:
! ````
<xml xmlns="http://www.w3.org/1999/xhtml"><block type="schedule" id="#q]X?XA6,T#oVG0~p2-k" x="-137" y="-162"><field name="SCHEDULE">/5 * * * * </field>
<statement name="STATEMENT"><block type="controls_if" id="SPb@1vaoX%#8}Ztk9|.{"><value name="IF0"><block type="logic_compare" id=")|KD~LFn0EfiYM^m@Nn"><field name="OP">NEQ</field>
<value name="A"><block type="variables_get" id="d71W,pX%pJ72;8{kfdS"><field name="VAR">TimerAktiv</field></block></value> <value name="B"><block type="logic_boolean" id="(%,AB0sDN!#y4ic_{VjS"><field name="BOOL">TRUE</field></block></value></block></value> <statement name="DO0"><block type="variables_set" id="}.-BM_s!1lz.V*hvU@AY"><field name="VAR">valZufall</field> <value name="VALUE"><block type="math_random_int" id="3Q/HHpL~EpbBr^HE~1df"><value name="FROM"><shadow type="math_number" id="A.LJ5W.UeB
qK(Tl2GvZ"><field name="NUM">1</field></shadow></value>
<value name="TO"><shadow type="math_number" id="T{/dDJqQ1%YlMESV9(Nv"><field name="NUM">3</field></shadow></value></block></value>
<next><block type="controls_if" id="kGg5uFcR8[gxXgSzVl5n"><mutation elseif="2"></mutation>
<value name="IF0"><block type="logic_compare" id="?nV9axQ.ztUS+?mvR:^v"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="eGQClh}yINaaminM]h@M"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="w)p6@Kl(M%rZZC2w[fk^"><field name="NUM">1</field></block></value></block></value>
<statement name="DO0"><block type="procedures_callnoreturn" id="K0BT]GJP:#6Le6RdwqF8"><mutation name="ZufallEins"></mutation></block></statement>
<value name="IF1"><block type="logic_compare" id="M0[QB+35R8YTEh=5Xge"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="(tpMntf[RTlhk6nXF#Xk"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="Nc.|J~M;eYEIWS|Q!J;l"><field name="NUM">2</field></block></value></block></value>
<statement name="DO1"><block type="procedures_callnoreturn" id="W87g2nl8jprwJXB]J[hw"><mutation name="ZufallZwei"></mutation></block></statement>
<value name="IF2"><block type="logic_compare" id="gj}gnPUy#/5aHdoBnr@"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="leS?FhGaeYN^U_eW=UC@"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="L+jsa(J@;}6M8Rr%a}Yd"><field name="NUM">3</field></block></value></block></value>
<statement name="DO2"><block type="procedures_callnoreturn" id="{;AN3#fKQQ0kBms}=oDy"><mutation name="ZufallDrei"></mutation></block></statement></block></next></block></statement></block></statement></block>
<block type="procedures_defnoreturn" id="]aih=G55?HS]7lpbvSc" x="538" y="-187"><field name="NAME">ZufallEins</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK"><block type="debug" id="m(8lX4Y:**J%J^9ti)M"><field name="Severity">log</field> <value name="TEXT"><shadow type="text" id="
7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow>
<block type="variables_get" id="y1Q1BFtS+I+?X!T;vdJ|"><field name="VAR">valZufall</field></block></value>
<next><block type="comment" id="UD8iI_FNE6Pa0}07og*["><field name="COMMENT">Schalte etwas ein</field>
<next><block type="variables_set" id="gc%||Eu?4a-GR[lV#V+9"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id=".f:;9;bHuW@Q8uTIM7cx"><field name="BOOL">TRUE</field></block></value>
<next><block type="timeouts_settimeout" id="KUky=Au9Hf42KvRsaZi"><field name="NAME">timeout</field>
<field name="DELAY">1000</field>
<statement name="STATEMENT"><block type="comment" id="!/W#E)^phCi/#d:rZ11M"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="45qLb@}f0E5vBYwGUs,H"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="M69l1/uK.(zT^%3mbA|@"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block>
<block type="procedures_defnoreturn" id="j6lr@jITsr]ms8yhUh0" x="538" y="63"><field name="NAME">ZufallZwei</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK"><block type="debug" id="Yj?[d2mz/jUbw6B@}i^w"><field name="Severity">log</field>
<value name="TEXT"><shadow type="text" id="7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow> <block type="variables_get" id=")6F1e[,wecN:0#OxtHo5"><field name="VAR">valZufall</field></block></value> <next><block type="comment" id="(K~gPu|WTF3rn%_]Wu|p"><field name="COMMENT">Schalte etwas ein</field> <next><block type="variables_set" id="{(kXy~N;Z
.QRt}vr3I"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="G6@Xxm=)a-dD[j{I=Yfv"><field name="BOOL">TRUE</field></block></value>
<next><block type="timeouts_settimeout" id="xefMj,DIwtkW2@Phw1Q"><field name="NAME">timeout2</field>
<field name="DELAY">2000</field>
<statement name="STATEMENT"><block type="comment" id="A[?425Oyazos+*y8;Y2:"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="W,)iWjtj;*J19I8rbs8"><field name="VAR">TimerAktiv</field> <value name="VALUE"><block type="logic_boolean" id="P=PZWs~Sdnb/7A_g1IMp"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block> <block type="procedures_defnoreturn" id=",%sXx)neL(hBuOH~l%%9" x="538" y="313"><field name="NAME">ZufallDrei</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> <statement name="STACK"><block type="debug" id="k}),=oVBLM[qL:1,0K=%"><field name="Severity">log</field> <value name="TEXT"><shadow type="text" id="
7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow>
<block type="variables_get" id="zY3NJB^6bk2C?gA/]Qa9"><field name="VAR">valZufall</field></block></value>
<next><block type="comment" id="|;jKXPh/w,O.!TE~)5y6"><field name="COMMENT">Schalte etwas ein</field>
<next><block type="variables_set" id="WDYnD=%[7Ot3b94P*cl"><field name="VAR">TimerAktiv</field> <value name="VALUE"><block type="logic_boolean" id="m{t-glCB~U:?~U6VhWvj"><field name="BOOL">TRUE</field></block></value> <next><block type="timeouts_settimeout" id="TX2ufws
26#AES|*Hmty"><field name="NAME">timeout3</field>
<field name="DELAY">3000</field>
<statement name="STATEMENT"><block type="comment" id=";6|h5I,9xy=NsXaK6Pv{"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="q7GtkJVZ!-R+JVdai^K("><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="p!%n^3t8Q}JFG!y8~NPI"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block></xml>Grüße `
Danke!
Der wichtige Hinweis war für mich, dass es unter Mathematik zufällige Zahlen gibt. Damit kann man sich dann was basteln.
EDIT: funktioniert gut dein Test-Script:
script.js.common.Übung: 2 javascript.1 2017-04-23 15:44:10.147 info script.js.common.Übung: 1 javascript.1 2017-04-23 15:44:05.146 info script.js.common.Übung: 3 javascript.1 2017-04-23 15:44:00.147 info script.js.common.Übung: 3 javascript.1 2017-04-23 15:43:55.147 info script.js.common.Übung: 2 javascript.1 2017-04-23 15:43:50.150 info script.js.common.Übung: 2 javascript.1 2017-04-23 15:43:45.147 info script.js.common.Übung: 3 javascript.1 2017-04-23 15:43:40.147 info script.js.common.Übung: 2 javascript.1 2017-04-23 15:43:35.146 info script.js.common.Übung: 2 javascript.1 2017-04-23 15:43:30.145 info script.js.common.Übung: 1 javascript.1 2017-04-23 15:43:25.148 info script.js.common.Übung: 1 javascript.1 2017-04-23 15:43:20.152 info script.js.common.Übung: 1
Wobei ich dachte dass ganzzahlige Zahl zwischen 1 und 3 immer 2 ist. Ist also eher als "größer gleich" zu verstehen und nicht "größer".
-
Wobei ich dachte dass ganzzahlige Zahl zwischen 1 und 3 immer 2 ist. Ist also eher als "größer gleich" zu verstehen und nicht "größer". `
Ja, ist eher wie bei den alten Zaubertricks "…sage mir eine Zahl von 1 bis 10..."
Grüße
-
Gibt es sonst eine Möglichkeit nur mit Blockly einen zufälligen Zeitbereich zu erstellen?
Ich möchte dass nachts ein Licht 10 mal schaltet, aber jeweils im zufälligen Bereich von 0 bis 5 Minuten. `
Hallo lobomau
Nicht direkt. Leider läßt Blockly in vielen Bausteinen keine Variablen zu.
Aber vom Rücken, durch die Brust ins Auge könnte es gehen.
Auf die Schnelle fällt mir dazu folgende Möglichkeit ein.
Blocky Zufall.png
Der Export:
! ````
<xml xmlns="http://www.w3.org/1999/xhtml"><block type="schedule" id="#q]X?XA6,T#oVG0~p2-k" x="-137" y="-162"><field name="SCHEDULE">/5 * * * * </field>
<statement name="STATEMENT"><block type="controls_if" id="SPb@1vaoX%#8}Ztk9|.{"><value name="IF0"><block type="logic_compare" id=")|KD~LFn0EfiYM^m@Nn"><field name="OP">NEQ</field>
<value name="A"><block type="variables_get" id="d71W,pX%pJ72;8{kfdS"><field name="VAR">TimerAktiv</field></block></value> <value name="B"><block type="logic_boolean" id="(%,AB0sDN!#y4ic_{VjS"><field name="BOOL">TRUE</field></block></value></block></value> <statement name="DO0"><block type="variables_set" id="}.-BM_s!1lz.V*hvU@AY"><field name="VAR">valZufall</field> <value name="VALUE"><block type="math_random_int" id="3Q/HHpL~EpbBr^HE~1df"><value name="FROM"><shadow type="math_number" id="A.LJ5W.UeB
qK(Tl2GvZ"><field name="NUM">1</field></shadow></value>
<value name="TO"><shadow type="math_number" id="T{/dDJqQ1%YlMESV9(Nv"><field name="NUM">3</field></shadow></value></block></value>
<next><block type="controls_if" id="kGg5uFcR8[gxXgSzVl5n"><mutation elseif="2"></mutation>
<value name="IF0"><block type="logic_compare" id="?nV9axQ.ztUS+?mvR:^v"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="eGQClh}yINaaminM]h@M"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="w)p6@Kl(M%rZZC2w[fk^"><field name="NUM">1</field></block></value></block></value>
<statement name="DO0"><block type="procedures_callnoreturn" id="K0BT]GJP:#6Le6RdwqF8"><mutation name="ZufallEins"></mutation></block></statement>
<value name="IF1"><block type="logic_compare" id="M0[QB+35R8YTEh=5Xge"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="(tpMntf[RTlhk6nXF#Xk"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="Nc.|J~M;eYEIWS|Q!J;l"><field name="NUM">2</field></block></value></block></value>
<statement name="DO1"><block type="procedures_callnoreturn" id="W87g2nl8jprwJXB]J[hw"><mutation name="ZufallZwei"></mutation></block></statement>
<value name="IF2"><block type="logic_compare" id="gj}gnPUy#/5aHdoBnr@"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="leS?FhGaeYN^U_eW=UC@"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="L+jsa(J@;}6M8Rr%a}Yd"><field name="NUM">3</field></block></value></block></value>
<statement name="DO2"><block type="procedures_callnoreturn" id="{;AN3#fKQQ0kBms}=oDy"><mutation name="ZufallDrei"></mutation></block></statement></block></next></block></statement></block></statement></block>
<block type="procedures_defnoreturn" id="]aih=G55?HS]7lpbvSc" x="538" y="-187"><field name="NAME">ZufallEins</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK"><block type="debug" id="m(8lX4Y:**J%J^9ti)M"><field name="Severity">log</field> <value name="TEXT"><shadow type="text" id="
7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow>
<block type="variables_get" id="y1Q1BFtS+I+?X!T;vdJ|"><field name="VAR">valZufall</field></block></value>
<next><block type="comment" id="UD8iI_FNE6Pa0}07og*["><field name="COMMENT">Schalte etwas ein</field>
<next><block type="variables_set" id="gc%||Eu?4a-GR[lV#V+9"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id=".f:;9;bHuW@Q8uTIM7cx"><field name="BOOL">TRUE</field></block></value>
<next><block type="timeouts_settimeout" id="KUky=Au9Hf42KvRsaZi"><field name="NAME">timeout</field>
<field name="DELAY">1000</field>
<statement name="STATEMENT"><block type="comment" id="!/W#E)^phCi/#d:rZ11M"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="45qLb@}f0E5vBYwGUs,H"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="M69l1/uK.(zT^%3mbA|@"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block>
<block type="procedures_defnoreturn" id="j6lr@jITsr]ms8yhUh0" x="538" y="63"><field name="NAME">ZufallZwei</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK"><block type="debug" id="Yj?[d2mz/jUbw6B@}i^w"><field name="Severity">log</field>
<value name="TEXT"><shadow type="text" id="7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow> <block type="variables_get" id=")6F1e[,wecN:0#OxtHo5"><field name="VAR">valZufall</field></block></value> <next><block type="comment" id="(K~gPu|WTF3rn%_]Wu|p"><field name="COMMENT">Schalte etwas ein</field> <next><block type="variables_set" id="{(kXy~N;Z
.QRt}vr3I"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="G6@Xxm=)a-dD[j{I=Yfv"><field name="BOOL">TRUE</field></block></value>
<next><block type="timeouts_settimeout" id="xefMj,DIwtkW2@Phw1Q"><field name="NAME">timeout2</field>
<field name="DELAY">2000</field>
<statement name="STATEMENT"><block type="comment" id="A[?425Oyazos+*y8;Y2:"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="W,)iWjtj;*J19I8rbs8"><field name="VAR">TimerAktiv</field> <value name="VALUE"><block type="logic_boolean" id="P=PZWs~Sdnb/7A_g1IMp"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block> <block type="procedures_defnoreturn" id=",%sXx)neL(hBuOH~l%%9" x="538" y="313"><field name="NAME">ZufallDrei</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> <statement name="STACK"><block type="debug" id="k}),=oVBLM[qL:1,0K=%"><field name="Severity">log</field> <value name="TEXT"><shadow type="text" id="
7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow>
<block type="variables_get" id="zY3NJB^6bk2C?gA/]Qa9"><field name="VAR">valZufall</field></block></value>
<next><block type="comment" id="|;jKXPh/w,O.!TE~)5y6"><field name="COMMENT">Schalte etwas ein</field>
<next><block type="variables_set" id="WDYnD=%[7Ot3b94P*cl"><field name="VAR">TimerAktiv</field> <value name="VALUE"><block type="logic_boolean" id="m{t-glCB~U:?~U6VhWvj"><field name="BOOL">TRUE</field></block></value> <next><block type="timeouts_settimeout" id="TX2ufws
26#AES|*Hmty"><field name="NAME">timeout3</field>
<field name="DELAY">3000</field>
<statement name="STATEMENT"><block type="comment" id=";6|h5I,9xy=NsXaK6Pv{"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="q7GtkJVZ!-R+JVdai^K("><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="p!%n^3t8Q}JFG!y8~NPI"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block></xml>Grüße `
Wozu ist TimerAktiv gut? Kann ich nicht weglassen und beim Trigger gleich mit "setze ValZufall" anfangen?
-
Wozu ist TimerAktiv gut? Kann ich nicht weglassen und beim Trigger gleich mit "setze ValZufall" anfangen? `
Probiere es doch einfach mal aus TimerAktiv wegzulassen.
Grüße
-
Wozu ist TimerAktiv gut? Kann ich nicht weglassen und beim Trigger gleich mit "setze ValZufall" anfangen? `
Probiere es doch einfach mal aus TimerAktiv wegzulassen.
Grüße `
Ja, geht auch ohneIch verstehe TimerAktiv also als nice-to-have, um z.B. bei längeren Zeitbereichen zu wissen, dass ein Timer aktiv ist.
Ich lasse es drin. Stört ja nicht. Oder gibt es noch einen anderen Grund dafür?
-
Ja, geht auch ohne
Ich verstehe TimerAktiv also als nice-to-have, um z.B. bei längeren Zeitbereichen zu wissen, dass ein Timer aktiv ist.
Ich lasse es drin. Stört ja nicht. Oder gibt es noch einen anderen Grund dafür? `
Augenscheinlich hast Du nicht richtig getestet.
Natürlich läuft das Script. Aber auch richtig?
Jedesmal wenn Du einen Timer startest, wird er ausgeführt OHNE den vorherigen zu stoppen.
Wenn man einen Timer häufig startest, kannst Du schnell 100derte Timer aktiv haben.
Und dann wird irgendwann das Licht 100derte mal ausgeschaltet.
Von der verschwendeten Rechnerleistung gar nicht zu reden.
TimerAktiv ist also etwas mehr als nice-to-have.
Grüße
-
Gibt es sonst eine Möglichkeit nur mit Blockly einen zufälligen Zeitbereich zu erstellen?
Ich möchte dass nachts ein Licht 10 mal schaltet, aber jeweils im zufälligen Bereich von 0 bis 5 Minuten. `
Hallo lobomau
Nicht direkt. Leider läßt Blockly in vielen Bausteinen keine Variablen zu.
Aber vom Rücken, durch die Brust ins Auge könnte es gehen.
Auf die Schnelle fällt mir dazu folgende Möglichkeit ein.
Blocky Zufall.png
Der Export:
! ````
<xml xmlns="http://www.w3.org/1999/xhtml"><block type="schedule" id="#q]X?XA6,T#oVG0~p2-k" x="-137" y="-162"><field name="SCHEDULE">/5 * * * * </field>
<statement name="STATEMENT"><block type="controls_if" id="SPb@1vaoX%#8}Ztk9|.{"><value name="IF0"><block type="logic_compare" id=")|KD~LFn0EfiYM^m@Nn"><field name="OP">NEQ</field>
<value name="A"><block type="variables_get" id="d71W,pX%pJ72;8{kfdS"><field name="VAR">TimerAktiv</field></block></value> <value name="B"><block type="logic_boolean" id="(%,AB0sDN!#y4ic_{VjS"><field name="BOOL">TRUE</field></block></value></block></value> <statement name="DO0"><block type="variables_set" id="}.-BM_s!1lz.V*hvU@AY"><field name="VAR">valZufall</field> <value name="VALUE"><block type="math_random_int" id="3Q/HHpL~EpbBr^HE~1df"><value name="FROM"><shadow type="math_number" id="A.LJ5W.UeB
qK(Tl2GvZ"><field name="NUM">1</field></shadow></value>
<value name="TO"><shadow type="math_number" id="T{/dDJqQ1%YlMESV9(Nv"><field name="NUM">3</field></shadow></value></block></value>
<next><block type="controls_if" id="kGg5uFcR8[gxXgSzVl5n"><mutation elseif="2"></mutation>
<value name="IF0"><block type="logic_compare" id="?nV9axQ.ztUS+?mvR:^v"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="eGQClh}yINaaminM]h@M"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="w)p6@Kl(M%rZZC2w[fk^"><field name="NUM">1</field></block></value></block></value>
<statement name="DO0"><block type="procedures_callnoreturn" id="K0BT]GJP:#6Le6RdwqF8"><mutation name="ZufallEins"></mutation></block></statement>
<value name="IF1"><block type="logic_compare" id="M0[QB+35R8YTEh=5Xge"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="(tpMntf[RTlhk6nXF#Xk"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="Nc.|J~M;eYEIWS|Q!J;l"><field name="NUM">2</field></block></value></block></value>
<statement name="DO1"><block type="procedures_callnoreturn" id="W87g2nl8jprwJXB]J[hw"><mutation name="ZufallZwei"></mutation></block></statement>
<value name="IF2"><block type="logic_compare" id="gj}gnPUy#/5aHdoBnr@"><field name="OP">EQ</field>
<value name="A"><block type="variables_get" id="leS?FhGaeYN^U_eW=UC@"><field name="VAR">valZufall</field></block></value>
<value name="B"><block type="math_number" id="L+jsa(J@;}6M8Rr%a}Yd"><field name="NUM">3</field></block></value></block></value>
<statement name="DO2"><block type="procedures_callnoreturn" id="{;AN3#fKQQ0kBms}=oDy"><mutation name="ZufallDrei"></mutation></block></statement></block></next></block></statement></block></statement></block>
<block type="procedures_defnoreturn" id="]aih=G55?HS]7lpbvSc" x="538" y="-187"><field name="NAME">ZufallEins</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK"><block type="debug" id="m(8lX4Y:**J%J^9ti)M"><field name="Severity">log</field> <value name="TEXT"><shadow type="text" id="
7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow>
<block type="variables_get" id="y1Q1BFtS+I+?X!T;vdJ|"><field name="VAR">valZufall</field></block></value>
<next><block type="comment" id="UD8iI_FNE6Pa0}07og*["><field name="COMMENT">Schalte etwas ein</field>
<next><block type="variables_set" id="gc%||Eu?4a-GR[lV#V+9"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id=".f:;9;bHuW@Q8uTIM7cx"><field name="BOOL">TRUE</field></block></value>
<next><block type="timeouts_settimeout" id="KUky=Au9Hf42KvRsaZi"><field name="NAME">timeout</field>
<field name="DELAY">1000</field>
<statement name="STATEMENT"><block type="comment" id="!/W#E)^phCi/#d:rZ11M"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="45qLb@}f0E5vBYwGUs,H"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="M69l1/uK.(zT^%3mbA|@"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block>
<block type="procedures_defnoreturn" id="j6lr@jITsr]ms8yhUh0" x="538" y="63"><field name="NAME">ZufallZwei</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK"><block type="debug" id="Yj?[d2mz/jUbw6B@}i^w"><field name="Severity">log</field>
<value name="TEXT"><shadow type="text" id="7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow> <block type="variables_get" id=")6F1e[,wecN:0#OxtHo5"><field name="VAR">valZufall</field></block></value> <next><block type="comment" id="(K~gPu|WTF3rn%_]Wu|p"><field name="COMMENT">Schalte etwas ein</field> <next><block type="variables_set" id="{(kXy~N;Z
.QRt}vr3I"><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="G6@Xxm=)a-dD[j{I=Yfv"><field name="BOOL">TRUE</field></block></value>
<next><block type="timeouts_settimeout" id="xefMj,DIwtkW2@Phw1Q"><field name="NAME">timeout2</field>
<field name="DELAY">2000</field>
<statement name="STATEMENT"><block type="comment" id="A[?425Oyazos+*y8;Y2:"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="W,)iWjtj;*J19I8rbs8"><field name="VAR">TimerAktiv</field> <value name="VALUE"><block type="logic_boolean" id="P=PZWs~Sdnb/7A_g1IMp"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block> <block type="procedures_defnoreturn" id=",%sXx)neL(hBuOH~l%%9" x="538" y="313"><field name="NAME">ZufallDrei</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> <statement name="STACK"><block type="debug" id="k}),=oVBLM[qL:1,0K=%"><field name="Severity">log</field> <value name="TEXT"><shadow type="text" id="
7k{/9%WdRZg%WaMby}Z"><field name="TEXT">5 Min</field></shadow>
<block type="variables_get" id="zY3NJB^6bk2C?gA/]Qa9"><field name="VAR">valZufall</field></block></value>
<next><block type="comment" id="|;jKXPh/w,O.!TE~)5y6"><field name="COMMENT">Schalte etwas ein</field>
<next><block type="variables_set" id="WDYnD=%[7Ot3b94P*cl"><field name="VAR">TimerAktiv</field> <value name="VALUE"><block type="logic_boolean" id="m{t-glCB~U:?~U6VhWvj"><field name="BOOL">TRUE</field></block></value> <next><block type="timeouts_settimeout" id="TX2ufws
26#AES|*Hmty"><field name="NAME">timeout3</field>
<field name="DELAY">3000</field>
<statement name="STATEMENT"><block type="comment" id=";6|h5I,9xy=NsXaK6Pv{"><field name="COMMENT">Schalte etwas wieder aus</field>
<next><block type="variables_set" id="q7GtkJVZ!-R+JVdai^K("><field name="VAR">TimerAktiv</field>
<value name="VALUE"><block type="logic_boolean" id="p!%n^3t8Q}JFG!y8~NPI"><field name="BOOL">FALSE</field></block></value></block></next></block></statement></block></next></block></next></block></next></block></statement></block></xml>Grüße `
Für noch mehr Schaltungen füge ich einfach noch mehr Zufallszahlen ein.
Ich brauche ja für jedes Komado eine Zahl, oder?
also Lampe 1 an = Zufall 1
und Lampe 1 aus = Zufall 2
usw.
-
Ich brauche ja für jedes Komado eine Zahl, oder?
also Lampe 1 an = Zufall 1
und Lampe 1 aus = Zufall 2
usw. `
In dem Beispiel wird jeweils ein Timer gestartet. Darin wird das jeweilige Gerät wieder ausgeschaltet (s. Komentare).Man kann es aber so machen wie Du es beschreibst.
Grüße
-
OK hatte ich auch erst so verstanden aber bei meiner probe, wurde die Lichter nie ausgeschaltet.
-
Du hast ja auch den Aufruf der Funktionen "ZufallEins","ZufallZwei"….. raus genommen.
Das Ein-,Ausschalten soll in den Funktionen stattfinden.
Da wo die Kommentare "Schalte etwas ein" und innerhalb der Timer "Schalte etwas aus".
Grüße
-
ups, da hab ich wohl was flasch verstanden…
Also ist der Timer oben Links für den Interwall der Zufallszahlen und die Timeout in den Funktionen sind für die Auschaltzeit.?
-
Also ist der Timer oben Links für den Interwall der Zufallszahlen und die Timeout in den Funktionen sind für die Auschaltzeit.? `
"oben LInks" ist kein Timer.
Oder meinst Du den Trigger?
-
Ja meinte den Trigger muss die Begriffe besser beachten .
-
Nur noch mal zum Verständniss:
Ich starte den Script und nach Ablauf des Triggers geht der erste Block los, er guckt kein Timer aktiv also Zufallszahl 1-3 an
z.B. Funktionsblock 1 wird ausgewählt und Licht angeschaltet für Timeout von XX Minuten. Nach dem auschalten wird der Timer wieder auf unwahr gesetzt und der erste Block startet wieder nach Ablauf des Triggers?
Ist es dann nicht so das immer nur 1 Licht leuchtet und nie mal mehrere? Weil es wird ja immer nur nach Ablauf des Timers neugestartet, oder?
-
Hallo Belei
Das Blockly ist nur ein Beispiel, wie man so etwas lösen könnte.
Das ist keine fertige Vorlage oder Anwendung!
Wie viele Geräte Du in einer Zufalls-Funktion ein-/ausschaltest liegt in Deinem Ermessen.
Du kannst auch für jede Funktion einen eigenen Flag für "TimerAktiv" anlegen.
TimerAktivEins, TimerAktivZwei usw. usw.
"TimerAktivXXX" soll verhindern, dass ein Timer mehrmals gestartet wird!
Grüße
-
So? oder klappt das nicht mit den oders?
-
Ne, so wird das nicht klappen.
Das Programm wird laufen, aber die Timer können mehrmals gestartet werden.
Wenn Du einen Export bereitgestellt hättest, hätte ich Dir das umbauen können.
Ich versuche es mal mit Worten.
Das äußere "Falls" müsste weg.
Setze "valZufall" müsste der erste Block im Trigger werden.
Dann jeweils "Falls valZufall = 1
mache Falls TimerAktiv1 = unwahr
mache ZufallEins
sonst Falls valZufall = 2
mache Falls TimerAktiv2 = unwahr
mache ZufallZwei
usw. usw…...