This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Stekeblad's profile picture

Powergraph - displays stored energy with a graph

Started by Stekeblad, 27 February 2016 - 07:38 PM
Stekeblad #1
Posted 27 February 2016 - 08:38 PM
Do you want to have a quick and easy way to see how much RF or EU you have in your capacitorbank/energy cube/MFSU/energy cell/energy core….. ?
Do you want to see how its gone up and down the last minute, or ten?

Try Powergraph!






Introducing PowergraphMulti

PowergraphMulti is a updated version of Powergraph that supports multiple monitors and energy storage blocks, if you before wanted to use multiple monitors you had to run several copies of Powergraph, but not anymore.

Features!
  • Designed for all monitors from 3*2 and bigger (like the one above). But smaller works.
  • Advanced and normal monitor support.
  • Supports energy storage blocks from several mods.
  • The color of the graph can be changed (requires advanced monitor).
  • Supports adding a one line name at the bottom, with no name added the bottom row will be used by the graph.
  • Configurable update time.
  • PowergraphMulti is designed for using several energy storages and monitors
  • Set text scale / resolution for monitors - Fit more details on a small monitor or make it easier to read from far away!
[indent=1]SimpleMode[/indent]
[indent=1]With simpleMode (enabled by default) you can just place down the computer and connect the peripherals, run the program and it will hopefully work without any configuration in the program! simpleMode will only take the first monitor and energy storage it finds so if you want to connect multiple energy storages or monitors you still need to configure it. SimpleMode scans for the energy storages listed under "Tested mods and blocks"[/indent]

Current limitations
  • Screen size to not update automaticly, program restart required. (will probably not be implemented)
Tested mods and blocks
First, note that many blocks will not work with pure Computercraft, many of them will need one of the extra peripherals mods! (don't know witch)
The following mods and blocks should work with correct configuration, other blocks may or may not work, try it.
  • Energy Cell (Thermal Expansion)
  • Capacitor Bank (Ender IO)
  • Energy Core (Draconic Evolution) (connect to an energy pylon)
  • Batbox/MFE/MFSU (Industrial Craft 2) (Only with peripheral proxy from OpenPeripherals)
  • Energy Cube and Induction storage (Mekanism)
  • lv/mv/hv Capacitor (Immersive Engineering)
  • Reactor and Turbine (Big Reactors)
The following mods and blocks are known to not work
  • no currently known

Configuring program settings
SpoilerThe settings part of the program is located right at the beginning of the file and looks like this:

  ------------- Configuration part ------------------

  -- Seconds between checking stored energy
  -- and updating monitors (default: 5)
local updateInterval = 5

-- Simple mode tries to scan for compatible storages and
-- wrap the first found one and the first found monitor
-- For more advanced configuration, set this to false and
-- and fill the dataTable below (example follows)
-- Default: true
local simpleMode = true

local dataTable = {

}

  -- help for how to fill dataTable:
--[[ add a comma at the end of all lines except the
  last one in all tables.
  "[required]" in front of a line means you need to
  have it or the program won't work, rows with
  "[optional]" are optional and can be left out.
  The following information can be added:

  [required] monitor = the side or network name
			of a monitor connected to the computer.
  [required] energy = the energy storage witch
			content should be displayed on the
			monitor defined above.
  [optional] text = a word or sentence that will
			be displayed at the bottom line on the
			monitor.
  [optional] blitColor = Will be ignored if its
			not a advanced monitor, specifies the
			color of the graph, see following link
			for help:
			http://www.computercraft.info/wiki/Colors_(API)#Colors
			allowed values are 0-9 and a-f,
			defaults to 5 (green)
  [optional] textSize = Sets how large the text is and
			how thick the graph line is.
			Needs to be between 0.5 and 5 and is in
			steps of 0.5. eg 0.5, 1, 1.5 ... 4.5, 5
			Default is 1. (5 is very large text)

	local Example = {
	  {
	  monitor = "monitor_1",	<-- comma
	  energy = "tile_blockcapacitorbank_name_0", <--comma
	  text = "ME Backup",	 <-- comma
	  blitColor = "5"	   <-- no comma, last line for this monitor-battery pair
	  },{		 <-- comma between braces, their are more monitor-battery pairs
	  monitor = "top",	  <-- comma
	  energy = "back",	<-- comma
	  textSize = 0.5		<-- no comma, last line in this pair
	  }	   <-- no comma, this was last pair
	}		 <-- closing the example table, no comma

  ]] -- (ignore this two brackets, they indicate
	 -- the end of this long multi-line comment)

------------- End of configuration part --------------------

License
MIT-license

Download
pastebin get 9KpbFEqb powergraphMulti

Updates
6 March 2016: Bug fix and added support for IC2 EU storage

9 April 2016: Added PowergraphMulti

28 May 2016: Added ability to set text scale for monitors in powergraphMulti

10 August 2016: Small update to support Mekansim energy cubes and induction storage

24 January 2017: Added simpleMode

26 January 2017: Added support for BigReactors

10 November 2017: Added support for reading energy information using Plethora for increased peripheral support (looks for the existence of getMetadata().energy.capacity and getMetadata().energy.stored in the wrapped peripheral.)


Open for suggestions for new features.
Edited on 10 November 2017 - 09:45 PM
Lupus590 #2
Posted 28 February 2016 - 02:13 PM
Your image hasn't posted properly.

Also, change "not so good" to "current limitations" it reads better

as for multi monitor support, put them all in a table and put your monitor interactions in a loop.
Edited on 28 February 2016 - 01:15 PM
Stekeblad #3
Posted 29 February 2016 - 12:07 PM
Thanks, the Image looked like it worked in two different browsers then I posted it, updated the post. I also changed to current limitations as you suggested.

Is multi monitor support a function that many users want?
It would probably needs some bigger changes to support multiple monitors of different sizes, easiest right now is to run several copies of the program configured to use different monitors.
Stekeblad #4
Posted 02 March 2016 - 02:38 PM
Added License information and pasted a copy of the settings part of the program
LDDestroier #5
Posted 02 March 2016 - 04:58 PM
You can detect if the monitor changes shape with os.pullEvent("monitor_resize")
Stekeblad #6
Posted 02 March 2016 - 05:20 PM
I know I can detect montior resize but I don't feel like it is something needed. A quick restart of the program and its working. (ctrl+t, arrow up, enter or ctrl+r if running as startup)
Stekeblad #7
Posted 06 March 2016 - 05:26 PM
Fixed Image that seems to break after a short time, hope it works now.

Fixed a bug and added support for Industrial craft EU

I also took a look at monitor resize-ing and multi-monitor support but decided to not implement it, if I add support for multiple monitors I have so many features that I can think off and would like to add that it will not be the powergraph I want anymore. (And probably to difficult for me to do right now). Powergraph is made to be a short program that displays the power of a storage as a graph (currently ~175 lines). If someone want a multi-monitor version he or she is free to create one based on my code.
Edited on 06 March 2016 - 04:28 PM
Stekeblad #8
Posted 09 April 2016 - 05:59 PM
Added support for multiple monitors/energy storages!

Download PowergraphMulti if you want to test it, no changes in old Powergraph.
Stekeblad #9
Posted 28 May 2016 - 08:07 PM
Small update for PowergraphMulti: You can now set text scale for every monitor-battery pair. You can have bigger text on monitors far away and more details on a small one.
augiteSoul #10
Posted 29 May 2016 - 02:53 PM
How do you set it? (with modems? monitors?)
Stekeblad #11
Posted 30 May 2016 - 11:48 AM
How do you set it? (with modems? monitors?)

You need a monitor to display the graph on and a energy storage to watch (tested with Thermal Expansion, Ender IO and Industrial Craft), you connect the energy storage and monitor to the computer by placing them next to the computer or using modems.

How you configure the program settings is in the spoilers in the first post and in the code.

Little example for PowergraphMulti
You have an advanced computer and monitor and want to monitor the energy in your Ender IO capacitor bank. The monitor is on top of the computer and the capacitor bank is connected to the computer using wired modems. Then you turn on the modem the bank gets a name displayed in your chat, something like tile_blockcapacitorbank_name_0
You like the color blue and want your graph to have that color.

The configuration will then look like this:

  -- Seconds between checking stored energy
  -- and updating monitors (default: 5)
local updateInterval = 5

local dataTable = {
  {
	monitor = "top",
	energy = "tile_blockcapacitorbank_name_0",
	blitColor = "b"
  }
}
...

Then you run PowergraphMulti for the first time it will see their is no configuration and open itself to be edited.

If you still don't understand, reply and I will try to help you.
augiteSoul #12
Posted 30 May 2016 - 03:42 PM
How do you set it? (with modems? monitors?)

You need a monitor to display the graph on and a energy storage to watch (tested with Thermal Expansion, Ender IO and Industrial Craft), you connect the energy storage and monitor to the computer by placing them next to the computer or using modems.

How you configure the program settings is in the spoilers in the first post and in the code.

Little example for PowergraphMulti
You have an advanced computer and monitor and want to monitor the energy in your Ender IO capacitor bank. The monitor is on top of the computer and the capacitor bank is connected to the computer using wired modems. Then you turn on the modem the bank gets a name displayed in your chat, something like tile_blockcapacitorbank_name_0
You like the color blue and want your graph to have that color.

The configuration will then look like this:

  -- Seconds between checking stored energy
  -- and updating monitors (default: 5)
local updateInterval = 5

local dataTable = {
  {
	monitor = "top",
	energy = "tile_blockcapacitorbank_name_0",
	blitColor = "b"
  }
}
...

Then you run PowergraphMulti for the first time it will see their is no configuration and open itself to be edited.

If you still don't understand, reply and I will try to help you.

I'll try it and I will edit this post to say if it worked.
EDIT: Not working, will put code and screens here.
Edited on 30 May 2016 - 01:53 PM
Stekeblad #13
Posted 10 August 2016 - 12:12 AM
small update adding support for mekanism energy cubes and induction storage multi block
Stekeblad #14
Posted 24 January 2017 - 04:31 PM
Updated!
There is now a setting called simpleMode that is enabled by default. Use it then you only have one monitor and energy storage you want to monitor, you only need to connect the energy storage and monitor to the computer by wired modems or placing them next to it and then run the program. If the energy storage is one of the tested once it will work directly.
TheRockettek #15
Posted 24 January 2017 - 04:41 PM
erm the max storage for big reactors turbines and reactors is 10million rf reguardless
Stekeblad #16
Posted 25 January 2017 - 06:47 AM
They always have 10 million but because they don't have a type of maxEnergy function I need to write extra code to detect if it is a reactor or turbine and set a variable. I can probably write some code for it but currently they don't work. I have a idea I can test later.
TheRockettek #17
Posted 25 January 2017 - 07:22 AM
Well
You can do peripheral.getType() and I thought it returns like bigreators-reactor or -turbine
Stekeblad #18
Posted 26 January 2017 - 06:55 PM
I made some testing, for me a reactor has a storage of 10 million but a turbine only has 1 million. I believed they both had 10 million RF storage… I even tested in two different modpacks and one of them with default config. Both had big reactors 0.4.3A (currently latest for 1.7.10).

Well
You can do peripheral.getType() and I thought it returns like bigreators-reactor or -turbine
Getting the name of the blocks is not difficult, place down a modem, turn it on and write down the name. To handle it like I currently to with IC2 and Mekanism the peripheral is already wrapped then I check if it supports functions to get stored/max RF.

EnderIO and Thermal expansion for example has the functions getEnergyStored and getMaxEnergyStored. Then I added support for mekanism I took a more general approach and instead of looking for "Energy Cube" I checked for the functions getEnergy and getMaxEnergy. Note: getEnergy not getEnergyStored

For the reactors and turbines I was testing for a function they had in common and getEnergyStored and created my own getMaxEnergyStored that returned 10 million. Then they don't even have the same storage capacity and I can't call a function for it I will take a specific approach and test for something very unique for each of them, like getControlRodLevel and getBladeEfficiency.

———————————————
Support for Big Reactors turbine and reactor is now implemented and should work.
Stekeblad #19
Posted 10 November 2017 - 10:51 PM
New update! If you play with Plethora you should be able to get energy information of blocks. Not much testing done yet but you can for example connect a Thermal Expansion energy cell and Powergraph will be able to work with it. (Energy cells is not a valid peripheral without Plethora)