Results 81 to 90 of 90
Thread: SIOC "IF" Question
-
08-26-2010, 06:03 AM #81
Re: SIOC "IF" Question
Hi Nico,
What I mean is, I do not think the code achieves the following specs/requirements:
- If 0, LED is OFF
- If 1,2 LED is ON
- If 3, 4, 5 LED BLINKS
I want the LED to achieve the above. The script that you gave me, as far as I can see, does not achieve this. I used IOCPConsole to test. I think the problem lies within where it says Precip = 3, shouldn't it be Precip >= 3. Also, it says Precip = 1, shouldn't this be 1 OR 2? REF = 0 if Precip = 0 is correct.
Jack
-
08-26-2010, 06:39 AM #82
Re: SIOC "IF" Question
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 } ELSE { &REF = 1 } } ELSE { IF &precip >= 3 { 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 } } Var 9003, name REF, Link IOCARD_OUT, Output 93
-
08-26-2010, 01:27 PM #83
Re: SIOC "IF" Question
Hi Nico,
For the most parthat script works the only problem is the LED won't stop blinking if it is transition from 3/4/5 -> 0/1. No Worries, I have made some very small edits and I have finalised 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 if &Blinking = 1 { &Blinking = 0 &BlinkLed = 0 } } ELSE { IF &precip > 0 { IF &precip < 3 { &REF = 1 if &Blinking = 1 { &Blinking = 0 &BlinkLed = 1 } } ELSE { IF &precip >= 3 { 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 } } Var 9003, name REF, Link IOCARD_OUT, Output 93
-
08-26-2010, 01:34 PM #84
Re: SIOC "IF" Question
yes, in the IF &precip = 0 part, change
Code:&BlinkLed = 0
Code:&BlinkLed = 1
Nico
-
08-26-2010, 02:44 PM #85
Re: SIOC "IF" Question
Hi Nico,
I have purposely edited the &BlinkLED part. If Precip = 0, LED should be 0, not 1. If I edit it the script does work work properly how I'd like it to. In its currently state, all is good.
-
08-26-2010, 05:40 PM #86
Re: SIOC "IF" Question
??
The Led part is ok, my comment was about the blinking part in that piece of your script.
If you write this:
Code:if &Blinking = 1 { &Blinking = 0 &BlinkLed = 0 }
But if you want to stop the blinking you should write:
Code:if &Blinking = 1 { &Blinking = 0 &BlinkLed = 1 }
So "NOT all is good..".
Note: You cannot test the absence of errors, only the presence of errors....
That's why a good design is so important. Deering was leading you on that path ...
I now quit withy this topic.
Nico
-
08-26-2010, 05:56 PM #87
Re: SIOC "IF" Question
Hi Nico,
As I previously said, I did test all circumstances. If I switch from 3 to 0, the LED does exactly as I want it to (stop blinking, and REF = 0). This is my IOCPConsole Log:
Regardless of any "errors" the script does as I want it too. I tried changing it to this like you said:
Code:if &Blinking = 1 { &Blinking = 0 &BlinkLed = 1 }
Iunderstand what you are saying, what I posted is non-standard stop-code for blinking. However, if I change it to the above, like I said it does not work.
-
08-29-2010, 04:45 PM #88
Re: SIOC "IF" Question
Hi,
The Led does not "wrongfully" goes to 1, but "by design".... The BlinkLed Var was designed to stop blinking with value 1. That was because of the requirement that going from 3 to 2 it had to stop blinking but still be on. However, now another requirement pops up that it should be possible to go from 3 to 0 and the blinking has to stop with the led off.... These requirements are contradictive. Thats why you had to invent a "trick", so to speak
Programming with "tricks" is not a good idea, because if you look at your program one month or more later you have forgotton why you programmed it like that.
I have given this programming task some more thought over the weekend and I have come up with a completely new design. It's completely different from the previous one. I start a timer and let it run contineously...! (no need to stop it). In the variable controlled by the timer I check the precip value. Very robust and easy to understand:
Code:Var 0 Value 0 { &LedControl = 500000 // long enough ... &LedControl = TIMER 0 -1 40 } Var 9001 name &precip FSUIPC_IN Offset $C28D Length 1 Var 9002 name LedControl { IF &precip = 0 { &REF = 0 } ELSE { C0 = &precip = 1 C1 = &precip = 2 IF C0 OR C1 { &REF = 1 } ELSE { &REF = MOD &LedControl 2 } } } Var 9003 name &REF Link Output Number 93
Last edited by kiek; 08-29-2010 at 05:58 PM.
-
Post Thanks / Like - 1 Thanks, 0 Likes, 0 DislikesBoeing 747 Flyer thanked for this post
-
08-29-2010, 05:06 PM #89
- Join Date
- Apr 2009
- Location
- Toronto
- Posts
- 125
Re: SIOC "IF" Question
_________________________
-
08-29-2010, 05:34 PM #90
Re: SIOC "IF" Question
Thanks very much Nico, I will try that code very soon. I have studied it and I can understand the new design, definitely worth a try.
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
Find Prettys Womans in your town for night
Is it just me? - Upper ECAM...