fixes instruction steps for finer power usage

This commit is contained in:
darzu 2016-09-02 15:43:26 -07:00
parent 8adcab1cab
commit 13f53d730a
2 changed files with 9 additions and 7 deletions

View File

@ -195,12 +195,14 @@ namespace pxsim {
const GROUND_COLOR = "blue";
const POWER_COLOR = "red";
const wires: WireInst[] = [];
let groundStep = 0;
let threeVoltStep = (powerUsage.bottomGround || powerUsage.topGround) ? 1 : 0;
if (powerUsage.bottomGround && powerUsage.topGround) {
//bb top - <==> bb bot -
wires.push({
start: this.allocateLocation("ground", {nearestBBPin: top}),
end: this.allocateLocation("ground", {nearestBBPin: bot}),
color: GROUND_COLOR, assemblyStep: 0
color: GROUND_COLOR, assemblyStep: groundStep
});
}
if (powerUsage.topGround) {
@ -208,14 +210,14 @@ namespace pxsim {
wires.push({
start: this.allocateLocation("ground", {nearestBBPin: top}),
end: {type: "dalboard", pin: boardGround},
color: GROUND_COLOR, assemblyStep: 0
color: GROUND_COLOR, assemblyStep: groundStep
});
} else if (powerUsage.bottomGround) {
//board - <==> bb bot -
wires.push({
start: this.allocateLocation("ground", {nearestBBPin: bot}),
end: {type: "dalboard", pin: boardGround},
color: GROUND_COLOR, assemblyStep: 0
color: GROUND_COLOR, assemblyStep: groundStep
});
}
if (powerUsage.bottomThreeVolt && powerUsage.bottomGround) {
@ -223,7 +225,7 @@ namespace pxsim {
wires.push({
start: this.allocateLocation("threeVolt", {nearestBBPin: top}),
end: this.allocateLocation("threeVolt", {nearestBBPin: bot}),
color: POWER_COLOR, assemblyStep: 1
color: POWER_COLOR, assemblyStep: threeVoltStep
});
}
if (powerUsage.topThreeVolt) {
@ -231,14 +233,14 @@ namespace pxsim {
wires.push({
start: this.allocateLocation("threeVolt", {nearestBBPin: top}),
end: {type: "dalboard", pin: threeVoltPin},
color: POWER_COLOR, assemblyStep: 1
color: POWER_COLOR, assemblyStep: threeVoltStep
});
} else if (powerUsage.bottomThreeVolt) {
//board + <==> bb bot +
wires.push({
start: this.allocateLocation("threeVolt", {nearestBBPin: bot}),
end: {type: "dalboard", pin: threeVoltPin},
color: POWER_COLOR, assemblyStep: 1
color: POWER_COLOR, assemblyStep: threeVoltStep
});
}
return wires;

View File

@ -321,7 +321,7 @@ namespace pxsim.instructions {
(stepToWires[step] || (stepToWires[step] = [])).push(w)
});
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 => {
let {component, wires} = cAndWs;
let cStep = component.assemblyStep + stepOffset;