CK-InoDrive-API 0.2.8b0__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ck_inodrive_api-1.0.0/CK_InoDrive_API.egg-info/PKG-INFO +129 -0
- {CK-InoDrive-API-0.2.8b0 → ck_inodrive_api-1.0.0}/CK_InoDrive_API.egg-info/SOURCES.txt +5 -0
- ck_inodrive_api-1.0.0/CK_InoDrive_API.egg-info/requires.txt +3 -0
- ck_inodrive_api-1.0.0/CkInoDriveAPI/IO.py +336 -0
- ck_inodrive_api-1.0.0/CkInoDriveAPI/ck_ca.crt +15 -0
- {CK-InoDrive-API-0.2.8b0 → ck_inodrive_api-1.0.0}/CkInoDriveAPI/defines.py +65 -1
- {CK-InoDrive-API-0.2.8b0 → ck_inodrive_api-1.0.0}/CkInoDriveAPI/discoverLan.py +10 -133
- ck_inodrive_api-1.0.0/CkInoDriveAPI/discoverWs.py +42 -0
- {CK-InoDrive-API-0.2.8b0 → ck_inodrive_api-1.0.0}/CkInoDriveAPI/file.py +53 -44
- ck_inodrive_api-1.0.0/CkInoDriveAPI/inoDrive.py +133 -0
- ck_inodrive_api-1.0.0/CkInoDriveAPI/sysControl.py +104 -0
- ck_inodrive_api-1.0.0/CkInoDriveAPI/userApp.py +586 -0
- ck_inodrive_api-1.0.0/CkInoDriveAPI/utils.py +479 -0
- ck_inodrive_api-1.0.0/CkInoDriveAPI/wsHandle.py +540 -0
- ck_inodrive_api-1.0.0/LICENSE.txt +7 -0
- ck_inodrive_api-1.0.0/PKG-INFO +129 -0
- ck_inodrive_api-1.0.0/README.txt +1984 -0
- {CK-InoDrive-API-0.2.8b0 → ck_inodrive_api-1.0.0}/setup.py +14 -9
- CK-InoDrive-API-0.2.8b0/CK_InoDrive_API.egg-info/PKG-INFO +0 -99
- CK-InoDrive-API-0.2.8b0/CK_InoDrive_API.egg-info/requires.txt +0 -3
- CK-InoDrive-API-0.2.8b0/CkInoDriveAPI/discoverWs.py +0 -164
- CK-InoDrive-API-0.2.8b0/CkInoDriveAPI/inoDrive.py +0 -309
- CK-InoDrive-API-0.2.8b0/CkInoDriveAPI/userApp.py +0 -565
- CK-InoDrive-API-0.2.8b0/CkInoDriveAPI/utils.py +0 -373
- CK-InoDrive-API-0.2.8b0/CkInoDriveAPI/wsHandle.py +0 -359
- CK-InoDrive-API-0.2.8b0/PKG-INFO +0 -99
- {CK-InoDrive-API-0.2.8b0 → ck_inodrive_api-1.0.0}/CK_InoDrive_API.egg-info/dependency_links.txt +0 -0
- {CK-InoDrive-API-0.2.8b0 → ck_inodrive_api-1.0.0}/CK_InoDrive_API.egg-info/top_level.txt +0 -0
- {CK-InoDrive-API-0.2.8b0 → ck_inodrive_api-1.0.0}/CkInoDriveAPI/__init__.py +0 -0
- {CK-InoDrive-API-0.2.8b0 → ck_inodrive_api-1.0.0}/setup.cfg +0 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: CK-InoDrive-API
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: InoDrive API Library
|
|
5
|
+
Home-page: https://cardinalkinetic.com
|
|
6
|
+
Author: Cardinal Kinetic
|
|
7
|
+
Author-email: support@cardinalkinetic.com
|
|
8
|
+
License: https://www.cardinalkinetic.com/user-manual/api/inodrive-py
|
|
9
|
+
Project-URL: Documentation, https://www.cardinalkinetic.com/user-manual/api/inodrive-py
|
|
10
|
+
Keywords: InoWorx InoDrive InoSync MotionControl ServoControl
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE.txt
|
|
20
|
+
License-File: README.txt
|
|
21
|
+
Requires-Dist: websocket-client==1.8.0
|
|
22
|
+
Requires-Dist: ifaddr==0.2.0
|
|
23
|
+
Requires-Dist: msgpack==1.0.8
|
|
24
|
+
|
|
25
|
+
#### **Installation**
|
|
26
|
+
|
|
27
|
+
Install and Update package via [pip](https://pip.pypa.io/en/stable/getting-started/)
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
pip install CK-InoDrive-API
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
#### **Usage**
|
|
34
|
+
|
|
35
|
+
Importing Library
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
# Import InoDrive API library
|
|
39
|
+
import CkInoDriveAPI
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Create InoDrive Object using WebSocket
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
# Create instance to InoDrive module object
|
|
46
|
+
# Connect by Name
|
|
47
|
+
Drive = CkInoDriveAPI.InoDrive(target='Name')
|
|
48
|
+
|
|
49
|
+
# Connect by Serial Number
|
|
50
|
+
Drive = CkInoDriveAPI.InoDrive(target='SN')
|
|
51
|
+
|
|
52
|
+
# Connect by IP Address
|
|
53
|
+
Drive = CkInoDriveAPI.InoDrive(target='IPv4 Address')
|
|
54
|
+
|
|
55
|
+
# Auto connect
|
|
56
|
+
Drive = CkInoDriveAPI.InoDrive(target='IPv4 Address', autoConnect=True)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Read and Write Variable's
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
# Connect to the drive
|
|
63
|
+
Drive.connect()
|
|
64
|
+
|
|
65
|
+
# Read variable with name 'VariableName'
|
|
66
|
+
Drive.UserApp.read_var('VariableName')
|
|
67
|
+
|
|
68
|
+
# Write variable with name 'VariableName' and value equal to 1
|
|
69
|
+
Drive.UserApp.write_var('VariableName', 1)
|
|
70
|
+
|
|
71
|
+
# Disconnect from the drive
|
|
72
|
+
Drive.disconnect()
|
|
73
|
+
|
|
74
|
+
# Drive object cleanup
|
|
75
|
+
Drive.dispose()
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Get and Set Output's
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# Connect to the drive
|
|
82
|
+
Drive.connect()
|
|
83
|
+
|
|
84
|
+
# Read Output 2
|
|
85
|
+
state = Drive.IO.get_output(2)
|
|
86
|
+
|
|
87
|
+
# Take control of InoDrive module to override output state
|
|
88
|
+
Drive.SysControl.take_control(True)
|
|
89
|
+
|
|
90
|
+
# Set Output 2 to On state
|
|
91
|
+
Drive.IO.set_output(2, True)
|
|
92
|
+
state = Drive.IO.get_output(2)
|
|
93
|
+
|
|
94
|
+
# Disable module override
|
|
95
|
+
Drive.SysControl.take_control(False)
|
|
96
|
+
|
|
97
|
+
# Disconnect from the drive
|
|
98
|
+
Drive.disconnect()
|
|
99
|
+
|
|
100
|
+
# Drive object cleanup
|
|
101
|
+
Drive.dispose()
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Change Module Name (Power cycle InoDrive for changes to take effect)
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
# Connect to the drive
|
|
108
|
+
Drive.connect()
|
|
109
|
+
|
|
110
|
+
# Read module configuration file
|
|
111
|
+
config_file = Drive.File.read_module_config()
|
|
112
|
+
|
|
113
|
+
# Set new module name
|
|
114
|
+
config_file['name'] = "NewName"
|
|
115
|
+
|
|
116
|
+
# Write configuration changes out
|
|
117
|
+
Drive.File.write_module_config(config_file)
|
|
118
|
+
|
|
119
|
+
# Disconnect from the drive
|
|
120
|
+
Drive.disconnect()
|
|
121
|
+
|
|
122
|
+
# Drive object cleanup
|
|
123
|
+
Drive.dispose()
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### **Links**
|
|
127
|
+
|
|
128
|
+
- [API Documentation](https://www.cardinalkinetic.com/user-manual/api/inodrive-py)
|
|
129
|
+
- [Company Website](https://www.cardinalkinetic.com)
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
LICENSE.txt
|
|
2
|
+
README.txt
|
|
1
3
|
setup.py
|
|
2
4
|
CK_InoDrive_API.egg-info/PKG-INFO
|
|
3
5
|
CK_InoDrive_API.egg-info/SOURCES.txt
|
|
4
6
|
CK_InoDrive_API.egg-info/dependency_links.txt
|
|
5
7
|
CK_InoDrive_API.egg-info/requires.txt
|
|
6
8
|
CK_InoDrive_API.egg-info/top_level.txt
|
|
9
|
+
CkInoDriveAPI/IO.py
|
|
7
10
|
CkInoDriveAPI/__init__.py
|
|
11
|
+
CkInoDriveAPI/ck_ca.crt
|
|
8
12
|
CkInoDriveAPI/defines.py
|
|
9
13
|
CkInoDriveAPI/discoverLan.py
|
|
10
14
|
CkInoDriveAPI/discoverWs.py
|
|
11
15
|
CkInoDriveAPI/file.py
|
|
12
16
|
CkInoDriveAPI/inoDrive.py
|
|
17
|
+
CkInoDriveAPI/sysControl.py
|
|
13
18
|
CkInoDriveAPI/userApp.py
|
|
14
19
|
CkInoDriveAPI/utils.py
|
|
15
20
|
CkInoDriveAPI/wsHandle.py
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from .defines import CK
|
|
4
|
+
from .defines import OP_STATE
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class IO(object):
|
|
8
|
+
def __init__(self, **kwargs):
|
|
9
|
+
self._get_connection_handle = kwargs.get('get_connection_handle')
|
|
10
|
+
|
|
11
|
+
@property
|
|
12
|
+
def _connection_handle(self):
|
|
13
|
+
return self._get_connection_handle()
|
|
14
|
+
|
|
15
|
+
def dispose(self):
|
|
16
|
+
return
|
|
17
|
+
|
|
18
|
+
def get_metrics(self):
|
|
19
|
+
try:
|
|
20
|
+
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.GET_METRICS])
|
|
21
|
+
|
|
22
|
+
if response.get('error'):
|
|
23
|
+
return {'success': False, 'Error': f'InoDrive GetMetrics Error: {str(response.get("error"))}'}
|
|
24
|
+
|
|
25
|
+
data = response['data'][0]
|
|
26
|
+
|
|
27
|
+
# Operational State
|
|
28
|
+
if data.get('state'):
|
|
29
|
+
for key, value in data['state'].items():
|
|
30
|
+
data['state'][key] = OP_STATE.get_state_by_value(value)
|
|
31
|
+
|
|
32
|
+
# Ethernet Ports
|
|
33
|
+
ports = {}
|
|
34
|
+
for port in data['eth_ports']:
|
|
35
|
+
ports.update({
|
|
36
|
+
port['name']: {
|
|
37
|
+
'link': port['link'],
|
|
38
|
+
'errors': port['errors'],
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
data['eth_ports'] = ports
|
|
42
|
+
|
|
43
|
+
data.update({'success': True})
|
|
44
|
+
|
|
45
|
+
return data
|
|
46
|
+
except Exception as ex:
|
|
47
|
+
return {'success': False, 'error': str(ex)}
|
|
48
|
+
|
|
49
|
+
def get_temperatures(self):
|
|
50
|
+
try:
|
|
51
|
+
data = self.get_metrics()
|
|
52
|
+
if data.get('error'):
|
|
53
|
+
logging.error(data['error'])
|
|
54
|
+
return None
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
'case': data['temperatures']['case'],
|
|
58
|
+
'cpu': data['temperatures']['cpu'],
|
|
59
|
+
'fets': data['temperatures']['fets'],
|
|
60
|
+
'outputs': data['temperatures']['outputs'],
|
|
61
|
+
'regen': data['temperatures']['regen']
|
|
62
|
+
}
|
|
63
|
+
except Exception as ex:
|
|
64
|
+
logging.exception(ex)
|
|
65
|
+
return None
|
|
66
|
+
|
|
67
|
+
def get_input_voltage(self):
|
|
68
|
+
try:
|
|
69
|
+
data = self.get_metrics()
|
|
70
|
+
if data.get('error'):
|
|
71
|
+
logging.error(data['error'])
|
|
72
|
+
return None
|
|
73
|
+
|
|
74
|
+
return data['v_in']
|
|
75
|
+
except Exception as ex:
|
|
76
|
+
logging.exception(ex)
|
|
77
|
+
return None
|
|
78
|
+
|
|
79
|
+
def get_operational_state(self):
|
|
80
|
+
try:
|
|
81
|
+
data = self.get_metrics()
|
|
82
|
+
if data.get('error'):
|
|
83
|
+
logging.error(data['error'])
|
|
84
|
+
return None
|
|
85
|
+
|
|
86
|
+
return data['state']
|
|
87
|
+
except Exception as ex:
|
|
88
|
+
logging.exception(ex)
|
|
89
|
+
return None
|
|
90
|
+
|
|
91
|
+
def get_ethernet_ports(self):
|
|
92
|
+
try:
|
|
93
|
+
data = self.get_metrics()
|
|
94
|
+
if data.get('error'):
|
|
95
|
+
logging.error(data['error'])
|
|
96
|
+
return None
|
|
97
|
+
|
|
98
|
+
return data['eth_ports']
|
|
99
|
+
except Exception as ex:
|
|
100
|
+
logging.exception(ex)
|
|
101
|
+
return None
|
|
102
|
+
|
|
103
|
+
def get_inputs_data(self):
|
|
104
|
+
try:
|
|
105
|
+
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.GET_INPUTS])
|
|
106
|
+
|
|
107
|
+
if response.get('error'):
|
|
108
|
+
return {'success': False, 'Error': f'InoDrive GetInputData Error: {str(response.get("error"))}'}
|
|
109
|
+
|
|
110
|
+
data = response['data'][0]
|
|
111
|
+
data.update({'success': True})
|
|
112
|
+
|
|
113
|
+
return data
|
|
114
|
+
except Exception as ex:
|
|
115
|
+
return {'success': False, 'error': str(ex)}
|
|
116
|
+
|
|
117
|
+
def get_accelerometer(self):
|
|
118
|
+
try:
|
|
119
|
+
data = self.get_inputs_data()
|
|
120
|
+
if data.get('error'):
|
|
121
|
+
logging.error(data['error'])
|
|
122
|
+
return None
|
|
123
|
+
|
|
124
|
+
return {'x': data['g_forces'][0], 'y': data['g_forces'][1], 'z': data['g_forces'][2]}
|
|
125
|
+
except Exception as ex:
|
|
126
|
+
logging.exception(ex)
|
|
127
|
+
return None
|
|
128
|
+
|
|
129
|
+
def get_input(self, input=None):
|
|
130
|
+
try:
|
|
131
|
+
data = self.get_inputs_data()
|
|
132
|
+
if data.get('error'):
|
|
133
|
+
logging.error(data['error'])
|
|
134
|
+
return None
|
|
135
|
+
|
|
136
|
+
if type(input) is int and 0 <= input <= 3:
|
|
137
|
+
return 1 if (data['digital'] >> input) & 0x1 else 0
|
|
138
|
+
else:
|
|
139
|
+
return data['digital']
|
|
140
|
+
except Exception as ex:
|
|
141
|
+
logging.exception(ex)
|
|
142
|
+
|
|
143
|
+
return None
|
|
144
|
+
|
|
145
|
+
def get_safety_input(self, input=None):
|
|
146
|
+
try:
|
|
147
|
+
data = self.get_inputs_data()
|
|
148
|
+
if data.get('error'):
|
|
149
|
+
logging.error(data['error'])
|
|
150
|
+
return None
|
|
151
|
+
|
|
152
|
+
if type(input) is int and 0 <= input <= 1:
|
|
153
|
+
return 1 if (data['safety'] >> input) & 0x1 else 0
|
|
154
|
+
else:
|
|
155
|
+
return data['safety']
|
|
156
|
+
except Exception as ex:
|
|
157
|
+
logging.exception(ex)
|
|
158
|
+
|
|
159
|
+
return None
|
|
160
|
+
|
|
161
|
+
def get_analog_input(self):
|
|
162
|
+
try:
|
|
163
|
+
data = self.get_inputs_data()
|
|
164
|
+
if data.get('error'):
|
|
165
|
+
logging.error(data['error'])
|
|
166
|
+
return None
|
|
167
|
+
|
|
168
|
+
return data['analog']
|
|
169
|
+
except Exception as ex:
|
|
170
|
+
logging.exception(ex)
|
|
171
|
+
|
|
172
|
+
return None
|
|
173
|
+
|
|
174
|
+
def set_input_polarity(self, target=None, state=None):
|
|
175
|
+
try:
|
|
176
|
+
|
|
177
|
+
if target == 'all' and state is not None:
|
|
178
|
+
target = -1
|
|
179
|
+
if type(state) is str:
|
|
180
|
+
state = 0xf if state.upper() == 'NPN' else 0x0
|
|
181
|
+
else:
|
|
182
|
+
state = 0xf if state else 0x0
|
|
183
|
+
elif target == 'val' and type(state) is int:
|
|
184
|
+
target = -1
|
|
185
|
+
elif type(target) is int and 0 <= target <= 3 and state is not None:
|
|
186
|
+
if type(state) is str:
|
|
187
|
+
state = 0x1 if state.upper() == 'NPN' else 0x0
|
|
188
|
+
else:
|
|
189
|
+
state = 0x1 if state else 0x0
|
|
190
|
+
else:
|
|
191
|
+
logging.error(f'InoDrive SetInputPolarity Error: target or state not supported...')
|
|
192
|
+
return None
|
|
193
|
+
|
|
194
|
+
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.SET_INPUT_POLARITY, target, state])
|
|
195
|
+
|
|
196
|
+
if response.get('error'):
|
|
197
|
+
logging.error(f'InoDrive SetInputPolarity Error: {str(response)}')
|
|
198
|
+
return None
|
|
199
|
+
|
|
200
|
+
return True
|
|
201
|
+
except Exception as ex:
|
|
202
|
+
logging.exception(ex)
|
|
203
|
+
|
|
204
|
+
return None
|
|
205
|
+
|
|
206
|
+
def get_input_polarity(self, input=None):
|
|
207
|
+
try:
|
|
208
|
+
data = self.get_inputs_data()
|
|
209
|
+
if data.get('error'):
|
|
210
|
+
logging.error(data['error'])
|
|
211
|
+
return None
|
|
212
|
+
|
|
213
|
+
if type(input) is int and 0 <= input <= 3:
|
|
214
|
+
return 'NPN' if (data['polarity'] >> input) & 0x1 else 'PNP'
|
|
215
|
+
else:
|
|
216
|
+
return data['polarity']
|
|
217
|
+
except Exception as ex:
|
|
218
|
+
logging.exception(ex)
|
|
219
|
+
|
|
220
|
+
return None
|
|
221
|
+
|
|
222
|
+
def get_outputs_data(self):
|
|
223
|
+
try:
|
|
224
|
+
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.GET_OUTPUTS])
|
|
225
|
+
|
|
226
|
+
if response.get('error'):
|
|
227
|
+
return {'success': False, 'Error': f'InoDrive GetOutputData Error: {str(response.get("error"))}'}
|
|
228
|
+
|
|
229
|
+
data = response['data'][0]
|
|
230
|
+
data.update({'success': True})
|
|
231
|
+
|
|
232
|
+
return data
|
|
233
|
+
except Exception as ex:
|
|
234
|
+
return {'success': False, 'error': str(ex)}
|
|
235
|
+
|
|
236
|
+
def set_output(self, target=None, state=None):
|
|
237
|
+
try:
|
|
238
|
+
if target == 'all' and state is not None:
|
|
239
|
+
target = -1
|
|
240
|
+
state = 0x7 if state else 0x0
|
|
241
|
+
elif target == 'val' and type(state) is int:
|
|
242
|
+
target = -1
|
|
243
|
+
elif type(target) is int and 0 <= target <= 2 and state is not None:
|
|
244
|
+
state = 0x1 if state else 0x0
|
|
245
|
+
else:
|
|
246
|
+
logging.error(f'InoDrive SetOutput Error: target os state not supported...')
|
|
247
|
+
return None
|
|
248
|
+
|
|
249
|
+
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.SET_OUTPUTS, target, state])
|
|
250
|
+
|
|
251
|
+
if response.get('error'):
|
|
252
|
+
logging.error(f'InoDrive SetOutput Error: {str(response)}')
|
|
253
|
+
return None
|
|
254
|
+
|
|
255
|
+
return True
|
|
256
|
+
except Exception as ex:
|
|
257
|
+
logging.exception(ex)
|
|
258
|
+
|
|
259
|
+
return None
|
|
260
|
+
|
|
261
|
+
def get_output(self, output=None):
|
|
262
|
+
try:
|
|
263
|
+
|
|
264
|
+
data = self.get_outputs_data()
|
|
265
|
+
if data.get('error'):
|
|
266
|
+
logging.error(data['error'])
|
|
267
|
+
return None
|
|
268
|
+
|
|
269
|
+
if type(output) is int and 0 <= output <= 2:
|
|
270
|
+
return 1 if (data['digital'] >> output) & 0x1 else 0
|
|
271
|
+
else:
|
|
272
|
+
return data['digital']
|
|
273
|
+
|
|
274
|
+
except Exception as ex:
|
|
275
|
+
logging.exception(ex)
|
|
276
|
+
|
|
277
|
+
return None
|
|
278
|
+
|
|
279
|
+
def get_output_fault(self, output=None):
|
|
280
|
+
try:
|
|
281
|
+
|
|
282
|
+
data = self.get_outputs_data()
|
|
283
|
+
if data.get('error'):
|
|
284
|
+
logging.error(data['error'])
|
|
285
|
+
return None
|
|
286
|
+
|
|
287
|
+
if type(output) is int and 0 <= output <= 2:
|
|
288
|
+
return 1 if (data['digital_faults'] >> output) & 0x1 else 0
|
|
289
|
+
else:
|
|
290
|
+
return data['digital_faults']
|
|
291
|
+
|
|
292
|
+
except Exception as ex:
|
|
293
|
+
logging.exception(ex)
|
|
294
|
+
|
|
295
|
+
return None
|
|
296
|
+
|
|
297
|
+
def set_holding_brake(self, state=False):
|
|
298
|
+
try:
|
|
299
|
+
|
|
300
|
+
response = self._connection_handle.msg_pack_request([CK.MSG_PACK.SET_HOLDING_BRAKE, True if state else False])
|
|
301
|
+
|
|
302
|
+
if response.get('error'):
|
|
303
|
+
logging.error(f'InoDrive GetOutputFault Error: {str(response)}')
|
|
304
|
+
return None
|
|
305
|
+
|
|
306
|
+
return True
|
|
307
|
+
except Exception as ex:
|
|
308
|
+
logging.exception(ex)
|
|
309
|
+
|
|
310
|
+
return None
|
|
311
|
+
|
|
312
|
+
def get_holding_brake(self):
|
|
313
|
+
try:
|
|
314
|
+
data = self.get_outputs_data()
|
|
315
|
+
if data.get('error'):
|
|
316
|
+
logging.error(data['error'])
|
|
317
|
+
return None
|
|
318
|
+
|
|
319
|
+
return 0x1 if data['brake'] else 0x0
|
|
320
|
+
except Exception as ex:
|
|
321
|
+
logging.exception(ex)
|
|
322
|
+
|
|
323
|
+
return None
|
|
324
|
+
|
|
325
|
+
def get_holding_brake_fault(self):
|
|
326
|
+
try:
|
|
327
|
+
data = self.get_outputs_data()
|
|
328
|
+
if data.get('error'):
|
|
329
|
+
logging.error(data['error'])
|
|
330
|
+
return None
|
|
331
|
+
|
|
332
|
+
return 0x1 if data['brake_fault'] else 0x0
|
|
333
|
+
except Exception as ex:
|
|
334
|
+
logging.exception(ex)
|
|
335
|
+
|
|
336
|
+
return None
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIICUTCCAdigAwIBAgIUKSVqbARTYaxckTUEA7Gby+uWD8IwCgYIKoZIzj0EAwIw
|
|
3
|
+
VzELMAkGA1UEBhMCVVMxETAPBgNVBAgMCEtlbnR1Y2t5MRgwFgYDVQQKDA9DYXJk
|
|
4
|
+
aW5hbEtpbmV0aWMxGzAZBgNVBAMMEkNhcmRpbmFsS2luZXRpYy1DQTAgFw0yNDA3
|
|
5
|
+
MTUxODM1NTVaGA8yMDk5MDQxMzE4MzU1NVowVzELMAkGA1UEBhMCVVMxETAPBgNV
|
|
6
|
+
BAgMCEtlbnR1Y2t5MRgwFgYDVQQKDA9DYXJkaW5hbEtpbmV0aWMxGzAZBgNVBAMM
|
|
7
|
+
EkNhcmRpbmFsS2luZXRpYy1DQTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvtdcSO
|
|
8
|
+
PH4qPKdA/wSbraw88KgoiBmJMaD3ko4Gaix6iZSBTEK1TU+Oxp0XwVuaQxa0J7hp
|
|
9
|
+
xcjuy3BLYDhfF5e5Fp/Tjc4qaQNDZs9Z0MbVytZeNtrm7u4lwKWsjIjhUqNjMGEw
|
|
10
|
+
HQYDVR0OBBYEFOQ3kaz6Bd2kAHicNWlIoWdSYclMMB8GA1UdIwQYMBaAFOQ3kaz6
|
|
11
|
+
Bd2kAHicNWlIoWdSYclMMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGG
|
|
12
|
+
MAoGCCqGSM49BAMCA2cAMGQCMFhAt55Z+O88sJ60Z2FcGmYztu6QF18tdj04YlQX
|
|
13
|
+
SBWZ8tdpWofMsJi6yHwKlhqqQgIwVEpeh5RSuVSGmZAfYNFLLSnAYV0LnkKEAmuZ
|
|
14
|
+
2YwmOc7BTjgjgnZrhb9538baKIaG
|
|
15
|
+
-----END CERTIFICATE-----
|
|
@@ -8,7 +8,6 @@ class _MsgTypes(object):
|
|
|
8
8
|
IPv6 = 0x17
|
|
9
9
|
IPv6_CIDR = 0x18
|
|
10
10
|
NTP_TIME = 0x19
|
|
11
|
-
NTP_TIME = 0x19
|
|
12
11
|
PTP_TIME = 0x2a
|
|
13
12
|
RESERVED_TIME = 0x2b
|
|
14
13
|
MSG_PACK = 0x2c
|
|
@@ -33,6 +32,7 @@ class _MsgFile(object):
|
|
|
33
32
|
BACKUP_FW_TRANSFER = 0x203
|
|
34
33
|
TRANSFER = 0x204
|
|
35
34
|
LIST = 0x205
|
|
35
|
+
WEBPAGE_TRANSFER = 0x208
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
class _MsgSpecial(object):
|
|
@@ -56,6 +56,7 @@ class _MsgResult(object):
|
|
|
56
56
|
MULTIPLE_COMMANDS = 0x7
|
|
57
57
|
FILE_ERROR = 0x8
|
|
58
58
|
UPGRADE_ERROR = 0x9
|
|
59
|
+
MSG_PACK_NOT_SUPPORTED = 0xB
|
|
59
60
|
|
|
60
61
|
|
|
61
62
|
class _MsgCommand(object):
|
|
@@ -70,6 +71,66 @@ class _MsgJsonApi(object):
|
|
|
70
71
|
DISCONNECT = 255
|
|
71
72
|
|
|
72
73
|
|
|
74
|
+
class _MsgPack(object):
|
|
75
|
+
INVALID = 0x0
|
|
76
|
+
BEACON = 0x1
|
|
77
|
+
CONSOLE_ENABLE = 0x2
|
|
78
|
+
TAKE_CONTROL = 0x3
|
|
79
|
+
MODULE_INFO = 0x4
|
|
80
|
+
|
|
81
|
+
GET_INPUTS = 0x10
|
|
82
|
+
GET_OUTPUTS = 0x11
|
|
83
|
+
GET_METRICS = 0x12
|
|
84
|
+
LIST_VARIABLES = 0x16
|
|
85
|
+
ACCESS_VARIABLES = 0x17
|
|
86
|
+
|
|
87
|
+
SET_INPUT_POLARITY = 0x20
|
|
88
|
+
SET_OUTPUTS = 0x21
|
|
89
|
+
SET_HOLDING_BRAKE = 0x22
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class _MsgPackErrors(object):
|
|
93
|
+
NONE = 0x0
|
|
94
|
+
OUT_OF_MEMORY = 0x1
|
|
95
|
+
INTERNAL_ERROR = 0x2
|
|
96
|
+
BAD_INPUT = 0x3
|
|
97
|
+
BAD_VALUES = 0x4
|
|
98
|
+
NOT_IMPLEMENTED = 0x5
|
|
99
|
+
NOT_ALLOWED = 0x6
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class _OPState(object):
|
|
103
|
+
STATES = {
|
|
104
|
+
"invalid": 0,
|
|
105
|
+
"initializing": 1,
|
|
106
|
+
"initFailed": 2,
|
|
107
|
+
"faulted": 3,
|
|
108
|
+
"operational": 4,
|
|
109
|
+
|
|
110
|
+
"inFailSafeMode": 10,
|
|
111
|
+
"connectingToPeers": 11,
|
|
112
|
+
|
|
113
|
+
"motorNotConfigured": 20,
|
|
114
|
+
"motorDisabled": 21,
|
|
115
|
+
"motorI2tLimited": 22,
|
|
116
|
+
"motorInSto": 23,
|
|
117
|
+
"motorLimitSwitchActive": 24,
|
|
118
|
+
"motorHoldingBrakeFault": 25,
|
|
119
|
+
"motorStopped": 26,
|
|
120
|
+
"motorRunning": 27,
|
|
121
|
+
|
|
122
|
+
"externalControl": 40,
|
|
123
|
+
"uAppNotPresent": 41,
|
|
124
|
+
"uAppStartDelay": 42,
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
def get_state_by_value(self, state):
|
|
128
|
+
for key, value in self.STATES.items():
|
|
129
|
+
if state == value:
|
|
130
|
+
return key
|
|
131
|
+
return "invalid"
|
|
132
|
+
|
|
133
|
+
|
|
73
134
|
class _CkDefines(object):
|
|
74
135
|
NOP = 0x0
|
|
75
136
|
RESPONSE = 0x1
|
|
@@ -82,6 +143,8 @@ class _CkDefines(object):
|
|
|
82
143
|
RESULT = _MsgResult()
|
|
83
144
|
COMMAND = _MsgCommand()
|
|
84
145
|
JSON_API = _MsgJsonApi()
|
|
146
|
+
MSG_PACK = _MsgPack()
|
|
147
|
+
MSG_PACK_ERRORS = _MsgPackErrors()
|
|
85
148
|
|
|
86
149
|
API_VAR_ACCESS = {
|
|
87
150
|
'none': 0,
|
|
@@ -382,3 +445,4 @@ class _CkDefines(object):
|
|
|
382
445
|
|
|
383
446
|
|
|
384
447
|
CK = _CkDefines()
|
|
448
|
+
OP_STATE = _OPState()
|