Skip to content

Commit

Permalink
SVU is now 5 and everything that is signal related references it
Browse files Browse the repository at this point in the history
  • Loading branch information
jrddunbr committed Aug 6, 2023
1 parent 378dfa5 commit f04c87f
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/main/java/mods/eln/Eln.java
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,17 @@ public class Eln {
float xRayScannerRange;
boolean addOtherModOreToXRay;
boolean xRayScannerCanBeCrafted = true;
double stdBatteryHalfLife = 2 * Utils.minecraftDay; public static final double SVU = 50, SVII = gateOutputCurrent / 50, SVUinv = 1.0 / SVU;
double stdBatteryHalfLife = 2 * Utils.minecraftDay;
public static final double SVU = 5, SVII = gateOutputCurrent / SVU, SVUinv = 1.0 / SVU;
double batteryCapacityFactor = 1.;
TestBlock testBlock;
private boolean replicatorPop;
private int plateConversionRatio;
private boolean ComputerProbeEnable;
private boolean ElnToOtherEnergyConverterEnable;
private EnergyConverterElnToOtherBlock elnToOtherBlockConverter;
private ComputerProbeBlock computerProbeBlock; public static final double SVP = gateOutputCurrent * SVU;
private ComputerProbeBlock computerProbeBlock;
public static final double SVP = gateOutputCurrent * SVU;
private ElectricalFurnaceDescriptor electricalFurnace;
private double incandescentLampLife;
private double economicLampLife;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package mods.eln.sixnode.electricalgatesource;

import mods.eln.Eln;
import mods.eln.gui.GuiHelper;
import mods.eln.gui.GuiScreenEln;
import mods.eln.gui.GuiVerticalTrackBar;
Expand All @@ -24,7 +25,7 @@ public void initGui() {
voltage = newGuiVerticalTrackBar(6, 6 + 2, 20, 50);
voltage.setStepIdMax((int) 100);
voltage.setEnable(true);
voltage.setRange(0f, 50f);
voltage.setRange(0f, (float) Eln.SVU);

syncVoltage();
}
Expand All @@ -46,7 +47,7 @@ public void guiObjectEvent(IGuiObject object) {
protected void preDraw(float f, int x, int y) {
super.preDraw(f, x, y);
if (render.voltageSyncNew) syncVoltage();
voltage.setComment(0, tr("Output at %1$%", ((int) voltage.getValue() * 2)));
voltage.setComment(0, tr("Output at %1$%", (int)((voltage.getValue() / Eln.SVU) * 100)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class ElectricalSensorElement extends SixNodeElement implements IConfigur
byte dirType = dirNone;
public static final byte powerType = 0, currantType = 1, voltageType = 2;
int typeOfSensor = voltageType;
float lowValue = 0, highValue = 50;
float lowValue = 0, highValue = (float) Eln.SVU;

public static final byte setTypeOfSensorId = 1;
public static final byte setValueId = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ElectricalSensorRender extends SixNodeElementRender {
long time;

int typeOfSensor = 0;
float lowValue = 0, highValue = 50;
float lowValue = 0, highValue = (float) Eln.SVU;
byte dirType;
CableRenderDescriptor cableRender = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void draw() {

front.glRotateOnX();

descriptor.draw(voltage >= 25);
descriptor.draw(voltage >= (Eln.SVU/2));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class ThermalSensorElement extends SixNodeElement implements IConfigurabl

static final byte powerType = 0, temperatureType = 1;
int typeOfSensor = temperatureType;
float lowValue = 0, highValue = 50;
float lowValue = 0, highValue = (float) Eln.SVU;

public static final byte setTypeOfSensorId = 1;
public static final byte setValueId = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ThermalSensorRender extends SixNodeElementRender {
LRDU front;

int typeOfSensor = 0;
float lowValue = 0, highValue = 50;
float lowValue = 0, highValue = (float) Eln.SVU;

ThermalCableDescriptor cable;
ElectricalCableDescriptor eCable;
Expand Down
20 changes: 15 additions & 5 deletions src/main/kotlin/mods/eln/sixnode/AnalogChips.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import java.io.ByteArrayOutputStream
import java.io.DataInputStream
import java.io.DataOutputStream
import java.io.IOException
import kotlin.math.sin

open class AnalogChipDescriptor(name: String, obj: Obj3D?, functionName: String,
functionClass: Class<out AnalogFunction>,
Expand Down Expand Up @@ -145,17 +146,17 @@ open class AnalogChipElement(node: SixNode, side: Direction, sixNodeDescriptor:
val builder = StringBuilder()
for (i in 1..3) {
val pin = inputPins[i - 1]
if (pin != null && pin.connectedComponents.count() > 0) {
if (pin != null && pin.connectedComponents.isNotEmpty()) {
builder.append("I$i: ").append(if (pin.stateLow()) "0"
else if (pin.stateHigh()) "1" else "?").append(", ")
}
}
builder.append(I18N.tr(" O: ")).append(if (outputProcess.voltage == 50.0) "1" else "0")
builder.append(I18N.tr(" O: ")).append(if (outputProcess.voltage == Eln.SVU) "1" else "0")
return builder.toString()
}

override fun getWaila(): Map<String, String> = function.getWaila(
inputPins.map { if (it != null && it.connectedComponents.count() > 0) it.voltage else null }.toTypedArray(),
inputPins.map { if (it != null && it.connectedComponents.isNotEmpty()) it.voltage else null }.toTypedArray(),
outputPin.voltage
)

Expand Down Expand Up @@ -422,8 +423,13 @@ open class VoltageControlledSawtoothOscillator : AnalogFunction() {

private var out = 0.0

// 0v = 0.1Hz through 5v = 10Hz
open val hertzFunction = LinearFunction(0f, 0.1f, Eln.SVU.toFloat(), (1 / Eln.simulator.callPeriod).toFloat())

override fun process(inputs: Array<Double?>, deltaTime: Double): Double {
out += Math.pow(50.0, (inputs[0] ?: 0.0) / 50) * 2 * deltaTime
val hertz = hertzFunction.getValue(inputs[0]?: 0.0)
val halfPeriod = (1 / hertz) * 0.5
out += Eln.simulator.callPeriod/halfPeriod
if (out > Eln.SVU) {
out = 0.0
}
Expand All @@ -440,8 +446,12 @@ open class VoltageControlledSawtoothOscillator : AnalogFunction() {
}

class VoltageControlledSineOscillator : VoltageControlledSawtoothOscillator() {
val svu2 = Eln.SVU/2

override val hertzFunction = LinearFunction(0f, 0.01f, Eln.SVU.toFloat(), 0.5f)

override fun process(inputs: Array<Double?>, deltaTime: Double) =
25.0 + 25.0 * Math.sin(Math.PI * super.process(inputs, deltaTime) / 25.0)
svu2 + svu2 * sin(Math.PI * 2 * super.process(inputs, deltaTime))
}

class Amplifier : AnalogFunction() {
Expand Down
7 changes: 6 additions & 1 deletion src/main/kotlin/mods/eln/sixnode/LogicGate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,13 @@ class Oscillator : LogicFunction() {
private var ramp = 0.0
private var state = false

// 0v = 0.1Hz through 5v = 10Hz
private val hertzFunction = LinearFunction(0f, 0.1f, Eln.SVU.toFloat(), (1 / Eln.simulator.callPeriod).toFloat())

override fun process(inputs: Array<Double?>): Boolean {
ramp += Math.pow(50.0, (inputs[0] ?: 0.0)) / 50
val hertz = hertzFunction.getValue(inputs[0]?: 0.0)
val halfPeriod = (1 / hertz) * 0.5
ramp += Eln.simulator.callPeriod/halfPeriod
if (ramp >= 1) {
ramp = 0.0
state = !state
Expand Down

0 comments on commit f04c87f

Please sign in to comment.