From 2073effdd3882f32abff91a3a8d461242a7d4a5e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 17 Sep 2019 16:03:26 +0200 Subject: [PATCH 01/13] Bug Fixes and Improvements to better respond to UI --- CockpitSpace/RestartSimulation.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/CockpitSpace/RestartSimulation.js b/CockpitSpace/RestartSimulation.js index 98e7eb14e..edfa45127 100644 --- a/CockpitSpace/RestartSimulation.js +++ b/CockpitSpace/RestartSimulation.js @@ -35,9 +35,9 @@ function newRestartSimulation () { let executionFocusExists = false let idleLabel = '' - let refreshCounter = 0 let isRunning = false - let eventSubscriptionId + let eventSubscriptionIdSimulationFilesUpdated + let eventSubscriptionIdProcessStopped return thisObject @@ -46,7 +46,8 @@ function newRestartSimulation () { thisObject.container.eventHandler.stopListening(selfMouseClickEventSubscriptionId) thisObject.container.eventHandler.stopListening(selfMouseNotOverEventSubscriptionId) - systemEventHandler.stopListening('Jason-Multi-Period', eventSubscriptionId) + systemEventHandler.stopListening('Jason-Multi-Period', eventSubscriptionIdSimulationFilesUpdated) + systemEventHandler.stopListening('Jason-Multi-Period', eventSubscriptionIdProcessStopped) thisObject.container.finalize() thisObject.container = undefined @@ -68,16 +69,17 @@ function newRestartSimulation () { We will start listening to the event that is triggered when the simulation process finishes processing one day in the case of daily files or the whole market in the case of market files. */ - eventSubscriptionId = systemEventHandler.listenToEvent('Jason-Multi-Period', 'Status Report Updated', undefined, undefined, undefined, onEvent) + eventSubscriptionIdSimulationFilesUpdated = systemEventHandler.listenToEvent('Jason-Multi-Period', 'Simulation Files Updated', undefined, undefined, undefined, onFilesUpdated) - function onEvent (message) { - refreshCounter++ + function onFilesUpdated (message) { + turnOffProductCards() + turnOnProductCards() + } - if (refreshCounter === 1) { - refreshCounter = 0 - turnOffProductCards() - turnOnProductCards() - } + eventSubscriptionIdProcessStopped = systemEventHandler.listenToEvent('Jason-Multi-Period', 'Process Stopped', undefined, undefined, undefined, onProcessStopped) + + function onProcessStopped (message) { + thisObject.status = 'Ready' } } @@ -144,7 +146,6 @@ function newRestartSimulation () { systemEventHandler.raiseEvent('Cockpit-Restart-Button', 'Stop Requested') isRunning = false thisObject.status = 'Stopping' - counterTillNextState = 200 } } catch (err) { thisObject.status = 'Error' @@ -200,7 +201,7 @@ function newRestartSimulation () { break case 'Stopping': - thisObject.status = 'Ready' + break case 'Error': thisObject.status = 'Ready' From 1121acb3b46249d28fa94d70d68f5180556b4371 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 17 Sep 2019 20:15:58 +0200 Subject: [PATCH 02/13] Stabilization Day Finished --- CockpitSpace/RestartSimulation.js | 1 + FloatingSpace/CircularProgressBar.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CockpitSpace/RestartSimulation.js b/CockpitSpace/RestartSimulation.js index edfa45127..16198d49e 100644 --- a/CockpitSpace/RestartSimulation.js +++ b/CockpitSpace/RestartSimulation.js @@ -80,6 +80,7 @@ function newRestartSimulation () { function onProcessStopped (message) { thisObject.status = 'Ready' + isRunning = false } } diff --git a/FloatingSpace/CircularProgressBar.js b/FloatingSpace/CircularProgressBar.js index 2bb3da856..91bbdd3b6 100644 --- a/FloatingSpace/CircularProgressBar.js +++ b/FloatingSpace/CircularProgressBar.js @@ -69,6 +69,10 @@ function newCircularProgressBar () { } function drawBackground (pFloatingObject) { + + } + + function drawForeground (pFloatingObject) { const VISIBLE_RADIUS = thisObject.container.frame.radius * 2 let visiblePosition = { @@ -100,8 +104,4 @@ function newCircularProgressBar () { browserCanvasContext.stroke() } } - - function drawForeground (pFloatingObject) { - - } } From d19261e5deb54c470ee9396500228557a868c664 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 19 Sep 2019 14:46:29 +0200 Subject: [PATCH 03/13] Multiple Task Managers --- FloatingSpace/StrategyPart.js | 79 ++-- .../FunctionLibraries/AttachDetach.js | 18 +- .../FunctionLibraries/NodeChildren.js | 11 +- .../FunctionLibraries/NodeDeleter.js | 368 ++++++++++-------- .../FunctionLibraries/PartsFromNodes.js | 21 +- .../FunctionLibraries/ProtocolNode.js | 6 +- .../FunctionLibraries/StringifyNode.js | 17 +- 7 files changed, 293 insertions(+), 227 deletions(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 1bbd10c08..1552fdf4c 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -170,7 +170,7 @@ function newStrategyPart () { thisObject.codeEditor.physics() } - if (thisObject.payload.chainParent === undefined) { + if (thisObject.payload.chainParent === undefined || thisObject.payload.chainParent.payload === undefined) { thisObject.payload.targetPosition.x = thisObject.payload.position.x, thisObject.payload.targetPosition.y = thisObject.payload.position.y } else { @@ -203,151 +203,151 @@ function newStrategyPart () { let compatibleSubType switch (thisObject.payload.node.type) { case 'Trading System': - compatibleType = '->' + 'Definition' + compatibleType = '->' + 'Definition' + '->' compatibleSubType = undefined break case 'Personal Data': - compatibleType = '->' + 'Definition' + compatibleType = '->' + 'Definition' + '->' compatibleSubType = undefined break case 'Exchange Account': - compatibleType = '->' + 'Personal Data' + compatibleType = '->' + 'Personal Data' + '->' compatibleSubType = undefined break case 'Exchange Account Asset': - compatibleType = '->' + 'Exchange Account' + compatibleType = '->' + 'Exchange Account' + '->' compatibleSubType = undefined break case 'Exchange Account Key': - compatibleType = '->' + 'Exchange Account' + compatibleType = '->' + 'Exchange Account' + '->' compatibleSubType = undefined break case 'Parameters': - compatibleType = '->' + 'Trading System' + compatibleType = '->' + 'Trading System' + '->' compatibleSubType = undefined break case 'Base Asset': - compatibleType = '->' + 'Parameters' + compatibleType = '->' + 'Parameters' + '->' compatibleSubType = undefined break case 'Time Range': - compatibleType = '->' + 'Parameters' + compatibleType = '->' + 'Parameters' + '->' compatibleSubType = undefined break case 'Slippage': - compatibleType = '->' + 'Parameters' + compatibleType = '->' + 'Parameters' + '->' compatibleSubType = undefined break case 'Fee Structure': - compatibleType = '->' + 'Parameters' + compatibleType = '->' + 'Parameters' + '->' compatibleSubType = undefined break case 'Task Manager': - compatibleType = '->' + 'Definition' + compatibleType = '->' + 'Definition' + '->' compatibleSubType = undefined break case 'Task': - compatibleType = '->' + 'Task Manager' + compatibleType = '->' + 'Task Manager' + '->' compatibleSubType = undefined break case 'Sensor': - compatibleType = '->' + 'Task' + compatibleType = '->' + 'Task' + '->' compatibleSubType = undefined break case 'Indicator': - compatibleType = '->' + 'Task' + compatibleType = '->' + 'Task' + '->' compatibleSubType = undefined break case 'Trading Engine': - compatibleType = '->' + 'Task' + compatibleType = '->' + 'Task' + '->' compatibleSubType = undefined break case 'Process': - compatibleType = '->' + 'Sensor' + '->' + 'Indicator' + '->' + 'Trading Engine' + compatibleType = '->' + 'Sensor' + '->' + 'Indicator' + '->' + 'Trading Engine' + '->' compatibleSubType = undefined break case 'Strategy': - compatibleType = '->' + 'Trading System' + compatibleType = '->' + 'Trading System' + '->' compatibleSubType = undefined break case 'Trigger Stage': - compatibleType = '->' + 'Strategy' + compatibleType = '->' + 'Strategy' + '->' compatibleSubType = undefined break case 'Open Stage': - compatibleType = '->' + 'Strategy' + compatibleType = '->' + 'Strategy' + '->' compatibleSubType = undefined break case 'Manage Stage': - compatibleType = '->' + 'Strategy' + compatibleType = '->' + 'Strategy' + '->' compatibleSubType = undefined break case 'Close Stage': - compatibleType = '->' + 'Strategy' + compatibleType = '->' + 'Strategy' + '->' compatibleSubType = undefined break case 'Position Size': - compatibleType = '->' + 'Initial Definition' + compatibleType = '->' + 'Initial Definition' + '->' compatibleSubType = undefined break case 'Position Rate': - compatibleType = '->' + 'Initial Definition' + compatibleType = '->' + 'Initial Definition' + '->' compatibleSubType = undefined break case 'Take Position Event': - compatibleType = '->' + 'Trigger Stage' + compatibleType = '->' + 'Trigger Stage' + '->' compatibleSubType = undefined break case 'Trigger Off Event': - compatibleType = '->' + 'Trigger Stage' + compatibleType = '->' + 'Trigger Stage' + '->' compatibleSubType = undefined break case 'Trigger On Event': - compatibleType = '->' + 'Trigger Stage' + compatibleType = '->' + 'Trigger Stage' + '->' compatibleSubType = undefined break case 'Initial Definition': - compatibleType = '->' + 'Open Stage' + compatibleType = '->' + 'Open Stage' + '->' compatibleSubType = undefined break case 'Open Execution': - compatibleType = '->' + 'Open Stage' + compatibleType = '->' + 'Open Stage' + '->' compatibleSubType = undefined break case 'Close Execution': - compatibleType = '->' + 'Close Stage' + compatibleType = '->' + 'Close Stage' + '->' compatibleSubType = undefined break case 'Stop': - compatibleType = '->' + 'Manage Stage' + '->' + 'Initial Definition' + compatibleType = '->' + 'Manage Stage' + '->' + 'Initial Definition' + '->' compatibleSubType = undefined break case 'Take Profit': - compatibleType = '->' + 'Manage Stage' + '->' + 'Initial Definition' + compatibleType = '->' + 'Manage Stage' + '->' + 'Initial Definition' + '->' compatibleSubType = undefined break case 'Phase': - compatibleType = '->' + 'Stop' + '->' + 'Take Profit' + '->' + 'Phase' + compatibleType = '->' + 'Stop' + '->' + 'Take Profit' + '->' + 'Phase' + '->' compatibleSubType = undefined break case 'Formula': - compatibleType = '->' + 'Position Size' + '->' + 'Position Rate' + '->' + 'Phase' + compatibleType = '->' + 'Position Size' + '->' + 'Position Rate' + '->' + 'Phase' + '->' compatibleSubType = undefined break case 'Next Phase Event': - compatibleType = '->' + 'Phase' + compatibleType = '->' + 'Phase' + '->' compatibleSubType = undefined break case 'Situation': - compatibleType = '->' + 'Take Position Event' + '->' + 'Trigger On Event' + '->' + 'Trigger Off Event' + '->' + 'Next Phase Event' + compatibleType = '->' + 'Take Position Event' + '->' + 'Trigger On Event' + '->' + 'Trigger Off Event' + '->' + 'Next Phase Event' + '->' compatibleSubType = undefined break case 'Condition': - compatibleType = '->' + 'Situation' + compatibleType = '->' + 'Situation' + '->' compatibleSubType = undefined break case 'Code': - compatibleType = '->' + 'Condition' + compatibleType = '->' + 'Condition' + '->' compatibleSubType = undefined break default: @@ -362,9 +362,8 @@ function newStrategyPart () { let distance = nearby[0] let floatingObject = nearby[1] let nearbyNode = floatingObject.payload.node - if (compatibleType.indexOf('->' + nearbyNode.type) >= 0) { + if (compatibleType.indexOf('->' + nearbyNode.type + '->') >= 0) { /* Discard objects with busy coonection ports */ - if (thisObject.payload.node.type === 'Task Manager' && nearbyNode.taskManager !== undefined) { continue } if (thisObject.payload.node.type === 'Task' && nearbyNode.task !== undefined) { continue } if (thisObject.payload.node.type === 'Sensor' && nearbyNode.bot !== undefined) { continue } if (thisObject.payload.node.type === 'Indicator' && nearbyNode.bot !== undefined) { continue } diff --git a/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js b/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js index 86e4d13f1..01e71cdba 100644 --- a/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js +++ b/StrategySpace/Workspace/FunctionLibraries/AttachDetach.js @@ -50,12 +50,24 @@ function newAttachDetach () { return } case 'Task Manager': { - node.payload.parentNode.taskManager = undefined + let payload = node.payload + for (let i = 0; i < payload.parentNode.taskManagers.length; i++) { + let taskManager = payload.parentNode.taskManagers[i] + if (taskManager.id === node.id) { + payload.parentNode.taskManagers.splice(i, 1) + } + } completeDetachment(node, rootNodes) return } case 'Task': { - node.payload.parentNode.task = undefined + let payload = node.payload + for (let i = 0; i < payload.parentNode.tasks.length; i++) { + let task = payload.parentNode.tasks[i] + if (task.id === node.id) { + payload.parentNode.tasks.splice(i, 1) + } + } completeDetachment(node, rootNodes) return } @@ -251,7 +263,7 @@ function newAttachDetach () { case 'Task Manager': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode - node.payload.parentNode.taskManager = node + node.payload.parentNode.taskManagers.push(node) completeAttachment(node, rootNodes) } break diff --git a/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js b/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js index df0a8b531..5c6c2b311 100644 --- a/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js +++ b/StrategySpace/Workspace/FunctionLibraries/NodeChildren.js @@ -145,10 +145,13 @@ function newNodeChildren () { response.childIndex = response.childrenCount } } - if (parentNode.taskManager !== undefined) { - response.childrenCount++ - if (parentNode.taskManager.id === childNode.id) { - response.childIndex = response.childrenCount + if (parentNode.taskManagers !== undefined) { + for (let i = 0; i < parentNode.taskManagers.length; i++) { + let child = parentNode.taskManagers[i] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } } } return response diff --git a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js b/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js index 517f705bb..352515e85 100644 --- a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -44,149 +44,151 @@ function newNodeDeleter () { } function deleteWorkspace (node, rootNodes) { - while (node.rootNodes.length > 0) { - let rootNode = node.rootNodes[0] - switch (rootNode.type) { + if (node.rootNodes !== undefined) { + while (node.rootNodes.length > 0) { + let rootNode = node.rootNodes[0] + switch (rootNode.type) { - case 'Definition': { - deleteDefinition(rootNode, rootNodes, true) - break - } - case 'Task Manager': { - deleteTaskManager(rootNode, rootNodes) - break - } - case 'Task': { - deleteTask(rootNode, rootNodes) - break - } - case 'Sensor': { - deleteBot(rootNode, rootNodes) - break - } - case 'Indicator': { - deleteBot(rootNode, rootNodes) - break - } - case 'Trading Engine': { - deleteBot(rootNode, rootNodes) - break - } - case 'Process': { - deleteProcess(rootNode, rootNodes) - break - } - case 'Personal Data': { - deletePersonalData(rootNode, rootNodes) - break - } - case 'Exchange Account': { - deleteExchangeAccount(rootNode, rootNodes) - break - } - case 'Exchange Account Asset': { - deleteExchangeAccountAsset(rootNode, rootNodes) - break - } - case 'Exchange Account Key': { - deleteExchangeAccountKey(rootNode, rootNodes) - break - } - case 'Trading System': { - deleteTradingSystem(rootNode, rootNodes) - break - } - case 'Parameters': { - deleteParameters(rootNode, rootNodes) - break - } - case 'Base Asset': { - deleteBaseAsset(rootNode, rootNodes) - break - } - case 'Time Range': { - deleteTimeRange(rootNode, rootNodes) - break - } - case 'Slippage': { - deleteSlippage(rootNode, rootNodes) - break - } - case 'Fee Structure': { - deleteFeeStructure(rootNode, rootNodes) - break - } - case 'Strategy': { - deleteStrategy(rootNode, rootNodes) - break - } - case 'Trigger Stage': { - deleteTriggerStage(rootNode, rootNodes) - break - } - case 'Open Stage': { - deleteOpenStage(rootNode, rootNodes) - break - } - case 'Manage Stage': { - deleteManageStage(rootNode, rootNodes) - break - } - case 'Close Stage': { - deleteCloseStage(rootNode, rootNodes) - break - } - case 'Position Size': { - deletePositionSize(rootNode, rootNodes) - break - } - case 'Position Rate': { - deletePositionRate(rootNode, rootNodes) - break - } - case 'Initial Definition': { - deleteInitialDefinition(rootNode, rootNodes) - break - } - case 'Open Execution': { - deleteOpenExecution(rootNode, rootNodes) - break - } - case 'Close Execution': { - deleteCloseExecution(rootNode, rootNodes) - break - } - case 'Event': { - deleteEvent(rootNode, rootNodes) - break - } - case 'Managed Item': { - deleteManagedItem(rootNode, rootNodes) - break - } - case 'Phase': { - deletePhase(rootNode, rootNodes) - break - } - case 'Formula': { - deleteFormula(rootNode, rootNodes) - break - } - case 'Situation': { - deleteSituation(rootNode, rootNodes) - break - } - case 'Condition': { - deleteCondition(rootNode, rootNodes) - break - } - case 'Code': { - deleteCode(rootNode, rootNodes) - break - } + case 'Definition': { + deleteDefinition(rootNode, rootNodes, true) + break + } + case 'Task Manager': { + deleteTaskManager(rootNode, rootNodes) + break + } + case 'Task': { + deleteTask(rootNode, rootNodes) + break + } + case 'Sensor': { + deleteBot(rootNode, rootNodes) + break + } + case 'Indicator': { + deleteBot(rootNode, rootNodes) + break + } + case 'Trading Engine': { + deleteBot(rootNode, rootNodes) + break + } + case 'Process': { + deleteProcess(rootNode, rootNodes) + break + } + case 'Personal Data': { + deletePersonalData(rootNode, rootNodes) + break + } + case 'Exchange Account': { + deleteExchangeAccount(rootNode, rootNodes) + break + } + case 'Exchange Account Asset': { + deleteExchangeAccountAsset(rootNode, rootNodes) + break + } + case 'Exchange Account Key': { + deleteExchangeAccountKey(rootNode, rootNodes) + break + } + case 'Trading System': { + deleteTradingSystem(rootNode, rootNodes) + break + } + case 'Parameters': { + deleteParameters(rootNode, rootNodes) + break + } + case 'Base Asset': { + deleteBaseAsset(rootNode, rootNodes) + break + } + case 'Time Range': { + deleteTimeRange(rootNode, rootNodes) + break + } + case 'Slippage': { + deleteSlippage(rootNode, rootNodes) + break + } + case 'Fee Structure': { + deleteFeeStructure(rootNode, rootNodes) + break + } + case 'Strategy': { + deleteStrategy(rootNode, rootNodes) + break + } + case 'Trigger Stage': { + deleteTriggerStage(rootNode, rootNodes) + break + } + case 'Open Stage': { + deleteOpenStage(rootNode, rootNodes) + break + } + case 'Manage Stage': { + deleteManageStage(rootNode, rootNodes) + break + } + case 'Close Stage': { + deleteCloseStage(rootNode, rootNodes) + break + } + case 'Position Size': { + deletePositionSize(rootNode, rootNodes) + break + } + case 'Position Rate': { + deletePositionRate(rootNode, rootNodes) + break + } + case 'Initial Definition': { + deleteInitialDefinition(rootNode, rootNodes) + break + } + case 'Open Execution': { + deleteOpenExecution(rootNode, rootNodes) + break + } + case 'Close Execution': { + deleteCloseExecution(rootNode, rootNodes) + break + } + case 'Event': { + deleteEvent(rootNode, rootNodes) + break + } + case 'Managed Item': { + deleteManagedItem(rootNode, rootNodes) + break + } + case 'Phase': { + deletePhase(rootNode, rootNodes) + break + } + case 'Formula': { + deleteFormula(rootNode, rootNodes) + break + } + case 'Situation': { + deleteSituation(rootNode, rootNodes) + break + } + case 'Condition': { + deleteCondition(rootNode, rootNodes) + break + } + case 'Code': { + deleteCode(rootNode, rootNodes) + break + } - default: { - console.log('WARNING this node type is not listed at NodeDeleter: ' + node.type) + default: { + console.log('WARNING this node type is not listed at NodeDeleter: ' + node.type) + } } } } @@ -221,9 +223,12 @@ function newNodeDeleter () { if (node.personalData !== undefined) { deletePersonalData(node.personalData, rootNodes) } - if (node.taskManager !== undefined) { - deleteTaskManager(node.taskManager, rootNodes) + if (node.taskManagers !== undefined) { + while (node.taskManagers.length > 0) { + deleteTaskManager(node.taskManagers[0], rootNodes) + } } + completeDeletion(node, rootNodes) destroyPart(node) cleanNode(node) @@ -232,10 +237,17 @@ function newNodeDeleter () { function deleteTaskManager (node, rootNodes) { let payload = node.payload if (payload.parentNode !== undefined) { - payload.parentNode.taskManager = undefined + for (let j = 0; j < payload.parentNode.taskManagers.length; j++) { + let taskManager = payload.parentNode.taskManagers[j] + if (taskManager.id === node.id) { + payload.parentNode.taskManagers.splice(j, 1) + } + } } - while (node.tasks.length > 0) { - deleteTask(node.tasks[0], rootNodes) + if (node.tasks !== undefined) { + while (node.tasks.length > 0) { + deleteTask(node.tasks[0], rootNodes) + } } completeDeletion(node, rootNodes) destroyPart(node) @@ -265,9 +277,12 @@ function newNodeDeleter () { if (payload.parentNode !== undefined) { payload.parentNode.bot = undefined } - while (node.processes.length > 0) { - deleteProcess(node.processes[0], rootNodes) + if (node.processes !== undefined) { + while (node.processes.length > 0) { + deleteProcess(node.processes[0], rootNodes) + } } + completeDeletion(node, rootNodes) destroyPart(node) cleanNode(node) @@ -295,8 +310,10 @@ function newNodeDeleter () { payload.parentNode.personalData = undefined } - while (node.exchangeAccounts.length > 0) { - deleteExchangeAccount(node.exchangeAccounts[0], rootNodes) + if (node.exchangeAccounts !== undefined) { + while (node.exchangeAccounts.length > 0) { + deleteExchangeAccount(node.exchangeAccounts[0], rootNodes) + } } completeDeletion(node, rootNodes) @@ -314,12 +331,17 @@ function newNodeDeleter () { } } } - while (node.assets.length > 0) { - deleteExchangeAccountAsset(node.assets[0], rootNodes) + if (node.assets !== undefined) { + while (node.assets.length > 0) { + deleteExchangeAccountAsset(node.assets[0], rootNodes) + } } - while (node.keys.length > 0) { - deleteExchangeAccountKey(node.keys[0], rootNodes) + if (node.keys !== undefined) { + while (node.keys.length > 0) { + deleteExchangeAccountKey(node.keys[0], rootNodes) + } } + completeDeletion(node, rootNodes) destroyPart(node) cleanNode(node) @@ -364,8 +386,10 @@ function newNodeDeleter () { payload.parentNode.tradingSystem = undefined } - while (node.strategies.length > 0) { - deleteStrategy(node.strategies[0], rootNodes) + if (node.strategies !== undefined) { + while (node.strategies.length > 0) { + deleteStrategy(node.strategies[0], rootNodes) + } } if (node.parameters !== undefined) { @@ -640,9 +664,12 @@ function newNodeDeleter () { completeDeletion(node, rootNodes) } - while (node.situations.length > 0) { - deleteSituation(node.situations[0], rootNodes) + if (node.situations !== undefined) { + while (node.situations.length > 0) { + deleteSituation(node.situations[0], rootNodes) + } } + destroyPart(node) cleanNode(node) } @@ -664,9 +691,12 @@ function newNodeDeleter () { completeDeletion(node, rootNodes) } - while (node.phases.length > 0) { - deletePhase(node.phases[0]) + if (node.phases !== undefined) { + while (node.phases.length > 0) { + deletePhase(node.phases[0]) + } } + destroyPart(node) cleanNode(node) } @@ -718,10 +748,13 @@ function newNodeDeleter () { for (let j = 0; j < payload.parentNode.situations.length; j++) { let situation = payload.parentNode.situations[j] if (situation.id === node.id) { - while (situation.conditions.length > 0) { - let condition = situation.conditions[0] - deleteCondition(condition, rootNodes) + if (situation.conditions !== undefined) { + while (situation.conditions.length > 0) { + let condition = situation.conditions[0] + deleteCondition(condition, rootNodes) + } } + situation.conditions = [] payload.parentNode.situations.splice(j, 1) destroyPart(situation) @@ -730,10 +763,13 @@ function newNodeDeleter () { } } } else { - while (node.conditions.length > 0) { - let condition = node.conditions[0] - deleteCondition(condition) + if (node.conditions !== undefined) { + while (node.conditions.length > 0) { + let condition = node.conditions[0] + deleteCondition(condition) + } } + node.conditions = [] completeDeletion(node, rootNodes) destroyPart(node) diff --git a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js b/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js index 412d6160e..183843041 100644 --- a/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js +++ b/StrategySpace/Workspace/FunctionLibraries/PartsFromNodes.js @@ -333,8 +333,11 @@ function newPartsFromNodes () { if (node.personalData !== undefined) { createPartFromNode(node.personalData, node, node) } - if (node.taskManager !== undefined) { - createPartFromNode(node.taskManager, node, node) + if (node.taskManagers !== undefined) { + for (let m = 0; m < node.taskManagers.length; m++) { + let taskManager = node.taskManagers[m] + createPartFromNode(taskManager, node, node) + } } return } @@ -385,14 +388,16 @@ function newPartsFromNodes () { } function addTaskManager (node) { - if (node.taskManager === undefined) { - node.taskManager = { - tasks: [] - } - createPart('Task Manager', '', node.taskManager, node, node) + let taskManager = { + name: 'New Task Manager' } + if (node.taskManagers === undefined) { + node.taskManagers = [] + } + node.taskManagers.push(taskManager) + createPart('Task Manager', taskManager.name, taskManager, node, node, 'Task Manager') - return node.taskManager + return taskManager } function addTask (node) { diff --git a/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js b/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js index b9a9f95f4..9ee0774ed 100644 --- a/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/StrategySpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -450,7 +450,11 @@ function newProtocolNode () { name: node.name, tradingSystem: getProtocolNode(node.tradingSystem, removePersonalData, parseJSONStrings, includeIds), personalData: getProtocolNode(node.personalData, removePersonalData, parseJSONStrings, includeIds), - taskManager: getProtocolNode(node.taskManager, removePersonalData, parseJSONStrings, includeIds) + taskManagers: [] + } + for (let m = 0; m < node.taskManagers.length; m++) { + let taskManager = getProtocolNode(node.taskManagers[m], removePersonalData, parseJSONStrings, includeIds) + object.taskManagers.push(taskManager) } return object } diff --git a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js index 79a4ed6de..7320a0050 100644 --- a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js +++ b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js @@ -435,11 +435,12 @@ function newStringifyNode () { savedPayload: getSavedPayload(node) } - for (let m = 0; m < node.tasks.length; m++) { - let task = prepareForStringify(node.tasks[m], removePersonalData) - taskManager.tasks.push(task) + if (node.tasks !== undefined) { + for (let m = 0; m < node.tasks.length; m++) { + let task = prepareForStringify(node.tasks[m], removePersonalData) + taskManager.tasks.push(task) + } } - return taskManager } case 'Task': { @@ -523,9 +524,15 @@ function newStringifyNode () { name: node.name, tradingSystem: prepareForStringify(node.tradingSystem, removePersonalData), personalData: prepareForStringify(node.personalData, removePersonalData), - taskManager: prepareForStringify(node.taskManager, removePersonalData), + taskManagers: [], savedPayload: getSavedPayload(node) } + if (node.taskManagers !== undefined) { + for (let m = 0; m < node.taskManagers.length; m++) { + let taskManager = prepareForStringify(node.taskManagers[m], removePersonalData) + object.taskManagers.push(taskManager) + } + } return object } } From 22c8c328fa38496118c28c5141646bafbf15b983 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 20 Sep 2019 09:25:18 +0200 Subject: [PATCH 04/13] Refactoring from Running to Default --- FloatingSpace/StrategyPart.js | 18 +++++++++--------- FloatingSpace/StrategyPartConstructor.js | 10 +++++----- .../Workspace/FunctionLibraries/NodeDeleter.js | 2 +- .../FunctionLibraries/StringifyNode.js | 2 +- StrategySpace/Workspace/Workspace.js | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 1552fdf4c..d20ec7add 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -18,11 +18,11 @@ function newStrategyPart () { partTitle: undefined, circularProgressBar: undefined, isExecuting: undefined, - isRunning: undefined, - run: run, + isDefault: undefined, + setAsDefault: setAsDefault, play: play, stop: stop, - setRunningStatus: setRunningStatus, + setDefaultStatus: setDefaultStatus, setNotRunningStatus: setNotRunningStatus, getReadyToAttach: getReadyToAttach, showAvailabilityToAttach: showAvailabilityToAttach, @@ -549,20 +549,20 @@ function newStrategyPart () { } } - function run () { - setRunningStatus() + function setAsDefault () { + setDefaultStatus() canvas.cockpitSpace.restartSimulation.restart() } - function setRunningStatus () { + function setDefaultStatus () { canvas.strategySpace.workspace.definition = thisObject.payload.node - thisObject.isRunning = true + thisObject.isDefault = true runningCounter = 30 } function setNotRunningStatus () { canvas.strategySpace.workspace.definition = undefined - thisObject.isRunning = false + thisObject.isDefault = false } function iconPhysics () { @@ -939,7 +939,7 @@ function newStrategyPart () { browserCanvasContext.fill() - if (thisObject.isRunning === true) { + if (thisObject.isDefault === true) { VISIBLE_RADIUS = thisObject.container.frame.radius * 2 let OPACITY = runningCounter / 30 diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 04651ffc9..37b8c4a21 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -68,8 +68,8 @@ function newStrategyPartConstructor () { strategyPart.container.connectToParent(floatingObject.container, false, false, true, true, false, false, true, true, true, true, true) if (payload.node.savedPayload !== undefined) { - if (payload.node.savedPayload.uiObject.isRunning === true) { - strategyPart.setRunningStatus() + if (payload.node.savedPayload.uiObject.isDefault === true) { + strategyPart.setDefaultStatus() canvas.strategySpace.workspace.definition = payload.node } } @@ -217,9 +217,9 @@ function newStrategyPartConstructor () { addLeftIcons(menuItemsInitialValues, floatingObject) menuItemsInitialValues.push( { - action: 'Run Definition', - actionFunction: payload.uiObject.run, - label: 'Run', + action: 'Set as Default', + actionFunction: payload.uiObject.setAsDefault, + label: 'Set as Default', visible: false, iconPathOn: 'paper-plane', iconPathOff: 'paper-plane', diff --git a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js b/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js index 352515e85..bd0e1cc7d 100644 --- a/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/StrategySpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -213,7 +213,7 @@ function newNodeDeleter () { if (counter <= 1) { return } } - if (node.payload.uiObject.isRunning === true) { + if (node.payload.uiObject.isDefault === true) { node.payload.uiObject.setNotRunningStatus() } diff --git a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js index 7320a0050..6cdf0dbea 100644 --- a/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js +++ b/StrategySpace/Workspace/FunctionLibraries/StringifyNode.js @@ -558,7 +558,7 @@ function newStringifyNode () { isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually) }, uiObject: { - isRunning: node.payload.uiObject.isRunning + isDefault: node.payload.uiObject.isDefault } } return savedPayload diff --git a/StrategySpace/Workspace/Workspace.js b/StrategySpace/Workspace/Workspace.js index dae445530..9e8a3127a 100644 --- a/StrategySpace/Workspace/Workspace.js +++ b/StrategySpace/Workspace/Workspace.js @@ -93,7 +93,7 @@ function newWorkspace () { thisObject.definition = canvas.strategySpace.strategizerGateway.strategizerData workspaceNode.rootNodes.push(thisObject.definition) functionLibraryPartsFromNodes.createPartFromNode(thisObject.definition, undefined, undefined) - thisObject.definition.payload.uiObject.setRunningStatus() + thisObject.definition.payload.uiObject.setDefaultStatus() thisObject.enabled = true } } From a692801e999e6da0fa864471abf628263e6f77b5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 20 Sep 2019 09:27:44 +0200 Subject: [PATCH 05/13] Refactoring Play for Run --- FloatingSpace/StrategyPart.js | 4 ++-- StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index d20ec7add..bfc758b42 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -20,7 +20,7 @@ function newStrategyPart () { isExecuting: undefined, isDefault: undefined, setAsDefault: setAsDefault, - play: play, + run: run, stop: stop, setDefaultStatus: setDefaultStatus, setNotRunningStatus: setNotRunningStatus, @@ -530,7 +530,7 @@ function newStrategyPart () { } } - function play () { + function run () { if (thisObject.circularProgressBar !== undefined) { thisObject.circularProgressBar.finalize() } diff --git a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js b/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js index df729a1c3..e7eb9b60e 100644 --- a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -15,10 +15,10 @@ function newTaskFunctions () { for (let i = 0; i < node.bot.processes.length; i++) { let process = node.bot.processes[i] - process.payload.uiObject.play() + process.payload.uiObject.run() } - node.payload.uiObject.play() + node.payload.uiObject.run() let event = { taskId: node.id, From 1854d73ea4de4074dd636e5ea61755541b5beb21 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 20 Sep 2019 10:30:28 +0200 Subject: [PATCH 06/13] Menu Items waits for callbacks to change status --- FloatingSpace/CircularMenuItem.js | 57 +++++++++++++++++----------- StrategySpace/Workspace/Workspace.js | 8 +++- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index 40f87bfa0..ac7e9f5db 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -123,10 +123,10 @@ function newCircularMenuItem () { /* Temporary Status impacts on the label to use and the background of that label */ - temporaryStatus-- - if (temporaryStatus < 0) { - temporaryStatus = 0 + if (temporaryStatus > 0) { + temporaryStatus-- } + if (temporaryStatus === 0) { labelToPrint = thisObject.label backgroundColorToUse = defaultBackgroudColor @@ -172,31 +172,45 @@ function newCircularMenuItem () { } async function onMouseClick (event) { - if (temporaryStatus === 0 && thisObject.askConfirmation !== true) { + if (thisObject.askConfirmation !== true) { /* No confirmation is needed */ + if (temporaryStatus === 0) { + executeAction() + } + } else { + /* Confirmation is needed */ + + /* A Click during confirmation executes the pre-defined action. */ + if (temporaryStatus > 0) { + executeAction() + } + + /* The first click ask for confirmation. */ + if (temporaryStatus === 0) { + setTemporaryStatus(thisObject.confirmationLabel, UI_COLOR.GREY, 250) + } + } + + function executeAction () { + /* If there is a working label defined, we use it here. */ if (thisObject.workingLabel !== undefined) { - setTemporaryStatus(thisObject.workingLabel, UI_COLOR.GREY, 500) + setTemporaryStatus(thisObject.workingLabel, UI_COLOR.GREY, -1) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored. } - thisObject.currentStatus = await thisObject.actionFunction(thisObject.payload, thisObject.action) + /* Execute the action and wait for callbacks to update our statuus. */ + thisObject.actionFunction(thisObject.payload, thisObject.action, onCallBack) - if (thisObject.currentStatus === true) { - if (thisObject.workDoneLabel !== undefined) { - setTemporaryStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250) - } - } else { - if (thisObject.workFailedLabel != undefined) { - setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500) + function onCallBack (err) { + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + if (thisObject.workDoneLabel !== undefined) { + setTemporaryStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250) + } + } else { + if (thisObject.workFailedLabel != undefined) { + setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500) + } } } } - - if (temporaryStatus > 0 && thisObject.askConfirmation === true) { - thisObject.currentStatus = await thisObject.actionFunction(thisObject.payload, thisObject.action) - } - - if (temporaryStatus === 0 && thisObject.askConfirmation === true) { - setTemporaryStatus(thisObject.confirmationLabel, UI_COLOR.GREY, 50) - } } function setTemporaryStatus (text, backgroundColor, waitingCycles) { @@ -274,4 +288,3 @@ function newCircularMenuItem () { } } } - diff --git a/StrategySpace/Workspace/Workspace.js b/StrategySpace/Workspace/Workspace.js index 9e8a3127a..a57618621 100644 --- a/StrategySpace/Workspace/Workspace.js +++ b/StrategySpace/Workspace/Workspace.js @@ -167,7 +167,7 @@ function newWorkspace () { } } - async function onMenuItemClick (payload, action) { + async function onMenuItemClick (payload, action, callBackFunction) { switch (action) { case 'Share Workspace': { @@ -186,7 +186,11 @@ function newWorkspace () { case 'Save Trading System': { let result = await canvas.strategySpace.strategizerGateway.saveToStrategyzer(getSimulationParams()) - return result + if (result === true) { + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) + } else { + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + } break } From 065efd6017a29a986b7a559ea7243b4926f5396b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 20 Sep 2019 15:16:24 +0200 Subject: [PATCH 07/13] Menu Items with secondary Action implemented --- FloatingSpace/CircularMenu.js | 18 +- FloatingSpace/CircularMenuItem.js | 90 ++++-- FloatingSpace/CircularProgressBar.js | 2 +- FloatingSpace/StrategyPart.js | 21 +- FloatingSpace/StrategyPartConstructor.js | 291 +++++++++--------- .../FunctionLibraries/TaskFunctions.js | 8 +- StrategySpace/Workspace/Workspace.js | 4 +- 7 files changed, 253 insertions(+), 181 deletions(-) diff --git a/FloatingSpace/CircularMenu.js b/FloatingSpace/CircularMenu.js index d35759070..4b71e9de4 100644 --- a/FloatingSpace/CircularMenu.js +++ b/FloatingSpace/CircularMenu.js @@ -57,6 +57,12 @@ function newCircularMenu () { menuItem.workingLabel = menuItemInitialValue.workingLabel menuItem.workDoneLabel = menuItemInitialValue.workDoneLabel menuItem.workFailedLabel = menuItemInitialValue.workFailedLabel + menuItem.secondaryAction = menuItemInitialValue.secondaryAction + menuItem.secondaryLabel = menuItemInitialValue.secondaryLabel + menuItem.secondaryWorkingLabel = menuItemInitialValue.secondaryWorkingLabel + menuItem.secondaryWorkDoneLabel = menuItemInitialValue.secondaryWorkDoneLabel + menuItem.secondaryWorkFailedLabel = menuItemInitialValue.secondaryWorkFailedLabel + menuItem.secondaryIcon = menuItemInitialValue.secondaryIcon menuItem.visible = menuItemInitialValue.visible menuItem.iconPathOn = menuItemInitialValue.iconPathOn menuItem.iconPathOff = menuItemInitialValue.iconPathOff @@ -91,7 +97,9 @@ function newCircularMenu () { if (thisObject.isDeployed === true) { for (let i = 0; i < menuItems.length; i++) { let menutItem = menuItems[i] - container = menutItem.getContainer(point) + if (menutItem.visible === true) { + container = menutItem.getContainer(point) + } if (container !== undefined) { return container } } } @@ -125,14 +133,18 @@ function newCircularMenu () { function drawBackground (pFloatingObject) { for (let i = 0; i < menuItems.length; i++) { let menutItem = menuItems[i] - menutItem.drawBackground() + if (menutItem.visible === true) { + menutItem.drawBackground() + } } } function drawForeground (pFloatingObject) { for (let i = 0; i < menuItems.length; i++) { let menutItem = menuItems[i] - menutItem.drawForeground() + if (menutItem.visible === true) { + menutItem.drawForeground() + } } } } diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index ac7e9f5db..8242c4fed 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -17,6 +17,12 @@ function newCircularMenuItem () { workingLabel: undefined, workDoneLabel: undefined, workFailedLabel: undefined, + secondaryAction: undefined, + secondaryLabel: undefined, + secondaryWorkingLabel: undefined, + secondaryWorkDoneLabel: undefined, + secondaryWorkFailedLabel: undefined, + secondaryIcon: undefined, visible: false, iconPathOn: undefined, iconPathOff: undefined, @@ -59,6 +65,12 @@ function newCircularMenuItem () { let temporaryStatus = 0 const EXTRA_MOUSE_OVER_ICON_SIZE = 2 + + const STATUS_DEFAULT = 0 + const STATUS_WORKING = -1 + const STAtUS_SECONDARY_WORKING = -2 + const STATUS_PRIMARY_WORK_DONE = -3 + return thisObject function finalize () { @@ -127,7 +139,7 @@ function newCircularMenuItem () { temporaryStatus-- } - if (temporaryStatus === 0) { + if (temporaryStatus === STATUS_DEFAULT) { labelToPrint = thisObject.label backgroundColorToUse = defaultBackgroudColor } @@ -136,12 +148,17 @@ function newCircularMenuItem () { } function iconPhysics () { - if (thisObject.relatedStrategyPart !== undefined) { - thisObject.iconOn = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart) - thisObject.iconOff = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart) + if (temporaryStatus === STATUS_PRIMARY_WORK_DONE || temporaryStatus === STAtUS_SECONDARY_WORKING) { + thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon) + thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon) } else { - thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.iconPathOn) - thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.iconPathOff) + if (thisObject.relatedStrategyPart !== undefined) { + thisObject.iconOn = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart) + thisObject.iconOff = canvas.strategySpace.iconByPartType.get(thisObject.relatedStrategyPart) + } else { + thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.iconPathOn) + thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.iconPathOff) + } } /* Current Status might be linked to some other object status */ @@ -173,7 +190,7 @@ function newCircularMenuItem () { async function onMouseClick (event) { if (thisObject.askConfirmation !== true) { /* No confirmation is needed */ - if (temporaryStatus === 0) { + if (temporaryStatus === STATUS_DEFAULT || temporaryStatus === STATUS_PRIMARY_WORK_DONE) { executeAction() } } else { @@ -191,22 +208,57 @@ function newCircularMenuItem () { } function executeAction () { - /* If there is a working label defined, we use it here. */ - if (thisObject.workingLabel !== undefined) { - setTemporaryStatus(thisObject.workingLabel, UI_COLOR.GREY, -1) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored. + if (labelToPrint !== thisObject.workingLabel) { + /* We need to execute the main Action */ + /* If there is a working label defined, we use it here. */ + if (thisObject.workingLabel !== undefined) { + setTemporaryStatus(thisObject.workingLabel, UI_COLOR.GREY, STATUS_WORKING) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored. + } + + /* Execute the action and wait for callbacks to update our statuus. */ + thisObject.actionFunction(thisObject.payload, thisObject.action, onPrimaryCallBack) + } else { + /* We need to execute the secondary action. */ + if (thisObject.secondaryWorkingLabel !== undefined) { + setTemporaryStatus(thisObject.secondaryWorkingLabel, UI_COLOR.GREY, STAtUS_SECONDARY_WORKING) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored. + } + + /* Execute the action and wait for callbacks to update our statuus. */ + thisObject.actionFunction(thisObject.payload, thisObject.secondaryAction, onSecondaryCallBack) } - /* Execute the action and wait for callbacks to update our statuus. */ - thisObject.actionFunction(thisObject.payload, thisObject.action, onCallBack) - - function onCallBack (err) { - if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { - if (thisObject.workDoneLabel !== undefined) { - setTemporaryStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250) + function onPrimaryCallBack (err) { + /* If there is a secondary action we will act different that if there is not */ + if (thisObject.secondaryAction === undefined) { + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + if (thisObject.workDoneLabel !== undefined) { + setTemporaryStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250) + } + } else { + if (thisObject.workFailedLabel != undefined) { + setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500) + } } } else { - if (thisObject.workFailedLabel != undefined) { - setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500) + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + if (thisObject.workDoneLabel !== undefined) { + setTemporaryStatus(thisObject.secondaryLabel, defaultBackgroudColor, STATUS_PRIMARY_WORK_DONE) + } + } else { + if (thisObject.workFailedLabel != undefined) { + setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500) + } + } + } + } + function onSecondaryCallBack (err) { + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + if (thisObject.secondaryWorkDoneLabel !== undefined) { + setTemporaryStatus(thisObject.secondaryWorkDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250) + } + } else { + if (thisObject.secondaryWorkFailedLabel != undefined) { + setTemporaryStatus(thisObject.secondaryWorkFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500) } } } diff --git a/FloatingSpace/CircularProgressBar.js b/FloatingSpace/CircularProgressBar.js index 91bbdd3b6..9977d4068 100644 --- a/FloatingSpace/CircularProgressBar.js +++ b/FloatingSpace/CircularProgressBar.js @@ -40,7 +40,7 @@ function newCircularProgressBar () { } let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id - systemEventHandler.createEventHandler(key) + // systemEventHandler.createEventHandler(key) systemEventHandler.listenToEvent(key, 'Heartbeat', undefined, key, undefined, onHeartBeat) } diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index bfc758b42..f77b3ab77 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -530,7 +530,8 @@ function newStrategyPart () { } } - function run () { + function run (callBackFunction) { + /* We setup the circular progress bar. */ if (thisObject.circularProgressBar !== undefined) { thisObject.circularProgressBar.finalize() } @@ -539,11 +540,23 @@ function newStrategyPart () { thisObject.circularProgressBar.initialize(thisObject.payload) thisObject.circularProgressBar.fitFunction = thisObject.fitFunction thisObject.circularProgressBar.container = thisObject.container + + /* We will wait to the event that the task was terminated in order to call back the menu item */ + let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id + systemEventHandler.listenToEvent(key, 'Task Running', undefined, key, undefined, onTaskTerminated) + + function onTaskTerminated () { + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) + } } - function stop () { - setTimeout(removecircularProgressBar, 90000) - function removecircularProgressBar () { + function stop (callBackFunction) { + /* We will wait to the event that the task was terminated in order to call back the menu item */ + let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id + let eventSubscriptionId = systemEventHandler.listenToEvent(key, 'Task Stopped', undefined, key, undefined, onTaskTerminated) + + function onTaskTerminated () { + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) thisObject.circularProgressBar.finalize() thisObject.circularProgressBar = undefined } diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 37b8c4a21..87db6c451 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -91,7 +91,7 @@ function newStrategyPartConstructor () { actionStatus: floatingObject.getPinStatus, currentStatus: false, label: undefined, - visible: false, + visible: true, iconPathOn: 'menu-fix-pinned', iconPathOff: 'menu-fix-unpinned', rawRadius: 8, @@ -107,7 +107,7 @@ function newStrategyPartConstructor () { actionStatus: floatingObject.getTensionStatus, currentStatus: true, label: undefined, - visible: false, + visible: true, iconPathOn: 'menu-tensor-fixed-angles', iconPathOff: 'menu-tensor-free-angles', rawRadius: 8, @@ -123,7 +123,7 @@ function newStrategyPartConstructor () { actionStatus: floatingObject.getFreezeStatus, currentStatus: true, label: undefined, - visible: false, + visible: true, iconPathOn: 'menu-mobility-freeze', iconPathOff: 'menu-mobility-unfreeze', rawRadius: 8, @@ -139,7 +139,7 @@ function newStrategyPartConstructor () { actionStatus: floatingObject.getCollapeseStatus, currentStatus: false, label: undefined, - visible: false, + visible: true, iconPathOn: 'menu-tree-plus', iconPathOff: 'menu-tree-minus', rawRadius: 8, @@ -153,7 +153,7 @@ function newStrategyPartConstructor () { action: 'Backup', actionFunction: floatingObject.payload.onMenuItemClick, label: undefined, - visible: false, + visible: true, iconPathOn: 'menu-backup', iconPathOff: 'menu-backup', rawRadius: 8, @@ -177,7 +177,7 @@ function newStrategyPartConstructor () { actionStatus: floatingObject.getPinStatus, currentStatus: true, label: undefined, - visible: false, + visible: true, iconPathOn: 'menu-fix-unpinned', iconPathOff: 'menu-fix-pinned', rawRadius: 8, @@ -189,7 +189,7 @@ function newStrategyPartConstructor () { action: 'Backup Workspace', actionFunction: payload.onMenuItemClick, label: undefined, - visible: false, + visible: true, iconPathOn: 'menu-backup', iconPathOff: 'menu-backup', rawRadius: 8, @@ -201,7 +201,7 @@ function newStrategyPartConstructor () { action: 'Share Workspace', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -220,7 +220,7 @@ function newStrategyPartConstructor () { action: 'Set as Default', actionFunction: payload.uiObject.setAsDefault, label: 'Set as Default', - visible: false, + visible: true, iconPathOn: 'paper-plane', iconPathOff: 'paper-plane', rawRadius: 8, @@ -237,7 +237,7 @@ function newStrategyPartConstructor () { workingLabel: 'Saving...', workDoneLabel: 'Saved', workFailedLabel: 'Not Saved', - visible: false, + visible: true, iconPathOn: 'menu-backup', iconPathOff: 'menu-backup', rawRadius: 8, @@ -251,7 +251,7 @@ function newStrategyPartConstructor () { action: 'Add Trading System', actionFunction: payload.onMenuItemClick, label: 'Add Trading System', - visible: false, + visible: true, relatedStrategyPart: 'Trading System', rawRadius: 8, targetRadius: 0, @@ -264,7 +264,7 @@ function newStrategyPartConstructor () { action: 'Add Personal Data', actionFunction: payload.onMenuItemClick, label: 'Add Personal Data', - visible: false, + visible: true, relatedStrategyPart: 'Personal Data', rawRadius: 8, targetRadius: 0, @@ -277,7 +277,7 @@ function newStrategyPartConstructor () { action: 'Add Task Manager', actionFunction: payload.onMenuItemClick, label: 'Add Task Manager', - visible: false, + visible: true, relatedStrategyPart: 'Task Manager', rawRadius: 8, targetRadius: 0, @@ -292,7 +292,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Definition', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -306,7 +306,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -324,7 +324,7 @@ function newStrategyPartConstructor () { action: 'Run All Tasks', actionFunction: payload.onMenuItemClick, label: 'Run All Tasks', - visible: false, + visible: true, iconPathOn: 'paper-plane', iconPathOff: 'paper-plane', rawRadius: 8, @@ -338,7 +338,7 @@ function newStrategyPartConstructor () { action: 'Stop All Tasks', actionFunction: payload.onMenuItemClick, label: 'Stop All Tasks', - visible: false, + visible: true, iconPathOn: 'stop', iconPathOff: 'stop', rawRadius: 8, @@ -352,7 +352,7 @@ function newStrategyPartConstructor () { action: 'Add Task', actionFunction: payload.onMenuItemClick, label: 'Add Task', - visible: false, + visible: true, relatedStrategyPart: 'Task Manager', rawRadius: 8, targetRadius: 0, @@ -367,7 +367,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Task Manager', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -381,7 +381,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -399,27 +399,22 @@ function newStrategyPartConstructor () { action: 'Run Task', actionFunction: payload.onMenuItemClick, label: 'Run', - visible: false, + workingLabel: 'Stop', + workDoneLabel: 'Task Running', + workFailedLabel: 'Task Cannot be Run', + secondaryAction: 'Stop Task', + secondaryLabel: 'Stop', + secondaryWorkingLabel: 'Stopping...', + secondaryWorkDoneLabel: 'Task Stopped', + secondaryWorkFailedLabel: 'Task Cannot be Stopped', + secondaryIcon: 'stop', + visible: true, iconPathOn: 'paper-plane', iconPathOff: 'paper-plane', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -75 - } - ) - menuItemsInitialValues.push( - { - action: 'Stop Task', - actionFunction: payload.onMenuItemClick, - label: 'Stop', - visible: false, - iconPathOn: 'stop', - iconPathOff: 'stop', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 + angle: -65 } ) menuItemsInitialValues.push( @@ -427,12 +422,12 @@ function newStrategyPartConstructor () { action: 'Add Sensor', actionFunction: payload.onMenuItemClick, label: 'Add Sensor', - visible: false, + visible: true, relatedStrategyPart: 'Sensor', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: -30 } ) menuItemsInitialValues.push( @@ -440,12 +435,12 @@ function newStrategyPartConstructor () { action: 'Add Indicator', actionFunction: payload.onMenuItemClick, label: 'Add Indicator', - visible: false, + visible: true, relatedStrategyPart: 'Indicator', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 0 + angle: -10 } ) menuItemsInitialValues.push( @@ -453,12 +448,12 @@ function newStrategyPartConstructor () { action: 'Add Trading Engine', actionFunction: payload.onMenuItemClick, label: 'Add Trading Engine', - visible: false, + visible: true, relatedStrategyPart: 'Trading Engine', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: 10 } ) menuItemsInitialValues.push( @@ -468,13 +463,13 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Process', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: +40 + angle: +30 } ) menuItemsInitialValues.push( @@ -482,13 +477,13 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 75 + angle: 65 } ) break @@ -500,7 +495,7 @@ function newStrategyPartConstructor () { action: 'Add Process', actionFunction: payload.onMenuItemClick, label: 'Add Process', - visible: false, + visible: true, relatedStrategyPart: 'Process', rawRadius: 8, targetRadius: 0, @@ -515,7 +510,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Sensor', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -529,7 +524,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -547,7 +542,7 @@ function newStrategyPartConstructor () { action: 'Add Process', actionFunction: payload.onMenuItemClick, label: 'Add Process', - visible: false, + visible: true, relatedStrategyPart: 'Process', rawRadius: 8, targetRadius: 0, @@ -562,7 +557,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Indicator', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -576,7 +571,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -594,7 +589,7 @@ function newStrategyPartConstructor () { action: 'Add Process', actionFunction: payload.onMenuItemClick, label: 'Add Process', - visible: false, + visible: true, relatedStrategyPart: 'Process', rawRadius: 8, targetRadius: 0, @@ -609,7 +604,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Trading Engine', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -623,7 +618,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -646,7 +641,7 @@ function newStrategyPartConstructor () { action: 'Edit Process', actionFunction: strategyPart.codeEditor.activate, label: 'Edit Process', - visible: false, + visible: true, iconPathOn: 'html', iconPathOff: 'html', rawRadius: 8, @@ -663,7 +658,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Process', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -677,7 +672,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -695,7 +690,7 @@ function newStrategyPartConstructor () { action: 'Add Exchange Account', actionFunction: payload.onMenuItemClick, label: 'Add Exchange Account', - visible: false, + visible: true, relatedStrategyPart: 'Exchange Account', rawRadius: 8, targetRadius: 0, @@ -710,7 +705,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Personal Data', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -728,7 +723,7 @@ function newStrategyPartConstructor () { action: 'Add Exchange Account Asset', actionFunction: payload.onMenuItemClick, label: 'Add Asset', - visible: false, + visible: true, relatedStrategyPart: 'Exchange Account Asset', rawRadius: 8, targetRadius: 0, @@ -741,7 +736,7 @@ function newStrategyPartConstructor () { action: 'Add Exchange Account Key', actionFunction: payload.onMenuItemClick, label: 'Add Key', - visible: false, + visible: true, relatedStrategyPart: 'Exchange Account Key', rawRadius: 8, targetRadius: 0, @@ -756,7 +751,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Account', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -776,7 +771,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Asset', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -799,7 +794,7 @@ function newStrategyPartConstructor () { action: 'Edit Key Value', actionFunction: strategyPart.codeEditor.activate, label: 'Edit Key Value', - visible: false, + visible: true, iconPathOn: 'html', iconPathOff: 'html', rawRadius: 8, @@ -816,7 +811,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Key', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -834,7 +829,7 @@ function newStrategyPartConstructor () { action: 'Add Strategy', actionFunction: payload.onMenuItemClick, label: 'Add Strategy', - visible: false, + visible: true, relatedStrategyPart: 'Strategy', rawRadius: 8, targetRadius: 0, @@ -847,7 +842,7 @@ function newStrategyPartConstructor () { action: 'Add Parameters', actionFunction: payload.onMenuItemClick, label: 'Add Parameters', - visible: false, + visible: true, relatedStrategyPart: 'Parameters', rawRadius: 8, targetRadius: 0, @@ -862,7 +857,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Trading System', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -876,7 +871,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -894,7 +889,7 @@ function newStrategyPartConstructor () { action: 'Add Missing Parameters', actionFunction: payload.onMenuItemClick, label: 'Add Missing Params', - visible: false, + visible: true, relatedStrategyPart: 'Parameters', rawRadius: 8, targetRadius: 0, @@ -909,7 +904,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Parameters', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -923,7 +918,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -946,7 +941,7 @@ function newStrategyPartConstructor () { action: 'Edit Base Asset', actionFunction: strategyPart.codeEditor.activate, label: 'Edit Base Asset', - visible: false, + visible: true, iconPathOn: 'settings', iconPathOff: 'settings', rawRadius: 8, @@ -962,7 +957,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Base Asset', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -976,7 +971,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -999,7 +994,7 @@ function newStrategyPartConstructor () { action: 'Edit Time Range', actionFunction: strategyPart.codeEditor.activate, label: 'Edit Time Range', - visible: false, + visible: true, iconPathOn: 'settings', iconPathOff: 'settings', rawRadius: 8, @@ -1015,7 +1010,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Time Range', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1029,7 +1024,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1052,7 +1047,7 @@ function newStrategyPartConstructor () { action: 'Edit Slippage', actionFunction: strategyPart.codeEditor.activate, label: 'Edit Slippage', - visible: false, + visible: true, iconPathOn: 'settings', iconPathOff: 'settings', rawRadius: 8, @@ -1068,7 +1063,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Slippage', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1082,7 +1077,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1105,7 +1100,7 @@ function newStrategyPartConstructor () { action: 'Edit Fee Structure', actionFunction: strategyPart.codeEditor.activate, label: 'Edit Fee Structure', - visible: false, + visible: true, iconPathOn: 'settings', iconPathOff: 'settings', rawRadius: 8, @@ -1121,7 +1116,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Fee Structure', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1135,7 +1130,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1153,7 +1148,7 @@ function newStrategyPartConstructor () { action: 'Add Missing Stages', actionFunction: payload.onMenuItemClick, label: 'Add Missing Stages', - visible: false, + visible: true, relatedStrategyPart: 'Strategy', rawRadius: 8, targetRadius: 0, @@ -1168,7 +1163,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Strategy', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1182,7 +1177,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1200,7 +1195,7 @@ function newStrategyPartConstructor () { action: 'Add Missing Events', actionFunction: payload.onMenuItemClick, label: 'Add Missing Events', - visible: false, + visible: true, relatedStrategyPart: 'Trigger Stage', rawRadius: 8, targetRadius: 0, @@ -1215,7 +1210,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Stage', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1229,7 +1224,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1247,7 +1242,7 @@ function newStrategyPartConstructor () { action: 'Add Initial Definition', actionFunction: payload.onMenuItemClick, label: 'Add Initial Definition', - visible: false, + visible: true, relatedStrategyPart: 'Initial Definition', rawRadius: 8, targetRadius: 0, @@ -1260,7 +1255,7 @@ function newStrategyPartConstructor () { action: 'Add Open Execution', actionFunction: payload.onMenuItemClick, label: 'Add Open Execution', - visible: false, + visible: true, relatedStrategyPart: 'Open Execution', rawRadius: 8, targetRadius: 0, @@ -1275,7 +1270,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Stage', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1289,7 +1284,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1307,7 +1302,7 @@ function newStrategyPartConstructor () { action: 'Add Missing Items', actionFunction: payload.onMenuItemClick, label: 'Add Missing Items', - visible: false, + visible: true, relatedStrategyPart: 'Manage Stage', rawRadius: 8, targetRadius: 0, @@ -1322,7 +1317,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Stage', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1336,7 +1331,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1354,7 +1349,7 @@ function newStrategyPartConstructor () { action: 'Add Close Execution', actionFunction: payload.onMenuItemClick, label: 'Add Close Execution', - visible: false, + visible: true, relatedStrategyPart: 'Close Execution', rawRadius: 8, targetRadius: 0, @@ -1369,7 +1364,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Stage', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1383,7 +1378,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1401,7 +1396,7 @@ function newStrategyPartConstructor () { action: 'Add Formula', actionFunction: payload.onMenuItemClick, label: 'Add Formula', - visible: false, + visible: true, relatedStrategyPart: 'Formula', rawRadius: 8, targetRadius: 0, @@ -1416,7 +1411,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Position Size', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1430,7 +1425,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1448,7 +1443,7 @@ function newStrategyPartConstructor () { action: 'Add Formula', actionFunction: payload.onMenuItemClick, label: 'Add Formula', - visible: false, + visible: true, relatedStrategyPart: 'Formula', rawRadius: 8, targetRadius: 0, @@ -1463,7 +1458,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete Position Rate', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1477,7 +1472,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1495,7 +1490,7 @@ function newStrategyPartConstructor () { action: 'Add Situation', actionFunction: payload.onMenuItemClick, label: 'Add Situation', - visible: false, + visible: true, relatedStrategyPart: 'Situation', rawRadius: 8, targetRadius: 0, @@ -1510,7 +1505,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Event', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1524,7 +1519,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1542,7 +1537,7 @@ function newStrategyPartConstructor () { action: 'Add Situation', actionFunction: payload.onMenuItemClick, label: 'Add Situation', - visible: false, + visible: true, relatedStrategyPart: 'Situation', rawRadius: 8, targetRadius: 0, @@ -1557,7 +1552,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Event', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1571,7 +1566,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1589,7 +1584,7 @@ function newStrategyPartConstructor () { action: 'Add Situation', actionFunction: payload.onMenuItemClick, label: 'Add Situation', - visible: false, + visible: true, relatedStrategyPart: 'Situation', rawRadius: 8, targetRadius: 0, @@ -1604,7 +1599,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Event', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1618,7 +1613,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1636,7 +1631,7 @@ function newStrategyPartConstructor () { action: 'Add Missing Items', actionFunction: payload.onMenuItemClick, label: 'Add Missing Items', - visible: false, + visible: true, relatedStrategyPart: 'Initial Definition', rawRadius: 8, targetRadius: 0, @@ -1651,7 +1646,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Definition', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1665,7 +1660,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1685,7 +1680,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1699,7 +1694,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1719,7 +1714,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1733,7 +1728,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1751,7 +1746,7 @@ function newStrategyPartConstructor () { action: 'Add Phase', actionFunction: payload.onMenuItemClick, label: 'Add Phase', - visible: false, + visible: true, relatedStrategyPart: 'Phase', rawRadius: 8, targetRadius: 0, @@ -1766,7 +1761,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Item', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1780,7 +1775,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1798,7 +1793,7 @@ function newStrategyPartConstructor () { action: 'Add Phase', actionFunction: payload.onMenuItemClick, label: 'Add Phase', - visible: false, + visible: true, relatedStrategyPart: 'Phase', rawRadius: 8, targetRadius: 0, @@ -1813,7 +1808,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Item', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1827,7 +1822,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1845,7 +1840,7 @@ function newStrategyPartConstructor () { action: 'Add Formula', actionFunction: payload.onMenuItemClick, label: 'Add Formula', - visible: false, + visible: true, relatedStrategyPart: 'Formula', rawRadius: 8, targetRadius: 0, @@ -1858,7 +1853,7 @@ function newStrategyPartConstructor () { action: 'Add Next Phase Event', actionFunction: payload.onMenuItemClick, label: 'Add Next Phase Event', - visible: false, + visible: true, relatedStrategyPart: 'Next Phase Event', rawRadius: 8, targetRadius: 0, @@ -1873,7 +1868,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Phase', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1887,7 +1882,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1910,7 +1905,7 @@ function newStrategyPartConstructor () { action: 'Edit Formula', actionFunction: strategyPart.codeEditor.activate, label: 'Edit Formula', - visible: false, + visible: true, iconPathOn: 'html', iconPathOff: 'html', rawRadius: 8, @@ -1927,7 +1922,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Formula', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1941,7 +1936,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -1959,7 +1954,7 @@ function newStrategyPartConstructor () { action: 'Add Situation', actionFunction: payload.onMenuItemClick, label: 'Add Situation', - visible: false, + visible: true, relatedStrategyPart: 'Situation', rawRadius: 8, targetRadius: 0, @@ -1974,7 +1969,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Event', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -1988,7 +1983,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -2006,7 +2001,7 @@ function newStrategyPartConstructor () { action: 'Add Condition', actionFunction: payload.onMenuItemClick, label: 'Add Condition', - visible: false, + visible: true, relatedStrategyPart: 'Condition', rawRadius: 8, targetRadius: 0, @@ -2021,7 +2016,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Situation', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -2035,7 +2030,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -2053,7 +2048,7 @@ function newStrategyPartConstructor () { action: 'Add Code', actionFunction: payload.onMenuItemClick, label: 'Add Code', - visible: false, + visible: true, relatedStrategyPart: 'Code', rawRadius: 8, targetRadius: 0, @@ -2068,7 +2063,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Condition', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -2082,7 +2077,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, @@ -2105,7 +2100,7 @@ function newStrategyPartConstructor () { action: 'Edit Code', actionFunction: strategyPart.codeEditor.activate, label: 'Edit Code', - visible: false, + visible: true, iconPathOn: 'html', iconPathOff: 'html', rawRadius: 8, @@ -2122,7 +2117,7 @@ function newStrategyPartConstructor () { confirmationLabel: 'Confirm to Delete', actionFunction: payload.onMenuItemClick, label: 'Delete This Code', - visible: false, + visible: true, iconPathOn: 'delete', iconPathOff: 'delete', rawRadius: 8, @@ -2136,7 +2131,7 @@ function newStrategyPartConstructor () { action: 'Share', actionFunction: payload.onMenuItemClick, label: 'Share', - visible: false, + visible: true, iconPathOn: 'menu-share', iconPathOff: 'menu-share', rawRadius: 8, diff --git a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js b/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js index e7eb9b60e..32bc3a3f5 100644 --- a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -8,7 +8,7 @@ function newTaskFunctions () { return thisObject - function runTask (node, functionLibraryProtocolNode) { + function runTask (node, functionLibraryProtocolNode, callBackFunction) { /* Check if it is possible to Run or not */ if (node.bot === undefined) { return } if (node.bot.processes.length === 0) { return } @@ -18,7 +18,7 @@ function newTaskFunctions () { process.payload.uiObject.run() } - node.payload.uiObject.run() + node.payload.uiObject.run(callBackFunction) let event = { taskId: node.id, @@ -28,14 +28,14 @@ function newTaskFunctions () { systemEventHandler.raiseEvent('Task Manager', 'Run Task', event) } - function stopTask (node, functionLibraryProtocolNode) { + function stopTask (node, functionLibraryProtocolNode, callBackFunction) { let event = { taskId: node.id, taskName: node.name } systemEventHandler.raiseEvent('Task Manager', 'Stop Task', event) - node.payload.uiObject.stop() + node.payload.uiObject.stop(callBackFunction) if (node.bot === undefined) { return } if (node.bot.processes.length === 0) { return } diff --git a/StrategySpace/Workspace/Workspace.js b/StrategySpace/Workspace/Workspace.js index a57618621..0a31a8006 100644 --- a/StrategySpace/Workspace/Workspace.js +++ b/StrategySpace/Workspace/Workspace.js @@ -227,12 +227,12 @@ function newWorkspace () { break case 'Run Task': { - functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode) + functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, callBackFunction) } break case 'Stop Task': { - functionLibraryTaskFunctions.stopTask(payload.node, functionLibraryProtocolNode) + functionLibraryTaskFunctions.stopTask(payload.node, functionLibraryProtocolNode, callBackFunction) } break case 'Run All Tasks': From a9e3941e1272be144f87de17ca41dcd31804d83d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 20 Sep 2019 15:48:56 +0200 Subject: [PATCH 08/13] Running and Stopping all tasks --- FloatingSpace/CircularMenu.js | 46 ++++++++++++------- FloatingSpace/CircularMenuItem.js | 12 ++++- .../FunctionLibraries/TaskFunctions.js | 8 +++- 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/FloatingSpace/CircularMenu.js b/FloatingSpace/CircularMenu.js index 4b71e9de4..4b4676921 100644 --- a/FloatingSpace/CircularMenu.js +++ b/FloatingSpace/CircularMenu.js @@ -5,6 +5,7 @@ function newCircularMenu () { let thisObject = { container: undefined, isDeployed: undefined, + internalClick: internalClick, physics: physics, drawBackground: drawBackground, drawForeground: drawForeground, @@ -96,54 +97,65 @@ function newCircularMenu () { if (thisObject.isDeployed === true) { for (let i = 0; i < menuItems.length; i++) { - let menutItem = menuItems[i] - if (menutItem.visible === true) { - container = menutItem.getContainer(point) + let menuItem = menuItems[i] + if (menuItem.visible === true) { + container = menuItem.getContainer(point) } if (container !== undefined) { return container } } } } + function internalClick (action) { + for (let i = 0; i < menuItems.length; i++) { + let menuItem = menuItems[i] + if (menuItem.visible === true) { + if (menuItem.nextAction === action) { + menuItem.internalClick() + } + } + } + } + function physics () { for (let i = 0; i < menuItems.length; i++) { - let menutItem = menuItems[i] - menutItem.physics() + let menuItem = menuItems[i] + menuItem.physics() } } function onFocus () { for (let i = 0; i < menuItems.length; i++) { - let menutItem = menuItems[i] - menutItem.targetRadius = menutItem.rawRadius * 1.5 - menutItem.isDeployed = true + let menuItem = menuItems[i] + menuItem.targetRadius = menuItem.rawRadius * 1.5 + menuItem.isDeployed = true } thisObject.isDeployed = true } function onNotFocus () { for (let i = 0; i < menuItems.length; i++) { - let menutItem = menuItems[i] - menutItem.targetRadius = menutItem.rawRadius * 0 - i * 4 - menutItem.isDeployed = false + let menuItem = menuItems[i] + menuItem.targetRadius = menuItem.rawRadius * 0 - i * 4 + menuItem.isDeployed = false } thisObject.isDeployed = false } function drawBackground (pFloatingObject) { for (let i = 0; i < menuItems.length; i++) { - let menutItem = menuItems[i] - if (menutItem.visible === true) { - menutItem.drawBackground() + let menuItem = menuItems[i] + if (menuItem.visible === true) { + menuItem.drawBackground() } } } function drawForeground (pFloatingObject) { for (let i = 0; i < menuItems.length; i++) { - let menutItem = menuItems[i] - if (menutItem.visible === true) { - menutItem.drawForeground() + let menuItem = menuItems[i] + if (menuItem.visible === true) { + menuItem.drawForeground() } } } diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index 8242c4fed..1753835cb 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -23,6 +23,7 @@ function newCircularMenuItem () { secondaryWorkDoneLabel: undefined, secondaryWorkFailedLabel: undefined, secondaryIcon: undefined, + nextAction: undefined, visible: false, iconPathOn: undefined, iconPathOff: undefined, @@ -34,6 +35,7 @@ function newCircularMenuItem () { payload: undefined, relatedStrategyPart: undefined, dontShowAtFullscreen: undefined, + internalClick: internalClick, physics: physics, drawBackground: drawBackground, drawForeground: drawForeground, @@ -102,6 +104,8 @@ function newCircularMenuItem () { } else { thisObject.container.frame.width = 50 } + + thisObject.nextAction = thisObject.action } function getContainer (point) { @@ -142,6 +146,7 @@ function newCircularMenuItem () { if (temporaryStatus === STATUS_DEFAULT) { labelToPrint = thisObject.label backgroundColorToUse = defaultBackgroudColor + thisObject.nextAction = thisObject.action } iconPhysics() @@ -188,7 +193,11 @@ function newCircularMenuItem () { isMouseOver = false } - async function onMouseClick (event) { + function internalClick () { + onMouseClick() + } + + function onMouseClick () { if (thisObject.askConfirmation !== true) { /* No confirmation is needed */ if (temporaryStatus === STATUS_DEFAULT || temporaryStatus === STATUS_PRIMARY_WORK_DONE) { executeAction() @@ -242,6 +251,7 @@ function newCircularMenuItem () { } else { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { if (thisObject.workDoneLabel !== undefined) { + thisObject.nextAction = thisObject.secondaryAction setTemporaryStatus(thisObject.secondaryLabel, defaultBackgroudColor, STATUS_PRIMARY_WORK_DONE) } } else { diff --git a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js b/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js index 32bc3a3f5..341f386dc 100644 --- a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -49,14 +49,18 @@ function newTaskFunctions () { function runAllTasks (taskManager, functionLibraryProtocolNode) { for (let i = 0; i < taskManager.tasks.length; i++) { let node = taskManager.tasks[i] - runTask(node, functionLibraryProtocolNode) + let menu = node.payload.uiObject.menu + + menu.internalClick('Run Task') } } function stopAllTasks (taskManager, functionLibraryProtocolNode) { for (let i = 0; i < taskManager.tasks.length; i++) { let node = taskManager.tasks[i] - stopTask(node, functionLibraryProtocolNode) + let menu = node.payload.uiObject.menu + + menu.internalClick('Stop Task') } } } From ba0903330e3537503fd735b9f7e6e567ad03343f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 20 Sep 2019 16:03:59 +0200 Subject: [PATCH 09/13] Bug Fixed --- FloatingSpace/StrategyPart.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index f77b3ab77..237449247 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -557,8 +557,10 @@ function newStrategyPart () { function onTaskTerminated () { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) - thisObject.circularProgressBar.finalize() - thisObject.circularProgressBar = undefined + if (thisObject.circularProgressBar !== undefined) { + thisObject.circularProgressBar.finalize() + thisObject.circularProgressBar = undefined + } } } From 07ad411bfb4653cf3897eff42d350b9587b874b0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 20 Sep 2019 16:28:18 +0200 Subject: [PATCH 10/13] Stopping Processes correctly --- FloatingSpace/StrategyPart.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/FloatingSpace/StrategyPart.js b/FloatingSpace/StrategyPart.js index 237449247..fb3761428 100644 --- a/FloatingSpace/StrategyPart.js +++ b/FloatingSpace/StrategyPart.js @@ -543,20 +543,25 @@ function newStrategyPart () { /* We will wait to the event that the task was terminated in order to call back the menu item */ let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id - systemEventHandler.listenToEvent(key, 'Task Running', undefined, key, undefined, onTaskTerminated) + systemEventHandler.listenToEvent(key, 'Running', undefined, key, undefined, onTaskTerminated) function onTaskTerminated () { - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) + if (callBackFunction !== undefined) { + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) + } } } function stop (callBackFunction) { /* We will wait to the event that the task was terminated in order to call back the menu item */ let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id - let eventSubscriptionId = systemEventHandler.listenToEvent(key, 'Task Stopped', undefined, key, undefined, onTaskTerminated) + let eventSubscriptionId = systemEventHandler.listenToEvent(key, 'Stopped', undefined, key, undefined, onTaskTerminated) function onTaskTerminated () { - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) + if (callBackFunction !== undefined) { + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) + } + if (thisObject.circularProgressBar !== undefined) { thisObject.circularProgressBar.finalize() thisObject.circularProgressBar = undefined From 566e7060d8efd85a1f9e8bf7fdf0af742b9dfa55 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 21 Sep 2019 09:43:23 +0200 Subject: [PATCH 11/13] Bug Fixed that preventing using the icons --- FloatingSpace/CircularMenuItem.js | 85 ++++++++++++++++++++----------- 1 file changed, 56 insertions(+), 29 deletions(-) diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index 1753835cb..9fb252e8b 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -65,13 +65,18 @@ function newCircularMenuItem () { let defaultBackgroudColor = UI_COLOR.RED let backgroundColorToUse = UI_COLOR.RED let temporaryStatus = 0 + let temporaryStatusCounter = 0 const EXTRA_MOUSE_OVER_ICON_SIZE = 2 - const STATUS_DEFAULT = 0 - const STATUS_WORKING = -1 - const STAtUS_SECONDARY_WORKING = -2 + const STATUS_NO_ACTION_TAKEN_YET = 0 + const STATUS_PRIMARY_ACTION_WORKING = -1 + const STATUS_SECONDARY_ACTION_WORKING = -2 const STATUS_PRIMARY_WORK_DONE = -3 + const STATUS_PRIMARY_WORK_FAILED = -4 + const STATUS_WAITING_CONFIRMATION = -5 + const STATUS_SECONDARY_WORK_DONE = -6 + const STATUS_SECONDARY_WORK_FAILED = -7 return thisObject @@ -139,11 +144,12 @@ function newCircularMenuItem () { /* Temporary Status impacts on the label to use and the background of that label */ - if (temporaryStatus > 0) { - temporaryStatus-- + if (temporaryStatusCounter > 0) { + temporaryStatusCounter-- } - if (temporaryStatus === STATUS_DEFAULT) { + if (temporaryStatusCounter === 0) { + temporaryStatus = STATUS_NO_ACTION_TAKEN_YET labelToPrint = thisObject.label backgroundColorToUse = defaultBackgroudColor thisObject.nextAction = thisObject.action @@ -153,7 +159,14 @@ function newCircularMenuItem () { } function iconPhysics () { - if (temporaryStatus === STATUS_PRIMARY_WORK_DONE || temporaryStatus === STAtUS_SECONDARY_WORKING) { + if ( + ( + temporaryStatus === STATUS_PRIMARY_WORK_DONE || + temporaryStatus === STATUS_SECONDARY_ACTION_WORKING || + temporaryStatus === STATUS_SECONDARY_WORK_DONE || + temporaryStatus === STATUS_SECONDARY_WORK_FAILED + ) && thisObject.secondaryAction !== undefined + ) { thisObject.iconOn = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon) thisObject.iconOff = canvas.strategySpace.iconCollection.get(thisObject.secondaryIcon) } else { @@ -198,65 +211,75 @@ function newCircularMenuItem () { } function onMouseClick () { + if (thisObject.label === undefined) { + /* This is what we have in the case of menu items that are only Icons. In this situation there is no complex logic, just execute the specified action. */ + thisObject.actionFunction(thisObject.payload, thisObject.action) + return + } + if (thisObject.askConfirmation !== true) { /* No confirmation is needed */ - if (temporaryStatus === STATUS_DEFAULT || temporaryStatus === STATUS_PRIMARY_WORK_DONE) { + if (temporaryStatus === STATUS_NO_ACTION_TAKEN_YET || temporaryStatus === STATUS_PRIMARY_WORK_DONE) { executeAction() - } + } // Any click out of those states is ignored } else { /* Confirmation is needed */ - /* A Click during confirmation executes the pre-defined action. */ - if (temporaryStatus > 0) { - executeAction() - } - /* The first click ask for confirmation. */ - if (temporaryStatus === 0) { - setTemporaryStatus(thisObject.confirmationLabel, UI_COLOR.GREY, 250) + if (temporaryStatus === STATUS_NO_ACTION_TAKEN_YET) { + setStatus(thisObject.confirmationLabel, UI_COLOR.GREY, 250, STATUS_WAITING_CONFIRMATION) + return + } + /* A Click during confirmation executes the pre-defined action. */ + if (temporaryStatus === STATUS_WAITING_CONFIRMATION || temporaryStatus === STATUS_PRIMARY_WORK_DONE) { + executeAction() + return } } function executeAction () { - if (labelToPrint !== thisObject.workingLabel) { + if (temporaryStatus === STATUS_NO_ACTION_TAKEN_YET || temporaryStatus === STATUS_WAITING_CONFIRMATION) { /* We need to execute the main Action */ /* If there is a working label defined, we use it here. */ if (thisObject.workingLabel !== undefined) { - setTemporaryStatus(thisObject.workingLabel, UI_COLOR.GREY, STATUS_WORKING) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored. + setStatus(thisObject.workingLabel, UI_COLOR.GREY, undefined, STATUS_PRIMARY_ACTION_WORKING) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored. } /* Execute the action and wait for callbacks to update our statuus. */ thisObject.actionFunction(thisObject.payload, thisObject.action, onPrimaryCallBack) - } else { + return + } + if (temporaryStatus === STATUS_PRIMARY_WORK_DONE && thisObject.secondaryAction !== undefined) { /* We need to execute the secondary action. */ if (thisObject.secondaryWorkingLabel !== undefined) { - setTemporaryStatus(thisObject.secondaryWorkingLabel, UI_COLOR.GREY, STAtUS_SECONDARY_WORKING) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored. + setStatus(thisObject.secondaryWorkingLabel, UI_COLOR.GREY, undefined, STATUS_SECONDARY_ACTION_WORKING) // Status will not expire, will only change with a callback. Mouse Clicks will be ignored. } /* Execute the action and wait for callbacks to update our statuus. */ thisObject.actionFunction(thisObject.payload, thisObject.secondaryAction, onSecondaryCallBack) + return } function onPrimaryCallBack (err) { /* If there is a secondary action we will act different that if there is not */ - if (thisObject.secondaryAction === undefined) { + if (thisObject.secondaryAction === undefined) { // This means there are no more possible actions. if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { if (thisObject.workDoneLabel !== undefined) { - setTemporaryStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250) + setStatus(thisObject.workDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250, STATUS_PRIMARY_WORK_DONE) } } else { if (thisObject.workFailedLabel != undefined) { - setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500) + setStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500, STATUS_PRIMARY_WORK_FAILED) } } } else { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { if (thisObject.workDoneLabel !== undefined) { thisObject.nextAction = thisObject.secondaryAction - setTemporaryStatus(thisObject.secondaryLabel, defaultBackgroudColor, STATUS_PRIMARY_WORK_DONE) + setStatus(thisObject.secondaryLabel, defaultBackgroudColor, undefined, STATUS_PRIMARY_WORK_DONE) } } else { if (thisObject.workFailedLabel != undefined) { - setTemporaryStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500) + setStatus(thisObject.workFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500, STATUS_PRIMARY_WORK_FAILED) } } } @@ -264,21 +287,25 @@ function newCircularMenuItem () { function onSecondaryCallBack (err) { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { if (thisObject.secondaryWorkDoneLabel !== undefined) { - setTemporaryStatus(thisObject.secondaryWorkDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250) + setStatus(thisObject.secondaryWorkDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250, STATUS_SECONDARY_WORK_DONE) } } else { if (thisObject.secondaryWorkFailedLabel != undefined) { - setTemporaryStatus(thisObject.secondaryWorkFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500) + setStatus(thisObject.secondaryWorkFailedLabel, UI_COLOR.TITANIUM_YELLOW, 500, STATUS_SECONDARY_WORK_FAILED) } } } } } - function setTemporaryStatus (text, backgroundColor, waitingCycles) { + function setStatus (text, backgroundColor, waitingCycles, newStatus) { labelToPrint = text backgroundColorToUse = backgroundColor - temporaryStatus = waitingCycles + temporaryStatus = newStatus + temporaryStatusCounter = newStatus // This will often put this into negatives numbers, which will disable the counting back and automatic reseting. + if (waitingCycles !== undefined) { // This will override the often negative value with a positive one that will tend to zero onto the default state. + temporaryStatusCounter = waitingCycles + } } function drawBackground () { From 8cdb5e6078b3407c01f9ee95397e4b604e37ba9f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 22 Sep 2019 18:12:20 +0200 Subject: [PATCH 12/13] Listening to events when Datasets are updated on Daily Files --- ChartsSpace/PlottersManager.js | 4 ++-- CockpitSpace/RestartSimulation.js | 17 +++++------------ FloatingSpace/CircularProgressBar.js | 12 +++++++++--- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ChartsSpace/PlottersManager.js b/ChartsSpace/PlottersManager.js index ef59d597b..13d85f703 100644 --- a/ChartsSpace/PlottersManager.js +++ b/ChartsSpace/PlottersManager.js @@ -462,11 +462,12 @@ function newPlottersManager () { canvas.panelsSpace.destroyPanel(productPlotters[i].panels[j]) } /* Finally the Storage Objects */ - productPlotters[i].storage.finalize() + if (productPlotters[i].plotter.finalize !== undefined) { productPlotters[i].plotter.container.finalize() productPlotters[i].plotter.finalize() } + productPlotters[i].storage.finalize() productPlotters.splice(i, 1) // Delete item from array. return // We already found the product woth changes and processed it. } @@ -530,4 +531,3 @@ function newPlottersManager () { } } } - diff --git a/CockpitSpace/RestartSimulation.js b/CockpitSpace/RestartSimulation.js index 16198d49e..b73e1a75e 100644 --- a/CockpitSpace/RestartSimulation.js +++ b/CockpitSpace/RestartSimulation.js @@ -36,7 +36,7 @@ function newRestartSimulation () { let executionFocusExists = false let idleLabel = '' let isRunning = false - let eventSubscriptionIdSimulationFilesUpdated + let eventSubscriptionIdProcessStopped return thisObject @@ -46,8 +46,8 @@ function newRestartSimulation () { thisObject.container.eventHandler.stopListening(selfMouseClickEventSubscriptionId) thisObject.container.eventHandler.stopListening(selfMouseNotOverEventSubscriptionId) - systemEventHandler.stopListening('Jason-Multi-Period', eventSubscriptionIdSimulationFilesUpdated) systemEventHandler.stopListening('Jason-Multi-Period', eventSubscriptionIdProcessStopped) + systemEventHandler.deleteEventHandler('Cockpit-Restart-Button') thisObject.container.finalize() thisObject.container = undefined @@ -65,19 +65,12 @@ function newRestartSimulation () { systemEventHandler.createEventHandler('Cockpit-Restart-Button') - /* - We will start listening to the event that is triggered when the simulation process finishes processing one day in the case - of daily files or the whole market in the case of market files. - */ - eventSubscriptionIdSimulationFilesUpdated = systemEventHandler.listenToEvent('Jason-Multi-Period', 'Simulation Files Updated', undefined, undefined, undefined, onFilesUpdated) + systemEventHandler.listenToEvent('Jason-Multi-Period', 'Process Stopped', undefined, 'Cockpit-Restart-Button', onResponse, onProcessStopped) - function onFilesUpdated (message) { - turnOffProductCards() - turnOnProductCards() + function onResponse (message) { + eventSubscriptionIdProcessStopped = message.eventSubscriptionId } - eventSubscriptionIdProcessStopped = systemEventHandler.listenToEvent('Jason-Multi-Period', 'Process Stopped', undefined, undefined, undefined, onProcessStopped) - function onProcessStopped (message) { thisObject.status = 'Ready' isRunning = false diff --git a/FloatingSpace/CircularProgressBar.js b/FloatingSpace/CircularProgressBar.js index 9977d4068..a28c0ea68 100644 --- a/FloatingSpace/CircularProgressBar.js +++ b/FloatingSpace/CircularProgressBar.js @@ -23,11 +23,14 @@ function newCircularProgressBar () { let opacityCounters = [] + let eventSubscriptionHeartbeat + return thisObject function finalize () { - thisObject.container = undefined + systemEventHandler.stopListening('Jason-Heartbeat-Period', eventSubscriptionHeartbeat) + thisObject.container = undefined thisObject.payload = undefined thisObject.fitFunction = undefined } @@ -40,8 +43,11 @@ function newCircularProgressBar () { } let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id - // systemEventHandler.createEventHandler(key) - systemEventHandler.listenToEvent(key, 'Heartbeat', undefined, key, undefined, onHeartBeat) + systemEventHandler.listenToEvent(key, 'Heartbeat', undefined, key, onResponse, onHeartBeat) + + function onResponse (message) { + eventSubscriptionIdHeartbeat = message.eventSubscriptionId + } } function onHeartBeat (message) { From 2b20301528e191f55edb232835b9858b566509c3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 23 Sep 2019 11:29:21 +0200 Subject: [PATCH 13/13] Bug Fixed Handling events with caller Id --- SplashScreen.js | 2 +- SystemEventHandler.js | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/SplashScreen.js b/SplashScreen.js index a4c43f411..14293b854 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -125,7 +125,7 @@ function newSplashScreen () { fontSize = 15 - title = 'Trading Bots Competitions Platform' + title = 'Trading Automation System' titlePoint = { x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20, diff --git a/SystemEventHandler.js b/SystemEventHandler.js index 072fa880b..740048d48 100644 --- a/SystemEventHandler.js +++ b/SystemEventHandler.js @@ -30,7 +30,13 @@ function newSystemEventHandler () { function sendCommand (command, responseCallBack, eventsCallBack) { if (command.action === 'listenToEvent') { - eventListeners.set(command.eventHandlerName + '-' + command.eventType, eventsCallBack) + let key + if (command.callerId !== undefined) { + key = command.eventHandlerName + '-' + command.eventType + '-' + command.callerId + } else { + key = command.eventHandlerName + '-' + command.eventType + } + eventListeners.set(key, eventsCallBack) } if (command.callerId && responseCallBack) { responseWaiters.set(command.callerId, responseCallBack) @@ -107,7 +113,13 @@ function newSystemEventHandler () { let message = JSON.parse(e.data) if (message.action === 'Event Raised') { - let handler = eventListeners.get(message.eventHandlerName + '-' + message.eventType) + let key + if (message.callerId !== undefined) { + key = message.eventHandlerName + '-' + message.eventType + '-' + message.callerId + } else { + key = message.eventHandlerName + '-' + message.eventType + } + let handler = eventListeners.get(key) if (handler) { handler(message) }