-
Notifications
You must be signed in to change notification settings - Fork 0
/
BaseNode.py
51 lines (41 loc) · 1.63 KB
/
BaseNode.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# import * as fs from 'fs';
import numpy as np
class BaseNode:
def __init__(self, parentFlow, nodeName, parentNode, nextNode, actionFunction, isRootNode):
self.parentFlow = parentFlow
self.nodeName = nodeName
self.parentNode = parentNode
self.nextNode = nextNode
self.actionFunction = actionFunction
self.parameter = None
self.isRootNode = isRootNode
self.fullRes = {}
#writeDataFile(nodeName, {})
def setRootNode(self, isRootNode: bool):
self.isRootNode = isRootNode;
def setParentNode(self, node):
self.parentNode = node;
node.nextNode = self;
def setNextNode(self, node):
self.nextNode = node;
node.parentNode = self;
def setParameter(self, parameter):
self.parameter = parameter;
def executeAction(self):
currentNode = self;
result = None;
#if (self.parameter != None):
print("-----------------------", "Node Name: ", currentNode.nodeName, " | Parameter: " , self.parameter, "(Length:", len(self.parameter) ,")", "-----------------------")
result = self.actionFunction(self.parameter);
print("Node actionFunction Result: ", result)
self.fullRes = result;
if (isinstance(result, (list, tuple, np.ndarray))):
load = result[0];
print("Decider Node Load", load," | Decider Node resultMapper: ", result[1])
else:
load = result;
if (self.nextNode != None):
self.nextNode.parameter = load;
print("Node Load", load)
return load;
#writeDataFile(this.nodeName, load)