Removing Unused code

This commit is contained in:
Luis Fernando Molina committed 2019-10-07 14:59:07 +02:00
1 parent e4323deb83
commit ec33648467
2 files changed
+8 -294

No files matched your search

+8 -140
View File
@@ -85,52 +85,30 @@ function newPlottersManager () {
market = pMarket
/* Listen to the event of change of status */
productsPanel.container.eventHandler.listenToEvent('Product Card Status Changed', onProductCardStatusChanged)
initializeCompetitionPlotters(onCompetitionPlottersInitialized)
function onCompetitionPlottersInitialized (err) {
initializeProductPlotters(onProductPlottersInitialized)
function onProductPlottersInitialized (err) {
try {
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
initializationReady = true
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
break
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
default: {
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
initializeProductPlotters(onProductPlottersInitialized)
function onProductPlottersInitialized (err) {
try {
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
initializationReady = true
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
break
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
default: {
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onCompetitionPlottersInitialized -> onProductPlottersInitialized -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onCompetitionPlottersInitialized -> err = ' + err.stack) }
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onProductPlottersInitialized -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
@@ -140,116 +118,6 @@ function newPlottersManager () {
}
}
function initializeCompetitionPlotters (callBack) {
try {
/* Disabling this functionality since it is not currently available */
callBack(GLOBAL.DEFAULT_OK_RESPONSE)
return
/* At this current version of the platform, we will support only one competition with only one plotter. */
const COMPETITION_HOST = 'AAMasters'
const COMPETITION = 'Weekend-Deathmatch'
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, exchange, market, onCompetitionStorageInitialized)
function onCompetitionStorageInitialized (err) {
try {
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
break
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
callBack(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
default: {
callBack(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
/* 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.devTeam, competition.plotter.codeName, competition.plotter.moduleName)
plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true)
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
/* We add the profile picture of each participant, because the plotter will need it. */
for (let k = 0; k < competition.participants.length; k++) {
let participant = competition.participants[k]
let devTeam = ecosystem.getTeam(participant.devTeam)
let bot = ecosystem.getBot(devTeam, participant.bot)
participant.profilePicture = bot.profilePicture
}
plotter.fitFunction = thisObject.fitFunction
plotter.initialize(competition, storage, datetime, timePeriod, onPlotterInizialized)
function onPlotterInizialized (err) {
try {
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
break
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
callBack(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
default: {
callBack(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
}
let competitionPlotter = {
plotter: plotter,
storage: storage
}
/* Add the new Active Protter to the Array */
competitionPlotters.push(competitionPlotter)
/* Create The Profie Picture FloatingObject */
if (competitionPlotter.plotter.payload !== undefined) {
for (let k = 0; k < competition.participants.length; k++) {
let participant = competition.participants[k]
let devTeam = ecosystem.getTeam(participant.devTeam)
let bot = ecosystem.getBot(devTeam, participant.bot)
let imageId = participant.devTeam + '.' + participant.profilePicture
const TEAM = devTeam.codeName.toLowerCase()
const BOT = bot.codeName.toLowerCase()
/*
let botAvatar = new Image()
botAvatar.src = window.canvasApp.context.fbProfileImages.get(TEAM + '-' + BOT)
competitionPlotter.plotter.payload[k].profile.title = bot.displayName
competitionPlotter.plotter.payload[k].profile.imageId = imageId
competitionPlotter.plotter.payload[k].profile.botAvatar = botAvatar
canvas.floatingSpace.profileBalls.createNewProfileBall(competitionPlotter.plotter.payload[k], onProfileBallCreated)
function onProfileBallCreated (err, pProfileHandle) {
competitionPlotter.plotter.payload[k].profile.handle = pProfileHandle
}
*/
}
}
callBack(GLOBAL.DEFAULT_OK_RESPONSE)
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initializeCompetitionPlotters -> onCompetitionStorageInitialized -> onPlotterInizialized -> err = ' + err.stack) }
callBack(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initializeCompetitionPlotters -> onCompetitionStorageInitialized -> err = ' + err.stack) }
callBack(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initializeCompetitionPlotters -> err = ' + err.stack) }
callBack(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
function initializeProductPlotters (callBack) {
try {
/* Lets get all the cards that needs to be loaded. */
-154
View File
@@ -1,154 +0,0 @@
function newCompetitionStorage (pName) {
const MODULE_NAME = 'Competition Storage'
const INFO_LOG = false
const ERROR_LOG = true
const logger = newWebDebugLog()
logger.fileName = MODULE_NAME
let thisObject = {
competitorsSequences: [],
eventHandler: undefined,
initialize: initialize,
finalize: finalize
}
thisObject.eventHandler = newEventHandler()
/* We name the event Handler to easy debugging. */
thisObject.eventHandler.name = 'Storage-' + pName
let fileSequences = []
return thisObject
function finalize () {
try {
if (INFO_LOG === true) { logger.write('[INFO] finalize -> Entering function.') }
if (thisObject.fileSequences !== undefined) {
for (let i = 0; i < thisObject.fileSequences.length; i++) {
let fileSequence = thisObject.fileSequences[i]
fileSequence.finalize()
}
}
thisObject.fileSequences = undefined
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack) }
}
}
function initialize (pHost, pCompetition, pExchange, pMarket, callBackFunction) {
try {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> Entering function.') }
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + pHost.codeName + '-' + pCompetition.codeName) }
let dataSetsToLoad = 0
let dataSetsLoaded = 0
fileSequences = []
for (let j = 0; j < pCompetition.participants.length; j++) {
let devTeam = ecosystem.getTeam(pCompetition.participants[j].devTeam)
let bot = ecosystem.getBot(devTeam, pCompetition.participants[j].bot)
bot.cloneId = pCompetition.participants[j].clonesId
let product = ecosystem.getProduct(bot, 'Competition Trading History')
if (INFO_LOG === true) { logger.write('[INFO] initialize -> key = ' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
for (let i = 0; i < product.dataSets.length; i++) {
let thisSet = product.dataSets[i]
switch (thisSet.type) {
case 'File Sequence': {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> File Sequence -> key = ' + pHost.codeName + '-' + pCompetition.codeName + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
let fileSequence = newFileSequence()
fileSequence.initialize(devTeam, bot, product, thisSet, pExchange, pMarket, onFileSequenceReady)
fileSequences.push(fileSequence)
dataSetsToLoad++
}
break
}
function onFileSequenceReady (err, pCaller) {
try {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Entering function.') }
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> key = ' + pHost.codeName + '-' + pCompetition.codeName + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
switch (err.result) {
case GLOBAL.DEFAULT_OK_RESPONSE.result: {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received OK Response.') }
break
}
case GLOBAL.DEFAULT_FAIL_RESPONSE.result: {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received FAIL Response.') }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
return
}
case GLOBAL.CUSTOM_FAIL_RESPONSE.result: {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received CUSTOM FAIL Response.') }
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> err= ' + err.stack) }
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> This bot has not starting competing yet.') }
break
}
default: {
if (INFO_LOG === true) { logger.write('[INFO] initialize -> onFileSequenceReady -> Received Unexpected Response.') }
callBackFunction(err)
return
}
}
let event = {
totalValue: pCaller.getExpectedFiles(),
currentValue: pCaller.getFilesLoaded()
}
thisObject.eventHandler.raiseEvent('File Sequence Loaded', event)
if (event.currentValue === event.totalValue) {
dataSetsLoaded++
checkInitializeComplete()
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> onFileSequenceReady -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
function checkInitializeComplete () {
try {
if (INFO_LOG === true) { logger.write('[INFO] checkInitializeComplete -> Entering function.') }
if (INFO_LOG === true) { logger.write('[INFO] checkInitializeComplete -> key = ' + pHost.codeName + '-' + pCompetition.codeName + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName) }
if (dataSetsLoaded === dataSetsToLoad) {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> checkInitializeComplete -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
}
}
thisObject.competitorsSequences.push(fileSequences)
if (pCompetition.participants.length === 0) { // If there are no competitions, respond OK
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
}
} catch (err) {
if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) }
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
}
}
}