Question External Tanks

I wonder if it would be possible to develop a universal attached tanks addon...
 
So a vessel with no tanks would have 0 propellant mass. Each tank 's propellant mass is 5000.

Not 0...lets say, anything. name anything x. you have a defined maximum propellant mass possible in the main or sump tanks of the vessel. This tank gathers fuel from the external tanks for use in the engines.

So if I attach 1 tank I need to copy the propellant mass of the tank to a shadow tank. So now a shadow tank has a mass of 5000, right

Yes, but you can get the parameters "maximum propellant mass" and "current propellant mass" of the external tank from Orbiters API, no need to use constants, which would cause dependencies.

How does the fuel get from the shadow tanks to the main tank?

Simplest way: You refuel it to maximum every timestep, if possible.

First, you determine the difference between maximum propellant mass in your main tank and current propellant mass.

Then, you determine the available fuel tanks via the shadow tanks (you can include on/off masking here to say that a fuel tank is attached but not used) and count how much fuel they can provide in total. if zero, you can already abort here.

If the external fuel is not enough, increase the propellant mass of the main tank by the amount of fuel available in the external tanks. set all external tanks via their shadows to zero.

Otherwise, distribute the load among the tanks: Calculate the ratio between current fuel mass in the shadow tank and total fuel mass in external/shadow tanks for each external tank. Multiply this ratio by the amount of fuel needed to be transfered to the main tank. The resulting number is the amount of fuel you will transfer from this tank to the main tank. Reduce propellant mass in shadow tank by this amount, repeat for every tank (you have selected).

Now finally increase main propellant mass by the amount fuel transfered - or to maximum, both should be the same.

This assumes a greater pump capacity as the consumption of your engines, but you can easily include a limit there, by setting the maximum amount of fuel needed to be transfered to the maximum amount of fuel that can be transfered in one timestep (amount per second multiplied by delta-T).

Then every timestep set the mass of external tank to that of the shadow tank.

Correct.
 
Ok. I guess I am ignorant or brain dead.

If not sure how to get the Orbiter API from the Eagle vessel to read the Propellantmass of the vessel attached to FUEL1 point. I guess using this:

GetPropellantMass
Returns the current mass of a propellant resource.
Synopsis:
double GetPropellantMass (PROPELLANT_HANDLE ph) const

once it gets it add it to the current propellant mass of the main tank
 
I guess using this:

GetPropellantMass
To get the propellant handle for GetPropellantMass, you use GetPropellantHandleByIndex method on the attached vessel's interface.

To get the maximum index of propellant resource which you can use with GetPropellantHandleByIndex, you use GetPropellantCount method (on the attached vessel's interface). The maximum index will be attachedVessel->GetPropellantCount () - 1.


Alternatively, you can use VESSELSTATUS2 with GetStatusEx and DefSetStateEx methods and VS_FUELLIST flag set.
 
I guess my hang up is how to I get the information from the attached vessel?
 
I guess my hang up is how to I get the information from the attached vessel?

GetAttachmentStatus returns the OBJHANDLE of the attached vessel, if you ask it. OBJHANDLE can be turned into Vessel interface by oapiGetVesselInterface (Or so, I am not sure, and away from API docs, I work from my memory here).

The rest as described.

You can also query the default propellant resource, which is the resource displayed in Orbiters HUD.
 
Back
Top