Hi,
Jim is right, boolean algebra rules dictates that, read more about that here:
http://en.wikipedia.org/wiki/Introdu...oolean_algebra
Nico
Printable View
Hi,
Jim is right, boolean algebra rules dictates that, read more about that here:
http://en.wikipedia.org/wiki/Introdu...oolean_algebra
Nico
Hi Jim,
Is it possible to have a SIOC IF statement without an ELSE statement? This is because, earlier in the script, I have said ELSE &REF=0. So, is there reall a need to repeat the ELSE statement? It just causes unwatned difficulties.
________________________________
Hiya Jim,
Thanks for that post. I have made an amendment to mr original script, look below:
I want this code to achieve the following:Code:Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED
Var 7002, name OP, Link IOCARD_OUT, Output 5 // OP LED
Var 9991, name OPSW, Link IOCARD_SW, Input 29, Type I // OP SW
Var 8881, name REFSW, Link IOCARD_SW, Input 28, Type I // REF SW
Var 9090, name Chain5, Link IOCARD_SW, Input 20 // Chain 5 Selector
Var 7890, name Chain4, Link IOCARD_SW, Input 26 // Chain 4 Selector
Var 7665, name Chain3, Link IOCARD_SW, Input 25 // Chain 3 Selector
Var 7605, name Chain2, Link IOCARD_SW, Input 24 // Chain 2 Selector
Var 7645, name Chain1, Link IOCARD_SW, Input 23 // Chain 1 Selector
Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
C0 = V9991 = 1
C1 = V8881 = 1
IF C0 OR C1
{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 <= 3 // First sector
{
IF L0 > 0
{
IF &Chain1 = 1
{
&REF = 1
}
IF L0 > 3
{
&REF = 0 OR 1
&BlinkLed = 500000
&BlinkLed = TIMER 0 -1 40
ELSE
{
&REF = 0
}
}
}
}
}
Var 9077, name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 0 OR 1
}
}
}
- LED ONLY Lights if Precipitation is 1-3
- LED ONLY Blinks if Precipitation is MORE than 3
- LED stops blinking if turbulence drops below three
- LED is OFF if there is no Turbulence (=0)
Does my script achieve this? I think yes to all of them, with the exception of the second to last requirement (stop code).
Jack,
Just a tip to help you:
Make sure you indent each line properly. Your scripts are very hard to read because you do not adhere to normal programming practices.
Use a fixed number of spaces to indent each block, do not use tabs. Normally one uses 2 or 4 spaces to indent a block, like this:
rgrds,Code:IF condition
{
IF condition // two spaces at the beginning of this line, because this is the first block
{
statement // 4 spaces at the beginning of this line because this is a block within a block
}
ELSE
{
statement
}
}
Nico
___________________________
Hi Nico,
Yes you are correct, I have made a few tweaks to my script and have noticed that the brackets were messy.
In other news...
I have tried the following SIOC script, and absolutely nothing happens in IOCPConsole Log, whatever the Turbulence is set to. Any ideas?
EDIT: Jim, the script compiles fine here. Also, please note the one included in THIS post is the latest version, not post #45. I will still do as you ask though, it will probably help.Code:Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED
Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 <= 3 // First sector
{
IF L0 > 0
{
&REF = 1
}
IF L0 > 3
{
&REF = 0
&BlinkLed = 500000
&BlinkLed = TIMER 0 -1 40
ELSE
{
&REF = 0
}
}
}
}
Var 9077, name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 0
}
}
Hi Jim,
It may not be correct, but at least I've had a go.
I've produced those three different scripts you asked for, here:
Code:Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
Var 222
{
IF v9888 >= 3
{
&REF = 0
&BlinkLed = 500000 // Begin value of timer
&BlinkLed = TIMER 0 -1 40
}
}
Var 333 name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 1
}
}
Var 13 name REF Link IOCARD_OUT Output 93
//
Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
Var 222
{
IF v9888 <= 3
{
&REF = 1
{
&BlinkLed = 1 // equal to end value of timer (0) + 1
}
}
}
Var 13 name REF Link IOCARD_OUT Output 93
//
Var 222
{
IF v9888 = 0
{
&REF = 0
}
}
____________________________
Code:{
IF v9888 >= 3
{
&REF = 0
&BlinkLed = 500000 // Begin value of timer
&BlinkLed = TIMER 0 -1 40
}
}
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 1
}
__________________________________
Code:Var 222
{
IF v9888 >= 3
{
&REF = 0
&BlinkLed = 500000 // Begin value of timer
&BlinkLed = TIMER 0 -1 40
}
}
Var 333 name BlinkLed
//
Var 222
{
IF v9888 <= 3
{
&REF = 1
{
&BlinkLed = 1 // equal to end value of timer (0) + 1
}
}
}
//
Var 222
{
IF v9888 = 0
{
&REF = 0
}
}
_______________________________
Code:{
IF v9888 >= 3
{
&REF = 0
&BlinkLed = 500000 // Begin value of timer
&BlinkLed = TIMER 0 -1 40
}
}
//
{
IF v9888 <= 3
{
&REF = 1
{
&BlinkLed = 1 // equal to end value of timer (0) + 1
}
}
}
//
{
IF v9888 = 0
{
&REF = 0
}
}
____________________________________
Is this what you wanted Jim?Code:IF v9888 >= 3
{
&REF = 0
&BlinkLed = 500000 // Begin value of timer
&BlinkLed = TIMER 0 -1 40
}
IF v9888 < 3
{
&REF = 1
&BlinkLed = 1
}
IF v9888 = 0
{
&REF = 0
}
_________________________________
Hi Jim,
I *think* that meets my requirements. Could you just confirm?
Everything looks okay from here, timer starts if it's more than 3, stops if less than 3 & lights, off if 0. Looks good.
_____________________________
Hi Jim,
As far as I can see, that script looks good to me. Have I made an error? I cannot see anything visually wrong.
EDIT: This post was edited, for reasons explained TWICE above. Here is one of these examples:
http://i822.photobucket.com/albums/z...uspheric/g.jpg
Also highlighted is my clear willingness to MOVE ON with this thread. I'm not bothered if I messed up that script. I just want to continue.
Jack
"Any ideas?"
Yes, give Jim the courtesy of a proper reply to his last post - his investement deserves this.
David
EDIT 22/08/2010 12:53 - Since Jack has now severely edited his original post #61 (without direct indication), this reply makes little sense, but is left in to "keep the gist of the thread"
_____________________________________
WAG?
I am, yet again, sorry for trying.Quote:
Jack
"Any ideas?"
Yes, give Jim the courtesy of a proper reply to his last post - his investement deserves this.
David
It's hard you know when you're on a very very very tight time schedule?:shock:
I am trying to follow your path Jim, but I'm wondering what is next?
The script does accurately reflect what I want, as far as I can see.
Jack
Do not apologise for trying. I recall when HSBC took over Midland Bank, the comment was made how they (Midland) could invest so much time correcting things rather than investing in getting it right first time - I was a little hurt, but learnt the value of that statement.
Sacrificing a little haste to gain a good foundation for the future is not a failure. Jim is giving you sound advice, please persevere, assuming that you wish too
Regards
David
____________________________
There sure is Jim;).
I was actually very interested in following your route. We got to post #61 before the "attacks" began. I did actually answer your question in that post, I just added a bit of my own experiemtnation. I have now deleted all associated text, just leaving my reply for your previous post.
I would like it if the last six posts were to be forgotten and to continue on this journey.
_____________________________
I have NOT rewritten anything with my edits. Unfortunately, it seems you haven't been reading the reasons WHY I edited SOME of my posts. Hmmm... You, not reading? Isn't that ironic...:rolleyes:
"Careful desk-checking" you say... I think you just ate your own words.
In other words, I am sorry for running ahead. If you still want to showcase your method I will be happy to follow it.
___________________
Meh. I tried:roll:.
I really boils my water when people act like you have throughout this thread. Please do not repeat this pathetic behaviour again.
If I were a teacher, I would applaud a student's enthuasiasm. You have done the complete opposite; which, quite frankly, is disgusting.
If anyone's interested, I finally figured out how to do it.
Through use of a Subroutine as a "checker", at 12:15AM last night all pulled through:).
Script:
Nico Kaan has also suggested another method for me to use. I am currently experimenting with both to see which is the more efficient.Code:Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
IF v9888 >= 3
{
&REF = 0
&BlinkLed = 500000 // Begin value of timer
&BlinkLed = TIMER 0 -1 40
}
}
Var 9891, name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 1
}
}
Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED
{
IF &REF = 0
{
CALL &PRECIPTEST
}
}
Var 9105, name PRECIPSET, Link SUBRUTINE
{
IF v9888 > 0
{
IF v9888 < 3 // YEH
{
&REF = 1
}
}
}
Var 9887, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
IF v9887 < 3
{
&BlinkLed = 1 // equal to end value of timer (0) + 1
&REF = 1
}
}
Var 9886, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
IF v9886 = 0
{
&REF = 0
}
}
Hi Jack,
Just a few tips, to help you. In my (humble) opinion there are several things "wrong" with your script:
* You defined three variables linked to the same FSUIPC offset, which is not efficient and can lead to "race-conditions". E.g. if the FSUIPC offset becomes 0, Var 9887 is executed and &REF will be set to 1, while "concurrently" Var 9886 is executed and that code will try to set &REF to 0 ..... It is just because you have defined Var 9887 just before Var 9886 that it this time works, but if Opencockpits changes the order of evaluation from forwards to backwards your in trouble ... So never program like this. Always put all sioc code related to a FSUIPC offset in one Variable.
* It is also bad programming practice to attach sioc code to an output definition (Var 7675). If one writes to an output one assumes it will go to the output, not that an attached sioc statement changes the value that you just wrote .... E.g I write 0 to that output, but due to the CALL to PRECIPTEST it might be overwritten by the value 1... (UGLY ;-) )
* If precip becomes 3 you start a timer (in Var 9888) . However, if precip becomes 4 you start another timer, (same with 5, and so on). This is not efficient and the outcome becomes undefined.
Maybe it is better to move over to my code: :-)
Note that it is important keep status of whether the led is already blinking because you have to take into account whether you are going up or down in precip value ...
Code:Var 9000 name blinking value 0 // 0 or 1 (blinking)
Var 9001 name precip link FSUIPC_IN offset $C28D length 1
{
IF &precip = 0
{
&REF = 0
}
ELSE
{
C0 = &precip = 1
C1 = &precip = 2
IF C0 OR C1
{
&REF = 1
}
ELSE
{
IF &precip = 3
{
if &blinking = 1
{
&blinking = 0
&blinkLed = 1 // coming from 4, stop blinking
}
ELSE
{
&REF = 1 // coming from 2, keep led on ...
}
}
ELSE
{
if &blinking = 0
{
&blinking = 1
&blinkLed = 500000
&blinkLed = TIMER 0 -1 40
}
}
}
}
}
Var 9002 name blinkLed
{
// make sure that blinking stops with led = On,
// end value of TIMER has to be even.
L0 = MOD &Blinkled 2
IF L0 = 0
{
&REF = 1
}
ELSE
{
&REF = 0
}
}
Var 9003 name REF Link IOCARD_OUT Output 93
Hi Nico,
Not sure what I've done wrong, but I can't get your script to work. Basically, the LED goes ON and OFF as it should, but never BLINKS. I think this lies within Var "Blinking". The LED will only blink if this Var is =1, but I don't know how it becomes =1?
Script:
Code:Var 9003, name REF, Link IOCARD_OUT, Output 93
Var 9000, name Blinking, Value 0 // 0 or 1 (Blinking)
Var 9001, name precip, link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
IF &Precip = 0
{
&REF = 0
}
ELSE
{
C0 = &Precip = 1
C1 = &Precip = 2
IF C0 OR C1
{
&REF = 1
}
ELSE
{
IF &Precip >= 3
{
if &Blinking = 1
{
&Blinking = 0
&BlinkLed = 1 // coming from 4, stop blinking
}
ELSE
{
&REF = 1 // coming from 2, keep led on ...
}
}
ELSE
{
if &blinking = 0
{
&Blinking = 1
&BlinkLed = 500000
&BlinkLed = TIMER 0 -1 40
}
}
}
}
}
Var 9002, name BlinkLed
{
L0 = MOD &Blinkled 2
IF L0 = 0
{
&REF = 1
}
ELSE
{
&REF = 0
}
}
Is precip ever 4 ? I assumed it is, otherwise I have to change the script
Okaty, try this script:
NicoCode:Var 9000, name Blinking, Value 0 // 0 or 1 (Blinking)
Var 9001, name precip, link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
IF &precip = 0
{
&REF = 0
}
ELSE
{
IF &precip = 1
{
&REF = 1
}
ELSE
{
If &precip = 2
{
if &Blinking = 1
{
&Blinking = 0
&BlinkLed = 1 // coming from 3, stop blinking
}
}
ELSE
{
IF &precip = 3
{
IF &blinking = 0 // coming from 2
{
&Blinking = 1
&BlinkLed = 500000
&BlinkLed = TIMER 0 -1 40
}
}
}
}
}
}
Var 9002, name BlinkLed
{
L0 = MOD &Blinkled 2
IF L0 = 0
{
&REF = 1
}
ELSE
{
&REF = 0
}
}
Var 9003, name REF, Link IOCARD_OUT, Output 93
Hi Nico,
I am facing similar problems. Basically, I've had a look at the Script, and I (think) there are some errors:
- If 0, LED is OFF
- If 1,2 LED is ON
- If 3, 4, 5 LED BLINKS
I think there are parts of the code which do not achieve this?
Thanks very much,
Jack:D