diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo
index 9d90c6861..cf7d5572c 100644
Binary files a/.vs/AAWebPlatform/v15/.suo and b/.vs/AAWebPlatform/v15/.suo differ
diff --git a/AAWebPlatform.njsproj b/AAWebPlatform.njsproj
index 88a022a23..9d9e8ab6c 100644
--- a/AAWebPlatform.njsproj
+++ b/AAWebPlatform.njsproj
@@ -36,6 +36,9 @@
+
+ Code
+
Code
diff --git a/CompetitionStorage.js b/CompetitionStorage.js
new file mode 100644
index 000000000..280727ecc
--- /dev/null
+++ b/CompetitionStorage.js
@@ -0,0 +1,109 @@
+
+function newCompetitionStorage(pName) {
+
+ const CONSOLE_LOG = false;
+
+ /*
+
+ This object will initialize children objects that will end up loading the data of each participant on the competition.
+
+ At the same time it will raise an event for each underlaying file being loaded, so that the UI can reflect the progress to the end user.
+
+ */
+
+ let thisObject = {
+
+ files: new Map(),
+
+ eventHandler: undefined,
+ initialize: initialize
+
+ }
+
+ thisObject.eventHandler = newEventHandler();
+
+ /* We name the event Handler to easy debugging. */
+
+ thisObject.eventHandler.name = "Storage-" + pName;
+
+ return thisObject;
+
+ function initialize(pHost, pCompetition, callBackFunction) {
+
+ if (CONSOLE_LOG === true) {
+
+ console.log("Competition storage initialize for " + pHost.codeName + "-" + pCompetition.codeName);
+
+ }
+
+ let dataSetsToLoad = 0;
+ let dataSetsLoaded = 0;
+
+ for (let i = 0; i < pCompetition.participants.length; i++) {
+
+ let devTeam = ecosystem.getTeam(pCompetition.participants[i].devTeam);
+ let bot = ecosystem.getBot(devTeam, pCompetition.participants[i].bot)
+ let product = ecosystem.getProduct(bot, "Trading History");
+
+ for (let i = 0; i < product.sets.length; i++) {
+
+ let thisSet = product.sets[i];
+
+ switch (thisSet.type) {
+
+ case 'Single File': {
+
+ let file = newFile();
+ file.initialize(devTeam, bot, product, thisSet, undefined, undefined, onSingleFileReady);
+ thisObject.files.set(devTeam.codeName+ "-" + bot.codeName, file);
+ dataSetsToLoad++;
+
+ if (CONSOLE_LOG === true) {
+
+ console.log("Competition storage initialize Single File for " + devTeam.codeName + "-" + bot.codeName + "-" + product.codeName);
+
+ }
+ }
+ break;
+
+ }
+
+ function onSingleFileReady() {
+
+ if (CONSOLE_LOG === true) {
+
+ console.log("Competition storage initialize onSingleFileReady for " + devTeam.codeName + "-" + bot.codeName + "-" + product.codeName);
+
+ }
+
+ let event = {
+ totalValue: 1,
+ currentValue: 1
+ }
+
+ thisObject.eventHandler.raiseEvent('Single File Loaded', event);
+
+ if (event.currentValue === event.totalValue) {
+
+ dataSetsLoaded++;
+ checkInitializeComplete();
+ }
+ }
+
+ function checkInitializeComplete() {
+
+ if (CONSOLE_LOG === true) {
+
+ console.log("Competition storage initialize checkInitializeComplete for " + devTeam.codeName + "-" + bot.codeName + "-" + product.codeName);
+
+ }
+
+ if (dataSetsLoaded === dataSetsToLoad) {
+ callBackFunction();
+ }
+ }
+ }
+ }
+ }
+}
+
diff --git a/Ecosystem.js b/Ecosystem.js
index 91a2206ba..9da330e92 100644
--- a/Ecosystem.js
+++ b/Ecosystem.js
@@ -21,6 +21,27 @@ function newEcosystem() {
}
+ function getHost(pHostCodeName) {
+
+ for (let i = 0; i < ECOSYSTEM.hosts.length; i++) {
+
+ if (ECOSYSTEM.hosts[i].codeName === pHostCodeName) {
+
+ return ECOSYSTEM.hosts[i];
+ }
+ }
+ }
+
+ function getCompetition(pHost, pCompetitionCodeName) {
+
+ for (let i = 0; i < pHost.competitions.length; i++) {
+
+ if (pHost.competitions[i].codeName === pCompetitionCodeName) {
+
+ return pHost.competitions[i];
+ }
+ }
+ }
function getTeams() {
diff --git a/Plotters.js b/Plotters.js
index 554f17a68..a481a565a 100644
--- a/Plotters.js
+++ b/Plotters.js
@@ -1,9 +1,9 @@
-function getNewPlotter(pDevTeam, pRepo, pModule) {
+function getNewPlotter(pDevTeamOrHost, pRepo, pModule) {
let plotter;
- let fullCode = pDevTeam + pRepo + pModule;
+ let fullCode = pDevTeamOrHost + pRepo + pModule;
fullCode = fullCode.replace(/-/g, "");
switch (fullCode) {
diff --git a/ProductStorage.js b/ProductStorage.js
index 7e5266058..d5281a674 100644
--- a/ProductStorage.js
+++ b/ProductStorage.js
@@ -44,7 +44,7 @@ function newProductStorage(pName) {
if (CONSOLE_LOG === true) {
- console.log("Storage initialize for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
+ console.log("Product storage initialize for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
}
@@ -64,7 +64,7 @@ function newProductStorage(pName) {
if (CONSOLE_LOG === true) {
- console.log("Storage initialize Market Files for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
+ console.log("Product storage initialize Market Files for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
}
}
@@ -78,7 +78,7 @@ function newProductStorage(pName) {
if (CONSOLE_LOG === true) {
- console.log("Storage initialize Daily Files for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
+ console.log("Product storage initialize Daily Files for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
}
}
@@ -92,7 +92,7 @@ function newProductStorage(pName) {
if (CONSOLE_LOG === true) {
- console.log("Storage initialize Single File for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
+ console.log("Product storage initialize Single File for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
}
}
@@ -104,7 +104,7 @@ function newProductStorage(pName) {
if (CONSOLE_LOG === true) {
- console.log("Storage initialize onCacheFileReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
+ console.log("Product storage initialize onCacheFileReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
}
@@ -127,7 +127,7 @@ function newProductStorage(pName) {
if (CONSOLE_LOG === true) {
- console.log("Storage initialize onFileCursorReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
+ console.log("Product storage initialize onFileCursorReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
}
@@ -150,7 +150,7 @@ function newProductStorage(pName) {
if (CONSOLE_LOG === true) {
- console.log("Storage initialize onSingleFileReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
+ console.log("Product storage initialize onSingleFileReady for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
}
@@ -173,7 +173,7 @@ function newProductStorage(pName) {
if (CONSOLE_LOG === true) {
- console.log("Storage initialize checkInitializeComplete for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
+ console.log("Product storage initialize checkInitializeComplete for " + pDevTeam.codeName + "-" + pBot.codeName + "-" + pProduct.codeName);
}
diff --git a/TimelineChart.js b/TimelineChart.js
index 10604b9a8..fb5a305d1 100644
--- a/TimelineChart.js
+++ b/TimelineChart.js
@@ -79,7 +79,8 @@ function newTimelineChart() {
viewPort.eventHandler.listenToEvent("Zoom Changed", onZoomChanged);
canvas.eventHandler.listenToEvent("Drag Finished", onDragFinished);
- initializePlotters();
+ initializeProductPlotters();
+ initializeCompetitionPlotters();
callBackFunction();
@@ -87,7 +88,64 @@ function newTimelineChart() {
}
}
- function initializePlotters() {
+ function initializeCompetitionPlotters() {
+
+ /* At this current version of the platform, we will support only one competition with only one plotter. */
+
+ const COMPETITION_HOST = "AAArena";
+ const COMPETITION = "First-Closed-Door";
+
+ let objName = COMPETITION_HOST + "-" + COMPETITION;
+ let storage = newCompetitionStorage(objName);
+
+ let host = ecosystem.getHost(COMPETITION_HOST);
+ let competition = ecosystem.getCompetition(host, COMPETITION);
+
+ storage.initialize(host, competition, onStorageInitialized);
+
+ function onStorageInitialized() {
+
+ /* 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.repo, competition.plotter.moduleName);
+
+ plotter.container.displacement.parentDisplacement = thisObject.container.displacement;
+ plotter.container.zoom.parentZoom = thisObject.container.zoom;
+ plotter.container.frame.parentFrame = thisObject.container.frame;
+
+ plotter.container.parentContainer = thisObject.container;
+
+ plotter.container.frame.width = thisObject.container.frame.width * 1;
+ plotter.container.frame.height = thisObject.container.frame.height * 1;
+
+ plotter.container.frame.position.x = thisObject.container.frame.width / 2 - plotter.container.frame.width / 2;
+ plotter.container.frame.position.y = thisObject.container.frame.height / 2 - plotter.container.frame.height / 2;
+
+ plotter.initialize(storage, datetime, timePeriod, onPlotterInizialized);
+
+ function onPlotterInizialized() {
+
+ if (CONSOLE_LOG === true) {
+
+ console.log(competition.plotter.host, competition.plotter.repo, competition.plotter.moduleName + " Initialized. ");
+
+ }
+
+ let activePlotter = {
+ productCard: undefined,
+ plotter: plotter,
+ storage: storage
+ };
+
+ /* Add the new Active Protter to the Array */
+
+ activePlotters.push(activePlotter);
+
+ }
+ }
+ }
+
+ function initializeProductPlotters() {
/* Lets get all the cards that needs to be loaded. */
@@ -97,17 +155,12 @@ function newTimelineChart() {
/* For each one, we will initialize the associated plotter. */
- initializePlotter(loadingProductCards[i]);
+ initializeProductPlotter(loadingProductCards[i]);
}
-
- /* Finally we initialize the Competition Plotter. */
-
-
-
}
- function initializePlotter(pProductCard) {
+ function initializeProductPlotter(pProductCard) {
/* Before Initializing a Plotter, we need the Storage it will use, loaded with the files it will initially need. */
@@ -223,7 +276,7 @@ function newTimelineChart() {
if (found === false) {
- initializePlotter(pProductCard);
+ initializeProductPlotter(pProductCard);
}
diff --git a/index.html b/index.html
index 67f0c3930..b9e5f7b63 100644
--- a/index.html
+++ b/index.html
@@ -8,6 +8,7 @@
+
diff --git a/server.js b/server.js
index 32033320a..9c1dcd4e9 100644
--- a/server.js
+++ b/server.js
@@ -117,9 +117,9 @@ function initialize() {
let requestsSent = 0;
let responsesReceived = 0;
- for (let i = 0; i < ecosystemObject.competitionHosts.length; i++) {
+ for (let i = 0; i < ecosystemObject.hosts.length; i++) {
- let host = ecosystemObject.competitionHosts[i];
+ let host = ecosystemObject.hosts[i];
for (let j = 0; j < host.competitions.length; j++) {
@@ -375,16 +375,16 @@ function onBrowserRequest(request, response) {
' break;' + '\n' + '\n'
let devTeams = ecosystemObject.devTeams;
- let competitionHosts = ecosystemObject.competitionHosts;
+ let hosts = ecosystemObject.hosts;
addToFileContent(devTeams);
- addToFileContent(competitionHosts);
+ addToFileContent(hosts);
- function addToFileContent(pDevTeamsOrCompetitionHosts) {
+ function addToFileContent(pDevTeamsOrHosts) {
- for (let i = 0; i < pDevTeamsOrCompetitionHosts.length; i++) {
+ for (let i = 0; i < pDevTeamsOrHosts.length; i++) {
- let devTeam = pDevTeamsOrCompetitionHosts[i];
+ let devTeam = pDevTeamsOrHosts[i];
for (let j = 0; j < devTeam.plotters.length; j++) {
@@ -523,16 +523,16 @@ function onBrowserRequest(request, response) {
' '
let devTeams = ecosystemObject.devTeams;
- let competitionHosts = ecosystemObject.competitionHosts;
+ let hosts = ecosystemObject.hosts;
addScript(devTeams);
- addScript(competitionHosts);
+ addScript(hosts);
- function addScript(pDevTeamsOrCompetitionHosts) {
+ function addScript(pDevTeamsOrHosts) {
- for (let i = 0; i < pDevTeamsOrCompetitionHosts.length; i++) {
+ for (let i = 0; i < pDevTeamsOrHosts.length; i++) {
- let devTeam = pDevTeamsOrCompetitionHosts[i];
+ let devTeam = pDevTeamsOrHosts[i];
for (let j = 0; j < devTeam.plotters.length; j++) {