Skip to content

Commit

Permalink
Code Style: Indentation settings
Browse files Browse the repository at this point in the history
  • Loading branch information
11 committed Feb 27, 2024
1 parent 2eab128 commit 3422802
Show file tree
Hide file tree
Showing 191 changed files with 30,878 additions and 28,048 deletions.
16 changes: 12 additions & 4 deletions src/main/java/com/lushprojects/circuitjs1/client/ACRailElm.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@

package com.lushprojects.circuitjs1.client;

class ACRailElm extends RailElm {
public ACRailElm(int xx, int yy) { super(xx, yy, WF_AC); }
Class getDumpClass() { return RailElm.class; }
int getShortcut() { return 0; }
public class ACRailElm extends RailElm {
public ACRailElm(int xx, int yy) {
super(xx, yy, WF_AC);
}

Class getDumpClass() {
return RailElm.class;
}

int getShortcut() {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@

package com.lushprojects.circuitjs1.client;

class ACVoltageElm extends VoltageElm {
public ACVoltageElm(int xx, int yy) { super(xx, yy, WF_AC); }
Class getDumpClass() { return VoltageElm.class; }
public class ACVoltageElm extends VoltageElm {
public ACVoltageElm(int xx, int yy) {
super(xx, yy, WF_AC);
}

Class getDumpClass() {
return VoltageElm.class;
}
}
85 changes: 55 additions & 30 deletions src/main/java/com/lushprojects/circuitjs1/client/ADCElm.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,51 +19,76 @@

package com.lushprojects.circuitjs1.client;

class ADCElm extends ChipElm {
public ADCElm(int xx, int yy) { super(xx, yy); }
public class ADCElm extends ChipElm {
public ADCElm(int xx, int yy) {
super(xx, yy);
}

public ADCElm(int xa, int ya, int xb, int yb, int f,
StringTokenizer st) {
super(xa, ya, xb, yb, f, st);
StringTokenizer st) {
super(xa, ya, xb, yb, f, st);
}
String getChipName() { return "ADC"; }
boolean needsBits() { return true; }

String getChipName() {
return "ADC";
}

boolean needsBits() {
return true;
}

void setupPins() {
sizeX = 2;
sizeY = bits > 2 ? bits : 2;
pins = new Pin[getPostCount()];
int i;
for (i = 0; i != bits; i++) {
pins[i] = new Pin(bits-1-i, SIDE_E, "D" + i);
pins[i].output = true;
}
pins[bits] = new Pin(0, SIDE_W, "In");
pins[bits+1] = new Pin(sizeY-1, SIDE_W, "V+");
allocNodes();
sizeX = 2;
sizeY = bits > 2 ? bits : 2;
pins = new Pin[getPostCount()];
int i;
for (i = 0; i != bits; i++) {
pins[i] = new Pin(bits - 1 - i, SIDE_E, "D" + i);
pins[i].output = true;
}
pins[bits] = new Pin(0, SIDE_W, "In");
pins[bits + 1] = new Pin(sizeY - 1, SIDE_W, "V+");
allocNodes();
}

void execute() {
int imax = (1<<bits)-1;
// if we round, the half-flash doesn't work
double val = imax*volts[bits]/volts[bits+1]; // + .5;
int ival = (int) val;
ival = min(imax, max(0, ival));
int i;
for (i = 0; i != bits; i++)
pins[i].value = ((ival & (1<<i)) != 0);
int imax = (1 << bits) - 1;
// if we round, the half-flash doesn't work
double val = imax * volts[bits] / volts[bits + 1]; // + .5;
int ival = (int) val;
ival = min(imax, max(0, ival));
int i;
for (i = 0; i != bits; i++)
pins[i].value = ((ival & (1 << i)) != 0);
}

int getVoltageSourceCount() {
return bits;
}

int getPostCount() {
return bits + 2;
}

int getDumpType() {
return 167;
}
int getVoltageSourceCount() { return bits; }
int getPostCount() { return bits+2; }
int getDumpType() { return 167; }

// there's already a V+ pin, how does that relate to high logic voltage? figure out later
@Override boolean isDigitalChip() { return false; }
@Override
boolean isDigitalChip() {
return false;
}

public EditInfo getChipEditInfo(int n) {
if (n == 0)
return new EditInfo("# of Bits", bits, 1, 1).setDimensionless();
return null;
}

public void setChipEditValue(int n, EditInfo ei) {
if (n == 0 && ei.value >= 2) {
bits = (int)ei.value;
bits = (int) ei.value;
setupPins();
setPoints();
}
Expand Down
193 changes: 108 additions & 85 deletions src/main/java/com/lushprojects/circuitjs1/client/AMElm.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,123 +21,146 @@

// contributed by Edward Calver

class AMElm extends CircuitElm {
public class AMElm extends CircuitElm {
static final int FLAG_COS = 2;
double carrierfreq,signalfreq, maxVoltage, freqTimeZero;
double carrierfreq, signalfreq, maxVoltage, freqTimeZero;

public AMElm(int xx, int yy) {
super(xx, yy);
maxVoltage = 5;
carrierfreq = 1000;
signalfreq=40;
reset();
super(xx, yy);
maxVoltage = 5;
carrierfreq = 1000;
signalfreq = 40;
reset();
}

public AMElm(int xa, int ya, int xb, int yb, int f,
StringTokenizer st) {
super(xa, ya, xb, yb, f);
carrierfreq = new Double(st.nextToken()).doubleValue();
signalfreq= new Double(st.nextToken()).doubleValue();
maxVoltage = new Double(st.nextToken()).doubleValue();
if ((flags & FLAG_COS) != 0) {
flags &= ~FLAG_COS;
}
reset();
}
int getDumpType() { return 200; }
StringTokenizer st) {
super(xa, ya, xb, yb, f);
carrierfreq = new Double(st.nextToken()).doubleValue();
signalfreq = new Double(st.nextToken()).doubleValue();
maxVoltage = new Double(st.nextToken()).doubleValue();
if ((flags & FLAG_COS) != 0) {
flags &= ~FLAG_COS;
}
reset();
}

int getDumpType() {
return 200;
}

String dump() {
return super.dump() + " " +carrierfreq+" " + signalfreq + " " +maxVoltage;
return super.dump() + " " + carrierfreq + " " + signalfreq + " " + maxVoltage;
}
/*void setCurrent(double c) {
current = c;
System.out.print("v current set to " + c + "\n");
}*/

void reset() {
freqTimeZero = 0;
curcount = 0;
freqTimeZero = 0;
curcount = 0;
}

int getPostCount() {
return 1;
}
int getPostCount() { return 1; }

void stamp() {
sim.stampVoltageSource(0, nodes[0], voltSource);

void stamp() {
sim.stampVoltageSource(0, nodes[0], voltSource);
}

void doStep() {
sim.updateVoltageSource(0, nodes[0], voltSource, getVoltage());
sim.updateVoltageSource(0, nodes[0], voltSource, getVoltage());
}

double getVoltage() {
double w = 2*pi*(sim.t-freqTimeZero);
return ((Math.sin(w*signalfreq)+1)/2)*Math.sin(w*carrierfreq)*maxVoltage;
double w = 2 * pi * (sim.t - freqTimeZero);
return ((Math.sin(w * signalfreq) + 1) / 2) * Math.sin(w * carrierfreq) * maxVoltage;
}

final int circleSize = 17;

void draw(Graphics g) {
setBbox(point1, point2, circleSize);
setVoltageColor(g, volts[0]);
drawThickLine(g, point1, lead1);

Font f = new Font("SansSerif", 0, 12);
g.setFont(f);
g.setColor(needsHighlight() ? selectColor : whiteColor);
setPowerColor(g, false);
double v = getVoltage();
String s = "AM";
drawCenteredText(g, s, x2, y2, true);
drawWaveform(g, point2);
drawPosts(g);
curcount = updateDotCount(-current, curcount);
if (sim.dragElm != this)
drawDots(g, point1, lead1, curcount);
}
setBbox(point1, point2, circleSize);
setVoltageColor(g, volts[0]);
drawThickLine(g, point1, lead1);

Font f = new Font("SansSerif", 0, 12);
g.setFont(f);
g.setColor(needsHighlight() ? selectColor : whiteColor);
setPowerColor(g, false);
double v = getVoltage();
String s = "AM";
drawCenteredText(g, s, x2, y2, true);
drawWaveform(g, point2);
drawPosts(g);
curcount = updateDotCount(-current, curcount);
if (sim.dragElm != this)
drawDots(g, point1, lead1, curcount);
}

void drawWaveform(Graphics g, Point center) {
g.setColor(needsHighlight() ? selectColor : Color.gray);
setPowerColor(g, false);
int xc = center.x; int yc = center.y;
drawThickCircle(g, xc, yc, circleSize);
int wl = 8;
adjustBbox(xc-circleSize, yc-circleSize,
xc+circleSize, yc+circleSize);
g.setColor(needsHighlight() ? selectColor : Color.gray);
setPowerColor(g, false);
int xc = center.x;
int yc = center.y;
drawThickCircle(g, xc, yc, circleSize);
int wl = 8;
adjustBbox(xc - circleSize, yc - circleSize,
xc + circleSize, yc + circleSize);
}


void setPoints() {
super.setPoints();
lead1 = interpPoint(point1, point2, 1-circleSize/dn);
void setPoints() {
super.setPoints();
lead1 = interpPoint(point1, point2, 1 - circleSize / dn);
}

double getVoltageDiff() { return volts[0]; }

boolean hasGroundConnection(int n1) { return true; }


double getVoltageDiff() {
return volts[0];
}

boolean hasGroundConnection(int n1) {
return true;
}

int getVoltageSourceCount() {
return 1;
return 1;
}
double getPower() { return -getVoltageDiff()*current; }

double getPower() {
return -getVoltageDiff() * current;
}

void getInfo(String arr[]) {
arr[0] = "AM Source";
arr[1] = "I = " + getCurrentText(getCurrent());
arr[2] = "V = " +
getVoltageText(getVoltageDiff());
arr[3] = "cf = " + getUnitText(carrierfreq, "Hz");
arr[4] = "sf = " + getUnitText(signalfreq, "Hz");
arr[5] = "Vmax = " + getVoltageText(maxVoltage);

arr[0] = "AM Source";
arr[1] = "I = " + getCurrentText(getCurrent());
arr[2] = "V = " +
getVoltageText(getVoltageDiff());
arr[3] = "cf = " + getUnitText(carrierfreq, "Hz");
arr[4] = "sf = " + getUnitText(signalfreq, "Hz");
arr[5] = "Vmax = " + getVoltageText(maxVoltage);
}

public EditInfo getEditInfo(int n) {
if (n == 0)
return new EditInfo("Max Voltage", maxVoltage, -20, 20);
if (n == 1)
return new EditInfo("Carrier Frequency (Hz)", carrierfreq, 4, 500);
if (n == 2)
return new EditInfo("Signal Frequency (Hz)", signalfreq, 4, 500);
return null;
if (n == 0)
return new EditInfo("Max Voltage", maxVoltage, -20, 20);
if (n == 1)
return new EditInfo("Carrier Frequency (Hz)", carrierfreq, 4, 500);
if (n == 2)
return new EditInfo("Signal Frequency (Hz)", signalfreq, 4, 500);

return null;
}

public void setEditValue(int n, EditInfo ei) {
if (n == 0)
maxVoltage = ei.value;
if (n == 1)
carrierfreq = ei.value;
if (n == 2)
signalfreq=ei.value;
if (n == 0)
maxVoltage = ei.value;
if (n == 1)
carrierfreq = ei.value;
if (n == 2)
signalfreq = ei.value;
}
}
Loading

0 comments on commit 3422802

Please sign in to comment.