Multimeter now only shows power for appropriate devices
This commit is contained in:
parent
4d2e7a10f6
commit
f5e35f9924
7 changed files with 73 additions and 19 deletions
|
@ -86,4 +86,6 @@ public abstract class Graph<V extends Comparable<V>>
|
||||||
public abstract NBTTagCompound save();
|
public abstract NBTTagCompound save();
|
||||||
|
|
||||||
public abstract double getDouble();
|
public abstract double getDouble();
|
||||||
|
|
||||||
|
public abstract V getAverage();
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,4 +66,23 @@ public class GraphF extends Graph<Float>
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Float getAverage()
|
||||||
|
{
|
||||||
|
if (points.size() > 0)
|
||||||
|
{
|
||||||
|
float average = 0;
|
||||||
|
|
||||||
|
for (float point : points)
|
||||||
|
{
|
||||||
|
average += point;
|
||||||
|
}
|
||||||
|
|
||||||
|
average /= points.size();
|
||||||
|
|
||||||
|
return average;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,4 +65,23 @@ public class GraphI extends Graph<Integer>
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer getAverage()
|
||||||
|
{
|
||||||
|
if (points.size() > 0)
|
||||||
|
{
|
||||||
|
int average = 0;
|
||||||
|
|
||||||
|
for (int point : points)
|
||||||
|
{
|
||||||
|
average += point;
|
||||||
|
}
|
||||||
|
|
||||||
|
average /= points.size();
|
||||||
|
|
||||||
|
return average;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,4 +65,24 @@ public class GraphL extends Graph<Long>
|
||||||
return get();
|
return get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getAverage()
|
||||||
|
{
|
||||||
|
if (points.size() > 0)
|
||||||
|
{
|
||||||
|
long average = 0;
|
||||||
|
|
||||||
|
for (long point : points)
|
||||||
|
{
|
||||||
|
average += point;
|
||||||
|
}
|
||||||
|
|
||||||
|
average /= points.size();
|
||||||
|
|
||||||
|
return average;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,15 +17,19 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
||||||
{
|
{
|
||||||
public final List<String> displayInformation = new ArrayList<String>();
|
public final List<String> displayInformation = new ArrayList<String>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum data points a graph can store.
|
||||||
|
*/
|
||||||
|
private int maxData = 1;
|
||||||
/**
|
/**
|
||||||
* The available graphs to be handled.
|
* The available graphs to be handled.
|
||||||
*/
|
*/
|
||||||
private int maxData = 20 * 10;
|
|
||||||
public final List<Graph> graphs = new ArrayList<Graph>();
|
public final List<Graph> graphs = new ArrayList<Graph>();
|
||||||
/**
|
/**
|
||||||
* Energy Related
|
* Energy Related
|
||||||
*/
|
*/
|
||||||
public final GraphL energyGraph = new GraphL("Energy", maxData);
|
public final GraphL energyGraph = new GraphL("Energy", maxData);
|
||||||
|
public final GraphL powerGraph = new GraphL("Power", maxData);
|
||||||
public final GraphL energyCapacityGraph = new GraphL("Capacity", 1);
|
public final GraphL energyCapacityGraph = new GraphL("Capacity", 1);
|
||||||
public final GraphL voltageGraph = new GraphL("Voltage", maxData);
|
public final GraphL voltageGraph = new GraphL("Voltage", maxData);
|
||||||
public final GraphL torqueGraph = new GraphL("Torque", maxData);
|
public final GraphL torqueGraph = new GraphL("Torque", maxData);
|
||||||
|
@ -63,6 +67,7 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
||||||
public MultimeterNetwork()
|
public MultimeterNetwork()
|
||||||
{
|
{
|
||||||
graphs.add(energyGraph);
|
graphs.add(energyGraph);
|
||||||
|
graphs.add(powerGraph);
|
||||||
graphs.add(energyCapacityGraph);
|
graphs.add(energyCapacityGraph);
|
||||||
graphs.add(voltageGraph);
|
graphs.add(voltageGraph);
|
||||||
graphs.add(torqueGraph);
|
graphs.add(torqueGraph);
|
||||||
|
@ -81,6 +86,9 @@ public class MultimeterNetwork extends Network<MultimeterNetwork, PartMultimeter
|
||||||
if (graph == energyGraph)
|
if (graph == energyGraph)
|
||||||
graphValue = UnitDisplay.getDisplay(energyGraph.get(), Unit.JOULES);
|
graphValue = UnitDisplay.getDisplay(energyGraph.get(), Unit.JOULES);
|
||||||
|
|
||||||
|
if (graph == powerGraph)
|
||||||
|
graphValue = UnitDisplay.getDisplay(powerGraph.get(), Unit.WATT);
|
||||||
|
|
||||||
if (graph == energyCapacityGraph)
|
if (graph == energyCapacityGraph)
|
||||||
graphValue = UnitDisplay.getDisplay(energyCapacityGraph.get(), Unit.JOULES);
|
graphValue = UnitDisplay.getDisplay(energyCapacityGraph.get(), Unit.JOULES);
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ import universalelectricity.api.CompatibilityModule;
|
||||||
import universalelectricity.api.electricity.IElectricalNetwork;
|
import universalelectricity.api.electricity.IElectricalNetwork;
|
||||||
import universalelectricity.api.energy.IConductor;
|
import universalelectricity.api.energy.IConductor;
|
||||||
import universalelectricity.api.energy.IEnergyNetwork;
|
import universalelectricity.api.energy.IEnergyNetwork;
|
||||||
|
import universalelectricity.api.energy.UnitDisplay;
|
||||||
|
import universalelectricity.api.energy.UnitDisplay.Unit;
|
||||||
import universalelectricity.api.net.IConnector;
|
import universalelectricity.api.net.IConnector;
|
||||||
import atomicscience.api.ITemperature;
|
import atomicscience.api.ITemperature;
|
||||||
import calclavia.lib.network.IPacketReceiver;
|
import calclavia.lib.network.IPacketReceiver;
|
||||||
|
@ -260,6 +262,7 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
|
||||||
{
|
{
|
||||||
IEnergyNetwork network = instance.getNetwork();
|
IEnergyNetwork network = instance.getNetwork();
|
||||||
getNetwork().energyGraph.queue(Math.max(network.getBuffer(), network.getLastBuffer()));
|
getNetwork().energyGraph.queue(Math.max(network.getBuffer(), network.getLastBuffer()));
|
||||||
|
getNetwork().powerGraph.queue(getNetwork().energyGraph.getAverage() * 20);
|
||||||
|
|
||||||
if (instance.getNetwork() instanceof IElectricalNetwork)
|
if (instance.getNetwork() instanceof IElectricalNetwork)
|
||||||
getNetwork().voltageGraph.queue(((IElectricalNetwork) network).getVoltage());
|
getNetwork().voltageGraph.queue(((IElectricalNetwork) network).getVoltage());
|
||||||
|
@ -286,6 +289,7 @@ public class PartMultimeter extends PartFace implements IConnector<MultimeterNet
|
||||||
getNetwork().torqueGraph.queue(instance.getTorque());
|
getNetwork().torqueGraph.queue(instance.getTorque());
|
||||||
getNetwork().angularVelocityGraph.queue(instance.getAngularVelocity());
|
getNetwork().angularVelocityGraph.queue(instance.getAngularVelocity());
|
||||||
getNetwork().energyGraph.queue((long) (instance.getTorque() * instance.getAngularVelocity()));
|
getNetwork().energyGraph.queue((long) (instance.getTorque() * instance.getAngularVelocity()));
|
||||||
|
getNetwork().powerGraph.queue(getNetwork().energyGraph.getAverage() * 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,24 +189,6 @@ public class RenderMultimeter implements ISimpleItemRenderer
|
||||||
|
|
||||||
List<String> information = new ArrayList<String>();
|
List<String> information = new ArrayList<String>();
|
||||||
|
|
||||||
if (part.getNetwork().energyGraph.get(0) > 0 && part.getNetwork().energyGraph.points.size() > 0)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Compute power
|
|
||||||
*/
|
|
||||||
long power = 0;
|
|
||||||
|
|
||||||
for (long point : part.getNetwork().energyGraph.points)
|
|
||||||
{
|
|
||||||
power += point;
|
|
||||||
}
|
|
||||||
|
|
||||||
power /= part.getNetwork().energyGraph.points.size();
|
|
||||||
|
|
||||||
if (power > 0)
|
|
||||||
information.add("Power: " + UnitDisplay.getDisplay(power * 20, Unit.WATT));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < part.getNetwork().graphs.size(); i++)
|
for (int i = 0; i < part.getNetwork().graphs.size(); i++)
|
||||||
{
|
{
|
||||||
if (part.getNetwork().graphs.get(i).get() != null && !part.getNetwork().graphs.get(i).get().equals(part.getNetwork().graphs.get(i).getDefault()))
|
if (part.getNetwork().graphs.get(i).get() != null && !part.getNetwork().graphs.get(i).get().equals(part.getNetwork().graphs.get(i).getDefault()))
|
||||||
|
|
Loading…
Reference in a new issue