BUG fixed, duplicated data in Notes fileSequence files.

This commit is contained in:
Luis Fernando Molina committed 2018-05-28 08:38:29 +02:00
1 parent 78c9fb4bd3
commit e1ebd9d331
4 files changed
+75 -27

No files matched your search

+2 -2
View File
@@ -19,7 +19,7 @@ function newFileSequence() {
let filesLoaded = 0;
let fileCloud;
let files = new Map;
let maxSequence = -1; // This is replaced by the content of the sequence file, which contains an index that starts on zero. In the case that the sequence file is not found the default value is -1 sin when you add 1 it gives you the amount of files in the sequence, zero.
let maxSequence = -1; // This is replaced by the content of the sequence file, which contains an index that starts on zero. In the case that the sequence file is not found the default value is -1 so when you add 1 it gives you the amount of files in the sequence, zero.
let market;
let devTeam;
let bot;
@@ -70,7 +70,7 @@ function newFileSequence() {
}
intervalHandle = setInterval(updateFiles, _1_MINUTE_IN_MILISECONDS);
//intervalHandle = setInterval(updateFiles, _1_MINUTE_IN_MILISECONDS);
if (INFO_LOG === true) { logger.write("[INFO] initialize -> intervalHandle = " + intervalHandle); }
+24 -15
View File
@@ -62,6 +62,7 @@ function newFloatingLayer() {
let dyingFloatingObjects = [];
let maxTargetRepulsionForce = 0.0005;
let currentHandle = 0;
return thisObject;
@@ -98,7 +99,9 @@ function newFloatingLayer() {
if (INFO_LOG === true) { logger.write("[INFO] addFloatingObject -> invisibleFloatingObjects.length = " + invisibleFloatingObjects.length); }
pFloatingObject.handle = Math.floor((Math.random() * 10000000) + 1);
currentHandle++;
pFloatingObject.handle = currentHandle; //Math.floor((Math.random() * 10000000) + 1);
if (INFO_LOG === true) { logger.write("[INFO] addFloatingObject -> pFloatingObject.handle = " + pFloatingObject.handle); }
if (INFO_LOG === true) { logger.write("[INFO] addFloatingObject -> pFloatingObject.type = " + pFloatingObject.type); }
@@ -155,6 +158,12 @@ function newFloatingLayer() {
}
}
if (ERROR_LOG === true) { logger.write("[ERROR] killFloatingObject -> Floating Object Not Found."); }
if (ERROR_LOG === true) { logger.write("[ERROR] killFloatingObject -> Floating Object cannot be killed."); }
if (ERROR_LOG === true) { logger.write("[ERROR] killFloatingObject -> pFloatingObjectHandle = " + pFloatingObjectHandle); }
if (callBackFunction !== undefined) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE); }
function sendToDie(pFloatingObject) {
try {
@@ -524,7 +533,7 @@ function newFloatingLayer() {
if (payload.visible === true) {
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> payload.visible = " + payload.visible); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> payload.visible = " + payload.visible); }
/* The first time that the floatingObject becomes visible, we need to do this. */
@@ -533,15 +542,15 @@ function newFloatingLayer() {
visibleFloatingObjects.push(floatingObject);
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject.handle = " + floatingObject.handle); }
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject added to visibleFloatingObjects"); }
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> visibleFloatingObjects.length = " + visibleFloatingObjects.length); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject.handle = " + floatingObject.handle); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject added to visibleFloatingObjects"); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> visibleFloatingObjects.length = " + visibleFloatingObjects.length); }
invisibleFloatingObjects.splice(i, 1); // Delete item from array.
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject.handle = " + floatingObject.handle); }
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject removed from invisibleFloatingObjects"); }
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> invisibleFloatingObjects.length = " + invisibleFloatingObjects.length); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject.handle = " + floatingObject.handle); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject removed from invisibleFloatingObjects"); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> invisibleFloatingObjects.length = " + invisibleFloatingObjects.length); }
return; // Only one at the time.
@@ -595,19 +604,19 @@ function newFloatingLayer() {
if (payload.visible === false) {
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> payload.visible = " + payload.visible); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> payload.visible = " + payload.visible); }
invisibleFloatingObjects.push(floatingObject);
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject.handle = " + floatingObject.handle); }
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject added to invisibleFloatingObjects"); }
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> invisibleFloatingObjects.length = " + invisibleFloatingObjects.length); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject.handle = " + floatingObject.handle); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject added to invisibleFloatingObjects"); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> invisibleFloatingObjects.length = " + invisibleFloatingObjects.length); }
visibleFloatingObjects.splice(i, 1); // Delete item from array.
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject.handle = " + floatingObject.handle); }
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject removed from visibleFloatingObjects"); }
if (INFO_LOG === true) { logger.write("[INFO] physicsLoop -> visibleFloatingObjects.length = " + visibleFloatingObjects.length); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject.handle = " + floatingObject.handle); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> floatingObject removed from visibleFloatingObjects"); }
if (INTENSIVE_LOG === true) { logger.write("[INFO] physicsLoop -> visibleFloatingObjects.length = " + visibleFloatingObjects.length); }
return; // Only one at the time.
+35 -3
View File
@@ -16,6 +16,7 @@ function newNoteSets() {
const MODULE_NAME = "Note Sets";
const INFO_LOG = false;
const INFO_WARN = true;
const ERROR_LOG = true;
const logger = newWebDebugLog();
logger.fileName = MODULE_NAME;
@@ -142,10 +143,21 @@ function newNoteSets() {
Each time we identify a floatingObject that is not at the raw data anymore, we request the floatinglayer to kill it.
*/
floatingLayer.killFloatingObject(floatingNote.floatingHandle);
floatingLayer.killFloatingObject(floatingNote.floatingHandle, onObjectKilled);
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Removed from Layer."); }
function onObjectKilled(err) {
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object Not Found."); }
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> Floating Object cannot be killed."); }
if (ERROR_LOG === true) { logger.write("[ERROR] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
return;
}
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> floatingNote.floatingHandle = " + floatingNote.floatingHandle); }
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Removed from Layer."); }
}
} else {
@@ -155,6 +167,10 @@ function newNoteSets() {
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> Added to newFloatingNotes."); }
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Remove old Notes -> newFloatingNotes.length = " + newFloatingNotes.length); }
/*
We set a property at each floatingObject of which is the index of the note at the raw data array, so that it can later evaluate its position or its visibility.
*/
let floatingObject = floatingLayer.getFloatingObject(floatingNote.floatingHandle);
floatingObject.payloadNoteIndex = i;
@@ -182,6 +198,13 @@ function newNoteSets() {
newFloatingNotes = []; // We will create a new array of Floating Notes as a result of this operation.
/*
We are using the date and rate as a unique key to identify each note. To prevent the cases of duplicate keys, we will check that at
least to consecutive records dont have the same key, and if they do, will ignore the second one.
*/
let lastPlotterKey = "";
for (let i = 0; i < pNewNotes.length; i++) {
found = false;
@@ -191,6 +214,15 @@ function newNoteSets() {
let floatingNote;
let floatingNoteKey;
if (lastPlotterKey === plotterNoteKey) {
if (INFO_WARN=== true) { logger.write("[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> Duplicate record detected. Discarding it."); }
if (INFO_WARN === true) { logger.write("[WARN] createNoteSet -> onNotesChanged -> Add new Notes -> i = " + i); }
continue;
}
lastPlotterKey = plotterNoteKey;
if (INFO_LOG === true) { logger.write("[INFO] createNoteSet -> onNotesChanged -> Add new Notes -> i = " + i); }
for (let j = 0; j < noteSet.floatingNotes.length; j++) {
+14 -7
View File
@@ -948,15 +948,22 @@ function respondWithFile(fileName, response) {
function returnEmptyArray() {
if (CONSOLE_LOG === true) { console.log("[INFO] server -> respondWithFile -> returnEmptyArray -> Entering function."); }
try {
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setHeader("Expires", "0"); // Proxies.
if (CONSOLE_LOG === true) { console.log("[INFO] server -> respondWithFile -> returnEmptyArray -> Entering function."); }
response.writeHead(200, { 'Content-Type': 'text/html' });
response.write("[]");
response.end("\n");
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0.
response.setHeader("Expires", "0"); // Proxies.
response.writeHead(200, { 'Content-Type': 'text/html' });
response.write("[]");
response.end("\n");
} catch (err) {
console.log("[ERROR] server -> returnEmptyArray -> err.message " + err.message);
}
}