Page 1 of 1

SIOC Basic explanation

Posted: Fri Mar 17, 2023 2:45 am
by idj4
Hi All

Not too sure where to post this as there isn't a SIOC section on the forum, but I found this on a Flight Sim related site, and thought it might be useful to anyone trying to understand SIOC.


This was the script, with annotations explained below.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Var 0001, name EGT, Link FSUIPC_IN, Offset $3B70, Length 8 // EGT from Sim
{
L0 = &EGT - 459.67 // FSUIPC Conversion Rankine -> Farenheit
L0 = L0 - 32 // FSUIPC Conversion Farenheit -> Celsius
L0 = L0 * 5
L0 = L0 / 9
L0 = ABS L0 // L0 not signed
L0 = L0 * -1
L0 = L0 + 994
&EGT_Gauge = L0
}

Var 0002, name EGT_Gauge, Link USB_SERVOS, Output 1, PosL 1, PosC 498, PosR 994 // EGT Gauge

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Explanation of each line of code:

I have tried my hardest to keep explanations short and simple here. Should you require any further assistance, or have any further questions, please do not hesitate to contact me through the Mutley's Hangar forum.

Var 0001, name EGT, Link FSUIPC_IN, Offset $3B70, Length 8 – This line of SIOC code tells SIOC which FSUIPC offset we want to use, and then tells SIOC the “length” of the offset in bytes. Whenever we want to introduce an FSUIPC offset into a SIOC script, it must be defined as a variable. A variable is, as the name suggests, anything that can vary (or, more appropriately, anything that can have a value of some sort). A variable could be a switch, annunciator, lever; whatever – in this case, our variable is the exhaust gas temperature.

To define a variable, start a line of code with “Var XXXX”, whereby XXXX is any number between 0001 and 9999. You can also name a variable; note the “name EGT” part of the script just after we have defined the variable. “EGT” is what I have chosen to name the variable here, it could of course be anything you like (or, the “name” section of code can be omitted completely).

“Link FSUIPC_IN” tells SIOC that we want to extract information FROM the variable, and not the other way around (which would be “FSUIPC_OUT”). This is somewhat obvious since we are taking information FROM FSX to drive our EGT gauge. “FSUIPC_OUT” would be used in the case of a switch or something similar, where we are sending information TO FSX.

“Offset $3B70” is simply the offset number for the EGT engine 1 value; for any other offset the code will be different. FSUIPC offsets are always entered into SIOC in the form “Offset $XXXX”, whereby XXXX is the respective four digit code for the offset (found in the FSUIPC “Offsets Status” PDF file in the FSUIPC SDK). Many people often forget to put the dollar sign in front of the offset number; if this is not done, SIOC will reject the code. Finally, “Length 8” tells SIOC the offset is 8 bytes in length; this information is also found in the FSUIPC SDK.

L0 = &EGT – 459.67... - This entire section of calculations between the two curly brackets, although visually complex, simply converts the FSUIPC EGT (which is in degrees Rankine) into degrees Celsius. This code is, of course, different if one wishes to use Farenheit, however since the Opencockpits gauge is presented in degrees Celsius, coding for Farenheit would be a somewhat foolish move.

The “L0” entries seen at the start of some of the lines are examples of Internal Integer Variables. Due to the nature of SIOC, one cannot tell SIOC to do more than one calculation per line of script, and so there must be a way of “holding” values between one line and the next, otherwise one could only ever do simple single step calculations. The answer is to write “L0 =”, then the desired calculation, and then repeat “L0 =” on the next line, with “L0” having held the value from the previous line. “&EGT_Gauge = L0” sends the final value of “L0” (which by this point is the EGT in degrees Celsius) to the EGT gauge variable, which is explained below. The ampersand symbol (“&”) is necessary when referencing a named variable, or again SIOC will reject the code.

Var 0002, name EGT_Gauge, Link USB_SERVOS, Output 1, PosL 1, PosC 498, PosR 994 // EGT Gauge – This line defines the variable that is our EGT gauge; it tells SIOC we have a servo motor and then tells SIOC information about this servo motor.

The sections “Var 0002” and “name EGT_Gauge” serve a similar function to those explained on the “Var 0001” line. “Link USB_Gauge” tells SIOC that this variable is linked to an EGT gauge (in a similar way to how “FSUIPC_IN” told SIOC we were linking the variable to FSUIPC information).

“Output 1” tells SIOC that our servo motor is connected to position 1 on the USBServos card. “PosL 1, PosC 498, PosR 994” simply tells SIOC the left, right and centre positions of the gauge as previously explained.

And that's it! The scripts required for the other gauges are not discussed here since they largely follow a very similar concept, with the only changes being different offset values and different servo position values.

Re: SIOC Basic explanation

Posted: Fri Mar 17, 2023 9:19 am
by mvr1918
I really do not understand why you have this example here. You do not need to use FSUIPC when using Oi4FS and this Forum is for Oi4FS. How to use FSUIPC together with SIOC would be better suited to be covered in i.e. the FSUIPC Forum.

In my opinion, the best resource for understanding SIOC is this document:

https://www.lekseecon.nl/downloads/psx/How_to_SIOC.pdf

This was the document I read before I started to make SIOC scripts.

It is also important to understand that the SIOC scripts that come with Oi4FS and the airplane drivers are only a small part of the total Oi4FS and airplane driver solution.

Most of the coding is in the Oi4FS driver software.

Below is links to the Events (Inputs) and Variables(Outputs) that are implemented in Oi4FS for the PMDG 737.

Users making their own scripts or modifying the default scripts that come with Oi4FS's PMDG 737 driver should use the Events and Variables listed below.
Using other numbers than the listed ones will not work as they are not implemented in the PMDG 737 driver software.

viewtopic.php?t=1115


viewtopic.php?t=1114