PDA

View Full Version : SIOC expert needed



markusr
10-23-2009, 10:04 AM
Hi all,

i tried to get the following working with SIOC:

If Aircraft on ground and Engine is running, than one LED should go on.
If the Engines are off the LED should be off.

If the Aircraft is in the Air, the LED should be off, except if the Flapstatus is >0 than the led should be again on.

I tried it with the following (without Flap Status in this example.):


Var 0013, name Aircft_GND, Link FSUIPC_IN, Offset $0366, Length 2 //
Ground=1 / air=0

{

IF &Aircft_GND = 1

{

IF &OilP1 > 2383

{

&_Eng1_RAM_Door = 1

}

IF &OilP1 < 2383

{

&_Eng1_RAM_Door = 0

}

}

ELSE

{

&_Eng1_RAM_Door = 0

}

}

the next what i tried was with subroutines:


Var 0013, name Aircft_GND, Link FSUIPC_IN, Offset $0366, Length 2 // Ground=1 / air=0
{
IF &Aircft_GND = 1
{
CALL &sub1
}
ELSE
{
&_Eng1_RAM_Door = 0
}
}

Var 0014, name Flapsstate, Link FSUIPC_IN, Offset $0BDC, Length 4 // Flaps state 0=up

Var 0015, name sub1, Link SUBRUTINE
{
IF &OilP1 < 2380
{
CALL &sub2
}
ELSE
{
&_Eng1_RAM_Door = 1
}
}

Var 0017, name sub2, Link SUBRUTINE
{
&_Eng1_RAM_Door = 0
}

The status of the LED is only correct when i reload the script with SIOC.
Any Ideas how to get this working correct??

thanks for all hints,

Markus

jeehell
10-23-2009, 10:51 AM
The use of subroutine is the way to go, your second approach is almost correct.

Bear in mind that the FSUIPC In/Out code will only be executed when the corresponding variable actually changes.
So you need to declare a FSUIPC variable for each condition you need:
-Aircft_GND
-OilP1 (by the way there is an offset for engine running flag, instead of using oil pressure, see $0894)
-Flapsstate

And each condition should call the same subroutine, which could look like this



IF &Aircft_GND = 1
{
IF &OilP1 > 2383
{
&_Eng1_RAM_Door = 1
}
ELSE
{
&_Eng1_RAM_Door = 0
}
}
ELSE
{
IF &Flapsstate> 0
{
&_Eng1_RAM_Door = 1
}
ELSE
{
&_Eng1_RAM_Door = 0
}
}

markusr
10-23-2009, 11:24 AM
thanks for the hint.

it worked.

So, i can only use 1 variable that i have decalred in sioc at one time.
I already had the OilP1 variable used for another thing.


Var 0013, name Aircft_GND, Link FSUIPC_IN, Offset $0366, Length 2 // Ground=1 / air=0
{
CALL &sub1
}

Var 0014, name Flapsstate, Link FSUIPC_IN, Offset $0BDC, Length 4 // Flaps state 0=up
{
CALL &sub1
}

Var 0017, name oilp1_2, Link FSUIPC_IN, Offset $08BA, Length 2
{
CALL &sub1
}

Var 0015, name sub1, Link SUBRUTINE
{
IF &Aircft_GND = 1
{
IF &oilp1_2 > 2380
{
&_Eng1_RAM_Door = 1
}
ELSE
{
&_Eng1_RAM_Door = 0
}
}
ELSE
{
IF &Flapsstate > 0
{
&_Eng1_RAM_Door = 1
}
ELSE
{
&_Eng1_RAM_Door = 0
}
}
}

jeehell
10-23-2009, 11:36 AM
To be more precise look at this variable declaration:

Var 0013, name Aircft_GND, Link FSUIPC_IN, Offset $0366, Length 2 // Ground=1 / air=0
{
" WHATEVER CODE FUNCTIONS YOU NEED"
}


the code will only be executed in two cases:
1) the ACFT was prior on ground then took off, thus offset $0366 changed from 1 to 0
2) the ACFT was prior in flight then touched down, thus offset $0366 changed from 0 to 1

While in flight or on ground , if any other parameter changes, this one won't change unless one of the two conditions above is met. Problem is, SIOC reacts only on "change events". Thus the code won't be executed unless 1 or 2.

Am I clear? :mrgreen:

kiek
10-23-2009, 11:50 AM
Problem is, SIOC reacts only on "change events".
That is not a problem, it is by design! That makes SIOC so powerful.

One should bear in mind that SIOC is not a procedural programming language but an event based scripting language.
The value change of a variable is such an event.

If you assign the same value a second time to a variable, nothing will happen.

jeehell
10-23-2009, 12:11 PM
Don't get me wrong, I never said SIOC was flawed. I used the word "problem" here in regards of what Markus tried to achieve with the first code he wrote, which clearly meant he hadn't yet grasped the concept of events.;)