Results 71 to 80 of 90
Thread: SIOC "IF" Question
-
08-22-2010, 01:25 PM #71
- Join Date
- Apr 2009
- Location
- Toronto
- Posts
- 125
Re: SIOC "IF" Question
___________________
-
08-22-2010, 01:35 PM #72
Re: SIOC "IF" Question
Meh. I tried.
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.
-
08-25-2010, 09:12 AM #73
Re: SIOC "IF" Question
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:
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 } }
-
08-25-2010, 12:32 PM #74
Re: SIOC "IF" Question
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 988 . 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
-
08-25-2010, 04:00 PM #75
Re: SIOC "IF" Question
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 } }
-
08-25-2010, 04:26 PM #76
Re: SIOC "IF" Question
Is precip ever 4 ? I assumed it is, otherwise I have to change the script
-
08-25-2010, 04:28 PM #77
-
08-25-2010, 05:18 PM #78
Re: SIOC "IF" Question
Okaty, try this script:
Code: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
-
08-25-2010, 05:33 PM #79
Re: SIOC "IF" Question
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
-
08-26-2010, 03:56 AM #80
Re: SIOC "IF" Question
Similar Threads
-
"Inner Circle" HSI - SIOC DC Motors Card Script
By Boeing 747 Flyer in forum OpenCockpits General DiscussionReplies: 64Last Post: 04-21-2011, 10:59 AM -
Looking for "Below GS" and "Spoilers armed" annunciator light offset
By PeterH in forum PM General Q & AReplies: 17Last Post: 03-05-2008, 12:39 PM -
A question for "Bus Drivers"
By mpl330 in forum General Builder Questions All Aircraft TypesReplies: 2Last Post: 01-31-2008, 06:56 PM -
PM updates and a question for "proof of concept"
By pap in forum PM General Q & AReplies: 4Last Post: 01-27-2008, 06:22 AM
Beautiful Girls in your city
HDG preselect function