PDA

View Full Version : Big SIOC Task



Boeing 747 Flyer
07-20-2010, 10:03 AM
Hello everyone,

I have managed to get working and test my fuel gauge with te USBServos Software, but a rather large SIOC task is required...

Basically, I want the fuel gauge to display the OVERALL WEIGHT in Pounds of all the fuel in my aircraft.

Unfortunately, no offset is available directly for this (?), so I will have to add many offsets of the tank values in gallons, then times this by offset 0AF4 to get the WEIGHT(?).

Please could somebody give me a SIOC example, or something alnog the lines, of how this is achieved?

fordgt40
07-20-2010, 11:06 AM
Jack

Is this what you want

Fuel: total quantity weight in pounds (32-bit integer)

If so, then I should check your FSUIPC offset table - try in the region of 123E to 1270 :)

David

Boeing 747 Flyer
07-20-2010, 11:42 AM
Jack

Is this what you want

Fuel: total quantity weight in pounds (32-bit integer)

If so, then I should check your FSUIPC offset table - try in the region of 123E to 1270 :)

David

Hi David,

Yes, that's exactly what I'm looking for. Thank you very much!

However, I can't seem to find that particular offset in neither the PM Offsets table or FSUIPC SDK Programmers Manual. Any ideas?

EDIT: Would offset $126C do the job?

kiek
07-20-2010, 11:43 AM
Hi Jack,

Here an example in kg (but that is easy to change to lbs):



// For the Level-D 767
//
// Total amount of fuel, displayed as xy.z * 1000 kg
//
// Note for other aircaft you have to use otther scaling factors for the
// Left, Center and Right tank.
//
// Nico Kaan

Var 1 name FI_FuelL Link FSUIPC_IN Offset $0B7C Length 4
{
CALL &CalcTotal
}

Var 2 name FI_FuelC Link FSUIPC_IN Offset $0B74 Length 4
{
CALL &CalcTotal
}

Var 3 name FI_FuelR Link FSUIPC_IN Offset $0B94 Length 4
{
CALL &CalcTotal
}

Var 4 name FuelTotal
{
CALL &OutFuelTotal
}

Var 5 name CalcTotal Link SUBRUTINE
{
L0 = &FI_FuelL
L1 = L0 + &FI_FuelR
L2 = DIV L1 45467
L1 = DIV &FI_FuelC 22734
&FuelTotal = L1 + L2
}

Var 6 name OutFuelTotal Link SUBRUTINE
{
&O_FuelTDP = 1
L0 = MOD &FuelTotal 100
L1 = DIV &FuelTotal 100
IF L1 > 0
{
&D_FuelTH = L1
}
ELSE
{
&D_FuelTH = -999999 // blank display
}
&D_FuelT = L0
}

Var 9019 name D_FuelT Link IOCARD_DISPLAY Digit 76 Numbers 2
Var 9020 name D_FuelTH Link IOCARD_DISPLAY Digit 78 Numbers 1


Nico

fordgt40
07-20-2010, 12:33 PM
Jack

EDIT: Would offset $126C do the job?

That is what I would use

David

Boeing 747 Flyer
07-20-2010, 03:38 PM
Hiya guys,

@Nico, wouldn't it just be easier to use one Offset?

kiek
07-20-2010, 04:47 PM
Hiya guys,

@Nico, wouldn't it just be easier to use one Offset?

If there is such an offset: yes of course....
This code is from my 767 cockpit, I also display the fuel amounts in the Left, Center and Right tanks.

Nico

Boeing 747 Flyer
07-20-2010, 04:52 PM
Right, prepare to recoil in horror at this SIOC script... BUT! I have had a go nonetheless. I know I've really mssed the brackets up at the end but I'm posting it here incase someone can note any false calcs or other problems (I AM AWARE THE SIOC SCRIPT ISN'T PERFECT):


Var 8666, Link FSUIPC_IN, Offset $126C, Length 4, Type 1 // Vertical Speed
{
L0 = V8666 // FSUIPC conversion, L0=VS
L0 = ABS L0 // L0 not signed
L2 = L0
IF L0 <= 400 // First sector
{
L1 = L2 * 0.91 // (364 steps/400 values) = 0.91
}
IF L0 <= 1200
{
L1 = L2 * 0.5975 // (478 steps / 800 values) = 0.5975
L1 = L1 + 364 // Add steps of others sectors
}
IF L0 <= 1500 // 3. Sector
{
L1 = L2 * 0.47 // ( 141 / 300) = 0.47
L1 = L1 + 842 // Add steps of others sectors 364 + 478
}
L1 = 983 // Max. position
}
{
&FuelGauge = 0 + L1 // Add to Minimum
}


Var 0555, name FuelGauge, Link USB_SERVOS, Output 2, PosL 0, PosC 492 , PosR 983, Type 2 // Fuel Gauge Servo

I know it's probably wrong... I just literally ripped it off've my VSI script and modified it, reason being is that both of them are non-linear scales.

fordgt40
07-21-2010, 07:45 AM
Jack

Firstly, well done for trying!

As a courtesy to those you are seeking help from, it would be nice if the comments were updated to reflect what you are trying to do. Also, you should really try compiling and removing any syntax errors prior to posting, it makes it easier to give advice.

Specific comments are that your brackets controlling the IF functions will not achieve the logic you intend. For example, assuming that L0 has a value of 300 then the line is executed

L1 = L2 * 0.91 // (364 steps/400 values) = 0.91

However, the fllowing line will also be executed (which you do not want)

L1 = L2 * 0.5975 // (478 steps / 800 values) = 0.5975

In both cases the value of L0 passes the code tests, ie it is both less than 400 and less than 1200

You need to look again at your code logic and use of brackets. Nico`s site has some useful info on this
Also not certain that you need TYPE 1 in line 1

David

Boeing 747 Flyer
07-21-2010, 08:01 AM
Right, one thing I need to know before starting again...

Is there any importance in leaving spaces on the brackets? What I mean is, the Brackets in most people scripts are all spaced out differently... Is this just here so we can associate which bracket goes with which, or is there another importance?

Also, regarding the IF logic - Can I just completely close the brackets around the previous action before the IF, or will I have to completely change the logic behind the values (ie just not the brackets), I see what you mean about => 400 and => 1200 being the same...

fordgt40
07-21-2010, 08:34 AM
Jack

"Is this just here so we can associate which bracket goes with which" The indentation of brackets is to easily show what code is attached to the IF function.

Re the IF logic, reference to Nico`s site will show you that if the IF statement is met then all the code within the associated brackets will be executed. Also, you can nest IF statemnts for example
IF x <100
{
do this code
IF > 50
{
only do this code ie only when x > 50 but < 100
}
}

Boeing 747 Flyer
07-21-2010, 09:53 AM
Okay how's this:


Var 8666, Link FSUIPC_IN, Offset $126C, Length 4 // Fuel Weight
{
L0 = V8666 // FSUIPC Offset Variable = L0
L0 = ABS L0 // L0 not signed
L2 = L0
IF L0 <= 400 // First sector
{
L1 = L2 * 0.91 // (364 steps/400 values) = 0.91
}
ELSE // Is a greater value
{
L2 = L0 - 400 // L2 only have values for next sector
IF L0 <= 1200 // Second sector
{
L1 = L2 * 0.052 // (478 steps / 800 values) = 0.5975
L1 = L1 + 364 // Add steps of others sectors
}
ELSE
{
L2 = L0 - 1200 // L2 only have values for next sector
IF L0 <= 1500 // 3. Sector
{
L1 = L2 * 0.028 // ( 141 / 300) = 0.47
L1 = L1 + 842 // Add steps of others sectors 364 + 478
}
ELSE // Out of range
{
L1 = 983 // Max. position
}
}
&FuelGauge = 0 + L1 // Add to minimum (0)
}
}

Var 0650, name FuelGauge, Link USB_SERVOS, Output 2, PosL 0, PosC 492, PosR 983, Type 2 // FuelGauge Servo

ANY problems at all, weather they be calculations or otherwise (please tll me if so)?

kiek
07-21-2010, 10:26 AM
Is there any importance in leaving spaces on the brackets? What I mean is, the Brackets in most people scripts are all spaced out differently... Is this just here so we can associate which bracket goes with which, or is there another importance?

You are now referring to the subject of 'syntaxis'.

Every programming language has production rules for producing correct sentences in that language. These rules define what a correct sentence (statement) is and what not. (The meaning of a correct statement is what is called 'semantics')


IF L0 > 0
{
L1 = L0
}

is a correct SIOC statement but


IF L0 > 0 {L1 = L0}

is not ...

SIOC has strict rules for where you can put for instance an opening bracket (always at a new line, and only that bracket at that line). It does not matter how many spaces or tabs there are in front of it, or after it at the same line. So


IF L0 > 0
{
L1 = L0
}

is also a correct sentence. However, in order to understand the 'flow' in the program more easily, it is good practise to indent and line up opening and closing brackets. This becomes even more important with statements that are nested.

Nico

fordgt40
07-21-2010, 10:34 AM
Jack

Good progress. Offhand, I see only one issue - your line "&FuelGauge = 0 + L1" needs to be run every time that the fuel weight changes. Currently, you have it too high, I think that it should be just above the last bracket. I have not checked all the nested logic, however, there is a simple way for you to troubleshoot the code, as explained in an earlier thread.

Change your variables to lower numbers ie 10 and 11
Run SIOC using this code - assuming that there are no syntax errors
Open the IOCPConsole (it is within the SIOC runtime window)
You can then see your variable values on the left of the screen, also you can change their values within that screen
Also, by using the Log function when there is a change in value of the FSUIPC variable, then you can see all the code that is actioned. This is great for testing the logic flow

Good luck

Boeing 747 Flyer
07-21-2010, 11:07 AM
Thanks very much Nico for clarifying that. I had a feeling that the brackets were spcaed out like that for easier reading.

Also, thanks David for your advice. When you say that it is a problem, do you mean it won't work or is it just "better" to write it another way (like you said it is "too high").

Another thing... Do any of you guys have information on Offset $126C? I have seen it referenced a few times, but it doesn't seem to be in the FSUIPC SDK Manual, or the table listed on PM's website! Any clues? I need to know incase I've got the length wrong or it needs dividing/multiplying.

fordgt40
07-21-2010, 11:26 AM
Jack

I am not bothered about "pretty code"! You check the logic flow, but I think that the line "&FuelGauge = 0 + L1" should be last. Try it within the IOCPConsole and see

I got the FSUIPC list from either the official site or within the fsuipc software package - I assume you have a registered copy. The info on fuel weight is in lbs and the offset has a length of 4 bytes.

EDIT: Not certain what you are reading, but I can assure you that the offset list is within the FSUIPC SDK manual zip file available from the official site. Suggest you check again - hint try the offset status file

David

Boeing 747 Flyer
07-21-2010, 12:08 PM
Okay, I have changed it so that FuelGauge = L1 is on the last line, only thing below it is the final closing bracket.

I will now test with SIOC and FSX!

kiek
07-21-2010, 01:20 PM
Another thing... Do any of you guys have information on Offset $126C? I have seen it referenced a few times, but it doesn't seem to be in the FSUIPC SDK Manual, or the table listed on PM's website! Any clues? I need to know incase I've got the length wrong or it needs dividing/multiplying.

The offset list is in the "FSUIPC for Programmers.pdf". This file is part of the "FSUIPC SDK 29th Release" available at the official Peter Dowson (http://www.schiratti.com/dowson.html) page.

By the way, Offset $126C is not in that list, so it s not a published offset by Pete Dowson. Maybe it is an extra offset by Project Magenta (PM)? If so it will only work if you are using PM.

Nico

fordgt40
07-21-2010, 01:38 PM
Nico

As advised earlier in the thread this offset is referenced in the FSUIPC Offsets Status file within the FSUIPC SDK 29th Release on the Official Peter Dowson Site. It is new to FSX.

David

kiek
07-21-2010, 01:42 PM
Hi David,
I see, thank you for the heads up. Was not aware of that file introducing new offsets (compared to the FSUIPC for Programmers.pdf).
Nico

fordgt40
07-21-2010, 02:09 PM
Nico

Lets hope that there are some pleasant surprises within the list :)

Regards

David

Boeing 747 Flyer
07-21-2010, 03:17 PM
Look at next post please.

Boeing 747 Flyer
07-23-2010, 09:39 AM
Hi everyone,

I'mh aving trouble with Offset $3B70 in SIOC. Basically, I have interfaced this Offset (EGT1 Value) to a real-life EGT Gauge... But for some reason the Instrument (real life) swings massively to the maximum scale deflection after starting SIOC and FSX.

The following SIOC Script controls offset $3B70 nad the EGT1 gauge:


Var 7777, Link FSUIPC_IN, Offset $3B70, Length 2 // EGT1
{
L0 = DIV V7777 2 // FSUIPC Offset Variable = L0 / 2
L0 = ABS L0 // L0 not signed
L2 = L0
IF L0 <= 100 // First sector
{
L1 = L2 * 0.07 // (7 steps/100 values) = 0.07
}
ELSE // Is a greater value
{
L2 = L0 - 100 // L2 only have values for next sector
IF L0 <= 200 // Second sector
{
L1 = L2 * 1.37 // (137 steps / 100 values) = 1.37
L1 = L1 + 7 // Add steps of others sectors (+7)
}
ELSE
{
L2 = L0 - 200 // L2 only have values for next sector
IF L0 <= 500 // 3. Sector
{
L1 = L2 * 1.463 // ( 439 / 300) = 1.463
L1 = L1 + 144 // Add steps of others sectors (7 + 137)
}
ELSE // Out of range
{
L2 = L0 - 500 // L2 only have values for next sector
IF L0 <= 800 // 4. sector
{
L1 = L2 * 1.437 // (431 steps / 300 values) = 1.437
L1 = L1 + 583 // Add steps of others sectors (7 + 137 + 439)
}
ELSE
{
L1 = 1014 // Max. position
}
}
}
}
&Servo5 = 0 + L1 // Add to minimum (0)
}

Var 5676, name Servo5, Link USB_SERVOS, Output 5, PosL 0, PosC 507, PosR 1014, Type 2 // EGT1 Servo

The code above does make the Instrument move, but definitely incorrectly. All Step values/integers etc are correct, so I'm wondering is there an operation I need to apply to Offset $3B70? Maybe divide it? I'm not sure, doesn't mention in FSUIPC Manual/Offset Table.

I have tried dividing the EGT1 value by 2 and still no luck. It brings it back a tiny bit but nowhere near the 700+ degrees it is off by

Thanks,

Jack:D