Restarting Sessions
This commit is contained in:
1 parent
7c7e11a311
commit
2ce2d8b800
1 file changed
+26
-1
@@ -10,12 +10,14 @@ function newUiObjectsFromNodes () {
|
||||
let mapOfReferenceChildren = new Map()
|
||||
let mapOfNodes
|
||||
let tasksToRun
|
||||
let sessionsToRun
|
||||
|
||||
return thisObject
|
||||
|
||||
function recreateWorkspace (node, replacingCurrentWorkspace) {
|
||||
mapOfNodes = new Map()
|
||||
tasksToRun = []
|
||||
sessionsToRun = []
|
||||
|
||||
/* Create the workspace UI OBject and then continue with the root nodes. */
|
||||
createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace')
|
||||
@@ -29,9 +31,14 @@ function newUiObjectsFromNodes () {
|
||||
tryToConnectChildrenWithReferenceParents()
|
||||
|
||||
if (replacingCurrentWorkspace === true) {
|
||||
setTimeout(runTasks, 70000) // We need to wait all tasks that were potentially running to stop
|
||||
// We need to wait all tasks that were potentially running to stop
|
||||
setTimeout(runTasks, 70000)
|
||||
// We give a few seconds for the tasks to start
|
||||
setTimeout(runSessions, 80000)
|
||||
} else {
|
||||
runTasks()
|
||||
// We give a few seconds for the tasks to start
|
||||
setTimeout(runSessions, 10000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +50,14 @@ function newUiObjectsFromNodes () {
|
||||
tasksToRun = undefined
|
||||
}
|
||||
|
||||
function runSessions () {
|
||||
for (let i = 0; i < sessionsToRun.length; i++) {
|
||||
let node = sessionsToRun[i]
|
||||
node.payload.uiObject.menu.internalClick('Run Session')
|
||||
}
|
||||
sessionsToRun = undefined
|
||||
}
|
||||
|
||||
function tryToConnectChildrenWithReferenceParents () {
|
||||
/* We reconstruct here the reference relationships. */
|
||||
for (const [key, node] of mapOfNodes) {
|
||||
@@ -379,10 +394,20 @@ function newUiObjectsFromNodes () {
|
||||
|
||||
mapOfNodes.set(node.id, node)
|
||||
|
||||
/* Check if there are tasks to run */
|
||||
if (userAddingNew === false && uiObjectType === 'Task' && node.savedPayload !== undefined) {
|
||||
if (node.savedPayload.uiObject.isRunning === true) {
|
||||
tasksToRun.push(node)
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if there are sessions to run */
|
||||
if (userAddingNew === false && node.savedPayload !== undefined) {
|
||||
if (uiObjectType === 'Live Trading Session' || uiObjectType === 'Fordward Testing Session' || uiObjectType === 'Backtesting Session' || uiObjectType === 'Paper Trading Session') {
|
||||
if (node.savedPayload.uiObject.isRunning === true) {
|
||||
sessionsToRun.push(node)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user