Everything Working Again!

This commit is contained in:
Luis Fernando Molina committed 2018-03-02 20:17:42 +01:00
1 parent 892437f669
commit afbdff268d
5 files changed
+161 -113

No files matched your search

Binary file not shown.
+6 -6
View File
@@ -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)'
};
}
+152 -105
View File
@@ -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();
}
}
}
+2 -2
View File
@@ -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() {
+1
View File
@@ -7,6 +7,7 @@
<!--Plotters-->
<script type="text/javascript" src="Plotters.js"></script>
<script type="text/javascript" src="Storage.js"></script>
<script type="text/javascript" src="ProductCard.js"></script>
<script type="text/javascript" src="Ecosystem.js"></script>
<script type="text/javascript" src="File.js"></script>