From cc4d9c44ca6a9e9116c714a89082de485f943887 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 30 Apr 2018 10:08:05 +0200 Subject: [PATCH] Any amount of dataSets per Product --- .vs/AAWeb/v15/.suo | Bin 66048 -> 67072 bytes Files/File.js | 2 +- Files/FileCache.js | 2 +- Files/FileCursorCache.js | 2 +- Files/FileSequence.js | 2 +- ProductStorage.js | 56 ++++++++++++++++++++++----------------- server.js | 2 +- 7 files changed, 36 insertions(+), 30 deletions(-) diff --git a/.vs/AAWeb/v15/.suo b/.vs/AAWeb/v15/.suo index 532e5d610b29e3d777e41a5d10b84fe4e0cd22a7..f2374a70523a52cf1e7d360af6a6b64b86235498 100644 GIT binary patch delta 1322 zcma)*ZERCz6vum>dvCjzt+p^0WU|!>LTE$gSY(VbJ1j)TqKxPmLj)&*FcX-(gpC&| zW@bjET>970)+q5x<;{iJ#}8zIY=cP%BEDdZ9}Lb(Vlt!IOvDjf=ec&93xSN2{O)tk zdCvblFZbSHlNx+m)tA%$Pb;&9UH5J)t?9l-^W+Yp5EYm%&~E^8_=KF;$aze2AGl9Gf}QGC6*f zd4PGC$!E-bk||<;K2yvrV5TzW+=xASM?5(dBUjUCDIU~jYL%R+!eVV1`qEUlsS9#u zQ>t#L4smTBB@ey$NLW;$!s^kwKY6Wpm3+l&OI=DiF4*?ckSt46NHx`X%3eZ2yl&r^ zv4@-NWz3BZ$y@e)nG}(YIn9bOTNu-=iDE@a#W$E?lnSFn7!|_sryJG6c-j%p*{&^N zC70JW6V-q|55V_RmRwzP%qB%$k`n7(R_WT@M=VR!AGFa`=sWAf``6&PhP4V`k!*jn zOfhy@5v*`X#~U{(vGt%fTovjZ}R3_0jd#e@i7xA`UcZzV%!%h?eI$y3 z__>7MB}TQNlZ)_b=UluHk6|#fF8tAB2u0V8(*l1)i&*h8T29(f5}C!yL%0}w56L4= z8oQ=^-*}epzDDGJ8@xnVet0QPx7y|E)_gJPG@oq5*0AH{i`sm=imV67OylPhwK(#w zS04Cyn{7g>FwQe>w6|>;*|3bASxG26Ts?kUcdG5Z8*L!0YKglSr7He=KF`l0+1^$~ zW72sYX8IX9?eceo@|MrWOj#`BD1ITtVm|n;UUn}WT_>-@{57)S>g>f^u?2UZm9EZO z@@yFuSuD-$FJsafWjGH#I!kt(cPY>>Ou;wNDaJ(={a-bVE0iCeT}%9d$$!33MWX9# z`oDoNz7^=%QG(X~G#U8etj*|AF|phuJ=ePlTQB8d&Wwp@_$>>kHaTVWpT{+$M;HUD zaYJCmm&LL;=_kCieKzthWkUZw9iba(@=AZ9Baz(2`n~}4YfgD(uux!eWtMa~dkGx@ nKm14it{>}8*%y`$v<1qpf4}7KUz?UOxJwC-0hOH?owAPFng9Z-tj)Un_|yD2%XHxLM2`dBAkdPVhEX^PQH(P z8u@f0gP23exj`HK+jzmi*xWyF$5GluZ55?lIA2?0FVe-u!i^F#5g}dc*#dm8}6x4~z z*n=v!F+R@B6Btji`I1y7)XZMs>5R_}<+B-I9?X|A-)a_wEVf)*MAg-zGWQ@rK6Yd- zz{Af*i-Pr+H4(Ay3rKw_^KJB4z>l>Ro9gDT#5G&K;m@M`eYcCz16A=OceB2~ePhg5l3RzIa-tqL5M zcxq%YGo;Q?G~$$7rPzIJGG=?~F}(h$6l}nYtrk3aHW6Eocqy5W-Q0>9-b8F}YHYa6 zpcxCjC$Q#B69WZb+?nyudhGMsz*tkXHLr#+1wd{KS;<_ZVVWw0;|$ygEwgXZl376Q zU&s8$EKIr|f}VScMyKNB+4W|OKeA}BO;ODc06IOcUlKtqQl9NW8%6>3FDCjQ!t!xzVixHsJzw)ZT?3ney@`{5k$w+s`?6VdS~NH}`BRQ`_f&y0T!#_9eT aeE!&m%SbuvN0y4)0|(IcEM27c`QazUZOzR9 diff --git a/Files/File.js b/Files/File.js index ed3aa34a7..3ef68497a 100644 --- a/Files/File.js +++ b/Files/File.js @@ -78,7 +78,7 @@ function newFile() { file = pFile; - callBackFunction(); + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); } catch (err) { diff --git a/Files/FileCache.js b/Files/FileCache.js index e5386b403..b04fbec6a 100644 --- a/Files/FileCache.js +++ b/Files/FileCache.js @@ -90,7 +90,7 @@ function newFileCache() { filesLoaded++; - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); // Note that the callback is called for every file loaded. + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, thisObject); // Note that the callback is called for every file loaded. } } diff --git a/Files/FileCursorCache.js b/Files/FileCursorCache.js index 94ce52b6d..30e6fd6a9 100644 --- a/Files/FileCursorCache.js +++ b/Files/FileCursorCache.js @@ -101,7 +101,7 @@ function newFileCursorCache() { } filesLoaded++; - callBackWhenFileReceived(GLOBAL.DEFAULT_OK_RESPONSE); // Note that the call back is called for every file loaded at each cursor. + callBackWhenFileReceived(GLOBAL.DEFAULT_OK_RESPONSE, thisObject); // Note that the call back is called for every file loaded at each cursor. } diff --git a/Files/FileSequence.js b/Files/FileSequence.js index f79449d86..ffa28cb6c 100644 --- a/Files/FileSequence.js +++ b/Files/FileSequence.js @@ -133,7 +133,7 @@ function newFileSequence() { filesLoaded++; - callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE); // Note that the callback is called for every file loaded. + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, thisObject); // Note that the callback is called for every file loaded. } } diff --git a/ProductStorage.js b/ProductStorage.js index f4b3ef26b..9dde69f23 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -29,10 +29,10 @@ function newProductStorage(pName) { let thisObject = { - fileCache: undefined, - fileCursorCache: undefined, - file: undefined, - fileSequence: undefined, + fileCache: [], + fileCursorCache: [], + file: [], + fileSequence: [], setDatetime: setDatetime, setTimePeriod: setTimePeriod, @@ -75,8 +75,9 @@ function newProductStorage(pName) { if (INFO_LOG === true) { logger.write("[INFO] initialize -> Market Files -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } - thisObject.fileCache = newFileCache(); - thisObject.fileCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onCacheFileReady); + let fileCache = newFileCache(); + fileCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onCacheFileReady); + thisObject.fileCache.push(fileCache); dataSetsToLoad++; } break; @@ -85,8 +86,9 @@ function newProductStorage(pName) { if (INFO_LOG === true) { logger.write("[INFO] initialize -> Daily Files -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } - thisObject.fileCursorCache = newFileCursorCache(); - thisObject.fileCursorCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onFileCursorReady); + let fileCursorCache = newFileCursorCache(); + fileCursorCache.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, pDatetime, pTimePeriod, onFileCursorReady); + thisObject.fileCursorCache.push(fileCursorCache); dataSetsToLoad++; } break; @@ -95,8 +97,9 @@ function newProductStorage(pName) { if (INFO_LOG === true) { logger.write("[INFO] initialize -> Single File -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } - thisObject.file = newFile(); - thisObject.file.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onSingleFileReady); + let file = newFile(); + file.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onSingleFileReady); + thisObject.file.push(file); dataSetsToLoad++; } break; @@ -105,14 +108,15 @@ function newProductStorage(pName) { if (INFO_LOG === true) { logger.write("[INFO] initialize -> File Sequence -> key = " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName); } - thisObject.fileSequence = newFileSequence(); - thisObject.fileSequence.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onFileSequenceReady); + let fileSequence = newFileSequence(); + fileSequence.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onFileSequenceReady); + thisObject.fileSequence.push(fileSequence); dataSetsToLoad++; } break; } - function onCacheFileReady(err) { + function onCacheFileReady(err, pCaller) { try { @@ -151,8 +155,8 @@ function newProductStorage(pName) { } let event = { - totalValue: thisObject.fileCache.getExpectedFiles(), - currentValue: thisObject.fileCache.getFilesLoaded() + totalValue: pCaller.getExpectedFiles(), + currentValue: pCaller.getFilesLoaded() } thisObject.eventHandler.raiseEvent('Market File Loaded', event); @@ -171,7 +175,7 @@ function newProductStorage(pName) { } } - function onFileCursorReady(err) { + function onFileCursorReady(err, pCaller) { try { @@ -210,8 +214,8 @@ function newProductStorage(pName) { } let event = { - totalValue: thisObject.fileCursorCache.getExpectedFiles(), - currentValue: thisObject.fileCursorCache.getFilesLoaded() + totalValue: pCaller.getExpectedFiles(), + currentValue: pCaller.getFilesLoaded() } thisObject.eventHandler.raiseEvent('Daily File Loaded', event); @@ -230,7 +234,7 @@ function newProductStorage(pName) { } } - function onSingleFileReady(err) { + function onSingleFileReady(err, pCaller) { try { @@ -289,7 +293,7 @@ function newProductStorage(pName) { } } - function onFileSequenceReady(err) { + function onFileSequenceReady(err, pCaller) { try { @@ -328,8 +332,8 @@ function newProductStorage(pName) { } let event = { - totalValue: thisObject.fileSequence.getExpectedFiles(), - currentValue: thisObject.fileSequence.getFilesLoaded() + totalValue: pCaller.getExpectedFiles(), + currentValue: pCaller.getFilesLoaded() } thisObject.eventHandler.raiseEvent('File Sequence Loaded', event); @@ -391,8 +395,10 @@ function newProductStorage(pName) { if (timePeriod <= _1_HOUR_IN_MILISECONDS) { - thisObject.fileCursorCache.setDatetime(pDatetime); + for (let i = 0; i < thisObject.fileCursorCache.length; i++) { + thisObject.fileCursorCache[i].setDatetime(pDatetime); + } } } @@ -410,9 +416,9 @@ function newProductStorage(pName) { if (timePeriod <= _1_HOUR_IN_MILISECONDS) { - if (thisObject.fileCursorCache !== undefined) { + for (let i = 0; i < thisObject.fileCursorCache.length; i++) { - thisObject.fileCursorCache.setTimePeriod(pTimePeriod, datetime); + thisObject.fileCursorCache[i].setTimePeriod(pTimePeriod, datetime); } } } diff --git a/server.js b/server.js index 1cf8bb361..330817bd6 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,7 @@ if (CONSOLE_LOG === true) { } -const DEBUG_MODE = false; // This forces the server to read Plotters from the local drive. +const DEBUG_MODE = true; // This forces the server to read Plotters from the local drive. if (CONSOLE_LOG === true && DEBUG_MODE === true) {