Setperiod and set time now out of plotters logic
This commit is contained in:
1 parent
406771c1eb
commit
b81be0c332
7 files changed
+137
-102
No files matched your search
Binary file not shown.
+7
-1
@@ -1,6 +1,8 @@
|
||||
|
||||
function newFileCloud() {
|
||||
|
||||
const CONSOLE_LOG = true;
|
||||
|
||||
var fileCloud = {
|
||||
getFile: getFile,
|
||||
initialize: initialize
|
||||
@@ -50,7 +52,11 @@ function newFileCloud() {
|
||||
|
||||
fileService.getFileToText('data', filePath, fileName, undefined, onFileReceived);
|
||||
|
||||
//console.log("File Requested > " + filePath);
|
||||
if (CONSOLE_LOG === true) {
|
||||
|
||||
console.log("FileCloud -> File Requested -> " + filePath + "/" + fileName);
|
||||
|
||||
}
|
||||
|
||||
function onFileReceived(err, text, response) {
|
||||
|
||||
|
||||
+7
-5
@@ -36,11 +36,11 @@ function newFileCursor() {
|
||||
cursorDate = pCursorDate;
|
||||
timePeriod = pTimePeriod;
|
||||
|
||||
setTimePeriod(pCurrentTimePeriod, callBackFunction);
|
||||
setTimePeriod(pCurrentTimePeriod, pCursorDate, callBackFunction);
|
||||
|
||||
}
|
||||
|
||||
function setTimePeriod(pTimePeriod, callBackFunction) {
|
||||
function setTimePeriod(pTimePeriod, pDatetime, callBackFunction) {
|
||||
|
||||
/*
|
||||
|
||||
@@ -53,6 +53,8 @@ function newFileCursor() {
|
||||
|
||||
*/
|
||||
|
||||
cursorDate = pDatetime; // Adjust the cursor date to the one received.
|
||||
|
||||
let positionA;
|
||||
|
||||
for (let i = 0; i < dailyFilePeriods.length; i++) {
|
||||
@@ -239,11 +241,11 @@ function newFileCursor() {
|
||||
|
||||
|
||||
|
||||
function setDatetime(datetime, callBackFunction) {
|
||||
function setDatetime(pDatetime, callBackFunction) {
|
||||
|
||||
if (datetime === undefined) { return; }
|
||||
if (pDatetime === undefined) { return; }
|
||||
|
||||
cursorDate = datetime;
|
||||
cursorDate = pDatetime;
|
||||
|
||||
getFiles(callBackFunction);
|
||||
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
|
||||
function newFileCursorCache() {
|
||||
|
||||
const CONSOLE_LOG = true;
|
||||
const CONSOLE_LOG = false;
|
||||
|
||||
let fileCursorCache = {
|
||||
getFileCursor: getFileCursor,
|
||||
@@ -95,7 +95,7 @@ function newFileCursorCache() {
|
||||
}
|
||||
}
|
||||
|
||||
function setTimePeriod(pTimePeriod) {
|
||||
function setTimePeriod(pTimePeriod, pDatetime) {
|
||||
|
||||
filesLoaded = 0;
|
||||
expectedFiles = 0;
|
||||
@@ -104,7 +104,7 @@ function newFileCursorCache() {
|
||||
|
||||
function setTimePeriodToEach(fileCursor, key, map) {
|
||||
|
||||
fileCursor.setTimePeriod(pTimePeriod, onFileReceived);
|
||||
fileCursor.setTimePeriod(pTimePeriod, pDatetime, onFileReceived);
|
||||
expectedFiles = expectedFiles + fileCursor.getExpectedFiles();
|
||||
|
||||
}
|
||||
|
||||
+48
-49
@@ -1,6 +1,6 @@
|
||||
function newProductCard() {
|
||||
|
||||
const CONSOLE_LOG = true;
|
||||
const CONSOLE_LOG = false;
|
||||
|
||||
var thisObject = {
|
||||
container: undefined,
|
||||
@@ -10,11 +10,14 @@
|
||||
bot: undefined,
|
||||
product: undefined,
|
||||
code: undefined,
|
||||
|
||||
setDatetime: setDatetime,
|
||||
setTimePeriod: setTimePeriod,
|
||||
|
||||
onMarketFileLoaded: onMarketFileLoaded,
|
||||
onDailyFileLoaded: onDailyFileLoaded,
|
||||
onSingleFileLoaded: onSingleFileLoaded,
|
||||
onDayChanged: onDayChanged,
|
||||
onTimePeriodChanged: onTimePeriodChanged,
|
||||
|
||||
getContainer: getContainer, // returns the inner most container that holds the point received by parameter.
|
||||
initialize: initialize
|
||||
};
|
||||
@@ -48,6 +51,9 @@
|
||||
strokeStyle: UNLOADED_STROKE_STYLE
|
||||
};
|
||||
|
||||
let timePeriod = INITIAL_TIME_PERIOD;
|
||||
let datetime = INITIAL_DATE;
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize() {
|
||||
@@ -118,7 +124,7 @@
|
||||
|
||||
}
|
||||
|
||||
function onDayChanged() {
|
||||
function setDatetime(pDatetime) {
|
||||
|
||||
/*
|
||||
|
||||
@@ -127,17 +133,27 @@
|
||||
|
||||
*/
|
||||
|
||||
dailyFileProgressBar.animatedValue = 0;
|
||||
let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
||||
let newDate = Math.trunc(pDatetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
datetime = pDatetime;
|
||||
|
||||
console.log("ProductCard -> onDayChanged -> dailyFileProgressBar.animatedValue = " + dailyFileProgressBar.animatedValue);
|
||||
if (currentDate !== newDate) {
|
||||
|
||||
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
dailyFileProgressBar.animatedValue = 0;
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
|
||||
console.log("ProductCard -> onDayChanged -> dailyFileProgressBar.animatedValue = " + dailyFileProgressBar.animatedValue);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onTimePeriodChanged() {
|
||||
function setTimePeriod(pTimePeriod) {
|
||||
|
||||
/*
|
||||
|
||||
@@ -146,75 +162,58 @@
|
||||
|
||||
*/
|
||||
|
||||
dailyFileProgressBar.animatedValue = 0;
|
||||
if (timePeriod !== pTimePeriod) {
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
timePeriod = pTimePeriod;
|
||||
|
||||
console.log("ProductCard -> onTimePeriodChanged -> dailyFileProgressBar.animatedValue = " + dailyFileProgressBar.animatedValue);
|
||||
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
dailyFileProgressBar.animatedValue = 0;
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
|
||||
console.log("ProductCard -> onTimePeriodChanged -> dailyFileProgressBar.animatedValue = " + dailyFileProgressBar.animatedValue);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onMarketFileLoaded(event) {
|
||||
|
||||
if (event.currentValue === event.totalValue) {
|
||||
|
||||
marketFileProgressBar.value= 100;
|
||||
|
||||
} else {
|
||||
|
||||
marketFileProgressBar.value = Math.trunc(event.currentValue * 100 / event.totalValue);
|
||||
marketFileProgressBar.fillStyle = LOADING_FILL_STYLE;
|
||||
marketFileProgressBar.strokeStyle = LOADING_STROKE_STYLE;
|
||||
|
||||
}
|
||||
marketFileProgressBar.value = Math.trunc(event.currentValue * 100 / event.totalValue);
|
||||
marketFileProgressBar.fillStyle = LOADING_FILL_STYLE;
|
||||
marketFileProgressBar.strokeStyle = LOADING_STROKE_STYLE;
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
|
||||
console.log("ProductCard onMarketFileLoaded Value = " + marketFileProgressBar.value + "% for " + thisObject.code);
|
||||
console.log("ProductCard onMarketFileLoaded Value = " + marketFileProgressBar.value + "% for " + thisObject.code + ". Event = " + JSON.stringify(event));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function onDailyFileLoaded(event) {
|
||||
|
||||
if (event.currentValue === event.totalValue) {
|
||||
|
||||
dailyFileProgressBar.value = 100;
|
||||
|
||||
} else {
|
||||
|
||||
dailyFileProgressBar.value = Math.trunc(event.currentValue * 100 / event.totalValue);
|
||||
dailyFileProgressBar.fillStyle = LOADING_FILL_STYLE;
|
||||
dailyFileProgressBar.strokeStyle = LOADING_STROKE_STYLE;
|
||||
|
||||
}
|
||||
dailyFileProgressBar.value = Math.trunc(event.currentValue * 100 / event.totalValue);
|
||||
dailyFileProgressBar.fillStyle = LOADING_FILL_STYLE;
|
||||
dailyFileProgressBar.strokeStyle = LOADING_STROKE_STYLE;
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
|
||||
console.log("ProductCard onDailyFileLoaded Value = " + dailyFileProgressBar.value + "% for " + thisObject.code);
|
||||
console.log("ProductCard onDailyFileLoaded Value = " + dailyFileProgressBar.value + "% for " + thisObject.code + ". Event = " + JSON.stringify(event));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function onSingleFileLoaded(event) {
|
||||
|
||||
if (event.currentValue === event.totalValue) {
|
||||
|
||||
singleFileProgressBar.value = 100;
|
||||
|
||||
} else {
|
||||
|
||||
singleFileProgressBar.value = Math.trunc(event.currentValue * 100 / event.totalValue);
|
||||
singleFileProgressBar.fillStyle = LOADING_FILL_STYLE;
|
||||
singleFileProgressBar.strokeStyle = LOADING_STROKE_STYLE;
|
||||
|
||||
}
|
||||
singleFileProgressBar.value = Math.trunc(event.currentValue * 100 / event.totalValue);
|
||||
singleFileProgressBar.fillStyle = LOADING_FILL_STYLE;
|
||||
singleFileProgressBar.strokeStyle = LOADING_STROKE_STYLE;
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
|
||||
console.log("ProductCard onSingleFileLoaded Value = " + singleFileProgressBar.value + "% for " + thisObject.code);
|
||||
console.log("ProductCard onSingleFileLoaded Value = " + singleFileProgressBar.value + "% for " + thisObject.code + ". Event = " + JSON.stringify(event));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+46
@@ -18,6 +18,9 @@ function newStorage(pName) {
|
||||
fileCursorCache: undefined,
|
||||
file: undefined,
|
||||
|
||||
setDatetime: setDatetime,
|
||||
setTimePeriod: setTimePeriod,
|
||||
|
||||
eventHandler: undefined,
|
||||
initialize: initialize
|
||||
|
||||
@@ -29,10 +32,16 @@ function newStorage(pName) {
|
||||
|
||||
thisObject.eventHandler.name = "Storage-" + pName;
|
||||
|
||||
let datetime;
|
||||
let timePeriod;
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(pDevTeam, pBot, pProduct, pExchange, pMarket, pDatetime, pTimePeriod, callBackFunction) {
|
||||
|
||||
datetime = pDatetime;
|
||||
timePeriod = pTimePeriod;
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
|
||||
console.log("Storage initialize for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
|
||||
@@ -176,5 +185,42 @@ function newStorage(pName) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setDatetime(pDatetime) {
|
||||
|
||||
/* If there is a change in the day, then we take some actions, otherwise, we dont. */
|
||||
|
||||
let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
||||
let newDate = Math.trunc(pDatetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
||||
|
||||
datetime = pDatetime;
|
||||
|
||||
if (currentDate !== newDate) {
|
||||
|
||||
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
thisObject.fileCursorCache.setDatetime(pDatetime);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setTimePeriod(pTimePeriod) {
|
||||
|
||||
/* We are going to filter out the cases in which the timePeriod received is the same that the one we already know. */
|
||||
|
||||
if (timePeriod !== pTimePeriod) {
|
||||
|
||||
timePeriod = pTimePeriod;
|
||||
|
||||
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
if (thisObject.fileCursorCache !== undefined) {
|
||||
|
||||
thisObject.fileCursorCache.setTimePeriod(pTimePeriod, datetime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+26
-44
@@ -182,7 +182,8 @@ function newTimelineChart() {
|
||||
|
||||
let activePlotter = {
|
||||
productCard: pProductCard,
|
||||
plotter: plotter
|
||||
plotter: plotter,
|
||||
storage: storage
|
||||
};
|
||||
|
||||
/* Add the new Active Protter to the Array */
|
||||
@@ -244,33 +245,24 @@ function newTimelineChart() {
|
||||
|
||||
timePeriod = recalculatePeriod(event.newLevel);
|
||||
|
||||
/* If the period changes, we need to spread the word in cascade towards all the depending objects. */
|
||||
|
||||
if (timePeriod !== currentTimePeriod) {
|
||||
|
||||
for (var i = 0; i < activePlotters.length; i++) {
|
||||
for (let i = 0; i < activePlotters.length; i++) {
|
||||
|
||||
let activePlotter = activePlotters[i];
|
||||
|
||||
activePlotter.productCard.setTimePeriod(timePeriod);
|
||||
activePlotter.storage.setTimePeriod(timePeriod);
|
||||
activePlotter.plotter.setTimePeriod(timePeriod);
|
||||
|
||||
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
for (var i = 0; i < activePlotters.length; i++) {
|
||||
|
||||
activePlotter.productCard.onTimePeriodChanged();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
recalculateCurrentDatetime();
|
||||
|
||||
if (thisObject.container.frame.isInViewPort() && tooSmall() === false) {
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onDragFinished() {
|
||||
@@ -300,6 +292,13 @@ function newTimelineChart() {
|
||||
|
||||
function recalculateCurrentDatetime() {
|
||||
|
||||
/*
|
||||
|
||||
The view port was moved or the view port zoom level was changed and the center of the screen points to a different datetime that me
|
||||
must calculate.
|
||||
|
||||
*/
|
||||
|
||||
let center = {
|
||||
x: (viewPort.visibleArea.bottomRight.x - viewPort.visibleArea.bottomLeft.x) / 2,
|
||||
y: (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topRight.y) / 2
|
||||
@@ -311,15 +310,16 @@ function newTimelineChart() {
|
||||
let newDate = new Date(0);
|
||||
newDate.setUTCSeconds(center.x / 1000);
|
||||
|
||||
tellProductCardsWhenDayChanges(newDate);
|
||||
|
||||
datetime = newDate;
|
||||
|
||||
for (var i = 0; i < activePlotters.length; i++) {
|
||||
|
||||
let activePlotter = activePlotters[i];
|
||||
activePlotter.plotter.setDatetime(datetime);
|
||||
|
||||
activePlotter.productCard.setDatetime(datetime);
|
||||
activePlotter.storage.setDatetime(datetime);
|
||||
activePlotter.plotter.setDatetime(datetime);
|
||||
|
||||
}
|
||||
|
||||
thisObject.container.eventHandler.raiseEvent("Datetime Changed", datetime);
|
||||
@@ -345,32 +345,9 @@ function newTimelineChart() {
|
||||
|
||||
}
|
||||
|
||||
function tellProductCardsWhenDayChanges(pDatetime) {
|
||||
|
||||
/* If there is a change in the day, then we tell it to the Product Card so that it can represent the activity of the daily cursors on the UI. */
|
||||
|
||||
let currentDate = Math.trunc(datetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
||||
let newDate = Math.trunc(pDatetime.valueOf() / ONE_DAY_IN_MILISECONDS);
|
||||
|
||||
if (currentDate !== newDate) {
|
||||
|
||||
if (timePeriod <= _1_HOUR_IN_MILISECONDS) {
|
||||
|
||||
for (var i = 0; i < activePlotters.length; i++) {
|
||||
|
||||
let activePlotter = activePlotters[i];
|
||||
activePlotter.productCard.onDayChanged();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function setDatetime(pDatetime) {
|
||||
|
||||
tellProductCardsWhenDayChanges(pDatetime);
|
||||
|
||||
/* This function is used when the time is changed through the user interface, but without zooming or panning. */
|
||||
/* No matter if the day changed or not, we need to inform all visible Plotters. */
|
||||
|
||||
if (thisObject.container.frame.isInViewPort()) {
|
||||
@@ -378,8 +355,13 @@ function newTimelineChart() {
|
||||
for (var i = 0; i < activePlotters.length; i++) {
|
||||
|
||||
let activePlotter = activePlotters[i];
|
||||
|
||||
activePlotter.productCard.setDatetime(pDatetime);
|
||||
activePlotter.storage.setDatetime(pDatetime);
|
||||
activePlotter.plotter.setDatetime(pDatetime);
|
||||
|
||||
/* The time has changed, but the viewPort is still on the same place, so we request any of the plotters to reposition it. */
|
||||
|
||||
if (activePlotter.plotter.positionAtDatetime !== undefined) {
|
||||
activePlotter.plotter.positionAtDatetime(pDatetime);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user