Skip to content

Commit

Permalink
feat(Controller): Allow controlling for output node
Browse files Browse the repository at this point in the history
  • Loading branch information
bamdadfr committed Apr 4, 2022
1 parent a41ee72 commit 7d9db58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/app/devices/controller.device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,15 @@ controllerDevice.attachButtonsToNeuron = function(): void {
* @param {number} selectedNode - The selected node.
*/
controllerDevice.attachControlsToNeuron = function(selectedNode: number): void {
const {neuron} = networkState.getNeuron(selectedNode);
let neuron;

if (networkState.isOutputNode(selectedNode)) {
neuron = networkState.getOutputNode();
}
else {
neuron = networkState.getNeuron(selectedNode).neuron;
}

const links = neuron.inputLinks;

// first draw
Expand Down
7 changes: 6 additions & 1 deletion src/app/state/network.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ networkState.getSelectedNeurons = function() {
return;
}
else if (selectedNodes.length === 1) {
targets = [this.getNeuron(selectedNodes[0]).neuron];
if (this.isOutputNode(selectedNodes[0])) {
targets = [this.getOutputNode()];
}
else {
targets = [this.getNeuron(selectedNodes[0]).neuron];
}
}
else {
targets = selectedNodes.map((i) => this.getNeuron(i).neuron);
Expand Down

0 comments on commit 7d9db58

Please sign in to comment.