From 60ad8bd819c2b06f65cb4df2c7a9a04f3c953335 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 6 Sep 2019 11:26:56 +0200 Subject: [PATCH] Adding new Icons / Objects Part 2 --- .../FunctionLibraries/AttachDetach.js | 42 +++++++ .../FunctionLibraries/NodeChildren.js | 104 ++++++++++++++++++ 2 files changed, 146 insertions(+) diff --git a/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js b/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js index 38ee5c501..837a66f3a 100644 --- a/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js +++ b/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js @@ -218,6 +218,48 @@ function newAttachDetach () { function attachNode (node, attachToNode, rootNodes) { switch (node.type) { + case 'Backend': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.backend = node + completeAttachment(node, rootNodes) + } + break + case 'Backend Process': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.backendProcesses.push(node) + completeAttachment(node, rootNodes) + } + break + case 'Sensor': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.bot = node + completeAttachment(node, rootNodes) + } + break + case 'Indicator': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.bot = node + completeAttachment(node, rootNodes) + } + break + case 'Trading Engine': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.bot = node + completeAttachment(node, rootNodes) + } + break + case 'Bot Process': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.botProcesses.push(node) + completeAttachment(node, rootNodes) + } + break case 'Personal Data': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode diff --git a/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js b/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js index b52a3b16a..02caab136 100644 --- a/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js +++ b/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js @@ -11,6 +11,24 @@ function newNodeChildren () { case 'Definition': { return countChildrenDefinition(parentNode, childNode) } + case 'Backend': { + return countChildrenBackend(parentNode, childNode) + } + case 'Backend Process': { + return countChildrenBackendProcess(parentNode, childNode) + } + case 'Sensor': { + return countChildrenSensor(parentNode, childNode) + } + case 'Indicator': { + return countChildrenIndicator(parentNode, childNode) + } + case 'Trading Engine': { + return countChildrenTradingEngine(parentNode, childNode) + } + case 'Bot Process': { + return countChildrenBotProcess(parentNode, childNode) + } case 'Personal Data': { return countChildrenPersonalData(parentNode, childNode) } @@ -130,6 +148,92 @@ function newNodeChildren () { return response } + function countChildrenBackend (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + + for (let i = 0; i < parentNode.exchangeAccounts.length; i++) { + let child = parentNode.backendProcesses[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + return response + } + + function countChildrenBackendProcess (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + if (parentNode.bot !== undefined) { + response.childrenCount++ + if (parentNode.bot.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + return response + } + + function countChildrenSensor (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + + for (let i = 0; i < parentNode.botProcesses.length; i++) { + let child = parentNode.botProcesses[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + return response + } + + function countChildrenIndicator (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + + for (let i = 0; i < parentNode.botProcesses.length; i++) { + let child = parentNode.botProcesses[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + return response + } + + function countChildrenTradingEngine (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + + for (let i = 0; i < parentNode.botProcesses.length; i++) { + let child = parentNode.botProcesses[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + return response + } + + function countChildrenBotProcess (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + return response + } + function countChildrenPersonalData (parentNode, childNode) { let response = { childrenCount: 0,