Competition Plotter connected, ready for debug
This commit is contained in:
1 parent
100eb21689
commit
308bd0db5f
9 files changed
+219
-32
No files matched your search
Binary file not shown.
@@ -36,6 +36,9 @@
|
||||
<Compile Include="Azure\azure-storage.file.js" />
|
||||
<Compile Include="Ball.js" />
|
||||
<Compile Include="Balls.js" />
|
||||
<Compile Include="CompetitionStorage.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ProductCard.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
+2
-2
@@ -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) {
|
||||
|
||||
+8
-8
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+63
-10
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
<script type="text/javascript" src="Plotters.js"></script>
|
||||
<script type="text/javascript" src="ProductStorage.js"></script>
|
||||
<script type="text/javascript" src="CompetitionStorage.js"></script>
|
||||
<script type="text/javascript" src="ProductCard.js"></script>
|
||||
<script type="text/javascript" src="Ecosystem.js"></script>
|
||||
<script type="text/javascript" src="File.js"></script>
|
||||
|
||||
@@ -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) {
|
||||
' <script type="text/javascript" src="Plotters/@devTeam@/@repo@/@module@.js"></script>'
|
||||
|
||||
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++) {
|
||||
|
||||
|
||||
Reference in new issue
Block a user