Fluid Level Indicator


Numerical display showing the fluid/gas level in a system.

Tweaks
13 days ago
1.1 - 2.0
55.0K
Fluids

i Flow circuit output

8 months ago
(updated 8 months ago)

I was honestly considering making a mod like this myself but I found this! These additions could be very powerful for flow control for a big distribution network with multiple inputs and outputs. Hopefully the factorio API has the stuff needed to make this work.
Bit of a long post but I feel like fully explaining the idea is better than not. All of the ideas kind of work together but I have written them in order of complexity.

Idea 1
Can you have the flow value output onto the circuit network as an "F" signal?

Idea 2
Can you also make the flow value output negative or positive depending on the direction the fluid is flowing through the pipe? The flow reading direction can be flipped by pressing "R"
(I foresee a possible crash or weird readings if two fluids are in the pipe somehow and it tries to do a calculation if you don't do a check for it)

Here are three images to demonstrate the entire concept:
https://imgur.com/a/dJXctVL

Also notice in the first two images that the flow reading is the same for both directions but the the level in the pipe is different?
This is exactly the kind of situation that would benefit from having the level and flow readings.
"I have 1500 units of fluid moving through the output pipe, but can only maintain a level of 37 even though my storage tank is at 80. The flow readings from the storage tank input pumps add up to 1000. I am losing 500 units overall...my consumption is too high for my fluid bus"

With access to the flow reading, the level reading would become roughly analogous to PSI in vanilla factorio.
Mod pipes with a different storage size will affect this.

Pipe mechanics forum post:
https://forums.factorio.com/viewtopic.php?t=19851

Eg)
Your level reading appears to be a percentage reading based off of the storage size of the pipe.
Indicator Output = (Fluid in pipe/Pipe storage size ) X 100 (AKA percentage full)

For a correct "PSI" reading that is inherently compatible with other mods the formula should be
Indicator Output = Fluid in pipe

All three readings are:
Percentage = (Fluid in pipe/Pipe storage size ) X 100
PSI = Fluid in pipe
Flow = Fluid unit(s)/second

In total you could have 3 circuit network readings:
Percentage = the reading this mod already has
PSI = P signal for fluid in pipe
Flow = F signal for fluid flow (negative or positive)

All three could theoretically be negative. I am not sure if factorio allows for negative PSI in its coding.
IRL the atmosphere has a pressure so a pressure reading from a gauge is actually the difference in pressure from the atmosphere to the gauge.
So sometimes people specify a reading as PSIG, where G indicates it is a gauge reading.

Eg)
The standard atmosphere pressure of earth is 14.69 PSI.
The atmosphere on Venus is 1334 PSI.

A gauge reading on earth that says -2 PSIG is 12.69 PSI Absolute
A gauge reading on venus that says -2 PSIG is 1332 PSI Absolute

If you took an "empty" tank of air from earth that has a PSIG of 0 and brought it to venus it would read -1317.31 PSIG

Idea 3
Time-series graph. This will probably be difficult to implement but it has been done before.
This would only be truly useful if all of the fluid reading are available.

Here is the only example mod I can find:
https://mods.factorio.com/mod/timeseries_fixfor110
This mod is quite old and appears to have issues

This idea would probably be best as an independent mod.
It plots any signal received over time and uses a combinator-like thing to receive signals.
This will probably be very UPS unfriendly so control over how many times the signal value is saved per minute is definitely needed.
And a limit to how far back the data is recorded.

Eg) 1 data point for all of the signals is plotted once every 10 seconds and the history is kept for 1 hour.

At the end of all of this I could make a factory alarms for oil fields that are dry
Predict how long my factory can keep running with current fluid stockpiles
And have alarms for when supply does not meet demand. (If i throw a bunch of speed modules in a refinery and alarms start going off then I know I will have issues)

All of the data manipulation can be done by combinators before being received by the "plotting combinator" for display.

And a couple of balance/UPS ideas

  1. I feel like the tech requirement for these should be "fluid handling and "circuit network."

  2. The UPS tax for each of these pipes may add up significantly. Instead, I suggest two tiers of indicators which also works into balancing.
    Basic and Advanced. Or "Local" and "Remote" indicators, respectively.

The Local indicator has no circuit network capabilities so it does not have unused extra resources. The tech and ingredient requirements are good as-is. Maybe reduce the display options as well. Anything to reduce the overhead while keeping them useful

The Remote indicator has circuit network capabilities, the tech requirement for these should be "fluid handling" and "circuit network," and also takes an arithmetic combinator to craft. If you think it should also take an advanced circuit, or just an advanced circuit without a combinator, then the tech should be "Advanced Electronics" and "circuit network." Fluid handling is already researched by the time you research Advanced Electronics, and even without the combinator the whole point of the Remote indicator is to be used with a circuit network.

8 months ago
(updated 8 months ago)

Thanks for this writeup! There are lots of good ideas there, I love it.

Idea 1:

It would be really awesome if we could do this. Unfortunately, you can not modify what gets output by the entity when you connect to it, it is all predefined (maybe in Factorio 2). As the fluid level indicators (FLI) are all “storage-tanks”, they only output the liquids contained in it. You could maybe specially design some constant combinator entity, that if you put it next to an FLI, it may be able to read out the flow from the neighboring FLI and then output it as a circuit signal.

Idea 2:

The flow direction could be displayed, with some overhead calculations. The unit would need to check pipe connections and see which one is input and output, then from the coordinates of the pipe connection, one could derive the flow direction. But again, a readout would not be directly possible unfortunately. But a negative sign, or due to lack of space an arrow alternating with the value is possible.
I agree, that the fluid percentage indicator is not showing “reality” with a non-stationary fluid. I had this in the description in the past, but removed it thinking that most people will not care. However, indeed, it shows the fluid amount in the pipe, which, if the system is stationary, will correspond to the level in the system. But is not a great indication of how “good” your fluid system is optimized. Probably a combo of the two types of readers e.g. a flow and the fluid level will give you a good idea.

Idea 3:

Not relevant because of my reply to 1 and 2, but there is also the mod graftorio, which I love the idea/concept of. This concept, combined with another mod (can’t remember the name), that just writes out all kinds of data in a csv file could in theory do what you want. And this way non circuit-stuff as well, could be written out, e.g. you could have a constant combi, that will get these values out using the API not the circuit network and write it to a file. Have a second monitor using Grafana to display all the juicy info.

8 months ago

I did quickly scan your code before this post and I did notice that you used storage tanks. I am not familiar with factorio modding but I got the jist of how you handled your mod output. To me it seems odd that it is "impossible" to get the flow value output when you have access to the data in a way that you can display it on the pipe already. Since you have the data there must be a way (even if not ideal) to get the same result.

Your combinator suggestion reminds me of this: Logistic Train Networks mod
The logistics train network mod has two entities used for I/O for every train stop. The solution to the problem may be to do what that modder has done.

Here are images of how they have done it:
https://imgur.com/a/nbDiwNf

Forum post about the mod:
https://forums.factorio.com/viewtopic.php?f=214&t=51072

If you read the post it says

"This mod adds one new train stop "logistic-train-stop" acting as anchor points for building a train powered logistic network.
Stops consist of 3 entities, the stop itself and the automatic placed lamp (input) and yellow constant combinator (output)."

8 months ago

Yes, that is exactly what I said in my reply under Idea 1. It is not impossible, but it is not possible to have it as a circuit network output of a storage tank, the only way is using a constant combinator entity in addition to the storage-tank.

8 months ago

Worth a try

New response