From eac4c47e2e9e22479d0f9d76fc0f4ef8c1241b92 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 Apr 2020 14:34:36 +0200 Subject: [PATCH] host and pot implementation --- ChartingSpace/PlottersManager.js | 7 +++++++ .../FunctionLibraries/UiObjectsFromNodes.js | 6 +++--- Panels/Layer.js | 15 ++++++++++++++- ProductStorage.js | 10 +++++----- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index 2b36cf693..5610ec1b1 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -146,6 +146,11 @@ function newPlottersManager () { } } + let host = layer.networkNode.code.host + let webPort = layer.networkNode.code.webPort + if (host === undefined) { host = 'localhost' } + if (webPort === undefined) { webPort = window.location.port } + storage.initialize( dataMine, bot, @@ -155,6 +160,8 @@ function newPlottersManager () { market, datetime, timeFrame, + host, + webPort, onProductStorageInitialized ) diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index eadf4355e..d6253f558 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -37,7 +37,7 @@ function newUiObjectsFromNodes () { for (let i = 0; i < includeDataMines.length; i++) { let name = includeDataMines[i] - blobService.getBlobToText('DataMines' + '/' + name, undefined, onFileReceived, true) + blobService.getFileFromHost('DataMines' + '/' + name, onFileReceived, true) function onFileReceived (err, text, response) { if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.') @@ -66,7 +66,7 @@ function newUiObjectsFromNodes () { for (let i = 0; i < includeTradingSystems.length; i++) { let name = includeTradingSystems[i] - blobService.getBlobToText('TradingSystems' + '/' + name, undefined, onFileReceived, true) + blobService.getFileFromHost('TradingSystems' + '/' + name, onFileReceived, true) function onFileReceived (err, text, response) { if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.') @@ -95,7 +95,7 @@ function newUiObjectsFromNodes () { for (let i = 0; i < includeSuperScripts.length; i++) { let name = includeSuperScripts[i] - blobService.getBlobToText('SuperScripts' + '/' + name, undefined, onFileReceived, true) + blobService.getFileFromHost('SuperScripts' + '/' + name, onFileReceived, true) function onFileReceived (err, text, response) { if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.') diff --git a/Panels/Layer.js b/Panels/Layer.js index bc1ffadb5..217d3d805 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -20,6 +20,7 @@ function newLayer () { plotterTypeIcon: undefined, baseAssetIcon: undefined, quotedAssetIcon: undefined, + networkNode: undefined, checkStatusAtShutDown: checkStatusAtShutDown, physics: physics, draw: draw, @@ -128,6 +129,7 @@ function newLayer () { thisObject.plotterTypeIcon = undefined thisObject.baseAssetIcon = undefined thisObject.quotedAssetIcon = undefined + thisObject.networkNode = undefined } function initialize (callBackFunction) { @@ -151,8 +153,9 @@ function newLayer () { let functionLibraryProtocolNode = newProtocolNode() let lightingPath = '->Layer->' + - 'Data Product->Single Market Data->' + + 'Data Product->Single Market Data->Exchange Data Products->' + 'Session Independent Data->Session Based Data->' + + 'Data Storage->Network Node->' + 'Session Reference->Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Market->Market Base Asset->Asset->' + 'Market Quoted Asset->Asset->' + @@ -186,6 +189,10 @@ function newLayer () { if (thisObject.definition.referenceParent.referenceParent === undefined) { return } if (thisObject.definition.referenceParent.referenceParent.parentNode === undefined) { return } if (thisObject.definition.referenceParent.referenceParent.parentNode.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode.parentNode === undefined) { return } /* Lets listen to our own events to react when we have a Mouse Click */ onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) @@ -226,6 +233,12 @@ function newLayer () { thisObject.baseAssetIcon = getIcon(thisObject.baseAsset) thisObject.quotedAssetIcon = getIcon(thisObject.quotedAsset) + if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode.type === 'Data Storage') { + thisObject.networkNode = thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode.parentNode + } else { + thisObject.networkNode = thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode + } + function getIcon (node) { let nodeDefinition = APP_SCHEMA_MAP.get(node.type) let iconName diff --git a/ProductStorage.js b/ProductStorage.js index 4e0c4142a..181486dcf 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -74,7 +74,7 @@ function newProductStorage (name) { } } - function initialize (dataMine, bot, session, product, exchange, market, pDatetime, pTimeFrame, callBackFunction) { + function initialize (dataMine, bot, session, product, exchange, market, pDatetime, pTimeFrame, host, port, callBackFunction) { try { datetime = pDatetime timeFrame = pTimeFrame @@ -90,7 +90,7 @@ function newProductStorage (name) { dataSetsToLoad++ let marketFiles = newMarketFiles() - marketFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, onMarketFileReady) + marketFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, onMarketFileReady) thisObject.marketFiles.push(marketFiles) } break @@ -99,7 +99,7 @@ function newProductStorage (name) { dataSetsToLoad++ let dailyFiles = newDailyFiles() - dailyFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, onDailyFileReady) + dailyFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, host, port, onDailyFileReady) thisObject.dailyFiles.push(dailyFiles) } break @@ -108,7 +108,7 @@ function newProductStorage (name) { dataSetsToLoad++ let singleFile = newSingleFile() - singleFile.initialize(dataMine, bot, session, product, dataset, exchange, market, onSingleFileReady) + singleFile.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, onSingleFileReady) thisObject.singleFile.push(singleFile) } break @@ -117,7 +117,7 @@ function newProductStorage (name) { dataSetsToLoad++ let fileSequences = newFileSequence() - fileSequences.initialize(dataMine, bot, session, product, dataset, exchange, market, onFileSequenceReady) + fileSequences.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, onFileSequenceReady) thisObject.fileSequences.push(fileSequences) } break