Files Moved
This commit is contained in:
1 parent
5221d68b42
commit
4cc74c1cbc
7 files changed
+11
No files matched your search
@@ -1,136 +0,0 @@
|
||||
exports.newSuperalgosProcessModulesDataDependencies = function (processIndex, DATA_SET) {
|
||||
|
||||
const MODULE_NAME = "Data Dependencies";
|
||||
|
||||
let thisObject = {
|
||||
nodeArray: undefined,
|
||||
dataSetsModulesArray: [],
|
||||
isItADepenency: isItADepenency,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
};
|
||||
|
||||
let filter = new Map()
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(callBackFunction) {
|
||||
try {
|
||||
/* Basic Valdidations */
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies !== undefined) {
|
||||
thisObject.nodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies, 'Data Dependency')
|
||||
if (thisObject.nodeArray.length === 0) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have data dependencies at all.");
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE)
|
||||
return
|
||||
}
|
||||
/*
|
||||
We will filter ourt declared dependencies that are not present in the workspace.
|
||||
This will allow the user to have less Data Mines loaded at the workspace
|
||||
that the ones that a Trading Mine depends on.
|
||||
*/
|
||||
thisObject.nodeArray = TS.projects.superalgos.utilities.nodeFunctions.filterOutNodeWihtoutReferenceParentFromNodeArray(thisObject.nodeArray)
|
||||
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible not to have process dependencies, which means not data dependencies.");
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
if (thisObject.nodeArray.length === 0) {
|
||||
|
||||
// We allow old indicators not to declare their data dependencies.
|
||||
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Session based dependency filters */
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER !== undefined) {
|
||||
for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER.length; i++) {
|
||||
let key = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER[i]
|
||||
filter.set(key, true)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
For each dependency declared at the nodeArray, we will initialize a DataSet as part of this initialization process.
|
||||
*/
|
||||
let alreadyCalledBack = false
|
||||
let addCount = 0
|
||||
let skipCount = 0
|
||||
|
||||
/*
|
||||
The current nodeArray that we have includes all the dependencies daclared in the Data Mine | Trading Mine | Learning Mine
|
||||
process dependencies, minus the ones without reference parent, meaning that references Data Mines that are
|
||||
not present at the workspace. From all the remaining dependencies there will be others that we need to
|
||||
filter out, and they are the ones which the user does not have a data product anywhere on the network where
|
||||
this task is running, that is storing the data associated to this dependency. The way we use to filter this
|
||||
out is by analizyng the response of the initialization call to the DataSet module. If it did not fail but
|
||||
it was not initialized, then we will assume this happened because the data could not be located and we will
|
||||
assume the user did this on purpose and we will filter out this dependency by not putting it on this new array.
|
||||
*/
|
||||
let newNodeArray = []
|
||||
|
||||
for (let i = 0; i < thisObject.nodeArray.length; i++) {
|
||||
let dataSetModule = DATA_SET.newSuperalgosProcessModulesDataset(processIndex);
|
||||
dataSetModule.initialize(thisObject.nodeArray[i], onInitilized);
|
||||
|
||||
function onInitilized(err, wasInitialized) {
|
||||
|
||||
if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + JSON.stringify(err));
|
||||
|
||||
alreadyCalledBack = true;
|
||||
callBackFunction(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wasInitialized === true) {
|
||||
addCount++;
|
||||
newNodeArray.push(thisObject.nodeArray[i])
|
||||
addDataSet()
|
||||
} else {
|
||||
skipCount++
|
||||
}
|
||||
checkIfWeAreDone()
|
||||
}
|
||||
|
||||
function addDataSet() {
|
||||
thisObject.dataSetsModulesArray.push(dataSetModule);
|
||||
}
|
||||
|
||||
function checkIfWeAreDone() {
|
||||
if (addCount + skipCount === thisObject.nodeArray.length) {
|
||||
if (alreadyCalledBack === false) {
|
||||
alreadyCalledBack = true
|
||||
thisObject.nodeArray = newNodeArray
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
for (let i = 0; i < thisObject.dataSetsModulesArray.length; i++) {
|
||||
let dataSetModule = thisObject.dataSetsModulesArray[i]
|
||||
dataSetModule.finalize()
|
||||
}
|
||||
thisObject.dataSetsModulesArray = undefined
|
||||
filter = undefined
|
||||
bot = undefined
|
||||
}
|
||||
|
||||
function isItADepenency(timeFrame, product) {
|
||||
let key = timeFrame + '-' + product
|
||||
|
||||
return filter.get(key)
|
||||
}
|
||||
};
|
||||
@@ -1,169 +0,0 @@
|
||||
exports.newSuperalgosProcessModulesDataset = function (processIndex) {
|
||||
|
||||
const MODULE_NAME = "Dataset";
|
||||
|
||||
let thisObject = {
|
||||
node: undefined,
|
||||
networkNode: undefined,
|
||||
initialize: initialize,
|
||||
finalize: finalize,
|
||||
getTextFile: getTextFile,
|
||||
createTextFile: createTextFile
|
||||
};
|
||||
|
||||
/* Storage account to be used here. */
|
||||
|
||||
const FILE_STORAGE = require('./FileStorage.js');
|
||||
let fileStorage
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(dataDependency, callBackFunction) {
|
||||
|
||||
try {
|
||||
thisObject.node = dataDependency.referenceParent;
|
||||
|
||||
|
||||
/* Some very basic validations that we have all the information needed. */
|
||||
if (thisObject.node === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Data Dependency without Reference Parent -> dataDependency = " + JSON.stringify(dataDependency));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
|
||||
if (thisObject.node.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Dataset witn no codeName defined -> Product Dataset = " + JSON.stringify(thisObject.node));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
|
||||
if (thisObject.node.parentNode === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Dataset not attached to a Product Definition -> Dataset = " + JSON.stringify(thisObject.node));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
|
||||
if (thisObject.node.parentNode.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Product Definition witn no codeName defined -> Product Definition = " + JSON.stringify(thisObject.node.parentNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
|
||||
if (thisObject.node.parentNode.parentNode === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Product Definition not attached to a Bot -> Product Definition = " + JSON.stringify(thisObject.node.parentNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
|
||||
if (thisObject.node.parentNode.parentNode.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Bot witn no codeName defined. Bot = " + JSON.stringify(thisObject.node.parentNode.parentNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
|
||||
if (thisObject.node.parentNode.parentNode.parentNode === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Bot not attached to a Data Mine or Trading Mine. Bot = " + JSON.stringify(thisObject.node.parentNode.parentNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
|
||||
if (thisObject.node.parentNode.parentNode.parentNode.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Data Mine witn no codeName defined. Data Mine = " + JSON.stringify(thisObject.node.parentNode.parentNode.parentNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
|
||||
/* Now we will see where do we need to fetch this data from. */
|
||||
let network = TS.projects.superalgos.globals.taskConstants.NETWORK_NODE
|
||||
let datasetProductDefinition = thisObject.node.parentNode
|
||||
|
||||
let nodeArray = TS.projects.superalgos.utilities.nodeFunctions.nodeMeshToPathArray(network, datasetProductDefinition.id)
|
||||
let networkNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeArray(nodeArray, 'Network Node')
|
||||
|
||||
if (networkNode === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] initialize -> Network Node not found.")
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] initialize -> Initialization Failed because we could not find where the data of this dataset is located within the network. Check the logs for more info.");
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] initialize -> Could not find where " + datasetProductDefinition.name + " for " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + " " + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName + " is stored within the network.");
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE, false);
|
||||
return
|
||||
}
|
||||
|
||||
/* We found where the data is located on the network. */
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> Retrieving data from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.')
|
||||
|
||||
fileStorage = FILE_STORAGE.newFileStorage(processIndex, networkNode.config.host, networkNode.config.webPort);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE, true);
|
||||
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
fileStorage = undefined
|
||||
thisObject.networkNode = undefined
|
||||
bot = undefined
|
||||
thisObject = undefined
|
||||
}
|
||||
|
||||
function getTextFile(pFolderPath, pFileName, callBackFunction) {
|
||||
|
||||
try {
|
||||
let mine = thisObject.node.parentNode.parentNode.parentNode.config.codeName
|
||||
let mineType = thisObject.node.parentNode.parentNode.parentNode.type.replace(' ', '-')
|
||||
let project = thisObject.node.parentNode.parentNode.parentNode.project
|
||||
let botCodeName = thisObject.node.parentNode.parentNode.config.codeName
|
||||
|
||||
let filePathRoot = 'Project/' + project + "/" + mineType + "/" + mine + "/" + botCodeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
let filePath = filePathRoot + "/Output/" + pFolderPath;
|
||||
filePath += '/' + pFileName
|
||||
|
||||
fileStorage.getTextFile(filePath, onFileReceived);
|
||||
|
||||
function onFileReceived(err, text) {
|
||||
callBackFunction(err, text);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] 'getTextFile' -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function createTextFile(pFolderPath, pFileName, pFileContent, callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] createTextFile -> pFolderPath = " + pFolderPath)
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] createTextFile -> pFileName = " + pFileName)
|
||||
|
||||
let ownerId = thisObject.node.dataMine + "-" + thisObject.node.bot
|
||||
let botId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName
|
||||
|
||||
if (ownerId !== botId) {
|
||||
|
||||
let customErr = {
|
||||
result: TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result,
|
||||
message: "Only bots owners of a Data Set can create text files on them."
|
||||
};
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] save -> customErr = " + customErr.message);
|
||||
callBackFunction(customErr);
|
||||
return;
|
||||
}
|
||||
|
||||
let filePathRoot = 'Project/' + thisObject.node.project + "/" + thisObject.node.mineType + "/" + thisObject.node.dataMine + "/" + thisObject.node.bot + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
let filePath = filePathRoot + "/Output/" + pFolderPath + '/' + pFileName;
|
||||
|
||||
fileStorage.createTextFile(filePath, pFileContent, onFileCreated);
|
||||
|
||||
function onFileCreated(err) {
|
||||
callBackFunction(err);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] 'createTextFile' -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -70,6 +70,17 @@ exports.newMultiProject = function () {
|
||||
projectInstance.botClasses[botClassDefinition.propertyName] = requiredFunction.call()
|
||||
}
|
||||
}
|
||||
|
||||
/* Set up Process Modules for this Project */
|
||||
if (projectDefinition.TS.processModules !== undefined) {
|
||||
for (let j = 0; j < projectDefinition.TS.processModules.length; j++) {
|
||||
let processModuleDefinition = projectDefinition.TS.processModules[j]
|
||||
let path = global.env.PATH_TO_PROJECTS_REQUIRED + '/' + projectDefinition.name + '/' + 'TS' + '/' + 'Process-Modules' + '/' + processModuleDefinition.fileName
|
||||
|
||||
let requiredObject = require(path)
|
||||
projectInstance.processModules[processModuleDefinition.propertyName] = requiredObject
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,284 +0,0 @@
|
||||
exports.newSuperalgosProcessModulesProcessExecutionEvents = function (processIndex) {
|
||||
/*
|
||||
Here we manage the process execution events. This allow us to emit events
|
||||
when the process starts and finishes. Also to wait for a dependent event
|
||||
of another process.
|
||||
*/
|
||||
const MODULE_NAME = "Process Execution Events";
|
||||
|
||||
|
||||
let thisObject = {
|
||||
networkNode: undefined,
|
||||
initialize: initialize,
|
||||
finalize: finalize,
|
||||
start: start,
|
||||
finish: finish
|
||||
};
|
||||
|
||||
let processThisDependsOn; // This is the process this process needs to wait for it to finishes in order to start.
|
||||
let currentProcessKey
|
||||
|
||||
let EVENT_SERVER_CLIENT = require('./EventServerClient.js');
|
||||
let eventServerClient
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(processConfig, callBackFunction) {
|
||||
try {
|
||||
let name = 'Not Depends on any Process'
|
||||
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent === undefined) {
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Initialization Failed because the Process Instance needs to have a Reference Parent.");
|
||||
return
|
||||
}
|
||||
|
||||
let market = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
currentProcessKey = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.name + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.type + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.id + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + market
|
||||
|
||||
/*
|
||||
A process can depend for its own execution on another process to finish, and
|
||||
this can be achieved in two different ways. The first one is by referencing
|
||||
the Execution Started Event node from a Process Definition node to a Execution
|
||||
Ended Event node of another Process Definition. The second way is when there is
|
||||
a Execution Started Event node at a Process Instance. This allows the user to
|
||||
override the definition created by the Data Mine for an specific task.
|
||||
*/
|
||||
|
||||
/*
|
||||
Here we check if we can find this relationship at the Data Mine level.
|
||||
*/
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.executionStartedEvent !== undefined) {
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.executionStartedEvent.referenceParent !== undefined) {
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.executionStartedEvent.referenceParent.parentNode !== undefined) {
|
||||
processThisDependsOn = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.executionStartedEvent.referenceParent.parentNode
|
||||
|
||||
name = processThisDependsOn.name
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the Data Mine depends on " + name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Here we check if at the task level if there is an overriding configuration.
|
||||
*/
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].executionStartedEvent !== undefined) {
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].executionStartedEvent.referenceParent !== undefined) {
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].executionStartedEvent.referenceParent.parentNode !== undefined) {
|
||||
processThisDependsOn = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].executionStartedEvent.referenceParent.parentNode
|
||||
|
||||
name = processThisDependsOn.name
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> " + currentProcessKey + " based on the User's Task depends on " + name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (processThisDependsOn !== undefined) {
|
||||
|
||||
/* We need to remember that this process waits for another process in order to start. */
|
||||
processConfig.waitsForExecutionFinishedEvent = true
|
||||
|
||||
/* We need to find at which network node is running the process that we need to hear from when it finished. */
|
||||
let network = TS.projects.superalgos.globals.taskConstants.NETWORK_NODE
|
||||
|
||||
/*
|
||||
Notice that the first task that matches the dependency is going to be considered.
|
||||
This means that if the same task, with the same process, pointing to the same
|
||||
process definition in the same data mine, with the same exchange and market
|
||||
configured, is at two different network nodes at the same time, the current task
|
||||
is going to depend on the first one found, not necesarily the one running at the
|
||||
same network node. If you need to control witch task specifically to depend on
|
||||
and need to exactly the same task to exist, you should split the network in two
|
||||
different networks, each one with unique tasks so as to avoid confussion.
|
||||
*/
|
||||
for (let i = 0; i < network.networkNodes.length; i++) {
|
||||
let networkNode = network.networkNodes[i]
|
||||
if (networkNode.dataTasks !== undefined) {
|
||||
for (let z = 0; z < networkNode.dataTasks.projectDataTasks.length; z++) {
|
||||
let projectDataTasks = networkNode.dataTasks.projectDataTasks[z]
|
||||
if (projectDataTasks.exchangeDataTasks === undefined) {continue}
|
||||
for (let j = 0; j < projectDataTasks.exchangeDataTasks.length; j++) {
|
||||
let exchangeTasks = projectDataTasks.exchangeDataTasks[j]
|
||||
for (let p = 0; p < exchangeTasks.marketDataTasks.length; p++) {
|
||||
let marketTasks = exchangeTasks.marketDataTasks[p]
|
||||
if (marketTasks.referenceParent === undefined) { continue }
|
||||
if (marketTasks.referenceParent.id !== global.MARKET_NODE.id) { continue }
|
||||
for (let q = 0; q < marketTasks.dataMineTasks.length; q++) {
|
||||
let mineTasks = marketTasks.dataMineTasks[q]
|
||||
for (let k = 0; k < mineTasks.taskManagers.length; k++) {
|
||||
let taskManager = mineTasks.taskManagers[k]
|
||||
for (let m = 0; m < taskManager.tasks.length; m++) {
|
||||
let task = taskManager.tasks[m]
|
||||
if (task.bot !== undefined) {
|
||||
for (let n = 0; n < task.bot.processes.length; n++) {
|
||||
let process = task.bot.processes[n]
|
||||
if (process.referenceParent !== undefined) {
|
||||
let processDefinition = process.referenceParent
|
||||
if (processThisDependsOn.id === processDefinition.id) {
|
||||
/*
|
||||
We found where the task that runs the process definition
|
||||
we are waiting for is located on the network.
|
||||
*/
|
||||
thisObject.networkNode = networkNode
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME,
|
||||
"[INFO] initialize -> Connecting to Websockets Server " + networkNode.name +
|
||||
" -> host = " + networkNode.config.host +
|
||||
' -> port = ' + networkNode.config.webSocketsPort + '.');
|
||||
|
||||
|
||||
eventServerClient = EVENT_SERVER_CLIENT.newEventsServerClient(networkNode.config.host, networkNode.config.webSocketsPort)
|
||||
eventServerClient.initialize(onConnected)
|
||||
|
||||
function onConnected() {
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> Connected to Websockets Server " + networkNode.name +
|
||||
" -> host = " + networkNode.config.host +
|
||||
' -> port = ' + networkNode.config.webSocketsPort + '.');
|
||||
|
||||
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Initialization Failed because we could not find where the task that runs the Process Definition we are waiting for is located within the network. Check the logs for more info.");
|
||||
return
|
||||
}
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
|
||||
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
if (eventServerClient !== undefined) {
|
||||
eventServerClient.finalize()
|
||||
eventServerClient = undefined
|
||||
}
|
||||
|
||||
processThisDependsOn = undefined
|
||||
currentProcessKey = undefined
|
||||
thisObject.networkNode = undefined
|
||||
bot = undefined
|
||||
thisObject = undefined
|
||||
}
|
||||
|
||||
function start(callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
if (processThisDependsOn !== undefined) {
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> Entering Code Block.")
|
||||
|
||||
/* This forces this process to wait until the process that this one depends on, emits its event signaling that the process execution has finished. */
|
||||
|
||||
let extraCallerId = '-' + Math.trunc(Math.random() * 10000) + '-'
|
||||
|
||||
let market = TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
let key = processThisDependsOn.name + "-" + processThisDependsOn.type + "-" + processThisDependsOn.id + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + market
|
||||
let callerId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName + extraCallerId
|
||||
|
||||
let subscriptionId
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> started listening to Process Execution Finished. ")
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> key = " + key)
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> callerId = " + callerId)
|
||||
|
||||
eventServerClient.listenToEvent(key, 'Process Execution Finished', undefined, callerId, responseCallBack, eventsCallBack)
|
||||
|
||||
TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, undefined, undefined, "Waiting for " + thisObject.networkNode.name + "->" + processThisDependsOn.parentNode.parentNode.name + "->" + processThisDependsOn.parentNode.config.codeName + "->" + processThisDependsOn.config.codeName)
|
||||
|
||||
function responseCallBack(message) {
|
||||
if (message.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] start -> responseCallBack -> message = " + JSON.stringify(message))
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
} else {
|
||||
subscriptionId = message.eventSubscriptionId
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> waitForDependantProcess -> subscriptionId = " + subscriptionId)
|
||||
}
|
||||
}
|
||||
|
||||
function eventsCallBack(message) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> Entering function.")
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> message = " + JSON.stringify(message))
|
||||
|
||||
/* We continue the normal flow after we learn the dependent process has finished its execution. */
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> stopListening to Process Execution Finished. ")
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> subscriptionId = " + subscriptionId)
|
||||
eventServerClient.stopListening(key, 'Process Execution Finished', subscriptionId)
|
||||
|
||||
if (message.event.err.result === TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) {
|
||||
/* We emit our own event that the process started. */
|
||||
let event = {
|
||||
err: TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(currentProcessKey, 'Process Execution Started')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(currentProcessKey, 'Process Execution Started', event)
|
||||
|
||||
TS.projects.superalgos.functionLibraries.processFunctions.processHeartBeat(processIndex, undefined, undefined, "Running...")
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> eventsCallBack -> " + currentProcessKey + " Process Execution Started because " + key + " Finished.")
|
||||
}
|
||||
|
||||
callBackFunction(message.event.err);
|
||||
}
|
||||
} else {
|
||||
/* In this case, the Process does not depends on a process which needs to wait for. */
|
||||
/* We emit our own event that the process started. */
|
||||
let event = {
|
||||
err: TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(currentProcessKey, 'Process Execution Started')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(currentProcessKey, 'Process Execution Started', event)
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] start -> " + currentProcessKey + " Process Execution Started ")
|
||||
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] start -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function finish(callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] finish -> Entering function.")
|
||||
|
||||
let event = {
|
||||
err: TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE
|
||||
}
|
||||
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(currentProcessKey, 'Process Execution Finished')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(currentProcessKey, 'Process Execution Finished', event)
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] finish -> " + currentProcessKey + " Process Execution Finished ")
|
||||
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
|
||||
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] finish -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,182 +0,0 @@
|
||||
exports.newSuperalgosProcessModulesProcessOutput = function (processIndex) {
|
||||
|
||||
/*
|
||||
Here we emit the events that signals that a Dataset was updated.
|
||||
*/
|
||||
|
||||
const MODULE_NAME = "Process Output";
|
||||
|
||||
let thisObject = {
|
||||
raiseEvents: raiseEvents,
|
||||
asyncRaiseEvents: asyncRaiseEvents
|
||||
};
|
||||
|
||||
return thisObject;
|
||||
|
||||
function raiseEvents(lastFile, timeFrames, callBackFunction) {
|
||||
try {
|
||||
/* We will reaise the events for the datasets impacted by the process that just finished. */
|
||||
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput !== undefined) {
|
||||
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
|
||||
|
||||
for (let j = 0; j < outputDatasets.length; j++) {
|
||||
let outputDataset = outputDatasets[j]
|
||||
|
||||
let botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Indicator Bot')
|
||||
if (botNode === undefined) {
|
||||
botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Trading Bot')
|
||||
}
|
||||
if (botNode === undefined) {
|
||||
botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Sensor Bot')
|
||||
}
|
||||
if (botNode === undefined) {
|
||||
botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Learning Bot')
|
||||
}
|
||||
|
||||
/* Some validations to verify that everything is in place. */
|
||||
if (outputDataset.referenceParent !== undefined) {
|
||||
if (outputDataset.referenceParent.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Dataset Definition not defined. Dataset Definition = " + JSON.stringify(outputDataset.referenceParent));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
if (outputDataset.referenceParent.parentNode !== undefined) {
|
||||
if (outputDataset.referenceParent.parentNode.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Product not defined. Product = " + JSON.stringify(outputDataset.referenceParent.parentNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
if (botNode !== undefined) {
|
||||
if (botNode.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Bot not defined. Bot = " + JSON.stringify(botNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
if (botNode.parentNode !== undefined) {
|
||||
if (botNode.parentNode.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Data Mine not defined. Data Mine = " + JSON.stringify(botNode.parentNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> Bot not attached to a Data Mine or Trading Mine. Bot = " + JSON.stringify(botNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> Product not attached to a Bot. Product = " + JSON.stringify(outputDataset.referenceParent.parentNode));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> Dataset Definition not attached to a Product. Dataset Definition = " + JSON.stringify(outputDataset.referenceParent));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> Output Dataset with no reference to a Dataset Definition. Output Dataset = " + JSON.stringify(outputDataset));
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
return
|
||||
}
|
||||
|
||||
/* All good, lets emit the event. */
|
||||
|
||||
let dataMine = botNode.parentNode.config.codeName
|
||||
let botName = botNode.config.codeName
|
||||
let product = outputDataset.referenceParent.parentNode.config.codeName
|
||||
let dataset = outputDataset.referenceParent.config.codeName
|
||||
|
||||
let key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
let event = {
|
||||
lastFile: lastFile,
|
||||
timeFrames: timeFrames
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(key, 'Dataset Updated')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Dataset Updated', event)
|
||||
}
|
||||
}
|
||||
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
|
||||
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function asyncRaiseEvents(lastFile, timeFrames) {
|
||||
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput !== undefined) {
|
||||
let outputDatasets = TS.projects.superalgos.utilities.nodeFunctions.nodeBranchToArray(TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processOutput, 'Output Dataset')
|
||||
|
||||
for (let j = 0; j < outputDatasets.length; j++) {
|
||||
let outputDataset = outputDatasets[j]
|
||||
|
||||
let botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Indicator Bot')
|
||||
if (botNode === undefined) {
|
||||
botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Trading Bot')
|
||||
}
|
||||
if (botNode === undefined) {
|
||||
botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Sensor Bot')
|
||||
}
|
||||
if (botNode === undefined) {
|
||||
botNode = TS.projects.superalgos.utilities.nodeFunctions.findNodeInNodeMesh(outputDataset, 'Learning Bot')
|
||||
}
|
||||
|
||||
/* Some validations to verify that everything is in place. */
|
||||
if (outputDataset.referenceParent !== undefined) {
|
||||
if (outputDataset.referenceParent.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Dataset Definition not defined. Dataset Definition = " + JSON.stringify(outputDataset.referenceParent));
|
||||
throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
if (outputDataset.referenceParent.parentNode !== undefined) {
|
||||
if (outputDataset.referenceParent.parentNode.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Product not defined. Product = " + JSON.stringify(outputDataset.referenceParent.parentNode));
|
||||
throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
if (botNode !== undefined) {
|
||||
if (botNode.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Bot not defined. Bot = " + JSON.stringify(botNode));
|
||||
throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
if (botNode.parentNode !== undefined) {
|
||||
if (botNode.parentNode.config.codeName === undefined) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> codeName at Mine not defined. Mine = " + JSON.stringify(botNode.parentNode));
|
||||
throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> Bot not attached to a Data Mine | Trading Mine | Learning Mine. Bot = " + JSON.stringify(botNode));
|
||||
throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> Product not attached to a Bot. Product = " + JSON.stringify(outputDataset.referenceParent.parentNode));
|
||||
throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> Dataset Definition not attached to a Product. Dataset Definition = " + JSON.stringify(outputDataset.referenceParent));
|
||||
throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] raiseEvents -> Output Dataset with no reference to a Dataset Definition. Output Dataset = " + JSON.stringify(outputDataset));
|
||||
throw (TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
|
||||
/* All good, lets emit the event. */
|
||||
|
||||
let dataMine = botNode.parentNode.config.codeName
|
||||
let botName = botNode.config.codeName
|
||||
let product = outputDataset.referenceParent.parentNode.config.codeName
|
||||
let dataset = outputDataset.referenceParent.config.codeName
|
||||
|
||||
let key = dataMine + "-" + botName + "-" + product + "-" + dataset + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
let event = {
|
||||
lastFile: lastFile,
|
||||
timeFrames: timeFrames
|
||||
}
|
||||
global.EVENT_SERVER_CLIENT_MODULE.createEventHandler(key, 'Dataset Updated')
|
||||
global.EVENT_SERVER_CLIENT_MODULE.raiseEvent(key, 'Dataset Updated', event)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,167 +0,0 @@
|
||||
exports.newSuperalgosProcessModulesStatusDependencies = function (processIndex, STATUS_REPORT, PROCESS_OUTPUT) {
|
||||
|
||||
const MODULE_NAME = "Status Dependencies";
|
||||
|
||||
let thisObject = {
|
||||
nodeArray: undefined,
|
||||
statusReports: new Map(),
|
||||
reportsByMainUtility: new Map(),
|
||||
initialize: initialize,
|
||||
finalize: finalize,
|
||||
keys: []
|
||||
};
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(callBackFunction) {
|
||||
try {
|
||||
/* Basic Valdidations */
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies !== undefined) {
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies.statusDependencies !== undefined) {
|
||||
thisObject.nodeArray = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.processDependencies.statusDependencies
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have status dependencies at all.");
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> It is not possible to not have process dependencies, which means not status dependencies.");
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
/*For each dependency we will initialize the status report, and load it as part of this initialization process.*/
|
||||
|
||||
let alreadyCalledBack = false;
|
||||
let loadCount = 0;
|
||||
let dependenciesToProcess = []
|
||||
for (let i = 0; i < thisObject.nodeArray.length; i++) {
|
||||
let statusDependency = {
|
||||
dependency: thisObject.nodeArray[i]
|
||||
}
|
||||
|
||||
dependenciesToProcess.push(statusDependency)
|
||||
|
||||
}
|
||||
|
||||
for (let i = 0; i < dependenciesToProcess.length; i++) {
|
||||
|
||||
let statusReportModule = STATUS_REPORT.newSuperalgosProcessModulesStatusReport(processIndex, PROCESS_OUTPUT);
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> onInitilized -> Initializing Status Report # " + (i + 1));
|
||||
let statusDependency = dependenciesToProcess[i]
|
||||
statusReportModule.initialize(statusDependency.dependency, onInitilized);
|
||||
|
||||
function onInitilized(err) {
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> onInitilized -> Initialized Status Report # " + (i + 1));
|
||||
|
||||
if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) {
|
||||
if (alreadyCalledBack === false) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err = " + err.stack);
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> onInitilized -> err.message = " + err.message);
|
||||
alreadyCalledBack = true;
|
||||
callBackFunction(err);
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] initialize -> Can not call back because I already did.")
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> onInitilized -> Loading Status Report # " + (i + 1));
|
||||
statusReportModule.load(onLoad);
|
||||
}
|
||||
|
||||
function onLoad(err) {
|
||||
|
||||
try {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> onLoad -> Loaded Status Report # " + (i + 1));
|
||||
statusReportModule.status = err.message;
|
||||
|
||||
switch (err.message) {
|
||||
case TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.message: {
|
||||
addReport();
|
||||
return;
|
||||
}
|
||||
case "Status Report was never created.": {
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] initialize -> onLoad -> err = " + err.stack);
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] initialize -> onLoad -> Report Not Found. -> Status Dependency = " + JSON.stringify(statusDependency.dependency))
|
||||
|
||||
addReport();
|
||||
return;
|
||||
}
|
||||
|
||||
case "Status Report is corrupt.": {
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] initialize -> onLoad -> err = " + err.stack);
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] initialize -> onLoad -> Report Not Found. -> Status Dependency = " + JSON.stringify(statusDependency.dependency))
|
||||
|
||||
addReport();
|
||||
return;
|
||||
}
|
||||
default:
|
||||
{
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> onLoad -> Operation Failed.");
|
||||
|
||||
if (alreadyCalledBack === false) {
|
||||
alreadyCalledBack = true;
|
||||
callBackFunction(err);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> onLoad -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function addReport() {
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> addReport -> Entering function.")
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> addReport -> Adding Status Report # " + (i + 1));
|
||||
|
||||
loadCount++;
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> addReport -> Total Added = " + loadCount);
|
||||
|
||||
let key = statusDependency.dependency.dataMine + "-" + statusDependency.dependency.bot + "-" + statusDependency.dependency.process
|
||||
|
||||
thisObject.keys.push(key);
|
||||
thisObject.statusReports.set(key, statusReportModule);
|
||||
|
||||
if (statusReportModule.mainUtility !== undefined) {
|
||||
thisObject.reportsByMainUtility.set(statusReportModule.mainUtility, statusReportModule)
|
||||
}
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> addReport -> Report added to Map. -> key = " + key)
|
||||
|
||||
if (loadCount === dependenciesToProcess.length) {
|
||||
if (alreadyCalledBack === false) {
|
||||
alreadyCalledBack = true
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
|
||||
return;
|
||||
} else {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] initialize -> addReport -> Can not call back because I already did.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
thisObject.statusReports.forEach(forEachStatusDependency)
|
||||
function forEachStatusDependency(statusDependency) {
|
||||
statusDependency.finalize()
|
||||
}
|
||||
thisObject.statusReports = undefined
|
||||
bot = undefined
|
||||
thisObject = undefined
|
||||
}
|
||||
};
|
||||
@@ -1,398 +0,0 @@
|
||||
exports.newSuperalgosProcessModulesStatusReport = function (processIndex, PROCESS_OUTPUT) {
|
||||
|
||||
/*
|
||||
|
||||
A Status Report is a file that every bot reads at the begining of its execution and saves after it finishes its job.
|
||||
The purpose of the file is to record checkpoint information of what was the last thing done by the bot and helpfull enough to start the next execution.
|
||||
It usually does not include business related context data.
|
||||
|
||||
*/
|
||||
|
||||
const MODULE_NAME = "Status Report";
|
||||
|
||||
let thisObject = {
|
||||
networkNode: undefined,
|
||||
mainUtility: undefined,
|
||||
file: undefined, // Here we have the JSON object representing the file content.
|
||||
initialize: initialize,
|
||||
finalize: finalize,
|
||||
load: load,
|
||||
save: save,
|
||||
asyncSave: asyncSave,
|
||||
status: undefined
|
||||
};
|
||||
|
||||
let statusDependencyNode;
|
||||
|
||||
/* Utilities needed. */
|
||||
|
||||
|
||||
|
||||
/* Storage account to be used here. */
|
||||
|
||||
const FILE_STORAGE = require('./FileStorage.js');
|
||||
let fileStorage
|
||||
|
||||
let sessionPath = ''
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(pStatusDependencyNode, callBackFunction) {
|
||||
try {
|
||||
statusDependencyNode = pStatusDependencyNode;
|
||||
|
||||
/* Some very basic validations that we have all the information needed. */
|
||||
if (statusDependencyNode.referenceParent === undefined) {
|
||||
validationFailed(statusDependencyNode, "Status Dependency without Reference Parent.")
|
||||
return
|
||||
}
|
||||
|
||||
if (statusDependencyNode.referenceParent.parentNode === undefined) {
|
||||
validationFailed(statusDependencyNode.referenceParent, "Status Report not attached to a Process Definition.")
|
||||
return
|
||||
}
|
||||
|
||||
if (statusDependencyNode.referenceParent.parentNode.config.codeName === undefined) {
|
||||
validationFailed(statusDependencyNode.referenceParent.parentNode, "Process Definition witn no codeName defined.")
|
||||
return
|
||||
}
|
||||
|
||||
if (statusDependencyNode.referenceParent.parentNode.parentNode === undefined) {
|
||||
validationFailed(statusDependencyNode.referenceParent.parentNode, "Process Definition not attached to a Bot.")
|
||||
return
|
||||
}
|
||||
|
||||
if (statusDependencyNode.referenceParent.parentNode.parentNode.config.codeName === undefined) {
|
||||
validationFailed(statusDependencyNode.referenceParent.parentNode.parentNode, "Bot with no codeName defined.")
|
||||
return
|
||||
}
|
||||
|
||||
if (statusDependencyNode.referenceParent.parentNode.parentNode.parentNode === undefined) {
|
||||
validationFailed(statusDependencyNode.referenceParent.parentNode.parentNode, "Bot not attached to a Data Mine.")
|
||||
return
|
||||
}
|
||||
|
||||
if (statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.config.codeName === undefined) {
|
||||
validationFailed(statusDependencyNode.referenceParent.parentNode.parentNode.parentNode, "Data Mine witn no codeName defined.")
|
||||
return
|
||||
}
|
||||
|
||||
function validationFailed(errorInNode, errorMessage) {
|
||||
let nodeString = JSON.stringify(errorInNode)
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> " + errorMessage + ' -> nodeString = ' + nodeString)
|
||||
TS.projects.superalgos.functionLibraries.processFunctions.processError(TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).PROCESS_KEY, errorInNode, errorMessage)
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
|
||||
/* Simplifying the access to basic info */
|
||||
statusDependencyNode.bot = statusDependencyNode.referenceParent.parentNode.parentNode.config.codeName
|
||||
statusDependencyNode.process = statusDependencyNode.referenceParent.parentNode.config.codeName
|
||||
statusDependencyNode.bottype = statusDependencyNode.referenceParent.parentNode.parentNode.type
|
||||
statusDependencyNode.dataMine = statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.config.codeName
|
||||
statusDependencyNode.mineType = statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.type.replace(' ', '-')
|
||||
statusDependencyNode.project = statusDependencyNode.referenceParent.parentNode.parentNode.parentNode.project
|
||||
|
||||
/* We retrieve the report main utility */
|
||||
if (statusDependencyNode.config !== undefined) {
|
||||
if (statusDependencyNode.config.mainUtility !== undefined) {
|
||||
thisObject.mainUtility = statusDependencyNode.config.mainUtility
|
||||
}
|
||||
}
|
||||
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE !== undefined && statusDependencyNode.bottype === "Trading Bot") {
|
||||
sessionPath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_FOLDER_NAME + "/"
|
||||
}
|
||||
|
||||
/* Now we will see where do we need to fetch this status report from. */
|
||||
let network = TS.projects.superalgos.globals.taskConstants.NETWORK_NODE
|
||||
let processThisDependsOn = statusDependencyNode.referenceParent.parentNode
|
||||
|
||||
for (let i = 0; i < network.networkNodes.length; i++) {
|
||||
let networkNode = network.networkNodes[i]
|
||||
|
||||
if (checkThisDataBranch(networkNode.dataTasks) === true) { return }
|
||||
if (checkThisTradingBranch(networkNode.testingTradingTasks) === true) { return }
|
||||
if (checkThisTradingBranch(networkNode.productionTradingTasks) === true) { return }
|
||||
|
||||
function checkThisDataBranch(branch) {
|
||||
if (branch === undefined) { return }
|
||||
for (let z = 0; z < branch.projectDataTasks.length; z++) {
|
||||
let projectDataTasks = branch.projectDataTasks[z]
|
||||
if (projectDataTasks.exchangeDataTasks === undefined) {continue}
|
||||
for (let j = 0; j < projectDataTasks.exchangeDataTasks.length; j++) {
|
||||
let exchangeTasks = projectDataTasks.exchangeDataTasks[j]
|
||||
for (let p = 0; p < exchangeTasks.marketDataTasks.length; p++) {
|
||||
let marketTasks = exchangeTasks.marketDataTasks[p]
|
||||
if (marketTasks.referenceParent === undefined) { continue }
|
||||
if (marketTasks.referenceParent.id !== global.MARKET_NODE.id) { continue }
|
||||
for (let q = 0; q < marketTasks.dataMineTasks.length; q++) {
|
||||
let mineTasks = marketTasks.dataMineTasks[q]
|
||||
for (let k = 0; k < mineTasks.taskManagers.length; k++) {
|
||||
let taskManager = mineTasks.taskManagers[k]
|
||||
for (let m = 0; m < taskManager.tasks.length; m++) {
|
||||
let task = taskManager.tasks[m]
|
||||
if (task.bot === undefined) { continue }
|
||||
for (let n = 0; n < task.bot.processes.length; n++) {
|
||||
let process = task.bot.processes[n]
|
||||
if (process.referenceParent === undefined) { continue }
|
||||
let processDefinition = process.referenceParent
|
||||
if (processThisDependsOn.id === processDefinition.id) {
|
||||
if (process.type === 'Trading Process Instance') {
|
||||
if (process.session !== undefined) {
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.id !== process.session.id) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
/*
|
||||
We found where the task that runs the process definition this status report depends on
|
||||
and where it is located on the network.
|
||||
*/
|
||||
thisObject.networkNode = networkNode
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.')
|
||||
|
||||
fileStorage = FILE_STORAGE.newFileStorage(processIndex, networkNode.config.host, networkNode.config.webPort)
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkThisTradingBranch(branch) {
|
||||
if (branch === undefined) { return }
|
||||
for (let z = 0; z < branch.projectTradingTasks.length; z++) {
|
||||
let projectTradingTasks = branch.projectTradingTasks[z]
|
||||
for (let j = 0; j < projectTradingTasks.exchangeTradingTasks.length; j++) {
|
||||
let exchangeTasks = projectTradingTasks.exchangeTradingTasks[j]
|
||||
for (let p = 0; p < exchangeTasks.marketTradingTasks.length; p++) {
|
||||
let marketTasks = exchangeTasks.marketTradingTasks[p]
|
||||
if (marketTasks.referenceParent === undefined) { continue }
|
||||
if (marketTasks.referenceParent.id !== global.MARKET_NODE.id) { continue }
|
||||
for (let q = 0; q < marketTasks.tradingMineTasks.length; q++) {
|
||||
let mineTasks = marketTasks.tradingMineTasks[q]
|
||||
for (let k = 0; k < mineTasks.taskManagers.length; k++) {
|
||||
let taskManager = mineTasks.taskManagers[k]
|
||||
for (let m = 0; m < taskManager.tasks.length; m++) {
|
||||
let task = taskManager.tasks[m]
|
||||
if (task.bot === undefined) { continue }
|
||||
for (let n = 0; n < task.bot.processes.length; n++) {
|
||||
let process = task.bot.processes[n]
|
||||
if (process.referenceParent === undefined) { continue }
|
||||
let processDefinition = process.referenceParent
|
||||
if (processThisDependsOn.id === processDefinition.id) {
|
||||
if (process.type === 'Trading Process Instance') {
|
||||
if (process.session !== undefined) {
|
||||
if (TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].session.id !== process.session.id) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
/*
|
||||
We found where the task that runs the process definition this status report depends on
|
||||
and where it is located on the network.
|
||||
*/
|
||||
thisObject.networkNode = networkNode
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] initialize -> Retrieving status report from " + networkNode.name + " -> host = " + networkNode.config.host + ' -> port = ' + networkNode.config.webPort + '.')
|
||||
|
||||
fileStorage = FILE_STORAGE.newFileStorage(processIndex, networkNode.config.host, networkNode.config.webPort)
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> Initialization Failed because we could not find where the data of this status report is located within the network. Check the logs for more info.");
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> bot = " + statusDependencyNode.bot)
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> process = " + statusDependencyNode.process)
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> bottype = " + statusDependencyNode.bottype)
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> dataMine = " + statusDependencyNode.dataMine)
|
||||
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] initialize -> err = " + err.stack);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
fileStorage = undefined
|
||||
thisObject.networkNode = undefined
|
||||
bot = undefined
|
||||
thisObject = undefined
|
||||
}
|
||||
|
||||
function load(callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
let fileName = "Status.Report.json";
|
||||
let filePath;
|
||||
|
||||
let ownerId = statusDependencyNode.dataMine + "-" + statusDependencyNode.bot + "-" + statusDependencyNode.process
|
||||
let botId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
|
||||
|
||||
if (ownerId !== botId) {
|
||||
|
||||
let filePathRoot = 'Project/' + statusDependencyNode.project + "/" + statusDependencyNode.mineType + "/" + statusDependencyNode.dataMine + "/" + statusDependencyNode.bot + '/' + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name + "/" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
filePath = filePathRoot + "/Reports/" + sessionPath + statusDependencyNode.process
|
||||
} else {
|
||||
filePath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).FILE_PATH_ROOT + "/Reports/" + sessionPath + statusDependencyNode.process
|
||||
}
|
||||
|
||||
filePath += '/' + fileName
|
||||
|
||||
let canUserPrevious
|
||||
/*
|
||||
If we are funning Trading Engines, we can not allow ourselves to use a Status Report that is not the latest one, because it might contain
|
||||
transactioinal information related to the context of the operations the trading engine is doing.
|
||||
|
||||
On the contraty, if we are running a Sensor bot or an Indicator we might, if necesary, use a previous version of a Status Report since
|
||||
there will be no big impact, just some reprocessing.
|
||||
*/
|
||||
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE !== undefined) {
|
||||
canUserPrevious = false
|
||||
} else {
|
||||
canUserPrevious = true
|
||||
}
|
||||
|
||||
fileStorage.getTextFile(filePath, onFileReceived, undefined, canUserPrevious);
|
||||
|
||||
function onFileReceived(err, text) {
|
||||
|
||||
if (err.result === TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result && (err.message === 'Folder does not exist.' || err.message === 'File does not exist.')
|
||||
|| err.code === "The specified key does not exist.") {
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[INFO] load -> onFileReceived -> err = " + err.message)
|
||||
|
||||
/* In this case we can assume that this is the first execution ever of this bot.*/
|
||||
|
||||
thisObject.file = JSON.parse('{}');
|
||||
|
||||
let customOK = {
|
||||
result: TS.projects.superalgos.globals.standardResponses.CUSTOM_OK_RESPONSE.result,
|
||||
message: "Status Report was never created."
|
||||
};
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] load -> onFileReceived -> customOK = " + customOK.message)
|
||||
callBackFunction(customOK);
|
||||
return;
|
||||
}
|
||||
|
||||
if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] load -> onFileReceived -> err = " + err.message)
|
||||
callBackFunction(err);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
thisObject.file = JSON.parse(text);
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE)
|
||||
} catch (err) {
|
||||
|
||||
/*
|
||||
It might happen that the file content is corrupt. We will consider this as a temporary situation, since sometimes the file
|
||||
is being updated at the moment of the read. The bot can not run without a valid Status Report but we can request the platform to retry later.
|
||||
*/
|
||||
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] load -> onFileReceived -> Error Parsing the Status report. -> Err = " + err.message)
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] load -> onFileReceived -> Error Parsing the Status report. -> text = " + text)
|
||||
|
||||
let customFail = {
|
||||
result: TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result,
|
||||
message: "Status Report is corrupt."
|
||||
};
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[WARN] load -> onFileReceived -> customFail = " + customFail.message)
|
||||
callBackFunction(customFail);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] load -> err = " + err.stack)
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
function save(callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
let ownerId = statusDependencyNode.dataMine + "-" + statusDependencyNode.bot + "-" + statusDependencyNode.process
|
||||
let botId = TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.parentNode.config.codeName + "-" + TS.projects.superalgos.globals.taskConstants.TASK_NODE.bot.processes[processIndex].referenceParent.config.codeName
|
||||
|
||||
if (ownerId !== botId && statusDependencyNode.process !== "Context") { // Context is a special case where the report is created by the Context.js module itself.
|
||||
|
||||
let customErr = {
|
||||
result: TS.projects.superalgos.globals.standardResponses.CUSTOM_FAIL_RESPONSE.result,
|
||||
message: "Only bots owners of a Status Report can save them."
|
||||
};
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] save -> customErr = " + customErr.message)
|
||||
callBackFunction(customErr)
|
||||
return;
|
||||
}
|
||||
|
||||
let fileName = "Status.Report.json"
|
||||
let filePath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).FILE_PATH_ROOT + "/Reports/" + sessionPath + statusDependencyNode.process
|
||||
|
||||
filePath += '/' + fileName
|
||||
let fileContent = JSON.stringify(thisObject.file);
|
||||
|
||||
fileStorage.createTextFile(filePath, fileContent + '\n', onFileCreated, true)
|
||||
|
||||
function onFileCreated(err) {
|
||||
if (err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] save -> onFileCreated -> err = " + err.stack)
|
||||
callBackFunction(err)
|
||||
return
|
||||
}
|
||||
|
||||
/* All good, lets emit the event that means data has been updated. */
|
||||
|
||||
let processOutput = PROCESS_OUTPUT.newSuperalgosProcessModulesProcessOutput(processIndex)
|
||||
processOutput.raiseEvents(thisObject.file.lastFile, thisObject.file.timeFrames, callBackFunction);
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
catch (err) {
|
||||
TS.projects.superalgos.globals.loggerVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).BOT_MAIN_LOOP_LOGGER_MODULE.write(MODULE_NAME, "[ERROR] save -> err = " + err.stack)
|
||||
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
async function asyncSave() {
|
||||
|
||||
let fileName = "Status.Report.json";
|
||||
let filePath = TS.projects.superalgos.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).FILE_PATH_ROOT + "/Reports/" + sessionPath + statusDependencyNode.process
|
||||
|
||||
filePath += '/' + fileName
|
||||
let fileContent = JSON.stringify(thisObject.file);
|
||||
|
||||
let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n', true)
|
||||
|
||||
if (response.err.result !== TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE.result) {
|
||||
throw (response.err)
|
||||
}
|
||||
|
||||
/* All good, lets emit the event that means data has been updated. */
|
||||
let processOutput = PROCESS_OUTPUT.newSuperalgosProcessModulesProcessOutput(processIndex)
|
||||
processOutput.asyncRaiseEvents(thisObject.file.lastFile, thisObject.file.timeFrames)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user