katateochi

[1.3.1] Docking Fuel Pump

Recommended Posts

Docking Fuel Pump
Download 0.0.4  | KSP Support: [1.3.1]
Source | Bug Reporting | Licence: CC BY-NC-ND 4.0

DFP is a simple mod that adds a fuel pump to docking ports, enabling them to pump resources from parts on one side of the docking port to the parts on the other side with a single click.  Useful for refuelling a craft from a tanker (especially on craft with lots of tanks & resource types, or tanks that are awkward to access).
Note: - requires module manger, not included in download.

It adds a "pump fuel" button to the context menu for docking ports.  Switching on the fuel pump will transfer all available resource types (except electricity) on the attachment node side of the docking port to the parts on the docking node side. ODKRGHR.png?3

 

7aBi7g0.png  Right-Arrow-PNG-Transparent.png  whqONlL.png

In the above example clicking "pump fuel" on the left hand docking port results in all the resources on the left hand side of the docking ports being pumped to the tanks on the right.  

Running the fuel pump consumes electricity and generates heat.  Heat generation can be switched off and the rate of power drain can be configured in settings.  
The fuel pump will consume all resources from connected parts on the non-docking side of the docking port and will fill connected parts on the docking side, but it will respect barriers presented by crossfeed disabled parts. Each docking port can only transfer resources in one direction; into the parts of whatever has docked to it (to transfer in the other direction just use the fuel pump on the other docking port).
 

WARNING:

Do not simultaneously run two adjacent fuel pumps against each other, it will cause very rapid heating resulting in explosive undocking within a few seconds.

eWpKGYi.png k0YOZ4w.png
 

 

Efficiency and Heat :
The fuel pump generates heat as resources are transferred, as the pump's heat increases it becomes less efficient so using radiators around pumps on fuel stations is recommended. 

NOTE on heating. I have not got the right balance of heating and pump efficiency working. On some test craft it works nicely, but on other craft (with different mass) it is either almost non-existent or way to aggressive. For now I  would suggest disabling the heating feature in the settings (see below). I will try to get a more robust solution working.

Transfer Rates:
Different sized docking ports have slightly different flow rates; the larger the docking port the faster it can transfer resources.
The rate of transfer for each resource is independent of other resources and is limited by the "bore" of the docking port.  eg: if you have lots of small tanks and a couple large tanks, to start with resources will be extracted-from/added-to the large tanks slowly, but once the smaller tanks have been filled/emptied the rate of transfer on the larger tanks will increase.  Think of it as there being a separate pipe for each resource type running through the docking port and the rate of flow of each resource is governed by the bore of its pipe.  (at the moment the 'pipe' for each resource has the same bore, but I plan to have different flow rates for different resources).

The claw (Advanced Grabbing Unit) is slightly different; it can pump fuel in the same way as docking ports (ie into whatever it's docked with), but it also has an "extract fuel" button that enables it to pump resources in the other direction.

Settings:
You can modify a few things by altering the values in the dfp_settings.cfg file.

SETTINGS
{
  flow_rate = 1                 
  power_drain = 0.05            
  transfer_highlighting = false 
  transfer_heating = true       
  heating_factor = 0.6          

  RESOPTS
  {
  	ElectricCharge = ignore     
  	CarbonDioxide = reverse     
  	WasteWater = reverse        
  	Waste = reverse             
  }
}

flow_rate -  defines a multiplication factor for how fast resources are transferred.
power_drain - defines how much power is consumed in transferring a single unit of resource 
transfer_highlighting - this is mostly a development helper; enabling it will highlight the tanks engaged in transfer (blue for the parts being transferred into, green for those resources are being extracted from).
transfer_heating - set this to false if you want to disable the heat production of the fuel pump. note this doesn't disable the rapid overheating (and exploding) which happens when running two pumps against each other.
heating_factor - rate that the docking ports gain heat

RESOPTS
All resources are transferred (except NOFLOW resources like solid fuel), but you can specify resources to be ignored during the transfer, by default this is just electric charge. 
Resources can also be set to be transferred in reverse.  The default reverse resources are waste products from TAC life support, with these set as reverse all other resources will be transferred to the recipient craft while these waste resources will be extracted from it. 


Example use:
with one click, all the resources on the aircraft will be restocked from the fuel tanker, except of course you don't have to open up all the menus for each tank. (heating has been reduced since these pictures were taken).

WDK47wJ.png T4bNGtr.png


Big thanks to @dueb for help with bug fixes and KSP updates.

Edited by katateochi
new release

Share this post


Link to post
Share on other sites

Oh sweet. This is almost the exact same concept as the first mod I was going to write, about 2 years ago. But then GoodSpeed Fuel Pumps came out (and I was even less good at modding back then than I am now) and I forgot about it. When the time comes to pump fuel again, I'll be sure to try this out!

Share this post


Link to post
Share on other sites

After a first test, one thing I've noticed (except the insane power consumption and heat generation :D) is that resources flowMode is not respected: it can transfert fuels like SRB fuel were it shouldn't.

But beside of that, thank you for this oh-so-long-awaited mod! :D

Share this post


Link to post
Share on other sites

Ok, so after a few more tests, I've noticed an other thing that bothered me: you can transfert the content of locked tanks.

I didn't want that, so I step ahead and recompiled the source with some changes! :D

(I don't have a github account to make a PR, so here is what I did.)

 

In DockingFuelPump/Source/DockingFuelPump.cs

Line 254:
  if (resource.resourceName != "ElectricCharge" && resource.amount < resource.maxAmount && source_resources.Keys.Contains(resource.resourceName)) {

Replaced by:
  if (resource.resourceName != "ElectricCharge" && !resource.info.resourceFlowMode.Equals(ResourceFlowMode.NO_FLOW) && resource.amount < resource.maxAmount && source_resources.Keys.Contains(resource.resourceName)) {

This prevent transfering fuels sets to NO_FLOW.

 

Line 268 and 274:
  if(res.amount > 0){
  if(res.maxAmount - res.amount > 0){

Replaced by:
  if(res.amount > 0 &&  res.flowState){
  if(res.maxAmount - res.amount > 0 &&  res.flowState){

Respectively.

And this prevent transfering from locked tanks.

 

I don't know if this is the right way of doing it, but I wanted to share you my findings. :wink:

Share this post


Link to post
Share on other sites
21 minutes ago, dueb said:

Ok, so after a few more tests, I've noticed an other thing that bothered me: you can transfert the content of locked tanks.
I didn't want that, so I step ahead and recompiled the source with some changes! :D
(I don't have a github account to make a PR, so here is what I did.)

ah, yes...I knew there was something else I'd meant to do! I'm v new to plugin writing so I didn't know how to do that so your "PR" really helps, thanks @dueb! Consider that pull request accepted (I'll add that in tomorrow).
That and I'll tone down the heating, I just damaged a station while transferring fuel! I do want to reflect the fact that in RL pumping large quantities of fuel does have risks (and have another reason for needing heat dissipation), but as it is it's too extreme. I'll reduce it and probably also make the level it heats the docking port a setting along with the option to disable it completely. 

Share this post


Link to post
Share on other sites
35 minutes ago, katateochi said:

ah, yes...I knew there was something else I'd meant to do! I'm v new to plugin writing so I didn't know how to do that so your "PR" really helps, thanks @dueb! Consider that pull request accepted (I'll add that in tomorrow).
That and I'll tone down the heating, I just damaged a station while transferring fuel! I do want to reflect the fact that in RL pumping large quantities of fuel does have risks (and have another reason for needing heat dissipation), but as it is it's too extreme. I'll reduce it and probably also make the level it heats the docking port a setting along with the option to disable it completely. 

You can consider me as new to plugin writing too... :D

So don't take for granted everything I did there, (especially the part on locked tanks) knowing that I didn't spent more than 10 min on it! :P

For the heat mechanic, I totally understand and I'm totally agree with it! (That's sad for this poor station... :()

But I have to ask you: Is it intended that the transferts are that fast? I did my tests on medium docking ports and found that this was really fast compared to stock fuel transfert! :blink:

Changing the flow_rate in the config didn't changed anything noticeable (but maybe I'm doing something wrong here...).

Share this post


Link to post
Share on other sites

I've just posted an update - 0.0.2 - download here
Changes in this update:
- prevent transfer of non-transferable resources ie solid rocket fuel.
- prevent transferring fuel from tanks which have been locked.
- much lower power usage.
- transfer speed is slightly reduced.
- different heating system; pump is less likely to overheat but will become less efficient as the temperature goes up. So radiators can be used to increase efficiency.
Thanks @dueb for pointing out some of the issues and providing solutions!

I'm still not 100% sure about the heating process, but I think this is better.  It's much less likely to overheat with normal use. The previous version simply applied a set level of temperature to the pump, in this version the amount of heat generated is related to the amount of resources transferred, but as the heat goes up the efficiency of the pump reduces so the rate of transfer and heat production will go down.  It still functions well without any radiators, but by adding them the pumps efficiency can be kept higher. 
 

16 hours ago, dueb said:

But I have to ask you: Is it intended that the transferts are that fast? I did my tests on medium docking ports and found that this was really fast compared to stock fuel transfert! :blink:

It is intended to be faster than standard stock fuel transfer rates, but I have reduced the speed a bit in this update.  I don't see there's any benefit (or fun) in making the player sit and watch a slow transfers and also stock transferring doesn't consume any power, so the logic is that this uses a more powerful/faster fuel pump which therefore requires power to run.  
Stock transfers are also generally 1-to-1 or 1-to-many tanks where as this does many-to-many and the rate of transfer out-of/in-to each tank is dependent on how much fuel can be moved through the docking port on each frame. So when transferring between many tanks, the rate on each tank will be lower than with stock, but when transferring between just two or a small number of tanks the rate on each tank will be higher.  

16 hours ago, dueb said:

Changing the flow_rate in the config didn't changed anything noticeable (but maybe I'm doing something wrong here...).

It seems to be working ok for me in Linux, I shall check that again when I'm next in windows. It might be due to the different line endings used in the different OSs. 

Share this post


Link to post
Share on other sites

Congratz for this new release! :D

 

5 hours ago, katateochi said:

I'm still not 100% sure about the heating process, but I think this is better.  It's much less likely to overheat with normal use. The previous version simply applied a set level of temperature to the pump, in this version the amount of heat generated is related to the amount of resources transferred, but as the heat goes up the efficiency of the pump reduces so the rate of transfer and heat production will go down.  It still functions well without any radiators, but by adding them the pumps efficiency can be kept higher.

I really like this new mechanic! Especially if you consider some mods like RoverDude's ones which take into account heat levels for Kerbals!

 

5 hours ago, katateochi said:

It is intended to be faster than standard stock fuel transfer rates, but I have reduced the speed a bit in this update.  I don't see there's any benefit (or fun) in making the player sit and watch a slow transfers and also stock transferring doesn't consume any power, so the logic is that this uses a more powerful/faster fuel pump which therefore requires power to run.  
Stock transfers are also generally 1-to-1 or 1-to-many tanks where as this does many-to-many and the rate of transfer out-of/in-to each tank is dependent on how much fuel can be moved through the docking port on each frame. So when transferring between many tanks, the rate on each tank will be lower than with stock, but when transferring between just two or a small number of tanks the rate on each tank will be higher.

I can see why some would like to have fast transferts, but on an other hand, I'm pretty sure that there is people that play the game the hard way. :D (I have in mind Realism Overhaul for example)

Since fuel transfert timewarp is a thing, you can imagine one who miss the transfert window because of the refuelling e.g. :P

But that's fine, maybe a config option to adjust the transfert speed could solve this issue if it's not too hard to implement? (I dunno I didn't checked)

(Edit: Well, there is flow_rate for that, forget what I said... :rolleyes:)

 

5 hours ago, katateochi said:

It seems to be working ok for me in Linux, I shall check that again when I'm next in windows. It might be due to the different line endings used in the different OSs. 

Yeah, I have no idea here. It could be. I remember seeing briefly a related error in my logs while bughunting for my new KSP 1.2 install, but this one was not related to your mod since I didn't have it at that time...

Well, let me check again... Ok, nevermind! That's working!

I just had to nerf really hard the fuel flow to be noticeable! :D (divided by 1000 in this test, whereas in my previous tests it was only by 100 max.)

 

Oh! And that's remind me:

The EC consumption is barely noticeable now (even without the nerfed flow rate)!

I feel stupid now...after complaining about that!

It was really high before, but now it can be neglicted on any standard stations... I think if I had to choose, I'll prefer the first one rather than the later.

 

Anyway great job and thank you for this awesome handy mod! :wink:

 

Edited by dueb

Share this post


Link to post
Share on other sites

Great idea! I think I can use it as a water pump for my piston engines (less cumbersome than my own design).

Share this post


Link to post
Share on other sites

Wow.  Very nice in both design and execution.

I took a peek at the code and notice that you hook GameEvents.onPartUndock to stop the pump from running if someone undocks.. but what if a fuel tank decouples/explodes while you're pumping?  I suspect you'll get a lot of NullReferenceException errors when you try to access a part that no longer exists.  Or you start pumping, then dock another ship?  The new ship will be ignored until you stop and re-start the pump.  One solution is to hook GameEvents.onVesselStandardModification and when that fires, re-scan the north/south parts and resources. onVesselStandardModification rolls up a bunch of different events, including onPartUndock, so it basically captures any change to the ship.

One possible feature to make in the future is a toggle for auto-pump, to automatically start the pump once docked. Then when GameEvents.onPartCouple fires, check if autopump is enabled, and if so, start the pump.  There's two benefits to something like this: 1. it's sometimes hard to click on the docking port itself once docked, and 2. laziness :D Users could set autopump on in the VAB, save it that way, and then never actually have to click anything while in flight.

Share this post


Link to post
Share on other sites
15 hours ago, dueb said:

really like this new mechanic! Especially if you consider some mods like RoverDude's ones which take into account heat levels for Kerbals!

heat is a rather under utilised mechanic in the stock game!

15 hours ago, dueb said:

I can see why some would like to have fast transferts, but on an other hand, I'm pretty sure that there is people that play the game the hard way. :D (I have in mind Realism Overhaul for example)

Since fuel transfert timewarp is a thing, you can imagine one who miss the transfert window because of the refuelling e.g. :P

15 hours ago, dueb said:

The EC consumption is barely noticeable now (even without the nerfed flow rate)!

Yes, I think I reduced it too much now! If it's balanced right then I think that will be ok to offset the gain of the faster fuel transfers. I shall tune it up again (but not as much as before) in the next update.  If you have a play around with the power drain setting and find one what feels right let me know. 

 

6 hours ago, hab136 said:

Wow.  Very nice in both design and execution.

Thanks @hab136!

6 hours ago, hab136 said:

I took a peek at the code and notice that you hook GameEvents.onPartUndock to stop the pump from running if someone undocks.. but what if a fuel tank decouples/explodes while you're pumping?  I suspect you'll get a lot of NullReferenceException errors when you try to access a part that no longer exists.

That's a good point, I'd not considered parts being decoupled or destroyed while pumping! 

6 hours ago, hab136 said:

Or you start pumping, then dock another ship?  The new ship will be ignored until you stop and re-start the pump

hmmm, is that a feature or a limitation? I think ignoring added parts until you restart the pump is probably more intuitive. not totally sure though. 

6 hours ago, hab136 said:

One solution is to hook GameEvents.onVesselStandardModification

ah, that's very helpful thanks. I'll use that to sort the issue of decoupling/exploding parts while pumping and I'll ponder the idea about recalculating the parts when additional parts join.

 

7 hours ago, hab136 said:

One possible feature to make in the future is a toggle for auto-pump, to automatically start the pump once docked. Then when GameEvents.onPartCouple fires, check if autopump is enabled, and if so, start the pump.

I'd not thought about having an auto pump option, but that's not a bad idea. I'm still learning my way around both c# and KSP's API, do you know how to have an option appear on a context menu while in the VAB/SPH but not while in flight?

Share this post


Link to post
Share on other sites
1 hour ago, katateochi said:

I'd not thought about having an auto pump option, but that's not a bad idea. I'm still learning my way around both c# and KSP's API, do you know how to have an option appear on a context menu while in the VAB/SPH but not while in flight?

 

[KSPField (isPersistant = true, guiActive = false, guiActiveEditor = true, guiName = "Autopump "), UI_Toggle (disabledText = "Off", enabledText = "On")] public bool autoPump;
 

guiActive is for flight, guiActiveEditor is for editor.  https://kerbalspaceprogram.com/api/class_k_s_p_field.html

I'd personally prefer it changeable both in flight and in the editor (guiActive=true, guiActiveEditor=true), but like with all these suggestions, it's your mod and you can do what you want :)

Share this post


Link to post
Share on other sites

Added this to the pile of mods I didn't know I needed till I saw it. Now I must have it :)

Share this post


Link to post
Share on other sites

I've tried this a couple of times and haven't been able to get it to work. I've been using modded docking ports (Construction and Flexo), but they did still have the pump fuel option in the menu, it just didn't actually move any fuel. I'll do some proper testing in a bit, but has anyone else had this issue?

Share this post


Link to post
Share on other sites
48 minutes ago, Rodger said:

I've tried this a couple of times and haven't been able to get it to work. I've been using modded docking ports (Construction and Flexo), but they did still have the pump fuel option in the menu, it just didn't actually move any fuel. I'll do some proper testing in a bit, but has anyone else had this issue?

I've not tested this with those mods so it might be that I need to add support for them.  Can you check that it's working as expected with the stock docking ports in your save (and could you give me links to those mods, just to save me hunting for them). oh and also, crack open the debug console and see if there are any errors going past when you try to use the modded docking ports. 

Share this post


Link to post
Share on other sites

Ok, well I tested it in a vanilla install with just this mod + MM, and it wouldn't pump monoprop between two probes: http://i.imgur.com/NlsHmyI.png

Tried with LFO as well to be sure, with room in the tanks on both sides, still no luck: http://i.imgur.com/oTtoJkA.png

Also found a NaN error too, when all the tanks on the supplier side are locked, and you then try to pump from them, it breaks: http://i.imgur.com/pe1xfBt.png

Edited by Rodger

Share this post


Link to post
Share on other sites

@katateochi Cant believe it took this long for someone to think of this... Good Job :D

Minor note in my log. I'm guessing its not game-breaking, since it skips it? :P

[WRN 20:20:02.897] Config in file 'E:\KSP\Windows\1.2.1\KSP_win64\GameData\DockingFuelPump\dfp_settings.cfg' contains an unnamed node. Skipping.

Share this post


Link to post
Share on other sites

@Rodger sorry for slow reply, I had to take a break from code things for a bit! 
Thanks for the info. I've also noticed that with some craft setups it fails to pump any fuel so I will be looking into it.

 

26 minutes ago, Stone Blue said:

@katateochi Cant believe it took this long for someone to think of this... Good Job :D

Minor note in my log. I'm guessing its not game-breaking, since it skips it? :P

[WRN 20:20:02.897] Config in file 'E:\KSP\Windows\1.2.1\KSP_win64\GameData\DockingFuelPump\dfp_settings.cfg' contains an unnamed node. Skipping.

Thanks dude! 
That error is probably down to my noobish usage of config node! I'll see if I can sort that too. 
 

Share this post


Link to post
Share on other sites

I need that mod, badly. I've always had problems with fuel management and refueling stations, along with the horrid FPS drop and unresponsiveness of the game, I had enough and went looking for something like this that'll just transfer fuel from craft to craft, instead from specified tank to specified tank only. Which is stupid. Incredibly, incredibly stupid. This mod definitely should have been stock functionality from the beginning, and it astonishes me that it still is not, to this day.

The mod however doesn't seem to work anymore as of KSP v1.2.2.1622 x64 with Module Manager v2.7.5 either, it just crashes the game once the pump starts pumping. Before it crashes though, this happens:

ujxX79Z.png

Edited by BlackSun

Share this post


Link to post
Share on other sites

Update: Does it just not work with mod parts...? I tried it again, on the ground, with two rovers made from stock parts. And it worked. When trying in orbit, with my refueling station, it refuses to work. Depending on which ports I click on pump fuel, it even glitches and then crashes my game, like in the post above.

I'm using the OPT Space Plane parts, which offer right-click to change fuel tank layouts, and my stations main fuselage is the Warp Ship fuel tanks. Which are basically identical to the orange stock ones in values, just a bit shorter and looking much better. I don't like the raw orange finish on my station... so I went with the white ones instead.

And a shuttle out of OPT parts is docked there, too. So it's both Warpship and OPT parts connected to the station when attempting to pump.

I'll have to check if it's some specific parts on the ground... I really need this mod. Badly.

Edited by BlackSun

Share this post


Link to post
Share on other sites

Here we go.

GpUJ83g.png

That's what I tried to do just now. All stock parts, sandbox mode. It wouldn't transfer fuel.

On the other hand, however, this...

NlQA2n3.png

... does work. All stock parts, as well.

What gives? Did I miss something?

I really need this, badly. Someone, pliz halp. ;.;

Edited by BlackSun

Share this post


Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.