Skip to content

Commit

Permalink
Added mAh to battery descriptor
Browse files Browse the repository at this point in the history
Signal cables do not anymore connect to power cables
Added min-max integrator function to math block
  • Loading branch information
Michael Clausen committed Feb 25, 2014
1 parent 216d109 commit 36bb634
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 21 deletions.
3 changes: 2 additions & 1 deletion mods/eln/battery/BatteryDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import org.bouncycastle.jcajce.provider.asymmetric.dsa.DSASigner.stdDSA;


import mods.eln.Eln;
import mods.eln.client.ClientProxy;
import mods.eln.electricalcable.ElectricalCableDescriptor;
import mods.eln.gui.GuiLabel;
import mods.eln.misc.FunctionTable;
import mods.eln.misc.Obj3D.Obj3DPart;
import mods.eln.misc.Utils;
import mods.eln.node.NodeElectricalLoad;
import mods.eln.node.NodeThermalLoad;
import mods.eln.node.NodeThermalWatchdogProcess;
Expand Down Expand Up @@ -186,6 +186,7 @@ public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer,
list.add("Nominal voltage : " + (int)(electricalU) + "V");
list.add("Nominal power : " + (int)(electricalStdP) + "W");
list.add("Full charge energy : " + (int)(electricalStdDischargeTime*electricalStdP/1000) + "KJ");
list.add("Capacity : " + Utils.plotValue((electricalQ/3600),"Ah"));
list.add("");
list.add("Charge : " + (int)(getChargeInTag(itemStack)*100) + "%");

Expand Down
2 changes: 1 addition & 1 deletion mods/eln/electricalcable/ElectricalCableElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public ThermalLoad getThermalLoad(LRDU lrdu) {
@Override
public int getConnectionMask(LRDU lrdu) {
// TODO Auto-generated method stub
return descriptor.getNodeMask() + NodeBase.maskElectricalWire + (color << NodeBase.maskColorShift) +(colorCare << NodeBase.maskColorCareShift);
return descriptor.getNodeMask() /*+ NodeBase.maskElectricalWire*/ + (color << NodeBase.maskColorShift) +(colorCare << NodeBase.maskColorCareShift);
}


Expand Down
14 changes: 0 additions & 14 deletions mods/eln/modbusrtu/ModbusRtuDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,5 @@ void draw(float open, boolean activityLed, boolean errorLed)
display.draw();
}
}

GL11.glEnable(GL11.GL_TEXTURE_2D);

FontRenderer fontrenderer = Minecraft.getMinecraft().fontRenderer;
GL11.glPushMatrix();
float scale = 0.01f;
GL11.glScalef(scale,scale, 1f);

fontrenderer.drawString("Toto", 0, 0, 0);
GL11.glPopMatrix();
}




}
7 changes: 6 additions & 1 deletion mods/eln/modbusrtu/ModbusRtuGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,12 @@ public void guiObjectEvent(IGuiObject object) {
// TODO Auto-generated method stub
super.guiObjectEvent(object);
if(object == station){
render.clientSetInt(ModbusRtuElement.setStation, Integer.parseInt(station.getText()));
try {
render.clientSetInt(ModbusRtuElement.setStation, Integer.parseInt(station.getText()));
} catch (NumberFormatException e) {
// TODO: handle exception
}

}else if(object == name){
render.clientSetString(ModbusRtuElement.setName, name.getText());
}else if(object == txAddButton){
Expand Down
12 changes: 8 additions & 4 deletions mods/eln/modbusrtu/ModbusRtuRender.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.ArrayList;
import java.util.HashMap;

import mods.eln.Eln;
import mods.eln.cable.CableRenderDescriptor;
import mods.eln.cable.CableRenderType;
import mods.eln.client.ClientProxy;
Expand Down Expand Up @@ -79,13 +80,13 @@ public void draw() {

LRDU.Down.glRotateOnX();

descriptor.draw(interpolator.get(), modbusActivityTimeout > 0, modbusErrorTimeout > 0);

if (modbusActivityTimeout > 0)
modbusActivityTimeout -= FrameTime.get();

if (modbusErrorTimeout > 0)
modbusErrorTimeout -= FrameTime.get();

descriptor.draw(interpolator.get(), modbusActivityTimeout > 0, modbusErrorTimeout > 0);
}

int station = -1;
Expand Down Expand Up @@ -173,7 +174,7 @@ public void serverPacketUnserialize(DataInputStream stream)
break;

case ModbusRtuElement.ClientModbusActivityEvent:
modbusActivityTimeout = 0.1f;
modbusActivityTimeout = 0.05f;
break;

case ModbusRtuElement.ClientModbusErrorEvent:
Expand All @@ -190,6 +191,9 @@ public GuiScreen newGuiDraw(Direction side, EntityPlayer player) {
return new ModbusRtuGui(player, this);
}


public CableRenderDescriptor getCableRender(LRDU lrdu)
{
return Eln.instance.signalCableDescriptor.render;
}

}
47 changes: 47 additions & 0 deletions mods/eln/solver/Equation.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,22 @@ public Equation(String exp,ArrayList<ISymbole> symboleList,int iterationLimit)
break;
}
}
if(str.equals("integrate")){
if(isFuncReady(3,list,idx)){
operatorCount+=3;
IntegratorMinMax integrator;
IValue c = (IValue) list.get(idx + 2);
IValue d = (IValue) list.get(idx + 4);
IValue e = (IValue) list.get(idx + 6);
list.set(idx,integrator = new IntegratorMinMax(c,d,e));
removeFunc(3,list,idx);
priority = -1;
depthMax = getDepthMax(list);
processList.add(integrator);
nbtList.add(integrator);
break;
}
}
if(str.equals("derivate")){
if(isFuncReady(1,list,idx)){
operatorCount+=2;
Expand Down Expand Up @@ -629,6 +645,37 @@ public void process(double time) {
}
}

public class IntegratorMinMax implements IValue,INBTTReady,IProcess{
public double counter;
public IntegratorMinMax(IValue probe,IValue min, IValue max) {
this.probe = probe;
this.min = min;
this.max = max;
counter = 0.0;
}
public IValue probe,min,max;
@Override
public double getValue() {
return counter;
}
@Override
public void readFromNBT(NBTTagCompound nbt, String str) {
// TODO Auto-generated method stub
counter = nbt.getDouble(str + "counter");
}
@Override
public void writeToNBT(NBTTagCompound nbt, String str) {
// TODO Auto-generated method stub
nbt.setDouble(str + "counter", counter);
}
@Override
public void process(double time) {
counter += time*probe.getValue();
if(counter < min.getValue()) counter = min.getValue();
if(counter > max.getValue()) counter = max.getValue();
}
}

public class Derivator implements IValue,INBTTReady,IProcess{
public double old,value;
public Derivator(IValue probe) {
Expand Down

0 comments on commit 36bb634

Please sign in to comment.