File Sequence dataSets code implemented
This commit is contained in:
1 parent
fff81122c4
commit
879f76f3ab
10 files changed
+218
-10
No files matched your search
Binary file not shown.
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
|
||||
+2
-4
@@ -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) {
|
||||
|
||||
|
||||
+6
-1
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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 {
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
+26
-2
@@ -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) {
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
<Compile Include="CompetitionStorage.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FileSequence.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ImageButton.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
+6
-1
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user