Storage and downwards ready
This commit is contained in:
1 parent
108f2122f2
commit
d70e8995d9
9 files changed
+216
-91
No files matched your search
+25
-23
@@ -3,9 +3,13 @@ function newFileCache() {
|
||||
|
||||
let fileCache = {
|
||||
getFile: getFile,
|
||||
getExpectedFiles: getExpectedFiles,
|
||||
getFilesLoaded: getFilesLoaded,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
let filesLoaded = 0;
|
||||
|
||||
let fileCloud;
|
||||
|
||||
let files = new Map;
|
||||
@@ -14,34 +18,18 @@ function newFileCache() {
|
||||
|
||||
return fileCache;
|
||||
|
||||
function initialize(pTeamCodeName, pBotCodeName, pProductCodeName, pSetCodeName, pExchange, pMarket, callBackFunction) {
|
||||
function initialize(pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) {
|
||||
|
||||
let product = ecosystem.getProduct(ecosystem.getBot(ecosystem.getTeam(pTeamCodeName), pBotCodeName), pProductCodeName);
|
||||
|
||||
if (product === undefined) {
|
||||
|
||||
throw "Product not found at this bot of the ecosystem! - pTeamCodeName = " + pTeamCodeName + ", pBotCodeName = " + pBotCodeName + ", pProductCodeName = " + pProductCodeName;
|
||||
|
||||
}
|
||||
|
||||
let exchange = ecosystem.getExchange(product, pExchange);
|
||||
let exchange = ecosystem.getExchange(pProduct, pExchange);
|
||||
|
||||
if (exchange === undefined) {
|
||||
|
||||
throw "Exchange not supoorted by this product of the ecosystem! - pTeamCodeName = " + pTeamCodeName + ", pBotCodeName = " + pBotCodeName + ", pProductCodeName = " + pProductCodeName + ", pExchange = " + pExchange;
|
||||
|
||||
}
|
||||
|
||||
let productSet = ecosystem.getSet(product, pSetCodeName);
|
||||
|
||||
if (productSet === undefined) {
|
||||
|
||||
throw "Set not found at this product of the ecosystem! - pTeamCodeName = " + pTeamCodeName + ", pBotCodeName = " + pBotCodeName + ", pProductCodeName = " + pProductCodeName + ", pSetCodeName = " + pSetCodeName;
|
||||
throw "Exchange not supoorted by this pProduct of the ecosystem! - pDevTeam.codeName = " + pDevTeam.codeName + ", pBot.codeName = " + pBot.codeName + ", pProduct.codeName = " + pProduct.codeName + ", pExchange = " + pExchange;
|
||||
|
||||
}
|
||||
|
||||
fileCloud = newFileCloud();
|
||||
fileCloud.initialize(pTeamCodeName, pBotCodeName);
|
||||
fileCloud.initialize(pBot);
|
||||
|
||||
/* Now we will get the market files */
|
||||
|
||||
@@ -50,15 +38,17 @@ function newFileCache() {
|
||||
let periodTime = marketFilesPeriods[i][0];
|
||||
let periodName = marketFilesPeriods[i][1];
|
||||
|
||||
if (productSet.validPeriods.includes(periodName) === true) {
|
||||
if (pSet.validPeriods.includes(periodName) === true) {
|
||||
|
||||
fileCloud.getFile(productSet, exchange, pMarket, periodName, undefined, onFileReceived);
|
||||
fileCloud.getFile(pSet, exchange, pMarket, periodName, undefined, onFileReceived);
|
||||
|
||||
function onFileReceived(file) {
|
||||
|
||||
files.set(periodTime, file);
|
||||
|
||||
callBackFunction(); // Note that the call back is called for every file loaded.
|
||||
filesLoaded++;
|
||||
|
||||
callBackFunction(); // Note that the callback is called for every file loaded.
|
||||
|
||||
}
|
||||
}
|
||||
@@ -71,4 +61,16 @@ function newFileCache() {
|
||||
|
||||
}
|
||||
|
||||
function getExpectedFiles() {
|
||||
|
||||
return marketFilesPeriods.length;
|
||||
|
||||
}
|
||||
|
||||
function getFilesLoaded() {
|
||||
|
||||
return filesLoaded;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user