From afbdff268d1bc8c83b5ac0d415e62a783214b5ac Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 2 Mar 2018 20:17:42 +0100 Subject: [PATCH] Everything Working Again! --- .vs/AAWebPlatform/v15/.suo | Bin 78336 -> 75776 bytes ProductCard.js | 12 +- Storage.js | 257 ++++++++++++++++++++++--------------- TimelineChart.js | 4 +- index.html | 1 + 5 files changed, 161 insertions(+), 113 deletions(-) diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index 954f27362feff2b844ca2fd699d8436b25571ec4..03b4c7d61ac132e5b98770119a74dabbc4ef2477 100644 GIT binary patch delta 1957 zcmcJQe{54#6vumRU$=JcwyrCsu+Da)x(QqDirdiP99xCC&9Rb^5Tb%;1W}P-M`R3E zH364YgdVUaxWS&Li9(|5MTq~9DWFjk{B34}qef=}F#}AOOpMfXa9uX$uYbJBC+FOA z&pr2^?|Xd>{iuXKQ}%j`gl1xxH5wziTH;zNmEtJ-&Vj&h02x>$oQA>duyu9(OQ?|@ zLJP13w`rTQ!NgevZAxLF#0^j4n6{>S0flZR<`6m}pIAz8nw4xLQAAV{g+vbFAPR`v zh*^Y<;Cvpx6L(C^^Cm1G&1-j(Et&9nzDT3#p4`X*FD=$iB(zM}YO;1Bi&x@`z{w z?R72Nb`OoPmiJ825>L&kfG!-%EXli-cHBbn0i|R!uv}lzeG_@C-5P?mn@@1YUunm2 z){k}Lv5@?7g0<5V9P^N^AXqy$!E$h%C9x32L|QuPBO}GymF){GfO-1@1#<#4?}uwB0GqkL^ts~5zlJK%!X|8(hrs2B@E_$rRUd@ z3vfUN=Y}C}^@E8I(oS2M6&9*XL@bRr?68C(;_##2?$zB#8?17hy%|hgk&m0KoGdh% zF=Q*o*PRYLsjb3beY?JFN(LtD+tAAW$7rW?TWftpwFEz^Si8I{;+4)%5RSyv5f3VCA-GPtFd~=N9rmO4?Bf) zKKi{j-gFAwUBR(e_an_|@TMf)pY4JOXp(KBp8SFa6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tz+c? 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 @@ +