Jump to content
The simFlight Network Forums

need help: small program, that sets center fuel tank to 0 kg, when amount is at/below 30 kg


Egyptair

Recommended Posts

Hello guys,

 

due to a problem with my homecockpit software (engine shut down, if I forget to switch of center pumps, when reaching 0 kg ), I need a small program, 

which monitors the amount of fuel in the center tank and when the amount is <= 30 kg, fsuipc shall set the amount to 0 kg.

Something like:

If center tank amount <= 0 kg  then center tank amount = 0

Is this possible and if yes, how ?

 

Thank you very much

Simulator MSFS / FSUIPC 7

Link to comment
Share on other sites

51 minutes ago, Egyptair said:

Simulator MSFS / FSUIPC 7

I have moved your post to the FSUIPC7 / MSFS sub-forum - please use that for all support requests when using FSUIPC7.

53 minutes ago, Egyptair said:

due to a problem with my homecockpit software (engine shut down, if I forget to switch of center pumps, when reaching 0 kg ), I need a small program, 

which monitors the amount of fuel in the center tank and when the amount is <= 30 kg, fsuipc shall set the amount to 0 kg.

Something like:

If center tank amount <= 0 kg  then center tank amount = 0

Is this possible and if yes, how ?

This should be possible using a lua script. First you have to determine what holds the centre tank fuel quantity. First, try monitoring/logging offset 0x0B74 (FUEL TANK CENTER LEVEL) using FSUIPC's offset logging facilities (log as U32). This should hold the % left (*128*65536). If that looks correct, also log offset 0x0B78 to get the centre tank capacity - you will need this to determine the % value in offset 0x0B74 for 30Kg of fuel. You will also need to convert this from US gallons to kilos.

Once you have determined what offset 0x0B74 holds when the centre tank is at 30kg, you can then monitor that offset in a lua script (using event.offset), and when the offset value is equal or is less that the 30Kg %age (that you have determined), you can write 0 to the same offset.

If you let me know which aircraft you are using, and I have access to that aircraft, I can help you further. Otherwise, if you can confirm that offsets 0x0B74 and 0x0B78 are used by the aircraft, and let me know what offset 0x0B78 holds, I can provide you with a lua script you can try and customise. Probably next week now though as I have no time this weekend.

If those offsets are not being used by the aircraft, you will need to determine what holds the capacity and current quantity. This could be held in other simvars or possibly in lvars. Again, if you let me know the aircraft, I can take a look.

John

Link to comment
Share on other sites

22 minutes ago, John Dowson said:

I have moved your post to the FSUIPC7 / MSFS sub-forum - please use that for all support requests when using FSUIPC7.

This should be possible using a lua script. First you have to determine what holds the centre tank fuel quantity. First, try monitoring/logging offset 0x0B74 (FUEL TANK CENTER LEVEL) using FSUIPC's offset logging facilities (log as U32). This should hold the % left (*128*65536). If that looks correct, also log offset 0x0B78 to get the centre tank capacity - you will need this to determine the % value in offset 0x0B74 for 30Kg of fuel. You will also need to convert this from US gallons to kilos.

Once you have determined what offset 0x0B74 holds when the centre tank is at 30kg, you can then monitor that offset in a lua script (using event.offset), and when the offset value is equal or is less that the 30Kg %age (that you have determined), you can write 0 to the same offset.

If you let me know which aircraft you are using, and I have access to that aircraft, I can help you further. Otherwise, if you can confirm that offsets 0x0B74 and 0x0B78 are used by the aircraft, and let me know what offset 0x0B78 holds, I can provide you with a lua script you can try and customise. Probably next week now though as I have no time this weekend.

If those offsets are not being used by the aircraft, you will need to determine what holds the capacity and current quantity. This could be held in other simvars or possibly in lvars. Again, if you let me know the aircraft, I can take a look.

John

Hello John,

I apologize for being in the wrong sub-forum, thanks for moving it to the correct place.

I have checked the fsuipc offset logging and it is indeed 0x0B74 (%) and 0x0B78 (total amount in Gallons).

30 kg is equal to 7.93 Gallons.

30 kg is equal to 0.0018609 (0.18609 %)  of total capacity of the center tank.

The aircraft I use is the prosim 738 flight model, which uses both 0x0B74 and 0x0B78.

I really appreciate your help and to offer the lua script file, which I would gratefully take.

Thank you and kind regards

Ahmed

Link to comment
Share on other sites

1 minute ago, Egyptair said:

30 kg is equal to 7.93 Gallons.

30 kg is equal to 0.0018609 % of total capacity of the center tank.

The aircraft I use is the prosim 738 flight model, which uses both 0x0B74 and 0x0B78.

I really appreciate your help and to offer the lua script file, which I would gratefully take.

Ok, thanks. I will provide you with a lua script to try - it is pretty straightforward and I may get a chance later today, but I will post again when ready.

John

Link to comment
Share on other sites

Please try the attach script. I have not tested this but its pretty simple. Make sure its running - best to add to the [Auto] (or a profile-specific [Auto.xxx]) section of your FSUIPC7.ini file, e.g.

Quote

[Auto]
1=Lua centerTankFuel

Any issues, please activate logging for Lua Plugins (only!) and show me your FSUIPC7.log and FSUIPC7.ini files.

centerTankFuel.lua

Link to comment
Share on other sites

30 minutes ago, John Dowson said:

Please try the attach script. I have not tested this but its pretty simple. Make sure its running - best to add to the [Auto] (or a profile-specific [Auto.xxx]) section of your FSUIPC7.ini file, e.g.

Any issues, please activate logging for Lua Plugins (only!) and show me your FSUIPC7.log and FSUIPC7.ini files.

centerTankFuel.lua 326 B · 0 downloads

Hello John,

 

thank you very much, I will try this asap and will report.

 

Kind regards

Ahmed

Link to comment
Share on other sites

2 hours ago, John Dowson said:

Please try the attach script. I have not tested this but its pretty simple. Make sure its running - best to add to the [Auto] (or a profile-specific [Auto.xxx]) section of your FSUIPC7.ini file, e.g.

Any issues, please activate logging for Lua Plugins (only!) and show me your FSUIPC7.log and FSUIPC7.ini files.

centerTankFuel.lua 326 B · 2 downloads

Hello John, 

I got this message:

15953   [INFO]: **** Starting FSUIPC7 WASM Interface (WAPI) version 1.0.3 (WASM version 1.0.2) using connection -1
    15953   [INFO]: Connected to MSFS
    15985 Lvars received: 146 L:vars & 0 H:vars now available
    15985 Lvars/Hvars received - checking aircraft autos....
    16047 LUA.1: beginning "C:\FSUIPC7\centerTankFuel.lua"
    16047 *** LUA Error: C:\FSUIPC7\centerTankFuel.lua:4: 'then' expected near '!'
   345047 LUA.2: beginning "C:\FSUIPC7\centerTankFuel.lua"
   345047 *** LUA Error: C:\FSUIPC7\centerTankFuel.lua:4: 'then' expected near '!'
   349719 LUA.3: beginning "C:\FSUIPC7\centerTankFuel.lua"
   349719 *** LUA Error: C:\FSUIPC7\centerTankFuel.lua:4: 'then' expected near '!'

 

I changed it to (and further reduced fuel amount)  :

 

local fuelLimit = 7000

function monitorCenterTankFuel(offset, value)
    if value <= fuelLimit and value > 0 then
        ipc.writeUD(0x0B74, 0)
        ipc.log("Center tank fuel quantity set to 0")
    end
end

event.offset(0x0B74, "UD", "monitorCenterTankFuel")
ipc.log("CenterTankFuel lua script now running")

 

I really thank you very much as you helped me out with an issue, I struggled with over many month !!

Kind regards

Ahmed

 

Link to comment
Share on other sites

1 hour ago, Egyptair said:

I got this message:

15953   [INFO]: **** Starting FSUIPC7 WASM Interface (WAPI) version 1.0.3 (WASM version 1.0.2) using connection -1
    15953   [INFO]: Connected to MSFS
    15985 Lvars received: 146 L:vars & 0 H:vars now available
    15985 Lvars/Hvars received - checking aircraft autos....
    16047 LUA.1: beginning "C:\FSUIPC7\centerTankFuel.lua"
    16047 *** LUA Error: C:\FSUIPC7\centerTankFuel.lua:4: 'then' expected near '!'
   345047 LUA.2: beginning "C:\FSUIPC7\centerTankFuel.lua"
   345047 *** LUA Error: C:\FSUIPC7\centerTankFuel.lua:4: 'then' expected near '!'
   349719 LUA.3: beginning "C:\FSUIPC7\centerTankFuel.lua"
   349719 *** LUA Error: C:\FSUIPC7\centerTankFuel.lua:4: 'then' expected near '!'

Yes, sorry  "not equals" in lua is '~=' not '!=' - that is C/C++, getting my languages confused... using '>0' is just as good.

1 hour ago, Egyptair said:

I really thank you very much as you helped me out with an issue, I struggled with over many month !!

 No problem - glad its now working and help with your issue.

Regards,

John

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.