From 7a0a6f6c04f3ac3c6fa725ae45c3b520fd966529 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 8 May 2018 20:56:32 +0200 Subject: [PATCH] Error Handling Improved Widelly --- .vs/AAWeb/v15/.suo | Bin 74240 -> 67072 bytes Animation.js | 12 +- Canvas.js | 2 +- CompetitionStorage.js | 6 +- Files/DailyFiles.js | 4 +- Files/FileCloud.js | 4 +- Files/FileCursor.js | 20 +- Files/FileSequence.js | 6 +- Files/MarketFiles.js | 4 +- Files/SingleFile.js | 4 +- FloatingSpace/NoteSets.js | 2 +- FloatingSpace/ProfileBalls.js | 2 +- ProductStorage.js | 12 +- TimelineChart.js | 518 +++++++++++++++++++++------------- 14 files changed, 358 insertions(+), 238 deletions(-) diff --git a/.vs/AAWeb/v15/.suo b/.vs/AAWeb/v15/.suo index fd4f208fd31b74b78dd45d4ae108f68ce3d4366c..3e1ee56c0a3dabd939efe52b66d96beae1d34258 100644 GIT binary patch delta 3270 zcmd6p4Nz3q702Jbyj^#3g$MGXvcmFF0|a!5AD|LkU`1k}fDojp1dU3>mJqXKl#uWd zX{X9idB;d?(WXyArzX|HO9eA6Zj_m(nnp});?$IpXi3t^hgzawl-IfrOPG_2# z+?n6rbI-l+-uwRN-21k!PpoSa_aq1U3xeQlxhO4eTiF@LCC{^a*~2*k_HP=LBI2atE$Woes8@V(oXZH5IWU(TE92LV}UG z$bCp0g3D@U8rrjwdk~s15Q#(#NIbFtxq~Cau?|A$p?k5Ok0c;QBm@aXdo%ji4EF2NSsglMo&{NYi;u8ydlCtrhrJ}Yev;tn zix<{<#MYL=A3csGSv+s)=U&hwJ&l_vJ+(d3+i`3*GEsW!pDaE3sG#(<+G|q$JlazS zX-_p3)L!`Rg!ThyuS33vc%;uoo1~}l9_h)REIs*1`V9z4?{ay$T$Yx+>9zFAvF;fX z-8GHQnPAUDTSQ2jEUd$jRY*Sa5JKaN+%?%0$h8yN6v*}Nb}80c46%M#5L)sB;d!Hh zJ%)Q>m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Animation() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -56,7 +56,7 @@ function newAnimation() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] start -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -71,7 +71,7 @@ function newAnimation() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] stop -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -86,7 +86,7 @@ function newAnimation() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] addCallBackFunction -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -101,7 +101,7 @@ function newAnimation() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] removeCallBackFunction -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -132,7 +132,7 @@ function newAnimation() { // if (ERROR_LOG === true) { logger.write("[ERROR] animationLoop -> err = " + err); } // if (callBackFunction !== undefined) { // When the loop is called by the browser there will be no callBackFunction. - // callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + // callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); // } // } } diff --git a/Canvas.js b/Canvas.js index 4127882cc..33232af19 100644 --- a/Canvas.js +++ b/Canvas.js @@ -122,7 +122,7 @@ function newCanvas() { function onFunctionAdded(err) { - if (err.result === GLOBAL.CUSTOM_FAIL_RESPONSE.result) { + if (err.result === GLOBAL.DEFAULT_FAIL_RESPONSE.result) { animation.stop(); diff --git a/CompetitionStorage.js b/CompetitionStorage.js index 14e476777..4ccc18017 100644 --- a/CompetitionStorage.js +++ b/CompetitionStorage.js @@ -117,7 +117,7 @@ function newCompetitionStorage(pName) { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileSequenceReady -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -137,7 +137,7 @@ function newCompetitionStorage(pName) { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> checkInitializeComplete -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } @@ -148,7 +148,7 @@ function newCompetitionStorage(pName) { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/Files/DailyFiles.js b/Files/DailyFiles.js index fc876255c..ac67a86f0 100644 --- a/Files/DailyFiles.js +++ b/Files/DailyFiles.js @@ -70,7 +70,7 @@ function newDailyFiles() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -117,7 +117,7 @@ function newDailyFiles() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] onFileReceived -> err = " + err); } - callBackWhenFileReceived(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackWhenFileReceived(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/Files/FileCloud.js b/Files/FileCloud.js index 1c48618b2..419f2c374 100644 --- a/Files/FileCloud.js +++ b/Files/FileCloud.js @@ -157,14 +157,14 @@ function newFileCloud() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> onFileReceived -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] getFile -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } \ No newline at end of file diff --git a/Files/FileCursor.js b/Files/FileCursor.js index ca6e8a669..3eef33dab 100644 --- a/Files/FileCursor.js +++ b/Files/FileCursor.js @@ -56,7 +56,7 @@ function newFileCursor() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -194,7 +194,7 @@ function newFileCursor() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] setTimePeriod -> enterSavingMode -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -278,14 +278,14 @@ function newFileCursor() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] setTimePeriod -> exitSavingMode -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] setTimePeriod -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -308,7 +308,7 @@ function newFileCursor() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] setDatetime -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -371,7 +371,7 @@ function newFileCursor() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] getFiles -> getNextFile -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -419,7 +419,7 @@ function newFileCursor() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] getFiles -> onFileReceived -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -446,14 +446,14 @@ function newFileCursor() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] getFiles -> controlLoop -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] getFiles -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -482,7 +482,7 @@ function newFileCursor() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] collectGarbage -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/Files/FileSequence.js b/Files/FileSequence.js index cc7c8aa99..a6e4013cc 100644 --- a/Files/FileSequence.js +++ b/Files/FileSequence.js @@ -145,7 +145,7 @@ function newFileSequence() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onSequenceFileReceived -> onFileReceived -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } @@ -153,14 +153,14 @@ function newFileSequence() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onSequenceFileReceived -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/Files/MarketFiles.js b/Files/MarketFiles.js index 6dbdd60b6..ee9fe0035 100644 --- a/Files/MarketFiles.js +++ b/Files/MarketFiles.js @@ -97,7 +97,7 @@ function newMarketFiles() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileReceived -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } @@ -107,7 +107,7 @@ function newMarketFiles() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/Files/SingleFile.js b/Files/SingleFile.js index 352ab2c03..710346470 100644 --- a/Files/SingleFile.js +++ b/Files/SingleFile.js @@ -83,14 +83,14 @@ function newSingleFile() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileReceived -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/FloatingSpace/NoteSets.js b/FloatingSpace/NoteSets.js index 604c4acd6..75c051611 100644 --- a/FloatingSpace/NoteSets.js +++ b/FloatingSpace/NoteSets.js @@ -31,7 +31,7 @@ function newNoteSets() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/FloatingSpace/ProfileBalls.js b/FloatingSpace/ProfileBalls.js index 9682a4030..47c2e8761 100644 --- a/FloatingSpace/ProfileBalls.js +++ b/FloatingSpace/ProfileBalls.js @@ -38,7 +38,7 @@ function newProfileBalls() { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/ProductStorage.js b/ProductStorage.js index 808f0995f..97fb04876 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -170,7 +170,7 @@ function newProductStorage(pName) { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onCacheFileReady -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -229,7 +229,7 @@ function newProductStorage(pName) { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileCursorReady -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -288,7 +288,7 @@ function newProductStorage(pName) { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onSingleFileReady -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -347,7 +347,7 @@ function newProductStorage(pName) { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onFileSequenceReady -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -367,7 +367,7 @@ function newProductStorage(pName) { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> checkInitializeComplete -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } @@ -375,7 +375,7 @@ function newProductStorage(pName) { } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } diff --git a/TimelineChart.js b/TimelineChart.js index 520ad905d..767bb192c 100644 --- a/TimelineChart.js +++ b/TimelineChart.js @@ -1,7 +1,7 @@ function newTimelineChart() { const MODULE_NAME = "Timeline Chart"; - const INFO_LOG = false; + const INFO_LOG = true; const INTENSIVE_LOG = false; const ERROR_LOG = true; const logger = newDebugLog(); @@ -77,41 +77,83 @@ function onCompetitionPlottersInitialized(err) { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> Entering function."); } + try { - switch (err.result) { - case GLOBAL.DEFAULT_OK_RESPONSE.result: { + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> Entering function."); } - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> Received OK Response."); } - break; + switch (err.result) { + case GLOBAL.DEFAULT_OK_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> Received OK Response."); } + break; + } + + case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> Received FAIL Response."); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; + } + + default: { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> Received Unexpected Response."); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; + } } - case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + initializeProductPlotters(onProductPlottersInitialized); - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> Received FAIL Response."); } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); - return; + function onProductPlottersInitialized(err) { + + try { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> onProductPlottersInitialized -> Entering function."); } + + switch (err.result) { + case GLOBAL.DEFAULT_OK_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> onProductPlottersInitialized -> Received OK Response."); } + + initializationReady = true; + callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE); + break; + } + + case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> onProductPlottersInitialized -> Received FAIL Response."); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; + } + + default: { + + if (INFO_LOG === true) { logger.write("[INFO] initialize -> onCompetitionPlottersInitialized -> onProductPlottersInitialized -> Received Unexpected Response."); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; + } + } + + } catch (err) { + + if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onCompetitionPlottersInitialized -> onProductPlottersInitialized -> err = " + err); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); + } } - default: { + } catch (err) { - if (INFO_LOG === true) { logger.write("[INFO] initialize -> onFileCursorReady -> Received Unexpected Response."); } - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); - return; - } + if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> onCompetitionPlottersInitialized -> err = " + err); } + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } - - initializeProductPlotters(); - - initializationReady = true; - - callBackFunction(GLOBAL.CUSTOM_OK_RESPONSE); } } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initialize -> err = " + err); } - callBackFunction(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -256,227 +298,299 @@ } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initializeCompetitionPlotters -> onCompetitionStorageInitialized -> onPlotterInizialized -> err = " + err); } - callBack(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBack(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initializeCompetitionPlotters -> onCompetitionStorageInitialized -> err = " + err); } - callBack(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBack(GLOBAL.DEFAULT_FAIL_RESPONSE); } } } catch (err) { if (ERROR_LOG === true) { logger.write("[ERROR] initializeCompetitionPlotters -> err = " + err); } - callBack(GLOBAL.CUSTOM_FAIL_RESPONSE); + callBack(GLOBAL.DEFAULT_FAIL_RESPONSE); } } - function initializeProductPlotters() { + function initializeProductPlotters(callBack) { - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> Entering function."); } + try { - /* Lets get all the cards that needs to be loaded. */ + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> Entering function."); } - let loadingProductCards = productsPanel.getLoadingProductCards(); + /* Lets get all the cards that needs to be loaded. */ - for (let i = 0; i < loadingProductCards.length; i++) { + let initializationCounter = 0; + let loadingProductCards = productsPanel.getLoadingProductCards(); + let okCounter = 0; + let failCounter = 0; - /* For each one, we will initialize the associated plotter. */ + for (let i = 0; i < loadingProductCards.length; i++) { - initializeProductPlotter(loadingProductCards[i]); + /* For each one, we will initialize the associated plotter. */ + initializeProductPlotter(loadingProductCards[i], onProductPlotterInitialized); + + function onProductPlotterInitialized(err) { + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> Entering function."); } + + initializationCounter++; + + switch (err.result) { + case GLOBAL.DEFAULT_OK_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> Received OK Response."); } + okCounter++; + break; + } + + case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> Received FAIL Response."); } + failCounter++; + return; + } + + default: { + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> onProductPlotterInitialized -> Received Unexpected Response."); } + failCounter++; + return; + } + } + + if (initializationCounter === loadingProductCards.length) { // This was the last one. + + /* If less than 50% of plotters are initialized then we return FAIL. */ + + if (okCounter >= 1) { + callBack(GLOBAL.DEFAULT_OK_RESPONSE); + } else { + callBack(GLOBAL.DEFAULT_FAIL_RESPONSE); + } + } + } + } + + } catch (err) { + + if (ERROR_LOG === true) { logger.write("[ERROR] initializeProductPlotters -> err = " + err); } + callBack(GLOBAL.DEFAULT_FAIL_RESPONSE); } } - function initializeProductPlotter(pProductCard) { + function initializeProductPlotter(pProductCard, callBack) { - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> Entering function."); } + try { - /* Before Initializing a Plotter, we need the Storage it will use, loaded with the files it will initially need. */ + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> Entering function."); } - let objName = pProductCard.devTeam.codeName + "-" + pProductCard.bot.codeName + "-" + pProductCard.product.codeName; - let storage = newProductStorage(objName); + /* Before Initializing a Plotter, we need the Storage it will use, loaded with the files it will initially need. */ - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> objName = " + objName); } + let objName = pProductCard.devTeam.codeName + "-" + pProductCard.bot.codeName + "-" + pProductCard.product.codeName; + let storage = newProductStorage(objName); - /* + if (INFO_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, - so that the UI can somehow show this. There are different types of events. + /* + + 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, + so that the UI can somehow show this. There are different types of events. + + */ - */ + for (let i = 0; i < pProductCard.product.dataSets.length; i++) { - for (let i = 0; i < pProductCard.product.dataSets.length; i++) { + let thisSet = pProductCard.product.dataSets[i]; - let thisSet = pProductCard.product.dataSets[i]; + switch (thisSet.type) { + case 'Market Files': { + storage.eventHandler.listenToEvent('Market File Loaded', pProductCard.onMarketFileLoaded); + } + break; - switch (thisSet.type) { - case 'Market Files': { - storage.eventHandler.listenToEvent('Market File Loaded', pProductCard.onMarketFileLoaded); - } - break; + case 'Daily Files': { + storage.eventHandler.listenToEvent('Daily File Loaded', pProductCard.onDailyFileLoaded); + } + break; - case 'Daily Files': { - storage.eventHandler.listenToEvent('Daily File Loaded', pProductCard.onDailyFileLoaded); - } - break; + case 'Single File': { + storage.eventHandler.listenToEvent('Single File Loaded', pProductCard.onSingleFileLoaded); + } + break; - case 'Single File': { - storage.eventHandler.listenToEvent('Single File Loaded', pProductCard.onSingleFileLoaded); - } - break; - - case 'File Sequence': { - storage.eventHandler.listenToEvent('File Sequence Loaded', pProductCard.onFileSequenceLoaded); - } - break; - } - } - - storage.initialize(pProductCard.devTeam, pProductCard.bot, pProductCard.product, DEFAULT_EXCHANGE, DEFAULT_MARKET, datetime, timePeriod, onProductStorageInitialized) ; - - function onProductStorageInitialized(err) { - - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> Entering function."); } - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> key = " + pProductCard.devTeam.codeName + "-" + pProductCard.bot.codeName + "-" + pProductCard.product.codeName); } - - switch (err.result) { - case GLOBAL.DEFAULT_OK_RESPONSE.result: { - - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> Received OK Response."); } - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> The plotter will be started."); } - break; - } - - case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { - - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> Received FAIL Response."); } - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> The plotter will not be started."); } - return; - } - - case GLOBAL.CUSTOM_FAIL_RESPONSE.result: { - - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> Received CUSTOM FAIL Response."); } - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> err.message = " + err.message); } - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> The plotter will not be started."); } - return; - } - - default: { - - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> Received Unexpected Response."); } - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> The plotter will not be started."); } - return; + case 'File Sequence': { + storage.eventHandler.listenToEvent('File Sequence Loaded', pProductCard.onFileSequenceLoaded); + } + break; } } - /* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */ + storage.initialize(pProductCard.devTeam, pProductCard.bot, pProductCard.product, DEFAULT_EXCHANGE, DEFAULT_MARKET, datetime, timePeriod, onProductStorageInitialized); - let plotter = getNewPlotter(pProductCard.product.plotter.devTeam, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName); - - plotter.container.displacement.parentDisplacement = thisObject.container.displacement; - 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, DEFAULT_EXCHANGE, DEFAULT_MARKET, datetime, timePeriod, onPlotterInizialized); - - function onPlotterInizialized() { - - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> onPlotterInizialized -> Entering function."); } - if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> onPlotterInizialized -> key = " + pProductCard.product.plotter.devTeam + "-" + pProductCard.product.plotter.repo + "-" + pProductCard.product.plotter.moduleName); } + function onProductStorageInitialized(err) { try { - plotter.positionAtDatetime(INITIAL_DATE); + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> Entering function."); } + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> key = " + pProductCard.devTeam.codeName + "-" + pProductCard.bot.codeName + "-" + pProductCard.product.codeName); } + + switch (err.result) { + case GLOBAL.DEFAULT_OK_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> Received OK Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> The plotter will be started."); } + break; + } + + case GLOBAL.DEFAULT_FAIL_RESPONSE.result: { + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> Received FAIL Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> The plotter will not be started."); } + callBack(GLOBAL.DEFAULT_FAIL_RESPONSE); + return; + } + + default: { + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> Received Unexpected Response."); } + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> The plotter will not be started."); } + 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(pProductCard.product.plotter.devTeam, pProductCard.product.plotter.codeName, pProductCard.product.plotter.moduleName); + + plotter.container.displacement.parentDisplacement = thisObject.container.displacement; + 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, DEFAULT_EXCHANGE, DEFAULT_MARKET, datetime, timePeriod, onPlotterInizialized); + + function onPlotterInizialized() { + + try { + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> onPlotterInizialized -> Entering function."); } + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotter -> onProductStorageInitialized -> onPlotterInizialized -> key = " + pProductCard.product.plotter.devTeam + "-" + pProductCard.product.plotter.codeName + "-" + pProductCard.product.plotter.moduleName); } + + try { + plotter.positionAtDatetime(INITIAL_DATE); + } catch (err) { + // If the plotter does not implement this function its ok. + } + + let productPlotter = { + productCard: pProductCard, + plotter: plotter, + storage: storage, + profile: undefined, + notes: undefined + }; + + /* Let the Plotter listen to the event of Cursor Files loaded, so that it can reack recalculating if needed. */ + + storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded); + + /* Lets load now this plotter panels. */ + + productPlotter.panels = []; + + for (let i = 0; i < pProductCard.product.plotter.module.panels.length; i++) { + + let panelConfig = pProductCard.product.plotter.module.panels[i]; + + let parameters = { + devTeam: pProductCard.product.plotter.devTeam, + plotterCodeName: pProductCard.product.plotter.codeName, + moduleCodeName: pProductCard.product.plotter.moduleName, + panelCodeName: panelConfig.codeName + } + + let plotterPanelHandle = canvas.panelsSpace.createNewPanel("Plotter Panel", parameters); + let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle); + + /* Connect Panel to the Plotter via an Event. */ + + if (panelConfig.event !== undefined) { + + productPlotter.plotter.container.eventHandler.listenToEvent(panelConfig.event, plotterPanel.onEventRaised); + + } + + productPlotter.panels.push(plotterPanelHandle); + } + + /* Create The Profie Picture FloatingObject */ + + if (productPlotter.plotter.payload !== undefined) { + + let imageId = pProductCard.bot.devTeam + "." + pProductCard.bot.profilePicture; + + productPlotter.plotter.payload.profile.upLabel = pProductCard.product.shortDisplayName; + productPlotter.plotter.payload.profile.downLabel = pProductCard.bot.displayName; + productPlotter.plotter.payload.profile.imageId = imageId; + + canvas.floatingSpace.profileBalls.createNewProfileBall(productPlotter.plotter.payload, onProfileBallCreated) + + function onProfileBallCreated(err, pProfileHandle) { + + productPlotter.profile = pProfileHandle; + + /* There is no policy yet of what to do if this fails. */ + } + + /* Create the Text Notes */ + + canvas.floatingSpace.noteSets.createNoteSet(productPlotter.plotter.payload, productPlotter.plotter.container.eventHandler, onNoteSetCreated); + + function onNoteSetCreated(err, pNoteSetHandle) { + + productPlotter.noteSet = pNoteSetHandle; + + /* There is no policy yet of what to do if this fails. */ + } + } + + /* Add the new Active Protter to the Array */ + + productPlotters.push(productPlotter); + + callBack(GLOBAL.DEFAULT_OK_RESPONSE); + + } catch (err) { + + if (ERROR_LOG === true) { logger.write("[ERROR] initializeProductPlotter -> onProductStorageInitialized -> onPlotterInizialized -> err = " + err); } + callBack(GLOBAL.DEFAULT_FAIL_RESPONSE); + } + } + } catch (err) { - // If the plotter does not implement this function its ok. + + if (ERROR_LOG === true) { logger.write("[ERROR] initializeProductPlotter -> onProductStorageInitialized -> err = " + err); } + callBack(GLOBAL.DEFAULT_FAIL_RESPONSE); } - - let productPlotter = { - productCard: pProductCard, - plotter: plotter, - storage: storage, - profile: undefined, - notes: undefined - }; - - /* Let the Plotter listen to the event of Cursor Files loaded, so that it can reack recalculating if needed. */ - - storage.eventHandler.listenToEvent('Daily File Loaded', plotter.onDailyFileLoaded); - - /* Lets load now this plotter panels. */ - - productPlotter.panels = []; - - for (let i = 0; i < pProductCard.product.plotter.module.panels.length; i++) { - - let panelConfig = pProductCard.product.plotter.module.panels[i]; - - let parameters = { - devTeam: pProductCard.product.plotter.devTeam, - plotterCodeName: pProductCard.product.plotter.codeName, - moduleCodeName: pProductCard.product.plotter.moduleName, - panelCodeName: panelConfig.codeName - } - - let plotterPanelHandle = canvas.panelsSpace.createNewPanel("Plotter Panel", parameters); - let plotterPanel = canvas.panelsSpace.getPanel(plotterPanelHandle); - - /* Connect Panel to the Plotter via an Event. */ - - if (panelConfig.event !== undefined) { - - productPlotter.plotter.container.eventHandler.listenToEvent(panelConfig.event, plotterPanel.onEventRaised); - - } - - productPlotter.panels.push(plotterPanelHandle); - } - - /* Create The Profie Picture FloatingObject */ - - if (productPlotter.plotter.payload !== undefined) { - - let imageId = pProductCard.bot.devTeam + "." + pProductCard.bot.profilePicture; - - productPlotter.plotter.payload.profile.upLabel = pProductCard.product.shortDisplayName; - productPlotter.plotter.payload.profile.downLabel = pProductCard.bot.displayName; - productPlotter.plotter.payload.profile.imageId = imageId; - - canvas.floatingSpace.profileBalls.createNewProfileBall(productPlotter.plotter.payload, onProfileBallCreated) - - function onProfileBallCreated(err, pProfileHandle) { - - productPlotter.profile = pProfileHandle; - - } - - /* Create the Text Notes */ - - canvas.floatingSpace.noteSets.createNoteSet(productPlotter.plotter.payload, productPlotter.plotter.container.eventHandler, onNoteSetCreated); - - function onNoteSetCreated(err, pNoteSetHandle) { - - productPlotter.noteSet = pNoteSetHandle; - - } - } - - /* Add the new Active Protter to the Array */ - - productPlotters.push(productPlotter); - } + + } catch (err) { + + if (ERROR_LOG === true) { logger.write("[ERROR] initializeProductPlotter -> err = " + err); } + callBack(GLOBAL.DEFAULT_FAIL_RESPONSE); } } @@ -502,10 +616,16 @@ if (found === false) { - initializeProductPlotter(pProductCard); + initializeProductPlotter(pProductCard, onProductPlotterInitialized); + function onProductPlotterInitialized(err) { + + if (INFO_LOG === true) { logger.write("[INFO] initializeProductPlotters -> onProductPlotterInitialized -> Entering function."); } + + /* There is no policy yet of what to do if this fails. */ + + } } - } if (pProductCard.status === PRODUCT_CARD_STATUS.OFF) {