ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray
BrainModularBrainModular Users Forum2009-03-11T15:06:36+02:00https://brainmodular.org/forums/app.php/feed/topic/12282009-03-11T15:06:36+02:002009-03-11T15:06:36+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=7806#p7806 What I meant was: Avoid getting (and setting) parameter values more than once like in:
CODE:
IF ((GetValue(p1) = 1) OR (GetVaue(p2) = 1)) THEN BEGIN ... IF (GetValue(p1) = 1) THEN BEGIN ... IF (GetVaue(p2) = 1) THEN BEGIN ...
What I would have done, could look something like this:
CODE:
VAR b1, b2 : BOOLEAN;...b1 := (GetValue(p1) = 1);b2 := (GetValue(p2) = 1);IF (b1 OR b2) THEN BEGIN ... IF (b1) THEN BEGIN ... IF (b2) THEN BEGIN ...
Reducing the number of parameters isn't necessarily the best way of reducing CPU load - it's getting and setting the values (and of course the internal computations in the script) that eats the cycles. You can use different strategies; some are discussed in this topic: http://www.sensomusic.com/forums/viewtopic.php?id=1050, and there are also quite a few other threads where scripts and CPU are being discussed.
---
PS: Just noticed that once again I've made a bad typo. It should have been "...another variable or three". I guess a "variable of three" could be mistaken with the Multiple Variable module(?).
If you can avoid reading parameters, do that, even if it means you have to create another variable of three.
you mean reduce the input number ? i think about several technic to create variable of three but i am sure
-use of multiple variable module -multiply 2 button input value by 1 and 2 in order to distinguish their value at the script input ...
Statistics: Posted by pansoul — 11 Mar 2009, 13:02
]]>2009-03-11T04:08:13+02:002009-03-11T04:08:13+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=7804#p7804i added the setvalue(outputbutton,0) close at the begining thank you for all your remarks, it helps me to understand further forward the button (and by the way the switch) concept
Vincent
Statistics: Posted by pansoul — 11 Mar 2009, 03:08
]]>2009-03-10T22:57:52+02:002009-03-10T22:57:52+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=7796#p7796 If I have understood things correctly, Usine won't update an input parameter unless something is passed along the "wire", so if you return it to 0 within the script somewhere after checking for 1, you can be sure that the code isn't executed repeatedly. (The p in pButton is jus my habit when naming the in/out parameters.)
Just for the record, a "proper" button message in Usine is a 1 followed by a 0 in the next block. What you're doing with
is assigning two values to the same variable, so he last one overrides the first. What you should do is set the value to 1 at the bottom of the script (assuming that you do this within a IF-test or something like that), and then at the top set the value to 0 - maybe with a check whether the value is 1 and needs to be updated.
A very general tip: If you can avoid reading parameters, do that, even if it means you have to create another variable of three. In most case you can save some CPU, while also getting a more readable script.
]]>2009-03-10T22:20:13+02:002009-03-10T22:20:13+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=7794#p7794i dont really unsderstand the use of button in script. bsork, when you write IF (GetValue(pButton) = 1) THEN BEGIN ... // To be on the safe side, add: SetValue(pButton, 0); END;
i suppose the pButton you refer in GetValue(pButton) is an input button and the pButton of SetValue(pButton, 0) an outuput button. an i wrong ? if i am not, it means the output pButton have never be in the 1 position before come back in 0 position.
if i write inval := getvalue(inputbutton); setvalue(outputbutton,inval);
there is no problem, the output button follow the input one behaviour
but between this two moments i want to make a lot of things. I want to trig a button behaviour (1..0) on an output at the end of my script i tried to put at the end of my script that i suppose to be the last performed code (?) setvalue(outputbutton,1); setvalue(outputbutton,0);
but i can only see the 0 in the output.
anyone can help me or to point me out a script without input/output correlation ? thanks
Statistics: Posted by pansoul — 10 Mar 2009, 21:20
Statistics: Posted by woodslanding — 23 Dec 2008, 10:39
]]>2008-12-23T02:38:42+02:002008-12-23T02:38:42+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6661#p6661 Wouldn't something like this do the trick?
var ButtonPressed: boolean;
If getvalue(pButton)=1 then begin Setvalue(pButton, 0); ButtonPressed:=true; end;
You put this before your slow loop, then you can check the value of ButtonPressed inside the slow loop, without forgetting to do ButtonPressed:=false; before exiting your slow loop.
Hope it can help. Rgds,
B.
Statistics: Posted by bmoussay — 23 Dec 2008, 01:38
]]>2008-12-23T00:35:10+02:002008-12-23T00:35:10+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6660#p6660 I'd like to run my main methods in a slower event loop, but then I seem to miss the button presses. I tried to keep track of whether the button had been pressed since the last iteration of my slow loop, but I haven't figured out how to track that reliably.....
For now, I'm running at full control rate, but I worry a little about the processor overhead.....
Statistics: Posted by woodslanding — 22 Dec 2008, 23:35
]]>2008-12-22T13:32:38+02:002008-12-22T13:32:38+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6658#p6658 ... // To be on the safe side, add: SetValue(pButton, 0); END;
]]>2008-12-22T12:11:53+02:002008-12-22T12:11:53+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6657#p6657Statistics: Posted by woodslanding — 22 Dec 2008, 11:11
]]>
2008-12-22T12:11:02+02:002008-12-22T12:11:02+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6656#p6656 Can anyone explain how to do this, or point me to a script that does it. I just want to have the script do something when the user pushes a button connected to an input.
Thanks! -eric
Statistics: Posted by woodslanding — 22 Dec 2008, 11:11
]]>BrainModularBrainModular Users Forum2009-03-11T15:06:36+02:00https://brainmodular.org/forums/app.php/feed/topic/12282009-03-11T15:06:36+02:002009-03-11T15:06:36+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=7806#p7806 What I meant was: Avoid getting (and setting) parameter values more than once like in:
CODE:
IF ((GetValue(p1) = 1) OR (GetVaue(p2) = 1)) THEN BEGIN ... IF (GetValue(p1) = 1) THEN BEGIN ... IF (GetVaue(p2) = 1) THEN BEGIN ...
What I would have done, could look something like this:
CODE:
VAR b1, b2 : BOOLEAN;...b1 := (GetValue(p1) = 1);b2 := (GetValue(p2) = 1);IF (b1 OR b2) THEN BEGIN ... IF (b1) THEN BEGIN ... IF (b2) THEN BEGIN ...
Reducing the number of parameters isn't necessarily the best way of reducing CPU load - it's getting and setting the values (and of course the internal computations in the script) that eats the cycles. You can use different strategies; some are discussed in this topic: http://www.sensomusic.com/forums/viewtopic.php?id=1050, and there are also quite a few other threads where scripts and CPU are being discussed.
---
PS: Just noticed that once again I've made a bad typo. It should have been "...another variable or three". I guess a "variable of three" could be mistaken with the Multiple Variable module(?).
If you can avoid reading parameters, do that, even if it means you have to create another variable of three.
you mean reduce the input number ? i think about several technic to create variable of three but i am sure
-use of multiple variable module -multiply 2 button input value by 1 and 2 in order to distinguish their value at the script input ...
Statistics: Posted by pansoul — 11 Mar 2009, 13:02
]]>2009-03-11T04:08:13+02:002009-03-11T04:08:13+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=7804#p7804i added the setvalue(outputbutton,0) close at the begining thank you for all your remarks, it helps me to understand further forward the button (and by the way the switch) concept
Vincent
Statistics: Posted by pansoul — 11 Mar 2009, 03:08
]]>2009-03-10T22:57:52+02:002009-03-10T22:57:52+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=7796#p7796 If I have understood things correctly, Usine won't update an input parameter unless something is passed along the "wire", so if you return it to 0 within the script somewhere after checking for 1, you can be sure that the code isn't executed repeatedly. (The p in pButton is jus my habit when naming the in/out parameters.)
Just for the record, a "proper" button message in Usine is a 1 followed by a 0 in the next block. What you're doing with
is assigning two values to the same variable, so he last one overrides the first. What you should do is set the value to 1 at the bottom of the script (assuming that you do this within a IF-test or something like that), and then at the top set the value to 0 - maybe with a check whether the value is 1 and needs to be updated.
A very general tip: If you can avoid reading parameters, do that, even if it means you have to create another variable of three. In most case you can save some CPU, while also getting a more readable script.
]]>2009-03-10T22:20:13+02:002009-03-10T22:20:13+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=7794#p7794i dont really unsderstand the use of button in script. bsork, when you write IF (GetValue(pButton) = 1) THEN BEGIN ... // To be on the safe side, add: SetValue(pButton, 0); END;
i suppose the pButton you refer in GetValue(pButton) is an input button and the pButton of SetValue(pButton, 0) an outuput button. an i wrong ? if i am not, it means the output pButton have never be in the 1 position before come back in 0 position.
if i write inval := getvalue(inputbutton); setvalue(outputbutton,inval);
there is no problem, the output button follow the input one behaviour
but between this two moments i want to make a lot of things. I want to trig a button behaviour (1..0) on an output at the end of my script i tried to put at the end of my script that i suppose to be the last performed code (?) setvalue(outputbutton,1); setvalue(outputbutton,0);
but i can only see the 0 in the output.
anyone can help me or to point me out a script without input/output correlation ? thanks
Statistics: Posted by pansoul — 10 Mar 2009, 21:20
Statistics: Posted by woodslanding — 23 Dec 2008, 10:39
]]>2008-12-23T02:38:42+02:002008-12-23T02:38:42+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6661#p6661 Wouldn't something like this do the trick?
var ButtonPressed: boolean;
If getvalue(pButton)=1 then begin Setvalue(pButton, 0); ButtonPressed:=true; end;
You put this before your slow loop, then you can check the value of ButtonPressed inside the slow loop, without forgetting to do ButtonPressed:=false; before exiting your slow loop.
Hope it can help. Rgds,
B.
Statistics: Posted by bmoussay — 23 Dec 2008, 01:38
]]>2008-12-23T00:35:10+02:002008-12-23T00:35:10+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6660#p6660 I'd like to run my main methods in a slower event loop, but then I seem to miss the button presses. I tried to keep track of whether the button had been pressed since the last iteration of my slow loop, but I haven't figured out how to track that reliably.....
For now, I'm running at full control rate, but I worry a little about the processor overhead.....
Statistics: Posted by woodslanding — 22 Dec 2008, 23:35
]]>2008-12-22T13:32:38+02:002008-12-22T13:32:38+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6658#p6658 ... // To be on the safe side, add: SetValue(pButton, 0); END;
]]>2008-12-22T12:11:53+02:002008-12-22T12:11:53+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6657#p6657Statistics: Posted by woodslanding — 22 Dec 2008, 11:11
]]>2008-12-22T12:11:02+02:002008-12-22T12:11:02+02:00https://brainmodular.org/forums/viewtopic.php?t=1228&p=6656#p6656 Can anyone explain how to do this, or point me to a script that does it. I just want to have the script do something when the user pushes a button connected to an input.
Thanks! -eric
Statistics: Posted by woodslanding — 22 Dec 2008, 11:11