fixes instruction steps for finer power usage
This commit is contained in:
parent
8adcab1cab
commit
13f53d730a
@ -195,12 +195,14 @@ namespace pxsim {
|
|||||||
const GROUND_COLOR = "blue";
|
const GROUND_COLOR = "blue";
|
||||||
const POWER_COLOR = "red";
|
const POWER_COLOR = "red";
|
||||||
const wires: WireInst[] = [];
|
const wires: WireInst[] = [];
|
||||||
|
let groundStep = 0;
|
||||||
|
let threeVoltStep = (powerUsage.bottomGround || powerUsage.topGround) ? 1 : 0;
|
||||||
if (powerUsage.bottomGround && powerUsage.topGround) {
|
if (powerUsage.bottomGround && powerUsage.topGround) {
|
||||||
//bb top - <==> bb bot -
|
//bb top - <==> bb bot -
|
||||||
wires.push({
|
wires.push({
|
||||||
start: this.allocateLocation("ground", {nearestBBPin: top}),
|
start: this.allocateLocation("ground", {nearestBBPin: top}),
|
||||||
end: this.allocateLocation("ground", {nearestBBPin: bot}),
|
end: this.allocateLocation("ground", {nearestBBPin: bot}),
|
||||||
color: GROUND_COLOR, assemblyStep: 0
|
color: GROUND_COLOR, assemblyStep: groundStep
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (powerUsage.topGround) {
|
if (powerUsage.topGround) {
|
||||||
@ -208,14 +210,14 @@ namespace pxsim {
|
|||||||
wires.push({
|
wires.push({
|
||||||
start: this.allocateLocation("ground", {nearestBBPin: top}),
|
start: this.allocateLocation("ground", {nearestBBPin: top}),
|
||||||
end: {type: "dalboard", pin: boardGround},
|
end: {type: "dalboard", pin: boardGround},
|
||||||
color: GROUND_COLOR, assemblyStep: 0
|
color: GROUND_COLOR, assemblyStep: groundStep
|
||||||
});
|
});
|
||||||
} else if (powerUsage.bottomGround) {
|
} else if (powerUsage.bottomGround) {
|
||||||
//board - <==> bb bot -
|
//board - <==> bb bot -
|
||||||
wires.push({
|
wires.push({
|
||||||
start: this.allocateLocation("ground", {nearestBBPin: bot}),
|
start: this.allocateLocation("ground", {nearestBBPin: bot}),
|
||||||
end: {type: "dalboard", pin: boardGround},
|
end: {type: "dalboard", pin: boardGround},
|
||||||
color: GROUND_COLOR, assemblyStep: 0
|
color: GROUND_COLOR, assemblyStep: groundStep
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (powerUsage.bottomThreeVolt && powerUsage.bottomGround) {
|
if (powerUsage.bottomThreeVolt && powerUsage.bottomGround) {
|
||||||
@ -223,7 +225,7 @@ namespace pxsim {
|
|||||||
wires.push({
|
wires.push({
|
||||||
start: this.allocateLocation("threeVolt", {nearestBBPin: top}),
|
start: this.allocateLocation("threeVolt", {nearestBBPin: top}),
|
||||||
end: this.allocateLocation("threeVolt", {nearestBBPin: bot}),
|
end: this.allocateLocation("threeVolt", {nearestBBPin: bot}),
|
||||||
color: POWER_COLOR, assemblyStep: 1
|
color: POWER_COLOR, assemblyStep: threeVoltStep
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (powerUsage.topThreeVolt) {
|
if (powerUsage.topThreeVolt) {
|
||||||
@ -231,14 +233,14 @@ namespace pxsim {
|
|||||||
wires.push({
|
wires.push({
|
||||||
start: this.allocateLocation("threeVolt", {nearestBBPin: top}),
|
start: this.allocateLocation("threeVolt", {nearestBBPin: top}),
|
||||||
end: {type: "dalboard", pin: threeVoltPin},
|
end: {type: "dalboard", pin: threeVoltPin},
|
||||||
color: POWER_COLOR, assemblyStep: 1
|
color: POWER_COLOR, assemblyStep: threeVoltStep
|
||||||
});
|
});
|
||||||
} else if (powerUsage.bottomThreeVolt) {
|
} else if (powerUsage.bottomThreeVolt) {
|
||||||
//board + <==> bb bot +
|
//board + <==> bb bot +
|
||||||
wires.push({
|
wires.push({
|
||||||
start: this.allocateLocation("threeVolt", {nearestBBPin: bot}),
|
start: this.allocateLocation("threeVolt", {nearestBBPin: bot}),
|
||||||
end: {type: "dalboard", pin: threeVoltPin},
|
end: {type: "dalboard", pin: threeVoltPin},
|
||||||
color: POWER_COLOR, assemblyStep: 1
|
color: POWER_COLOR, assemblyStep: threeVoltStep
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return wires;
|
return wires;
|
||||||
|
@ -321,7 +321,7 @@ namespace pxsim.instructions {
|
|||||||
(stepToWires[step] || (stepToWires[step] = [])).push(w)
|
(stepToWires[step] || (stepToWires[step] = [])).push(w)
|
||||||
});
|
});
|
||||||
let getMaxStep = (ns: {assemblyStep: number}[]) => ns.reduce((m, n) => Math.max(m, n.assemblyStep), 0);
|
let getMaxStep = (ns: {assemblyStep: number}[]) => ns.reduce((m, n) => Math.max(m, n.assemblyStep), 0);
|
||||||
let stepOffset = getMaxStep(powerWires) + 2;
|
let stepOffset = powerWires.length > 0 ? getMaxStep(powerWires) + 2 : 1;
|
||||||
components.forEach(cAndWs => {
|
components.forEach(cAndWs => {
|
||||||
let {component, wires} = cAndWs;
|
let {component, wires} = cAndWs;
|
||||||
let cStep = component.assemblyStep + stepOffset;
|
let cStep = component.assemblyStep + stepOffset;
|
||||||
|
Loading…
Reference in New Issue
Block a user