Jump to content
The simFlight Network Forums

Recommended Posts

Posted

I'm working on a generic fuel selector toggle Lua (each button press cycles to the next "working" non-off tank setting). My plan is to set the next tank state and see if it worked (if so, great, otherwise mark as inop and try the next one). I see there are some offsets to read...

FUEL TANK SELECTOR:1

RECIP ENG FUEL TANK SELECTOR:1 .. 4

TURB ENG TANK SELECTOR:1 .. 4

Before I go down this path... Are these really different? Is there a reason why there's no generic fuel tank selector 2..4?

 

Posted
6 hours ago, pilotjohn said:

Are these really different? Is there a reason why there's no generic fuel tank selector 2..4?

All FSUIPC can do is present, via the offsets, the values of defined SimConnect variables (SIMVARS). These are defined in the P3D SDK (the documentation for the MSFS SDK is lacking, but the SimVars are basically the same if they were also in FSX, which they were). Below are the original names and the total description provided. I append the tank list as well.

I don't know why there are the three entries. I suspect they operate similarly. Best thing you can do is use the offset logging to log the state of each, then use the fuel selector switch in assorted aircraft and see which offset changes.

Pete

FUEL TANK SELECTOR:index Which tank is selected. See fuel tank list.
RECIP ENG FUEL TANK SELECTOR:index Fuel tank selected for engine. See fuel tank list.
TURB ENG TANK SELECTOR:index Fuel tank selected for engine. See fuel tank list.

Fuel Tank Selection

Number Description
0 Off
1 All
2 Left
3 Right
4 Left auxiliary
5 Right auxiliary
6 Center
7 Center2
8 Center3
9 External1
10 External2
11 Right tip
12 Left tip
13 Crossfeed
14 Crossfeed left to right
15 Crossfeed right to left
16 Both
17 External
18 Isolate
19 Left main
20 Right main
Posted
1 hour ago, Pete Dowson said:

I don't know why there are the three entries. I suspect they operate similarly.

They do - they all use the Fuel Selector Set control. The offset for the other indices (2, 3, 4) use the Fuel Selector Set contols (n=2,3,4). I'm not sure why there is no generic fuel tank selector 2..4, but you can use the other indexed offsets instead as they use the same control.

John

Posted
2 hours ago, John Dowson said:

They do - they all use the Fuel Selector Set control. The offset for the other indices (2, 3, 4) use the Fuel Selector Set contols (n=2,3,4). I'm not sure why there is no generic fuel tank selector 2..4, but you can use the other indexed offsets instead as they use the same control.

John

Thanks... if I send a control (say Fuel Selector 2 Set 16), is there some deterministic delay for the offsets getting updated? My plan is to create a generic fuel selector toggle script which when run will read the current tank value and increment it until it "works" (meaning the change is reflected in the offset) or it reaches to the end. I'm wondering if there's some upper limit for the "wait to see if it worked".

Specific question, for which you may not have the answer, is why I see an event (fuel selector 1 off) when I switch something in the cockpit (mouse), but if I send that control, it doesn't actually cause the event to happen. On the DA62, sending fuel tank selector controls with appropriate values (like left/right main) work, but "off" is ignored.

 

Posted
1 hour ago, pilotjohn said:

if I send a control (say Fuel Selector 2 Set 16), is there some deterministic delay for the offsets getting updated?

Yes, as the control is sent to the FS and the offset is updated when we get this information back to tell us that the offset has been updated.

1 hour ago, pilotjohn said:

why I see an event (fuel selector 1 off) when I switch something in the cockpit (mouse), but if I send that control, it doesn't actually cause the event to happen.

Most probably due to the event not being connected yet - from the MSFS SDK:
    Internally, not all events are mapped to the relevant SimObjects

1 hour ago, pilotjohn said:

sending fuel tank selector controls with appropriate values (like left/right main) work, but "off" is ignored.

If that should be possible with the aircraft, you can raise a zendesk ticket with Asobo.

Posted
3 hours ago, John Dowson said:

Yes, as the control is sent to the FS and the offset is updated when we get this information back to tell us that the offset has been updated.

Is this based on the registered sampling rate of FSUIPC or something else? Can I rely on some upper bound for this to happen?

Also, are events dispatched on a single thread per Lua? Would an event.timer and event.offset callbacks ever happens on separate threads, or can I assume that while one is executing the other won't?

Posted

Well, scratch this idea. It looks as if I send a tank select X, even if X is not bound to anything in the plane, the offset gets updated with X. So I expected the offset to NOT be updated unless the event actually triggered something in the aircraft, but that's not the case.

Posted
3 hours ago, pilotjohn said:

Is this based on the registered sampling rate of FSUIPC or something else? Can I rely on some upper bound for this to happen?

Yes, probably on a 6 hz sampling rate but depends on the data item.

3 hours ago, pilotjohn said:

Also, are events dispatched on a single thread per Lua?

Yes, each lua runs in its own thread.

9 hours ago, pilotjohn said:

Well, scratch this idea. It looks as if I send a tank select X, even if X is not bound to anything in the plane, the offset gets updated with X.

That's strange... Does the control actually work on the aircraft you are using? If so, what happens when you send an invalid value - is it just ignored?

9 hours ago, pilotjohn said:

So I expected the offset to NOT be updated unless the event actually triggered something in the aircraft, but that's not the case.

The offset just holds the value of the associated simulator variable. But it doesn't make much sense that its being updated to an invalid value for that aircraft.

Posted
5 hours ago, John Dowson said:

Yes, probably on a 6 hz sampling rate but depends on the data item.

Yes, each lua runs in its own thread.

That's strange... Does the control actually work on the aircraft you are using? If so, what happens when you send an invalid value - is it just ignored?

Yes... the DA62 has 3 fuel selector positions for each engine (0 - Off, 19 - Left main, 20 - Right main). Using these controls via FSUIPC works and the selectors respond correctly in the aircraft. And if selected from the aircraft, the offsets are updated correctly. If I send something that is not one of those, it is ignored by the aircraft, but the offset is updated (as watched by an event).

5 hours ago, John Dowson said:

The offset just holds the value of the associated simulator variable. But it doesn't make much sense that its being updated to an invalid value for that aircraft.

Yes, it is. 🙂 Attached is my Lua. It read the current selection, then tries to increment it by one, waiting 1s for it succeed and be done, otherwise continue incrementing (until, for now, it aborts at 20). The odd thing was that it *always* succeeded. That is, I wrote to set the tank, and received the updated offset, even when it was invalid for the aircraft. Upon triggering the Lua again, the read value for the offset was most recently written "invalid" value.

If I "ipc.write", I should not expect an event unless the sim sends it to FSUIPC, correct?

fuel_select.lua

Posted
46 minutes ago, pilotjohn said:

Yes, it is

Its a problem with the model then. I suspect that the event is for a general model for all aircraft, and there is no specific check on this on what the actual aircraft model has.

47 minutes ago, pilotjohn said:

If I "ipc.write", I should not expect an event unless the sim sends it to FSUIPC, correct?

Yes, it will depend on the offset. Some offsets are updated by updating the sim variable directly (identified as 'Ok-SimC' in the offset documentation), and some use events/controls (documented as 'Ok-SimE').

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.