-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocumentation.txt
188 lines (150 loc) · 7.45 KB
/
documentation.txt
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
***************************************************************
*******************NODE INITIATION*****************************
***************************************************************
FUNCTIONALITY: Creates nodes and assigns corresponding devices to it. Devices must be in a list.
ENDPOINT: /initiate
TYPE: POST
URL ARGUMENTS: -
POSSIBLE RESPONSES:
401, 'Invalid Credentials' -> invalid credentials in the auth argument in post request
500, 'Internal server error' -> error occured on PBRcontrol, report immediately
404, 'Server not found' -> PBRcontrol is not running
200, {node_id: {device_type: True/False}} -> returns dictionary of requested node_ids, each has a dict of requested
devices. If the device was initiated, its value in the dict is True,
otherwise False (e.g. if the device already exists on node. This can
happen by user trying to initiate multiple devices of the same type on
one node)
-> if the node already exists, initiation will fail and the value of node_id
in dict will be False
DATA: Dictionary of nodes. All parameters are required in the expected format.
{
1 : {
'experiment_details' : {'sleep_time' : 120},
'devices' : [{
'device_type' : 'PBR',
'device_class' : 'PSI_test',
'address' : None,
'setup' : {
'initial_commands' : [{'time': (datetime.datetime.now().strftime("%Y-%m-%d, %H:%M:%S")),'cmd_id': 8, 'args': '[1, True]'}],
'lower_outlier_tol' : 2,
'upper_outlier_tol' : 3,
'max_outliers' : 6,
'min_OD' : 0.1,
'max_OD' : 0.9,
'pump_id' : 1
}
},
{
'device_type' : 'GAS',
'device_class' : 'PSI_test',
'address' : None,
'setup' : {
'initial_commands' : []
}
}
]
},
2 : {
'experiment_details' : {'sleep_time' : 180},
'devices' : [{
'device_type' : 'PBR',
'device_class' : 'PSI_test',
'address' : None,
'setup' : {
'initial_commands' : [],
'lower_outlier_tol' : 2,
'upper_outlier_tol' : 3,
'max_outliers' : 6,
'min_OD' : 0.1,
'max_OD' : 0.9,
'pump_id' : 1,
}
},
{
'device_type': 'GMS',
'device_class': 'PSI_test',
'address': None,
'setup': {
'initial_commands': []
}
}
]
}
}
***************************************************************
**************************ADD DEVICE***************************
***************************************************************
FUNCTIONALITY: Add device to an existing node
ENDPOINT: /add_device
TYPE: POST
URL ARGUMENTS: ?node_id=x
POSSIBLE RESPONSES:
401, 'Invalid Credentials' -> invalid credentials in the auth argument in post request
500, 'Internal server error' -> error occured on PBRcontrol, report immediately
404, 'Server not found' -> PBRcontrol is not running
200, True -> device was added to requested node
400, False -> device already exists on requested node
400, 'Node number unspecified' -> node wasn't specified in URL args
400, 'Requested node is not initialized'
DATA: dictionary
{
'device_type' : device,
'device_class' : 'PSI_test',
'address' : None,
'setup' : {
'initial_commands' : [{'time': (datetime.datetime.now().strftime("%Y-%m-%d, %H:%M:%S")),'cmd_id': 8, 'args': '[1, True]'}],
'lower_outlier_tol' : 2,
'upper_outlier_tol' : 3,
'max_outliers' : 6,
'min_OD' : 0.1,
'max_OD' : 0.9,
'pump_id' : 1
}
}
***************************************************************
**************************COMMAND******************************
***************************************************************
FUNCTIONALITY: Forward commands to device/node. It is possible to send multiple commands, but only to one device/one node.
Commands are to be sent as dictionaries in a list.
ENDPOINT: /command
TYPE: POST
URL ARGUMENTS: 1) ?node_id=x -> send command which affects whole node, currently used only to change time period of measurements
2) ?node_id=x&device_type=xyz -> send command to specific device on specific node
DATA:
[{'time': (datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")),'cmd_id': 8, 'args': '[1, True]'}]
POSSIBLE RESPONSES:
401, 'Invalid Credentials' -> invalid credentials in the auth argument in post request
500, 'Internal server error' -> error occured on PBRcontrol, report immediately
400, False -> invalid node_id or device_type requested
200, True -> success, the command has been added to corresponding queue and is waiting to be executed
***************************************************************
**************************END**********************************
***************************************************************
FUNCTIONALITY: end device, node or whole program
ENDPOINT: /end
TYPE: GET
URL ARGUMENTS: 1) - -> ends the program
2) ?node_id=x -> ends node and its devices
3) ?node_id=x&device_type=xyz -> ends device on specified node
POSSIBLE RESPONSES:
401, 'Invalid Credentials' -> invalid credentials in the auth argument in post request
500, 'Internal server error' -> error occured on PBRcontrol, report immediately
404, 'Server not found' -> PBRcontrol is not running
400, 'Requested node is not initialized'
400, 'Device doesnt exist on node x'
200, '' -> success
***************************************************************
**************************LOG**********************************
***************************************************************
FUNCTIONALITY: retrieve data from log
ENDPOINT: /log
TYPE: GET
URL ARGUMENTS: 1) ?node=x -> return all unseen data from node.
2) ?node=x&time=YYMMDDHHMMSS -> return all data from given time for given node
POSSIBLE RESPONSES:
401, 'Invalid Credentials' -> invalid credentials in the auth argument in post request
500, 'Internal server error' -> error occured on PBRcontrol, report immediately
400, 'Node_id not provided'
404, 'Server not found' -> PBRcontrol is not running
200, [data] -> success, return log data in a list ordered from oldest to most recent
204, '[]' -> no data to show for given parameters