Support for multiple motors in "used" logic. (#238)

* handle registerion of dual / single motors

* updated puppy
This commit is contained in:
Peli de Halleux
2018-01-15 23:57:21 -08:00
committed by GitHub
parent 3c2be25384
commit 9fadf49b0e
4 changed files with 73 additions and 27 deletions

View File

@ -97,28 +97,21 @@ namespace pxsim {
return this.brickNode;
}
motorUsed(port: number, large: boolean) {
motorUsed(ports: number, large: boolean): boolean {
for (let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
const p = 1 << i;
if (port & p) {
const motorPort = this.motorMap[p];
if (!this.outputNodes[motorPort])
this.outputNodes[motorPort] = new MotorNode(motorPort, large);
}
}
}
hasMotor(port: number) {
for (let i = 0; i < DAL.NUM_OUTPUTS; ++i) {
const p = 1 << i;
if (port & p) {
if (ports & p) {
const motorPort = this.motorMap[p];
const outputNode = this.outputNodes[motorPort];
if (outputNode)
return true;
if (!outputNode) {
this.outputNodes[motorPort] = new MotorNode(motorPort, large);
continue;
}
if (outputNode && outputNode.isLarge() != large)
return false;
}
}
return false;
return true;
}
getMotor(port: number, large?: boolean): MotorNode[] {