diff --git a/.vs/AAWeb/v15/.suo b/.vs/AAWeb/v15/.suo
index 1e366ff78..df941d30e 100644
Binary files a/.vs/AAWeb/v15/.suo and b/.vs/AAWeb/v15/.suo differ
diff --git a/FileSequence.js b/FileSequence.js
new file mode 100644
index 000000000..9de4e7d2c
--- /dev/null
+++ b/FileSequence.js
@@ -0,0 +1,79 @@
+
+function newFileSequence() {
+
+ let thisObject = {
+ getFile: getFile,
+ getExpectedFiles: getExpectedFiles,
+ getFilesLoaded: getFilesLoaded,
+ initialize: initialize
+ }
+
+ let filesLoaded = 0;
+
+ let fileCloud;
+
+ let files = new Map;
+
+ let maxSequence;
+
+ return thisObject;
+
+ function initialize(pDevTeam, pBot, pProduct, pSet, pExchange, pMarket, callBackFunction) {
+
+ let exchange = ecosystem.getExchange(pProduct, pExchange);
+
+ if (exchange === undefined) {
+
+ 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(pBot);
+
+ /* First we will get the sequence max number */
+
+ fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, "Sequence", onSequenceFileReceived);
+
+ function onSequenceFileReceived(file) {
+
+ maxSequence = Number(file);
+
+ /* Now we will get the sequence of files */
+
+ for (let i = 0; i <= maxSequence; i++) {
+
+ fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, i, onFileReceived);
+
+ function onFileReceived(file) {
+
+ files.set(i, file);
+
+ filesLoaded++;
+
+ callBackFunction(); // Note that the callback is called for every file loaded.
+
+ }
+ }
+ }
+ }
+
+ function getFile(pSequence) {
+
+ return files.get(pSequence);
+
+ }
+
+ function getExpectedFiles() {
+
+ return maxSequence + 1;
+
+ }
+
+ function getFilesLoaded() {
+
+ return filesLoaded;
+
+ }
+
+}
\ No newline at end of file
diff --git a/Files/File.js b/Files/File.js
index 878726be2..611506ea0 100644
--- a/Files/File.js
+++ b/Files/File.js
@@ -26,7 +26,7 @@ function newFile() {
/* Now we will get the file */
- fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, onFileReceived);
+ fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, undefined, undefined, undefined, onFileReceived);
function onFileReceived(pFile) {
diff --git a/Files/FileCache.js b/Files/FileCache.js
index 34de3368f..7187fb859 100644
--- a/Files/FileCache.js
+++ b/Files/FileCache.js
@@ -13,8 +13,6 @@ function newFileCache() {
let fileCloud;
let files = new Map;
-
- let datetime;
return fileCache;
@@ -33,14 +31,14 @@ function newFileCache() {
/* Now we will get the market files */
- for (i = 0; i < marketFilesPeriods.length; i++) {
+ for (let i = 0; i < marketFilesPeriods.length; i++) {
let periodTime = marketFilesPeriods[i][0];
let periodName = marketFilesPeriods[i][1];
if (pSet.validPeriods.includes(periodName) === true) {
- fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, periodName, undefined, onFileReceived);
+ fileCloud.getFile(pDevTeam, pBot, pSet, exchange, pMarket, periodName, undefined, undefined, onFileReceived);
function onFileReceived(file) {
diff --git a/Files/FileCloud.js b/Files/FileCloud.js
index b317dae22..e8ffc3433 100644
--- a/Files/FileCloud.js
+++ b/Files/FileCloud.js
@@ -18,7 +18,7 @@ function newFileCloud() {
}
- function getFile(pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, callBackFunction) {
+ function getFile(pDevTeam, pBot, pSet, pExchange, pMarket, pPeriodName, pDatetime, pSequence, callBackFunction) {
let fileName = pSet.fileName;
let filePath = pSet.filePath;
@@ -69,6 +69,11 @@ function newFileCloud() {
}
+ if (pSequence !== undefined) {
+
+ fileName = fileName.replace("@Sequence", pSequence);
+ }
+
blobService.getBlobToText('data', filePath + "/" + fileName, onFileReceived);
if (CONSOLE_LOG === true) {
diff --git a/Files/FileCursor.js b/Files/FileCursor.js
index 2aa2e591a..f809fac6e 100644
--- a/Files/FileCursor.js
+++ b/Files/FileCursor.js
@@ -295,7 +295,7 @@ function newFileCursor() {
if (fileCursor.files.get(dateString) === undefined) { // We dont reload files we already have.
- fileCloud.getFile(devTeam, bot, thisSet, exchange, market, periodName, targetDate, onFileReceived);
+ fileCloud.getFile(devTeam, bot, thisSet, exchange, market, periodName, targetDate, undefined, onFileReceived);
} else {
diff --git a/ProductCard.js b/ProductCard.js
index f7f789233..f91fff260 100644
--- a/ProductCard.js
+++ b/ProductCard.js
@@ -17,6 +17,7 @@
onMarketFileLoaded: onMarketFileLoaded,
onDailyFileLoaded: onDailyFileLoaded,
onSingleFileLoaded: onSingleFileLoaded,
+ onFileSequenceLoaded: onFileSequenceLoaded,
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
initialize: initialize
@@ -54,6 +55,14 @@
opacity: 0.00
};
+ let fileSequenceProgressBar = {
+ value: 0,
+ animatedValue: 0,
+ fillStyle: UNLOADED_FILL_STYLE,
+ strokeStyle: UNLOADED_STROKE_STYLE,
+ opacity: 0.00
+ };
+
let timePeriod = INITIAL_TIME_PERIOD;
let datetime = INITIAL_DATE;
@@ -235,6 +244,21 @@
}
}
+ function onFileSequenceLoaded(event) {
+
+ fileSequenceProgressBar.value = Math.trunc(event.currentValue * 100 / event.totalValue);
+ fileSequenceProgressBar.fillStyle = LOADING_FILL_STYLE;
+ fileSequenceProgressBar.strokeStyle = LOADING_STROKE_STYLE;
+
+ if (fileSequenceProgressBar.value > 100) { fileSequenceProgressBar.value = 100; }
+
+ if (CONSOLE_LOG === true) {
+
+ console.log("ProductCard onFileSequenceLoaded Value = " + fileSequenceProgressBar.value + "% for " + thisObject.code + ". Event = " + JSON.stringify(event));
+
+ }
+ }
+
function buttonPressed(event) {
switch (thisObject.status) {
@@ -258,6 +282,11 @@
singleFileProgressBar.fillStyle = UNLOADED_FILL_STYLE;
singleFileProgressBar.strokeStyle = UNLOADED_STROKE_STYLE;
+ fileSequenceProgressBar.animatedValue = 0;
+ fileSequenceProgressBar.value = 0;
+ fileSequenceProgressBar.fillStyle = UNLOADED_FILL_STYLE;
+ fileSequenceProgressBar.strokeStyle = UNLOADED_STROKE_STYLE;
+
break;
case PRODUCT_CARD_STATUS.OFF:
@@ -664,5 +693,70 @@
browserCanvasContext.fill();
browserCanvasContext.lineWidth = 0.1;
browserCanvasContext.stroke();
+
+ /* We draw here the File Sequence Progress Bar. */
+
+ /* Animate */
+
+ if (fileSequenceProgressBar.animatedValue < fileSequenceProgressBar.value) {
+
+ fileSequenceProgressBar.animatedValue = fileSequenceProgressBar.animatedValue + ANIMATED_INCREMENT;
+ fileSequenceProgressBar.opacity = fileSequenceProgressBar.opacity + OPACITY_INCREMENT;
+
+ }
+
+ if (fileSequenceProgressBar.animatedValue >= 100) {
+
+ fileSequenceProgressBar.animatedValue = 100;
+
+ fileSequenceProgressBar.opacity = fileSequenceProgressBar.opacity - OPACITY_INCREMENT;
+ if (fileSequenceProgressBar.opacity < OPACITY_MIN) { fileSequenceProgressBar.opacity = OPACITY_MIN; }
+
+ fileSequenceProgressBar.fillStyle = LOADED_FILL_STYLE.replace('@Opacity', fileSequenceProgressBar.opacity.toString());
+ fileSequenceProgressBar.strokeStyle = LOADED_STROKE_STYLE.replace('@Opacity', fileSequenceProgressBar.opacity.toString());
+
+ changeStatusTo(PRODUCT_CARD_STATUS.ON);
+ }
+
+ point1 = {
+ x: 0,
+ y: thisObject.container.frame.height - 10
+ };
+
+ point2 = {
+ x: thisObject.container.frame.width * fileSequenceProgressBar.animatedValue / 100,
+ y: thisObject.container.frame.height - 10
+ };
+
+ point3 = {
+ x: thisObject.container.frame.width * fileSequenceProgressBar.animatedValue / 100,
+ y: thisObject.container.frame.height - 11
+ };
+
+ point4 = {
+ x: 0,
+ y: thisObject.container.frame.height - 11
+ };
+
+ /* Now the transformations. */
+
+ point1 = thisObject.container.frame.frameThisPoint(point1);
+ point2 = thisObject.container.frame.frameThisPoint(point2);
+ point3 = thisObject.container.frame.frameThisPoint(point3);
+ point4 = thisObject.container.frame.frameThisPoint(point4);
+
+ browserCanvasContext.beginPath();
+ browserCanvasContext.moveTo(point1.x, point1.y);
+ browserCanvasContext.lineTo(point2.x, point2.y);
+ browserCanvasContext.lineTo(point3.x, point3.y);
+ browserCanvasContext.lineTo(point4.x, point4.y);
+ browserCanvasContext.closePath();
+
+ browserCanvasContext.fillStyle = fileSequenceProgressBar.fillStyle.replace('@Opacity', fileSequenceProgressBar.opacity.toString());
+ browserCanvasContext.strokeStyle = fileSequenceProgressBar.strokeStyle.replace('@Opacity', fileSequenceProgressBar.opacity.toString());
+
+ browserCanvasContext.fill();
+ browserCanvasContext.lineWidth = 0.1;
+ browserCanvasContext.stroke();
}
}
\ No newline at end of file
diff --git a/ProductStorage.js b/ProductStorage.js
index cfb6e852c..8f7d0027d 100644
--- a/ProductStorage.js
+++ b/ProductStorage.js
@@ -17,6 +17,7 @@ function newProductStorage(pName) {
fileCache: undefined,
fileCursorCache: undefined,
file: undefined,
+ fileSequence: undefined,
setDatetime: setDatetime,
setTimePeriod: setTimePeriod,
@@ -100,8 +101,8 @@ function newProductStorage(pName) {
case 'File Sequence': {
- thisObject.file = newFileSequence();
- thisObject.file.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onSingleFileReady);
+ thisObject.fileSequence = newFileSequence();
+ thisObject.fileSequence.initialize(pDevTeam, pBot, pProduct, thisSet, pExchange, pMarket, onFileSequenceReady);
dataSetsToLoad++;
if (CONSOLE_LOG === true) {
@@ -182,6 +183,29 @@ function newProductStorage(pName) {
}
}
+ function onFileSequenceReady() {
+
+ if (CONSOLE_LOG === true) {
+
+ console.log("Product storage initialize onFileSequenceReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
+
+ }
+
+ let event = {
+ totalValue: thisObject.fileSequence.getExpectedFiles(),
+ currentValue: thisObject.fileSequence.getFilesLoaded()
+ }
+
+ thisObject.eventHandler.raiseEvent('File Sequence Loaded', event);
+
+ if (event.currentValue === event.totalValue) {
+
+ dataSetsLoaded++;
+
+ checkInitializeComplete();
+ }
+ }
+
function checkInitializeComplete() {
if (CONSOLE_LOG === true) {
diff --git a/Project.njsproj b/Project.njsproj
index 192d15b10..9791a209f 100644
--- a/Project.njsproj
+++ b/Project.njsproj
@@ -38,6 +38,9 @@
Code
+
+ Code
+
Code
diff --git a/TimelineChart.js b/TimelineChart.js
index 784ce013a..05f417647 100644
--- a/TimelineChart.js
+++ b/TimelineChart.js
@@ -173,7 +173,12 @@
break;
case 'Single File': {
- storage.eventHandler.listenToEvent('Single File Loaded', pProductCard.onSingleFileLoaded);;
+ storage.eventHandler.listenToEvent('Single File Loaded', pProductCard.onSingleFileLoaded);
+ }
+ break;
+
+ case 'File Sequence': {
+ storage.eventHandler.listenToEvent('File Sequence Loaded', pProductCard.onFileSequenceLoaded);
}
break;
}