diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index 954f27362..03b4c7d61 100644 Binary files a/.vs/AAWebPlatform/v15/.suo and b/.vs/AAWebPlatform/v15/.suo differ diff --git a/ProductCard.js b/ProductCard.js index 7718b0573..2b6c5a439 100644 --- a/ProductCard.js +++ b/ProductCard.js @@ -15,8 +15,8 @@ let progressBar = { value: 100, - fillStyle = 'rgba(226, 226, 226, 1)', - strokeStyle = 'rgba(86, 86, 86, 1)' + fillStyle: 'rgba(226, 226, 226, 1)', + strokeStyle: 'rgba(86, 86, 86, 1)' }; return thisObject; @@ -93,16 +93,16 @@ progressBar = { value: 100, - fillStyle = 'rgba((56, 209, 6, 1)', - strokeStyle = 'rgba(40, 99, 21, 1)' + fillStyle: 'rgba((56, 209, 6, 1)', + strokeStyle: 'rgba(40, 99, 21, 1)' }; } else { progressBar = { value: event.totalValue * 100 / event.totalValue, - fillStyle = 'rgba(234, 143, 23, 1)', - strokeStyle = 'rgba(122, 79, 23, 1)' + fillStyle: 'rgba(234, 143, 23, 1)', + strokeStyle: 'rgba(122, 79, 23, 1)' }; } diff --git a/Storage.js b/Storage.js index 46d62d573..38e7ba693 100644 --- a/Storage.js +++ b/Storage.js @@ -1,6 +1,8 @@  function newStorage() { + const CONSOLE_LOG = false; + /* This object will initialize children objects that will end up loading the data of each set defined at each product of the bot received at initialization. @@ -10,7 +12,7 @@ function newStorage() { */ - thisObject = { + let thisObject = { fileCache: undefined, fileCursorCache: undefined, @@ -25,109 +27,154 @@ function newStorage() { return thisObject; + function initialize(pDevTeam, pBot, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) { + + /* We name the event Handler to easy debugging. */ + + thisObject.eventHandler.name = "Storage-" + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName + + if (CONSOLE_LOG === true) { + + console.log("Storage initialize for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); + + } + + let dataSetsToLoad = 0; + let dataSetsLoaded = 0; + + for (let i = 0; i < pProduct.sets.length; i++) { + + let thisSet = pProduct.sets[i]; + + switch (thisSet.type) { + case 'Market Files': { + + thisObject.fileCache = newFileCache(); + thisObject.fileCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onCacheFileReady); + dataSetsToLoad++; + + if (CONSOLE_LOG === true) { + + console.log("Storage initialize Market Files for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); + + } + } + break; + + case 'Daily Files': { + + thisObject.fileCursorCache = newFileCursorCache(); + thisObject.fileCursorCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onFileCursorReady); + dataSetsToLoad++; + + if (CONSOLE_LOG === true) { + + console.log("Storage initialize Daily Files for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); + + } + } + break; + + case 'Single File': { + + thisObject.file = newFile(); + thisObject.file.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onSingleFileReady); + dataSetsToLoad++; + + if (CONSOLE_LOG === true) { + + console.log("Storage initialize Single File for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); + + } + } + break; + + } + + function onCacheFileReady() { + + if (CONSOLE_LOG === true) { + + console.log("Storage initialize onCacheFileReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); + + } + + let event = { + totalValue: thisObject.fileCache.getExpectedFiles(), + currentValue: thisObject.fileCache.getFilesLoaded() + } + + thisObject.eventHandler.raiseEvent('Storage File Loaded', event); + + if (event.currentValue === event.totalValue) { + + dataSetsLoaded++; + + checkInitializeComplete(); + } + } + + function onFileCursorReady() { + + if (CONSOLE_LOG === true) { + + console.log("Storage initialize onFileCursorReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); + + } + + let event = { + totalValue: thisObject.fileCursorCache.getExpectedFiles(), + currentValue: thisObject.fileCursorCache.getFilesLoaded() + } + + thisObject.eventHandler.raiseEvent('Storage File Loaded', event); + + if (event.currentValue === event.totalValue) { + + dataSetsLoaded++; + + checkInitializeComplete(); + } + } + + function onSingleFileReady() { + + if (CONSOLE_LOG === true) { + + console.log("Storage initialize onSingleFileReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); + + } + + let event = { + totalValue: 1, + currentValue: 1 + } + + thisObject.eventHandler.raiseEvent('Storage File Loaded', event); + + if (event.currentValue === event.totalValue) { + + dataSetsLoaded++; + + checkInitializeComplete(); + } + } + + function checkInitializeComplete() { + + if (CONSOLE_LOG === true) { + + console.log("Storage initialize checkInitializeComplete for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); + + } + + if (dataSetsLoaded === dataSetsToLoad) { + + callBackFunction(); + + } + } + } + } } -function initialize(pDevTeam, pBot, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) { - - /* We name the event Handler to easy debugging. */ - - thisObject.eventHandler.name = "Storage" + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName - - let dataSetsToLoad = 0; - let dataSetsLoaded = 0; - - for (i = 0; i < pProduct.sets.length; i++) { - - let thisSet = pProduct.sets[i]; - - switch (thisSet.type) { - case 'Market Files': { - - thisObject.fileCache = newFileCache(); - thisObject.fileCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onCacheFileReady); - dataSetsToLoad++; - - } - break; - - case 'Daily Files': { - - thisObject.fileCursorCache = newFileCursorCache(); - thisObject.fileCursorCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onFileCursorReady); - dataSetsToLoad++; - - } - break; - - case 'Single File': { - - thisObject.file = newFile(); - thisObject.file.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onSingleFileReady); - dataSetsToLoad++; - - } - break; - - } - } - - function onCacheFileReady() { - - let event = { - totalValue: thisObject.fileCache.getExpectedFiles(), - currentValue: thisObject.fileCache.getFilesLoaded() - } - - thisObject.eventHandler.raiseEvent('Storage File Loaded', event); - - if (event.currentValue === event.totalValue) { - - dataSetsLoaded++; - - checkInitializeComplete(); - } - } - - function onFileCursorReady() { - - let event = { - totalValue: thisObject.fileCursorCache.getExpectedFiles(), - currentValue: thisObject.fileCursorCache.getFilesLoaded() - } - - thisObject.eventHandler.raiseEvent('Storage File Loaded', event); - - if (event.currentValue === event.totalValue) { - - dataSetsLoaded++; - - checkInitializeComplete(); - } - } - - function onSingleFileReady() { - - let event = { - totalValue: 1, - currentValue: 1 - } - - thisObject.eventHandler.raiseEvent('Storage File Loaded', event); - - if (event.currentValue === event.totalValue) { - - dataSetsLoaded++; - - checkInitializeComplete(); - } - } - - function checkInitializeComplete() { - - if (dataSetsLoaded === dataSetsToLoad) { - - callBackFunction(); - - } - } -} \ No newline at end of file diff --git a/TimelineChart.js b/TimelineChart.js index 0408dc172..5511171f2 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -129,7 +129,7 @@ function newTimelineChart() { storage.eventHandler.listenToEvent('Storage File Loaded', pProductCard.onFileLoaded); - storage.initialize(pProductCard.devTeam, pProductCard..bot, pProductCard.product, DEFAULT_EXCHANGE, DEFAULT_MARKET, datetime, timePeriod, onStorageInitialized) ; + storage.initialize(pProductCard.devTeam, pProductCard.bot, pProductCard.product, DEFAULT_EXCHANGE, DEFAULT_MARKET, datetime, timePeriod, onStorageInitialized) ; function onStorageInitialized() { @@ -149,7 +149,7 @@ function newTimelineChart() { plotter.container.frame.position.x = timelineChart.container.frame.width / 2 - plotter.container.frame.width / 2; plotter.container.frame.position.y = timelineChart.container.frame.height / 2 - plotter.container.frame.height / 2; - plotter.initialize(DEFAULT_EXCHANGE, DEFAULT_MARKET, datetime, timePeriod, onPlotterInizialized); + plotter.initialize(storage, DEFAULT_EXCHANGE, DEFAULT_MARKET, datetime, timePeriod, onPlotterInizialized); function onPlotterInizialized() { diff --git a/index.html b/index.html index cb72df15b..919e1760b 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,7 @@ +