PDA

View Full Version : SIOC "IF" Question



Boeing 747 Flyer
08-08-2010, 05:31 PM
Hiya everyone,

Quick SIOC Question here:

If I want to have two "IFs" in a scipt (ie only light LED 5 if switch 1 is ON AND switch 2 is ON) how would I do it?

as always, I had a little try... But it doesn't work. The problem lies obvious in line 9:


Var 9888, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate
{
L0 = V9888 // FSUIPC L0 = v9888
L0 = ABS L0 // L0 not signed
L2 = L0
IF L0 >= 3 // First sector
{
&Chain1 = 1 // 1 selected
{
&REF = 1
}
}
ELSE // Is a greater value
{
&REF = 0 // Off
}
}

Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED

Var 7645, name Chain1, Link IOCARD_SW, Input 23

Could someone please tell me how to do it?

Cheers,

Jack:D

fordgt40
08-09-2010, 04:39 AM
Jack

But you do not have 2 IF`s in your attempt. There are two ways in SIOC to make something happen on the value of two variables

IF Variable one = 1
{
IF Variable two = 1
{
LED = 1
}
}

OR

C0 = variable 1
C1 = variable 2
IF C0 AND C1
{
LED = 1
}


David

pdpo
08-09-2010, 05:22 AM
Hi all,

Davids first suggestion will work and is a good way to do it.
Suggestion 2 is ever better but be carefull with it , I would write it like this to be more clear

C0 = variable one = 1
C1 = variable two = 1
IF C0 AND C1
{
LED = 1
}

so when variable one equals 1 the C0 will become one, same for C1, then the AND function will see that both C0 and C1 are true (1) and if thats the case the led will turn on

Greetings Peter

Boeing 747 Flyer
08-09-2010, 07:47 AM
Very sorry Lads, I figured this out for myself but not before I switched of the PC last night!

Thanks for your suggestions anyway, especially suggestion 2 as it looks interesting.

However! Please don't disregard this thread, I am designing a SIoc script and I'd like to ask (once complete) if it achieves what i want it to do.

Jack:)

colt45
08-09-2010, 07:48 AM
I am far from an expert on SIOC as I am just starting to use it with IOCards but shouldn't the last line not have the ampersand (ie. the & symbol) removed so that it reads

Var 7645, name Chain1, Link IOCARD_SW, Input 23

Cheers, Dave

Boeing 747 Flyer
08-09-2010, 10:50 AM
Hi Dave,

that's correct, but the symbol is no logner there (it was removed when I figured out the IF ELSE constructs).

Okay, I now need you guys to do another favour for me. I have engineered my own weather radar system using SIOC and FSUIPC Offsets. The System is designed to work with an IOCard interafced "DECCA" Panel. You won't understand unless you see a photo of the panel:

http://i822.photobucket.com/albums/zz146/Stratuspheric/100_0118.jpg

Before you read the script, note the following:

- The "LI" (Lights) Switch is NOT interfaced

- The "Chain" (Rotary) Switch has numbers running from 1-5

- The "OFF/REF/OP" Switch is a three-way rotary switch, with OFF position not being wired (so just 2 terminals wired)

- REF (Orange) and OP (Green) Are two LEDs

- This has come from a real aircraft

I would like the SIOC Script to do the following:

- If Precipitation Rate is more than 3, REF Light illumnates

- If Turbulence Rate is more than 3, OP Light Illuminates

- REF Light ONLY illuminates if the above condition is met and the Knob is set to "REF" or "OP"

- OP Light ONLY illuminates if the above condition is met and the Knob is set to "OP"

- The "Chain" Knob controls the cloud level. For example, if it is turned to 2, precipitation and turbulence reports will ONLY be given for cloud level 2 (this is controlled using appropriate Offsets)

- If the Mode Knob is set to OFF, then nothing happens (nothing lights up)

Thanks for reading, and please tell me if the script will do what I want:


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 $CE8D, Length 4 // Cloud Precipitation Rate (1)
{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 >= 3 // First sector
{
IF &Chain1 = 1 // 1 selected
{
IF &REFSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

Var 9889, Link FSUIPC_IN, Offset $CE9D, Length 4 // Cloud Precipitation Rate (2)

{
L0 = V9889 // FSUIPC L0 = v9889
IF L0 >= 3 // First sector
{
IF &Chain2 = 1 // 1 selected
{
IF &REFSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

Var 9819, Link FSUIPC_IN, Offset $CEAD, Length 4 // Cloud Precipitation Rate (3)

{
L0 = V9819 // FSUIPC L0 = v9819
IF L0 >= 3 // First sector
{
IF &Chain3 = 1 // 1 selected
{
IF &REFSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

Var 9829, Link FSUIPC_IN, Offset $CEBD, Length 4 // Cloud Precipitation Rate (4)

{
L0 = V9829 // FSUIPC L0 = v9829
IF L0 >= 3 // First sector
{
IF &Chain4 = 1 // 1 selected
{
IF &REFSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

Var 3829, Link FSUIPC_IN, Offset $CECD, Length 4 // Cloud Precipitation Rate (5)

{
L0 = V3829 // FSUIPC L0 = v3829
IF L0 >= 3 // First sector
{
IF &Chain5 = 1 // 1 selected
{
IF &REFSW = 1
{
&REF = 1
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}
}

Var 1746, Link FSUIPC_IN, Offset $CE88, Length 4 // Cloud Turbulence Rate (1)

{
L0 = V1746 // FSUIPC L0 = v1746
IF L0 >= 3 // First sector
{
IF &Chain1 = 1 // 1 selected
{
IF &OPSW = 1
{
&OP = 1
}
}
ELSE // Otherwise
{
&OP = 0 // Off
}
}
}

Var 3889, Link FSUIPC_IN, Offset $CE98, Length 4 // Cloud Turbulence Rate (2)

{
L0 = v3889 // FSUIPC L0 = v3889
IF L0 >= 3 // First sector
{
IF &Chain2 = 1 // 2 selected
{
IF &OPSW = 1
{
&OP = 1
}
}
ELSE // Otherwise
{
&OP = 0 // Off
}
}
}

Var 3391, Link FSUIPC_IN, Offset $CEA8, Length 4 // Cloud Turbulence Rate (3)

{
L0 = V3391 // FSUIPC L0 = v3391
IF L0 >= 3 // First sector
{
IF &Chain3 = 1 // 3 selected
{
IF &OPSW
{
&OP = 1
}
}
}
ELSE // Otherwise
{
&OP = 0 // Off
}
}

Var 9716, Link FSUIPC_IN, Offset $CEB8, Length 4 // Cloud Turbulence Rate (4)

{
L0 = V9716 // FSUIPC L0 = v9716
IF L0 >= 3 // First sector
{
IF &Chain4 = 1 // 4 selected
{
IF &OPSW = 1
{
&OP = 1
}
}
}
ELSE // Otherwise
{
&OP = 0 // Off
}
}

Var 1019, Link FSUIPC_IN, Offset $CEC8, Length 4 // Cloud Turbulence Rate (5)

{
L0 = V1019 // FSUIPC L0 = v1019
IF L0 >= 3 // First sector
{
IF &Chain5 = 1 // 5 selected
{
IF &OPSW = 1
{
&OP = 1
}
}
ELSE // Otherwise
{
&OP = 0 // Off
}
}
}

Var 5678, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (1)

{
L0 = V5678 // FSUIPC L0 = v5678
IF L0 >= 3 // First sector
{
IF &Chain1 = 1 // 1 selected
{
IF &OPSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

Var 5679, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (2)

{
L0 = V5679 // FSUIPC L0 = v5679
IF L0 >= 3 // First sector
{
IF &Chain2 = 1 // 2 selected
{
IF &OPSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

Var 5680, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (3)

{
L0 = V5680 // FSUIPC L0 = v5680
IF L0 >= 3 // First sector
{
IF &Chain3 = 1 // 3 selected
{
IF &OPSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

Var 5681, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (4)

{
L0 = V5681 // FSUIPC L0 = v5681
IF L0 >= 3 // First sector
{
IF &Chain4 = 1 // 4 selected
{
IF &OPSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

Var 5682, Link FSUIPC_IN, Offset $CE8D, Length 4 // Cloud Precipitation Rate (5)
{
L0 = V5682 // FSUIPC L0 = v5682
IF L0 >= 3 // First sector
{
IF &Chain5 = 1 // 5 selected
{
IF &OPSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

Thank you so much if you managed to stay awake during all that!:p

fordgt40
08-09-2010, 11:06 AM
Jack

For a script of this size and with so many conditions you would be better advised to run it and track what happens using IOCPConsole etc. You know how you programmed it !

Regards

David

Boeing 747 Flyer
08-10-2010, 11:08 AM
Hi David,

If it helps I'd like to "chop up" the script a bit then. this is because I'd rather get it sorted before my Master card arrives, giving me maximum time for testing.

First question: I've put the structure:


{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 >= 3 // First sector
{
IF &Chain1 = 1 // 1 selected
{
IF &REFSW = 1
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}


Twice, the only difference the second time being that switch &OPSW is used to control LED &REF instead.

The question is, have I created a "contradictary paradox" here? I have used the same script for &REFSW and &OPSW to control the same LED (ie EITHER switch can control the LED). However, I have put at the end of each script ELSE &REF (LED) = 0 (OFF). This is contradictary because, for example, if the switch &OPSW was on, the LED should be lit. However, the script also says that if Switch &REF is off, the LED should be off. So, in short, the LED should in theory be ON and OFF at the same time.

How do I rectify this problem?

fordgt40
08-10-2010, 11:34 AM
Jack

If I understand you correctly, then if either of two switches is on then the led should be on subject to further tests - else the led should be off
If you amend the example I and pdpo gave earlier in this thread then you can test if either switch is on

C0 = variable one = 1
C1 = variable two = 1
IF C0 OR C1
{
Insert here your further tests for conditions to turn on the LED
}

ELSE
{
LED = off
}

I cannot emphasise more strongly about using IOCPConsole to troubleshoot your code. That way you can see what is happening and recode accordingly

David

Boeing 747 Flyer
08-10-2010, 12:54 PM
Hi David,

How does this look (basic example):


Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF 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 7645, name Chain1, Link IOCARD_SW, Input 23 // Chain 1 Selector
Var 9888, Link FSUIPC_IN, Offset $CE8D, Length 4 // 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 &Chain1 = 1 // 1 selected
{
&REF = 1
}
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}

It compiles okay, can't test with IOCPConsole atm because my MasterCard hasn't arrived!

fordgt40
08-11-2010, 11:57 AM
Jack

Sorry for the delayed reply - the Mycockpit server fell out with me and I could not logon. Your code looks ok to me. Two suggestions - always use names not numbers when referencing variables and use lower numbers ie start from 10 - you will see why when using IOCPConsole ( when your mastercard comes:))

David

Boeing 747 Flyer
08-12-2010, 10:59 AM
Hi David,

I have had to amend my script very slightly since the last post, just Offset changes, nothing major.

Anyway, I have a new question.

I want the LEDs to work like this:

If the precipitation is above a certain level, the LED lights up (it already does this). However, if the precipitation is above yet another level, I want it to blink/flash.

Nicos site does give advice on this but it is unfortunately timed. I want the LED to keep flashing until the precipitation has cleared (a "permenent" blink).

Any ideas?

fordgt40
08-12-2010, 12:07 PM
Jack

Nico`s site does indeed have the answer! Look at the coding for "Stop a Blinking Led".

David

Boeing 747 Flyer
08-12-2010, 05:33 PM
Sorry David, I don't know how I could interpose that. (It's for stopping not setting a Blinking LED?)

I want it to light up if Turbulence is more than 3, but blink instead of staying continuously lit.

fordgt40
08-12-2010, 06:38 PM
Jack

Perhaps I am being dim, or too much beer (quite likely), but what part of the below quote does not contribute or provide direction to what you want?

"In this example a led starts blinking at the start of the SIOC program, but you can ofcourse also take other events to start the blinking of a led. The blinking is done with a TIMER, just as in the previous example. The difference is that we now program the Timer for a very long period, it counts down from 500.000 to 0 in steps of .4 seconds, long enough for a long haul flight ;-).

As soon as you push the button, the code attached to the button will force the Timer value to 1 step before the end value. In the next Timer operation the Timer will end and the blinking will stop"

David

Boeing 747 Flyer
08-12-2010, 07:28 PM
Hi David,

Really sorry, but I think I don't physically understand Nico's statement. How could I adapt his code for my needs? I am confused because his script is focused on stopping an LED rather than making it blink continously.

fordgt40
08-12-2010, 08:28 PM
Jack

The first part of the code under Var0 shows how to start a led blinking almost indefinately. The remainder of the code shows how to stop it under the control of a switch. So for your needs you only need to determine the logic to start the led blinking, then use Nico`s example, followed by using the "stop code" to suit your "trigger"

Look at the code , not the "title"

David

Boeing 747 Flyer
08-13-2010, 03:06 PM
Hi David,

I've had a go and the script I've made looks & compiles okay. However, everything is far from complete. Basically, I do not know how to "join" the blink script and the standard LED light-up scripts together. This is because, whilst I probably could do the scripting, I just can't work it out in my head.

I'm wondering if you could have a little go for me? I would like the script to do the following:

- IF &Chain1 SW is ON, REF/OP SW is ON, and Turbulence is less than three, the LED illuminates. Otherwise, it is OFF if any one of those conditions are broken.

- Same as above, but if Turbulence is EQUAL OR MORE than three, then the LED Blinks instead of being lit. Otherwise, it is OFF/ON (but not blinking) if conditions are broken.

The current LED Lighting script:


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 &Chain1 = 1 // 1 selected
{
&REF = 1
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}
}
}


The Blinking LED script:


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 &Chain1 = 1 // 1 selected
{
&REF = 0 OR 1
&BlinkLed = 500000 // begin value of timer
&BlinkLed = TIMER 0 -1 40
}
}
}
}

Var 9077, name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 1
}
}

How could I join them together whilst still achieving what I originally wanted? Could you try?

Thanks very much,

Jack

fordgt40
08-14-2010, 09:43 AM
Jack

Sorry, but the best way is for you to persevere ( like many who have gone before you ), and when you get your Mastercard, to check what is happening (or not happening) - all as advised on previous threads. If you do not fully grasp this nettle, then you will not make progress and largely be reliant on others goodwill. I am happy to give advice on some specific issues, but do not have the time to provide a bespoke SIOC service

I do need to build my own cockpit!

David

Boeing 747 Flyer
08-14-2010, 05:43 PM
Hi David,

I'm now facing a new, unrelated problem.

Whenever I try and import a .txt file to SIOC using the "Config" interface, I get the following error message:

http://i822.photobucket.com/albums/zz146/Stratuspheric/Untitled-5.jpg

I'm using the following SIOC Script, just for testing purposes:


// *****************************************************************************
// * Config_SIOC ver 3.7B1 - By Manolo Vélez - www.opencockpits.com
// *****************************************************************************
// * FileName : Weather Radar System.txt
// * Date : 14/08/2010



Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED

Var 7002, name OP, Link IOCARD_OUT, Output 5 // OP LED

Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 < 3 // First sector
{
&REF = 1
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}

Var 9881, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 >= 3 // First sector
{
&REF = 0 OR 1
&BlinkLed = 500000 // begin value of timer
&BlinkLed = TIMER 0 -1 40
}
}
}
}

Var 9077, name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 0 OR 1
}
}

This problem is very annoying. I've tried renaming the txt file, making other copies of it in a different name (you can even see "yy.txt" file in background, this is a clone), stil lno luck. FSX/FSUIPC is not running, and the txt file I'm acessing is NOT open at the time of compiling. Any ideas?

fordgt40
08-14-2010, 05:51 PM
Jack

Sorry no idea:-(

Why not just change your sioc.ini file to the new .txt file and see what happens. My sioc.ini file has at least 6 lines of potential .txt files - all bracketed out except the one I am using at that time

David

Boeing 747 Flyer
08-14-2010, 06:26 PM
Hiya David,

I tried that, and I got the exact same message, except this time BEFORE SIOC started up.

fordgt40
08-15-2010, 04:52 AM
Jack

A long shot! Edit your sioc.txt to remove all // and comments plus any spaces on each line after the end of the code. Then try again, SIOC can be very funny about things especially // without any comments added. If no joy try the opencockpits forum to see if they know this one

David

Boeing 747 Flyer
08-15-2010, 07:29 AM
Hi Daiv,d

Unfortunately it's the exact same problem, same message. I wil ltry and contact Nico Kaan, maybe he will know?

fordgt40
08-15-2010, 07:43 AM
Jack

I am wondering if this error arises because you are not running fsx or fsuipc and have no mastercard installed. Also, what do you mean by saying that you get this error before sioc runs in post #22?

David

Boeing 747 Flyer
08-15-2010, 09:10 AM
I mean that I double click SIOC, and I get the error, THEN the SIOC interface opens (ie error before SIOC).

It cannot surely be tha tno mastercard is installed, because you can still make scripts with or without IOCards (I have done in the past).

I wil ltry running FSX and FSUIPC.

fordgt40
08-15-2010, 09:50 AM
Jack

If all else fails then re-install SIOC, but keeping a copy of your .ini file etc:)

David

Boeing 747 Flyer
08-15-2010, 10:23 AM
Hi David,

I re-installed SIOC but still the same error. I have contacted Opencockpits.

deering
08-15-2010, 10:26 AM
__________________________

kiek
08-15-2010, 10:47 AM
// *****************************************************************************
// * Config_SIOC ver 3.7B1 - By Manolo Vélez - www.opencockpits.com
// *****************************************************************************
// * FileName : Weather Radar System.txt
// * Date : 14/08/2010



Var 7675, name REF, Link IOCARD_OUT, Output 4 // REF LED

Var 7002, name OP, Link IOCARD_OUT, Output 5 // OP LED

Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 < 3 // First sector
{
&REF = 1
}
}
ELSE // Otherwise
{
&REF = 0 // Off
}

Var 9881, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 >= 3 // First sector
{
&REF = 0 OR 1
&BlinkLed = 500000 // begin value of timer
&BlinkLed = TIMER 0 -1 40
}
}
}
}

Var 9077, name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 0 OR 1
}
}This problem is very annoying. I've tried renaming the txt file, making other copies of it in a different name (you can even see "yy.txt" file in background, this is a clone), stil lno luck. FSX/FSUIPC is not running, and the txt file I'm acessing is NOT open at the time of compiling. Any ideas?

Hi Jack,
Well it's very easy to see what is wrong.
You made several mistakes with your opening and closing curly brackets (in 9888 first IF one closing bracket too many, and in 9881 two closing brackets too many...). Do remember that you have to match each open curly bracket with a closing curly bracket. This is SIOC for beginners .. ;-)

I have made some changes and now it compiles fine:


Var 7675, name REF, Link IOCARD_OUT, Output 4

Var 7002, name OP, Link IOCARD_OUT, Output 5

Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1
{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 < 3 // First sector
{
&REF = 1
}
ELSE
{
&REF = 0
}
}

Var 9881, Link FSUIPC_IN, Offset $C28D, Length 1
{
L0 = V9888
IF L0 >= 3
{
&REF = 0 OR 1
&BlinkLed = 500000
&BlinkLed = TIMER 0 -1 40
}
}

Var 9077, name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 0 OR 1
}
}


regards
Nico

fordgt40
08-15-2010, 10:58 AM
Jack

I wrongly assumed that you had done the basic syntax checking:roll:

David

Boeing 747 Flyer
08-15-2010, 12:37 PM
Hi guys,

I know you think I didn't do the basic checks, but I did. The script I posted here was the wrong one, you are correct, but I can guarentee that I tried to compile WITHOUT those brackets (I made two versions of that script, I posted the earlier one here by mistake). PLEASE do not assume I don't do basic checks, I do.

And Nico, Thanks very much. That script does compile fine.

The previous problem was very strange... It wouldn't compile because windows has injected random segments of TIME in to notepad!!! The script looks okay... but check first ELSE statement:


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 9998, Link FSUIPC_IN, Offset $C28D, Length 1 // Cloud Precipitation Rate (1)
{
L0 = V9998 // FSUIPC L0 = v9998
IF L0 < 3 // First sector
{
&REF = 1
}
}
ELSE
{15:34 15/08/2010
&REF = 0
}

Var 9881, Link FSUIPC_IN, Offset $C28D, Length 1
{
L0 = V9881
IF L0 >= 3
{
&REF = 0 OR 1
&BlinkLed = 500000
&BlinkLed = TIMER 0 -1 40
}
}

Var 9077, name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REFE = 0
}
ELSE
{
&REFE = 0 OR 1
}
}

Var 9889, Link FSUIPC_IN, Offset $C29D, Length 1 // Cloud Precipitation Rate (2)
{
L0 = V9889 // FSUIPC L0 = v9889
IF L0 < 3 // First sector
{
&REF = 1
}
}
ELSE
{
&REF = 0
}

Var 9881, Link FSUIPC_IN, Offset $C28D, Length 1
{
L0 = V9881
IF L0 >= 3
{
&REF = 0 OR 1
&BlinkLed = 500000
&BlinkLed = TIMER 0 -1 40
}
}
Why did this happen?

I know everyone thinks I'm the SIOC Dunce, but I'm more thoughtful than you think.

fordgt40
08-15-2010, 12:49 PM
Jack

We can only call on what we see!!!!
If you press key F5 in Notepad, it automatically inserts a time and date stamp into your text, it obviously missed your qa check:)

David

kiek
08-15-2010, 12:58 PM
The script I posted here was the wrong one
So please pay atttention to what you post, you're waisting my time...
Nico

Boeing 747 Flyer
08-15-2010, 01:50 PM
So please pay atttention to what you post, you're waisting my time...
Nico

E:???:verybody makes mistakes...

deering
08-15-2010, 03:28 PM
_____________________________

Boeing 747 Flyer
08-16-2010, 05:21 AM
Hiya everyone,

Now I have a working SIOC Script, I tested in IOCPConsole. Now, whilst elements of it do work (ie above level three turbulence the LED Does flash), parts of it don't.

However, I did say in the script to light the LED (NOT flash) if below level three turbulence. This didn't happen. Also, the LED never stopped flashing, even though my "stop" was the ELSE command if the turbulence dropped below three.

I wil ltry and sort myself, but, can anyone see any obvious problems? It should work if <3, then LED Lights, of =>3, then LED FLashes. If turbulence is 0, then LED is not lit.

Script:


ar 7675, name REF, Link IOCARD_OUT, Output 4

Var 7002, name OP, Link IOCARD_OUT, Output 5

Var 9888, Link FSUIPC_IN, Offset $C28D, Length 1
{
L0 = V9888 // FSUIPC L0 = v9888
IF L0 < 3 // First sector
{
IF L0 > 0
{
&REF = 1
}
ELSE
{
&REF = 0
}
}
}

Var 9881, Link FSUIPC_IN, Offset $C28D, Length 1
{
L0 = V9888
IF L0 >= 3
{
&REF = 0 OR 1
&BlinkLed = 500000
&BlinkLed = TIMER 0 -1 40
}
}

Var 9077, name BlinkLed
{
L0 = MOD &BlinkLed 2
IF L0 = 0
{
&REF = 0
}
ELSE
{
&REF = 0 OR 1
}
}

deering
08-16-2010, 02:06 PM
___________________________

Boeing 747 Flyer
08-19-2010, 01:52 PM
- what does


&REF = 0 OR 1
do?

Jim[/QUOTE]

I implemented that small snippe of code for one reason: If the Turbulence drops below three, the LED could either be On OR Off, depending on certain conditions (if turbulence is less than three, illuminate LED, if there is NO tubulence, LED is OFF).

deering
08-19-2010, 02:56 PM
_____________________________

kiek
08-19-2010, 03:14 PM
Hi,
Jim is right, boolean algebra rules dictates that, read more about that here:
http://en.wikipedia.org/wiki/Introduction_to_Boolean_algebra
Nico

Boeing 747 Flyer
08-19-2010, 03:16 PM
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.

kiek
08-19-2010, 03:23 PM
Is it possible to have a SIOC IF statement without an ELSE statement?
Yes, of course. The ELSE part is optional (like in most programming languages).
Just write


IF condition
{
statement
}


Nico

deering
08-19-2010, 05:18 PM
________________________________

Boeing 747 Flyer
08-20-2010, 01:02 PM
Hiya Jim,

Thanks for that post. I have made an amendment to mr original script, look below:


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
}
}
}

I want this code to achieve the following:

- 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).

kiek
08-20-2010, 04:50 PM
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:



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
}
}

rgrds,
Nico

deering
08-20-2010, 05:02 PM
___________________________

Boeing 747 Flyer
08-20-2010, 05:03 PM
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?


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
}
}

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.

Boeing 747 Flyer
08-20-2010, 05:52 PM
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:


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
}
}

deering
08-21-2010, 02:07 AM
____________________________

Boeing 747 Flyer
08-21-2010, 05:59 AM
{
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
}

deering
08-21-2010, 10:38 AM
__________________________________

Boeing 747 Flyer
08-21-2010, 11:15 AM
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
}
}

deering
08-21-2010, 02:02 PM
_______________________________

Boeing 747 Flyer
08-21-2010, 02:05 PM
{
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
}
}

deering
08-21-2010, 02:33 PM
____________________________________

Boeing 747 Flyer
08-21-2010, 03:12 PM
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
}


Is this what you wanted Jim?

deering
08-21-2010, 03:28 PM
_________________________________

Boeing 747 Flyer
08-21-2010, 03:34 PM
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.

deering
08-21-2010, 04:53 PM
_____________________________

Boeing 747 Flyer
08-21-2010, 05:04 PM
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/zz146/Stratuspheric/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.

fordgt40
08-21-2010, 05:16 PM
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"

deering
08-21-2010, 05:27 PM
_____________________________________

Boeing 747 Flyer
08-21-2010, 05:41 PM
WAG?


Jack

"Any ideas?"

Yes, give Jim the courtesy of a proper reply to his last post - his investement deserves this.

David

I am, yet again, sorry for trying.

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?


Every detail is important. Do those conditions cover all the requirements as we stated them? Does the script accurately reflect them?


- LED Blinks if Precipitation is MORE than 3

- LED Lights if Precipitation is <= 3
and
LED stops blinking

- LED is OFF if there is no Turbulence (=0)


Keep going, Jack, we're almost there for this part.

Jim.

The script does accurately reflect what I want, as far as I can see.

fordgt40
08-21-2010, 05:54 PM
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

deering
08-21-2010, 06:03 PM
____________________________

Boeing 747 Flyer
08-21-2010, 06:12 PM
Jack,

I didn't realise there was a time schedule. Seems like there's not enough room in that schedule to learn SIOC.

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.

deering
08-21-2010, 07:30 PM
_____________________________

Boeing 747 Flyer
08-21-2010, 07:39 PM
Dear John,

I'm afraid the route will be too long for you; much remains to be done. Besides, it's obvious that we have different objectives. Also, you've been rewriting history with the edits to your posts.

Jim

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.

Boeing 747 Flyer
08-22-2010, 07:59 AM
In other words, I am sorry for running ahead. If you still want to showcase your method I will be happy to follow it.

deering
08-22-2010, 01:25 PM
___________________

Boeing 747 Flyer
08-22-2010, 01:35 PM
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.

Boeing 747 Flyer
08-25-2010, 09:12 AM
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:


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
}
}

Nico Kaan has also suggested another method for me to use. I am currently experimenting with both to see which is the more efficient.

kiek
08-25-2010, 12:32 PM
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 ...



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

Boeing 747 Flyer
08-25-2010, 04:00 PM
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:


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
}
}

kiek
08-25-2010, 04:26 PM
Is precip ever 4 ? I assumed it is, otherwise I have to change the script

Boeing 747 Flyer
08-25-2010, 04:28 PM
Is precip ever 4 ? I assumed it is, otherwise I have to change the script
Hi Nico,

Precip can be anything 0-5.

kiek
08-25-2010, 05:18 PM
Okaty, try this script:


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

Nico

Boeing 747 Flyer
08-25-2010, 05:33 PM
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

kiek
08-26-2010, 03:56 AM
Jack,
Can you be more specific:?

Hi Nico,

there are some errors:

- If 0, LED is OFF
- If 1,2 LED is ON
- If 3, 4, 5 LED BLINKS

What do you mean by this: a specification? or is it what you see (which is according to my spec), so why do you speak about Errors?

What exactly do you think is missing?
How do you check this script?

Nico

Boeing 747 Flyer
08-26-2010, 06:03 AM
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

kiek
08-26-2010, 06:39 AM
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

Boeing 747 Flyer
08-26-2010, 01:27 PM
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:


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

Is there anything that needs improving (lining of brackets maybe)?

kiek
08-26-2010, 01:34 PM
yes, in the IF &precip = 0 part, change



&BlinkLed = 0

into


&BlinkLed = 1


and indent each line properly, but I leave that part to you ......
Nico

Boeing 747 Flyer
08-26-2010, 02:44 PM
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.

kiek
08-26-2010, 05:40 PM
??
The Led part is ok, my comment was about the blinking part in that piece of your script.

If you write this:


if &Blinking = 1
{
&Blinking = 0
&BlinkLed = 0
}

You write it because you want to STOP the blinking ..
But if you want to stop the blinking you should write:


if &Blinking = 1
{
&Blinking = 0
&BlinkLed = 1
}


But this error will only occur if precip goes from 3 (blinking) to 0... I assume you have not tested that ...

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

Boeing 747 Flyer
08-26-2010, 05:56 PM
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:

http://i822.photobucket.com/albums/zz146/Stratuspheric/LLL-1.jpg

Regardless of any "errors" the script does as I want it too. I tried changing it to this like you said:


if &Blinking = 1
{
&Blinking = 0
&BlinkLed = 1
}

And the LED wrongfully goes to = 1, not 0 as I want.

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.

kiek
08-29-2010, 04:45 PM
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:


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


Nico

deering
08-29-2010, 05:06 PM
_________________________

Boeing 747 Flyer
08-29-2010, 05:34 PM
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:D.