DebugLog Introduced in some modules
This commit is contained in:
1 parent
27c72c8586
commit
b5a6153a9b
10 files changed
+125
-3
No files matched your search
Binary file not shown.
@@ -1,4 +1,6 @@
|
||||
/*
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Whithin this sub-system, the canvas object represents a layer on top of the browser canvas object.
|
||||
|
||||
@@ -34,6 +36,11 @@ let splashScreenNeeded = true;
|
||||
|
||||
function newCanvas() {
|
||||
|
||||
const MODULE_NAME = "Canvas";
|
||||
const FULL_LOG = false;
|
||||
const logger = newDebugLog();
|
||||
logger.fileName = MODULE_NAME;
|
||||
|
||||
/* Mouse event related variables. */
|
||||
|
||||
let containerDragStarted = false;
|
||||
@@ -68,6 +75,8 @@ function newCanvas() {
|
||||
|
||||
function initialize() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
|
||||
initializeBrowserCanvas();
|
||||
|
||||
addCanvasEvents();
|
||||
@@ -111,6 +120,8 @@ function newCanvas() {
|
||||
|
||||
function initializeBrowserCanvas() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeBrowserCanvas -> Entering function."); }
|
||||
|
||||
browserCanvas = document.getElementById('canvas');
|
||||
browserCanvasContext = browserCanvas.getContext('2d');
|
||||
|
||||
@@ -125,12 +136,16 @@ function newCanvas() {
|
||||
|
||||
function clearBrowserCanvas() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] clearBrowserCanvas -> Entering function."); }
|
||||
|
||||
browserCanvasContext.clearRect(0, 0, browserCanvas.width, browserCanvas.height);
|
||||
|
||||
}
|
||||
|
||||
function addCanvasEvents() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] addCanvasEvents -> Entering function."); }
|
||||
|
||||
/* Mouse down and up events to control the drag of the canvas. */
|
||||
|
||||
browserCanvas.addEventListener('mousedown', onMouseDown, false);
|
||||
@@ -153,6 +168,8 @@ function newCanvas() {
|
||||
|
||||
function onMouseDown(event) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] onMouseDown -> Entering function."); }
|
||||
|
||||
/*
|
||||
|
||||
There are four types of elements that can be dragged.
|
||||
@@ -212,6 +229,8 @@ function newCanvas() {
|
||||
|
||||
function onMouseClick(event) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] onMouseClick -> Entering function."); }
|
||||
|
||||
let point = {
|
||||
x: event.pageX,
|
||||
y: event.pageY
|
||||
@@ -253,6 +272,8 @@ function newCanvas() {
|
||||
|
||||
function onMouseUp(event) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] onMouseUp -> Entering function."); }
|
||||
|
||||
if (containerDragStarted || viewPortBeingDragged || ballDragStarted) {
|
||||
|
||||
thisObject.eventHandler.raiseEvent("Drag Finished", undefined);
|
||||
@@ -273,6 +294,8 @@ function newCanvas() {
|
||||
|
||||
function onMouseMove(event) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] onMouseMove -> Entering function."); }
|
||||
|
||||
viewPort.mousePosition.x = event.pageX;
|
||||
viewPort.mousePosition.y = event.pageY;
|
||||
|
||||
@@ -301,6 +324,8 @@ function newCanvas() {
|
||||
|
||||
function onMouseWheel(event) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] onMouseWheel -> Entering function."); }
|
||||
|
||||
// cross-browser wheel delta
|
||||
var event = window.event || event; // old IE support
|
||||
let delta = Math.max(-1, Math.min(1, event.wheelDelta || -event.detail));
|
||||
@@ -343,6 +368,8 @@ function newCanvas() {
|
||||
|
||||
function checkDrag() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] checkDrag -> Entering function."); }
|
||||
|
||||
if (containerDragStarted === true || ballDragStarted === true || viewPortBeingDragged === true) {
|
||||
|
||||
browserCanvas.style.cursor = "grabbing";
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
|
||||
|
||||
|
||||
/* The Dashboard is the root object that contains all the other stuff in it. Some of that stuff is visible, some other is invisible. */
|
||||
|
||||
let canvas;
|
||||
let markets;
|
||||
let ecosystem = newEcosystem();
|
||||
|
||||
|
||||
let marketFilesPeriods =
|
||||
'[' +
|
||||
'[' + 24 * 60 * 60 * 1000 + ',' + '"24-hs"' + ']' + ',' +
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
|
||||
function newDebugLog() {
|
||||
|
||||
let thisObject = {
|
||||
write: write,
|
||||
fileName: undefined
|
||||
}
|
||||
|
||||
return thisObject;
|
||||
|
||||
function write(pText) {
|
||||
|
||||
console.log(thisObject.fileName + " : " + pText);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,9 @@
|
||||
<Compile Include="ImageButton.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DebugLog.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Spaces\PanelsSpace.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -8,6 +8,11 @@ changes, then all charts in it are replotted with the corresponging data.
|
||||
|
||||
function newChartSpace() {
|
||||
|
||||
const MODULE_NAME = "Chart Space";
|
||||
const FULL_LOG = true;
|
||||
const logger = newDebugLog();
|
||||
logger.fileName = MODULE_NAME;
|
||||
|
||||
var chartSpace = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
@@ -36,6 +41,7 @@ function newChartSpace() {
|
||||
|
||||
function initialize() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
|
||||
/* We create the first of many possible time machines that could live at the Chart Space. */
|
||||
|
||||
@@ -58,7 +64,6 @@ function newChartSpace() {
|
||||
|
||||
this.timeMachines.push(timeMachine);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function draw() {
|
||||
@@ -78,6 +83,8 @@ function newChartSpace() {
|
||||
|
||||
function getContainer(point) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
|
||||
|
||||
var container;
|
||||
|
||||
/* First we check if this point is inside this space. */
|
||||
|
||||
@@ -11,6 +11,11 @@ each one with it own charts, and each one positioned at an especific point in ti
|
||||
|
||||
function newTimeMachine() {
|
||||
|
||||
const MODULE_NAME = "Time Machine";
|
||||
const FULL_LOG = false;
|
||||
const logger = newDebugLog();
|
||||
logger.fileName = MODULE_NAME;
|
||||
|
||||
let thisObject = {
|
||||
container: undefined,
|
||||
draw: draw,
|
||||
@@ -34,6 +39,8 @@ function newTimeMachine() {
|
||||
|
||||
function initialize() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
|
||||
/* Each Time Machine has a Control Panel. */
|
||||
|
||||
controlPanelHandle = canvas.panelsSpace.createNewPanel("Time Control Panel");
|
||||
@@ -65,6 +72,8 @@ function newTimeMachine() {
|
||||
|
||||
function onDefaultMarketInitialized() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> onDefaultMarketInitialized -> Entering function."); }
|
||||
|
||||
thisObject.charts.push(timelineChart);
|
||||
|
||||
controlPanel.container.eventHandler.listenToEvent('Datetime Changed', timelineChart.setDatetime, undefined);
|
||||
@@ -76,10 +85,14 @@ function newTimeMachine() {
|
||||
|
||||
function initializeTheRestOfTheMarkets() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> initializeTheRestOfTheMarkets -> Entering function."); }
|
||||
|
||||
markets.forEach(initializeTimelineChart);
|
||||
|
||||
function initializeTimelineChart(item, key, mapObj) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> initializeTheRestOfTheMarkets -> initializeTimelineChart -> Entering function."); }
|
||||
|
||||
if (key === INITIAL_DEFAULT_MARKET) { // We skip this market since it has already been initialized.
|
||||
|
||||
return;
|
||||
@@ -104,6 +117,8 @@ function newTimeMachine() {
|
||||
|
||||
function finalSteps() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> initializeTheRestOfTheMarkets -> initializeTimelineChart -> finalSteps -> Entering function."); }
|
||||
|
||||
thisObject.charts.push(timelineChart);
|
||||
|
||||
controlPanel.container.eventHandler.listenToEvent('Datetime Changed', timelineChart.setDatetime, undefined);
|
||||
@@ -130,6 +145,8 @@ function newTimeMachine() {
|
||||
|
||||
function getContainer(point) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
|
||||
|
||||
let container;
|
||||
|
||||
/* First we check if this point is inside this space. */
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
function newTimelineChart() {
|
||||
|
||||
const MODULE_NAME = "Timeline Chart";
|
||||
const FULL_LOG = false;
|
||||
const logger = newDebugLog();
|
||||
logger.fileName = MODULE_NAME;
|
||||
|
||||
const CONSOLE_LOG = false;
|
||||
|
||||
let productPlotters = [];
|
||||
@@ -40,6 +45,8 @@
|
||||
|
||||
function initialize(exchange, market, pProductsPanel, callBackFunction) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); }
|
||||
|
||||
/* Remember the Products Panel */
|
||||
|
||||
productsPanel = pProductsPanel;
|
||||
@@ -75,6 +82,11 @@
|
||||
|
||||
function initializeCompetitionPlotters() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeCompetitionPlotters -> Entering function."); }
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeCompetitionPlotters -> Aborting function until Competition Plotter is ready."); }
|
||||
return;
|
||||
|
||||
/* At this current version of the platform, we will support only one competition with only one plotter. */
|
||||
|
||||
const COMPETITION_HOST = "AAArena";
|
||||
@@ -90,6 +102,8 @@
|
||||
|
||||
function onStorageInitialized() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeCompetitionPlotters -> onStorageInitialized -> Entering function."); }
|
||||
|
||||
/* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */
|
||||
|
||||
let plotter = getNewPlotter(competition.plotter.host, competition.plotter.codeName, competition.plotter.moduleName);
|
||||
@@ -109,6 +123,8 @@
|
||||
|
||||
function onPlotterInizialized() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeCompetitionPlotters -> onStorageInitialized -> onPlotterInizialized -> Entering function."); }
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
|
||||
console.log(competition.plotter.host, competition.plotter.repo, competition.plotter.moduleName + " Initialized. ");
|
||||
@@ -130,6 +146,8 @@
|
||||
|
||||
function initializeProductPlotters() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotters -> Entering function."); }
|
||||
|
||||
/* Lets get all the cards that needs to be loaded. */
|
||||
|
||||
let loadingProductCards = productsPanel.getLoadingProductCards();
|
||||
@@ -145,11 +163,15 @@
|
||||
|
||||
function initializeProductPlotter(pProductCard) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> Entering function."); }
|
||||
|
||||
/* Before Initializing a Plotter, we need the Storage it will use, loaded with the files it will initially need. */
|
||||
|
||||
let objName = pProductCard.devTeam.codeName + "-" + pProductCard.bot.codeName + "-" + pProductCard.product.codeName;
|
||||
let storage = newProductStorage(objName);
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> objName = " + objName); }
|
||||
|
||||
/*
|
||||
|
||||
Before Initializing the Storage, we will put the Product Card to listen to the events the storage will raise every time a file is loaded,
|
||||
@@ -188,6 +210,8 @@
|
||||
|
||||
function onStorageInitialized() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> Entering function."); }
|
||||
|
||||
/* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */
|
||||
|
||||
let plotter = getNewPlotter(pProductCard.product.plotter.devTeam, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName);
|
||||
@@ -207,6 +231,8 @@
|
||||
|
||||
function onPlotterInizialized() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onStorageInitialized -> onPlotterInizialized -> Entering function."); }
|
||||
|
||||
if (CONSOLE_LOG === true) {
|
||||
|
||||
console.log(pProductCard.product.plotter.devTeam + '->' + pProductCard.product.plotter.repo + '->' + pProductCard.product.plotter.moduleName + " Initialized. ");
|
||||
@@ -283,6 +309,8 @@
|
||||
|
||||
function onProductCardStatusChanged(pProductCard) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] onProductCardStatusChanged -> Entering function."); }
|
||||
|
||||
if (pProductCard.status === PRODUCT_CARD_STATUS.LOADING) {
|
||||
|
||||
/* Lets see if we can find the Plotter of this card on our Active Plotters list, other wise we will initialize it */
|
||||
@@ -338,6 +366,8 @@
|
||||
|
||||
function onZoomChanged(event) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] onZoomChanged -> Entering function."); }
|
||||
|
||||
if (initializationReady === true) {
|
||||
|
||||
level = event.newLevel; // for debugging purposes only
|
||||
@@ -376,6 +406,8 @@
|
||||
|
||||
function onDragFinished() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] onDragFinished -> Entering function."); }
|
||||
|
||||
if (initializationReady === true) {
|
||||
|
||||
if (thisObject.container.frame.isInViewPort() && tooSmall() === false) {
|
||||
@@ -388,6 +420,8 @@
|
||||
|
||||
function onOffsetChanged() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] onOffsetChanged -> Entering function."); }
|
||||
|
||||
if (initializationReady === true) {
|
||||
|
||||
if (thisObject.container.frame.isInViewPort()) {
|
||||
@@ -401,6 +435,8 @@
|
||||
|
||||
function recalculateCurrentDatetime() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] recalculateCurrentDatetime -> Entering function."); }
|
||||
|
||||
/*
|
||||
|
||||
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
|
||||
@@ -445,6 +481,8 @@
|
||||
|
||||
function getContainer(point) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] getContainer -> Entering function."); }
|
||||
|
||||
var container;
|
||||
|
||||
/* First we check if this point is inside this space. */
|
||||
@@ -464,6 +502,8 @@
|
||||
|
||||
function setDatetime(pDatetime) {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] setDatetime -> Entering function."); }
|
||||
|
||||
/* 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. */
|
||||
|
||||
@@ -528,6 +568,8 @@
|
||||
|
||||
function recalculateScale() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] recalculateScale -> Entering function."); }
|
||||
|
||||
var minValue = {
|
||||
x: EARLIEST_DATE.valueOf(),
|
||||
y: 0
|
||||
@@ -550,6 +592,8 @@
|
||||
|
||||
function tooTiny() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] tooTiny -> Entering function."); }
|
||||
|
||||
if (viewPort.zoomLevel < Math.trunc(-28.25 * 100) / 100) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -560,6 +604,8 @@
|
||||
|
||||
function tooSmall() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] tooSmall -> Entering function."); }
|
||||
|
||||
if (viewPort.zoomLevel < Math.trunc(-27.25 * 100) / 100) {
|
||||
return true;
|
||||
} else {
|
||||
@@ -643,6 +689,8 @@
|
||||
|
||||
function moveViewPortToCurrentDatetime() {
|
||||
|
||||
if (FULL_LOG === true) { logger.write("[INFO] moveViewPortToCurrentDatetime -> Entering function."); }
|
||||
|
||||
let targetPoint = {
|
||||
x: datetime.valueOf(),
|
||||
y: 0 // we wont touch the y axis here.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<meta charset="utf-8" />
|
||||
<title>Advanced Algos</title>
|
||||
|
||||
<script type="text/javascript" src="DebugLog.js"></script>
|
||||
|
||||
<!--Plotters-->
|
||||
<!--PlotterPanels-->
|
||||
@@ -54,6 +55,7 @@
|
||||
<script type="text/javascript" src="Dashboard.js"></script>
|
||||
<script type="text/javascript" src="AccumulatedVolumeBar.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" src="Azure/azure-storage.blob.js"></script>
|
||||
|
||||
<script type="text/javascript" src="Panels/TimeControlPanel.js"></script>
|
||||
|
||||
@@ -6,7 +6,7 @@ if (CONSOLE_LOG === true) {
|
||||
|
||||
}
|
||||
|
||||
const DEBUG_MODE = false; // This forces the server to read Plotters from the local drive.
|
||||
const DEBUG_MODE = true; // This forces the server to read Plotters from the local drive.
|
||||
|
||||
if (CONSOLE_LOG === true && DEBUG_MODE === true) {
|
||||
|
||||
|
||||
Reference in new issue
Block a user