UC2-REST 0.2.0.27__tar.gz → 0.2.0.28__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.
Files changed (39) hide show
  1. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/PKG-INFO +1 -1
  2. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/UC2_REST.egg-info/PKG-INFO +1 -1
  3. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/UC2_REST.egg-info/SOURCES.txt +0 -2
  4. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/UC2Client.py +6 -23
  5. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/__init__.py +0 -1
  6. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/__version__.py +1 -1
  7. uc2_rest-0.2.0.27/uc2rest/config.py +0 -164
  8. uc2_rest-0.2.0.27/uc2rest/config_.py +0 -104
  9. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/LICENSE +0 -0
  10. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/README.md +0 -0
  11. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/UC2_REST.egg-info/dependency_links.txt +0 -0
  12. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/UC2_REST.egg-info/not-zip-safe +0 -0
  13. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/UC2_REST.egg-info/requires.txt +0 -0
  14. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/UC2_REST.egg-info/top_level.txt +0 -0
  15. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/setup.cfg +0 -0
  16. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/setup.py +0 -0
  17. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/MockSerial.py +0 -0
  18. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/analog.py +0 -0
  19. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/camera.py +0 -0
  20. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/cmdrecorder.py +0 -0
  21. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/digitalout.py +0 -0
  22. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/galvo.py +0 -0
  23. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/gripper.py +0 -0
  24. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/home.py +0 -0
  25. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/laser.py +0 -0
  26. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/ledmatrix.py +0 -0
  27. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/logger.py +0 -0
  28. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/message.py +0 -0
  29. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/modules.py +0 -0
  30. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/motor.py +0 -0
  31. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/mserial.py +0 -0
  32. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/objective.py +0 -0
  33. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/pid.py +0 -0
  34. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/rotator.py +0 -0
  35. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/slm.py +0 -0
  36. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/state.py +0 -0
  37. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/temperature.py +0 -0
  38. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/utils.py +0 -0
  39. {uc2_rest-0.2.0.27 → uc2_rest-0.2.0.28}/uc2rest/wifi.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UC2-REST
3
- Version: 0.2.0.27
3
+ Version: 0.2.0.28
4
4
  Summary: This pacage will help you to drive the ESP32-driven microscopy control modules from UC2
5
5
  Home-page: https://github.com/openUC2/UC2-REST
6
6
  Author: Benedict Diederich
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UC2-REST
3
- Version: 0.2.0.27
3
+ Version: 0.2.0.28
4
4
  Summary: This pacage will help you to drive the ESP32-driven microscopy control modules from UC2
5
5
  Home-page: https://github.com/openUC2/UC2-REST
6
6
  Author: Benedict Diederich
@@ -14,8 +14,6 @@ uc2rest/__version__.py
14
14
  uc2rest/analog.py
15
15
  uc2rest/camera.py
16
16
  uc2rest/cmdrecorder.py
17
- uc2rest/config.py
18
- uc2rest/config_.py
19
17
  uc2rest/digitalout.py
20
18
  uc2rest/galvo.py
21
19
  uc2rest/gripper.py
@@ -8,7 +8,6 @@ Copyright 2021 Benedict Diederich, released under LGPL 3.0 or later
8
8
  from .mserial import Serial
9
9
  from .mserial import SerialManagerWrapper
10
10
  from .galvo import Galvo
11
- from .config import config
12
11
  from .ledmatrix import LedMatrix
13
12
  from .motor import Motor
14
13
  from .gripper import Gripper
@@ -39,11 +38,11 @@ class UC2Client(object):
39
38
 
40
39
  is_wifi = False
41
40
  is_serial = False
41
+ BAUDRATE = 115200
42
42
 
43
- # BAUDRATE = 500000
44
- BAUDRATE = 500000
45
-
46
- def __init__(self, host=None, port=31950, serialport=None, identity="UC2_Feather", baudrate=BAUDRATE, NLeds=64, SerialManager=None, DEBUG=False, logger=None, skipFirmwareCheck=False):
43
+ def __init__(self, host=None, port=31950, serialport=None, identity="UC2_Feather", baudrate=BAUDRATE,
44
+ NLeds=64, SerialManager=None, DEBUG=False, logger=None, skipFirmwareCheck=False,
45
+ isPyScript=False):
47
46
  '''
48
47
  This client connects to the UC2-REST microcontroller that can be found here
49
48
  https://github.com/openUC2/UC2-REST
@@ -61,7 +60,7 @@ class UC2Client(object):
61
60
  self.logger = logger
62
61
 
63
62
  # perhaps we are in the browser?
64
- self.isPyScript = False
63
+ self.isPyScript = isPyScript
65
64
 
66
65
  # initialize communication channel (# connect to wifi or usb)
67
66
  if serialport is not None:
@@ -89,18 +88,9 @@ class UC2Client(object):
89
88
 
90
89
  # import libraries depending on API version
91
90
  self.logger.debug("Using API version 2")
92
-
93
- #FIXME
94
- #self.set_state(debug=False)
95
-
91
+
96
92
  # initialize state
97
93
  self.state = State(self)
98
- if not self.isPyScript:
99
- state = self.state.get_state()
100
-
101
- # initialize config
102
- if not self.isPyScript:
103
- self.config = config(self)
104
94
 
105
95
  # initialize cmdRecorder
106
96
  self.cmdRecorder = cmdRecorder(self)
@@ -149,13 +139,6 @@ class UC2Client(object):
149
139
 
150
140
  # initialize messaging
151
141
  self.message = Message(self)
152
-
153
- # initialize config
154
- if False: # not self.isPyScript:
155
- self.config = config(self)
156
- try: self.pinConfig = self.config.loadConfigDevice()
157
- except: self.pinConfig = None
158
-
159
142
 
160
143
  # initialize module controller
161
144
  self.modules = Modules(parent=self)
@@ -1,2 +1 @@
1
- from .config import *
2
1
  from .UC2Client import *
@@ -6,7 +6,7 @@ __version__.py
6
6
 
7
7
  __title__ = 'UC2-REST'
8
8
  __description__ = 'This pacage will help you to drive the ESP32-driven microscopy control modules from UC2'
9
- __version__ = "v0.2.0.27"
9
+ __version__ = "v0.2.0.28"
10
10
  __author__ = 'Benedict Diederich'
11
11
  __author_email__ = 'benedictdied@gmail.com'
12
12
  __license__ = 'GPL v3'
@@ -1,164 +0,0 @@
1
- import json
2
-
3
-
4
- class config(object):
5
- def __init__(self, parent, configFilePath=None):
6
- self._parent = parent
7
- self.configFilePath = configFilePath
8
-
9
- if self.configFilePath is not None:
10
- self.configFilePath = "./config.json"
11
- #TODO: read file and load
12
-
13
- self.configFile = self.loadDefaultConfig()
14
-
15
-
16
- '''
17
- default Configuration
18
- '''
19
-
20
- def loadDefaultConfig(self):
21
- self.defaultConfig = {"motorconfig":
22
- [{"stepperid": 0, "dir": 18, "step": 19, "enable": 12, "dir_inverted": False, "step_inverted": False, "enable_inverted": False, "speed": 0, "speedmax": 200000, "max_pos": 100000, "min_pos": -100000},
23
- {"stepperid": 1, "dir": 16, "step": 26, "enable": 12, "dir_inverted": False, "step_inverted": False, "enable_inverted": False, "speed": 0, "speedmax": 200000, "max_pos": 100000, "min_pos": -100000},
24
- {"stepperid": 2, "dir": 27, "step": 25, "enable": 12, "dir_inverted": False, "step_inverted": False, "enable_inverted": False, "speed": 0, "speedmax": 200000, "max_pos": 100000, "min_pos": -100000},
25
- {"stepperid": 3, "dir": 14, "step": 17, "enable": 12, "dir_inverted": False, "step_inverted": False, "enable_inverted": False, "speed": 0, "speedmax": 200000, "max_pos": 100000, "min_pos": -100000}],
26
- "ledconfig": {"ledArrNum": 0, "ledArrPin": 0, "LEDArrMode": [0, 1, 2, 3, 4, 5, 6, 7], "led_ison": False},
27
- "stateconfig": {"identifier_name": "UC2_Feather", "identifier_id": "V1.2", "identifier_date": "Nov 7 202212:52:14", "identifier_author": "BD", "IDENTIFIER_NAME": ""},
28
- "laserconfig": {"LASER1pin": 0, "LASER2pin": 0, "LASER3pin": 0}}
29
- return self.defaultConfig
30
-
31
- def setDefaultConfig(self, configDict=None, configFile=None):
32
- if configDict is not None:
33
- self.defaultConfig = configDict
34
- if configFile is not None:
35
- self.defaultConfig = self.json2dict(configFile)
36
-
37
-
38
- def checkIfInitializedConfig(self, currentConfig, defaultConfig):
39
- ''' This should check if the different components were initialized with the config file
40
- Otherwise we won't be able to retrieve any signals from the device
41
- '''
42
- # TODO: Not implemented yet!
43
- if currentConfig['motorconfig'] == defaultConfig['motorconfig']:
44
- print("motorconfig not initialized")
45
- return False
46
-
47
- def json2dict(self, jsonFile):
48
- with open(jsonFile) as f:
49
- data = json.load(f)
50
- return data
51
-
52
- def checkConfig(self, configfile):
53
- # check if config is valid
54
- if type(configfile['motorconfig'])==list and len(configfile['motorconfig'])==4:
55
- print("loaded config is valid")
56
- return True
57
- else:
58
- print("config is not valid")
59
- return False
60
-
61
-
62
- '''
63
- send configuration to device
64
- '''
65
-
66
- '''################################################################################################################################################
67
- Set Configurations
68
- ################################################################################################################################################'''
69
-
70
- def loadConfigDevice(self, timeout=1):
71
- # load current configuration from device
72
- if 0:
73
- path = '/config_get'
74
- payload = {
75
- }
76
- r = self._parent.post_json(path, payload, timeout=timeout)
77
-
78
- if type(r) != dict:
79
- r = self.loadDefaultConfig()
80
- else:
81
- self.setDefaultConfig(r)
82
- return r
83
-
84
- else:
85
- motorconfig = self._parent.motor.get_motors()
86
- ledconfig = self._parent.led.get_ledpin()
87
- laserconfig = self._parent.laser.get_laserpins()
88
- stateconfig = self._parent.state.get_state()
89
- self.configfile = {"motorconfig": motorconfig,
90
- "ledconfig": ledconfig,
91
- "laserconfig": laserconfig,
92
- "stateconfig": stateconfig}
93
-
94
- # check if config is valid
95
- isValidConfig = self.checkConfig(self.configfile)
96
-
97
- if isValidConfig:
98
- return self.configfile
99
- else:
100
- return self.loadDefaultConfig()
101
-
102
-
103
-
104
- def setConfigDevice(self, configfile, timeout=1):
105
- # push changes back to device
106
- if 0:
107
- path = '/config_set'
108
- if type(configfile)==dict:
109
- payload = configfile
110
- else:
111
- return None
112
- r = self._parent.post_json(path, payload, timeout=timeout)
113
- return r
114
- else:
115
- # set all lasers
116
- notAllowedPins = (1,2,3,5)
117
- if configfile["laserconfig"]["LASER1pin"] in notAllowedPins:
118
- self._parent.laser.set_laserpin(1, configfile["laserconfig"]["LASER1pin"])
119
- if configfile["laserconfig"]["LASER2pin"] in notAllowedPins:
120
- self._parent.laser.set_laserpin(2, configfile["laserconfig"]["LASER2pin"])
121
- if configfile["laserconfig"]["LASER3pin"] in notAllowedPins:
122
- self._parent.laser.set_laserpin(3, configfile["laserconfig"]["LASER3pin"])
123
- self._parent.laser.set_laserpin(laserid=1, laserpin=configfile["laserconfig"]["LASER1pin"])
124
- self._parent.laser.set_laserpin(laserid=2, laserpin=configfile["laserconfig"]["LASER2pin"])
125
- self._parent.laser.set_laserpin(laserid=3, laserpin=configfile["laserconfig"]["LASER3pin"])
126
-
127
- # set led
128
- if configfile["ledconfig"]["ledArrPin"] in notAllowedPins:
129
- self._parent.led.set_ledpin(ledArrPin=configfile["ledconfig"]["ledArrPin"], ledArrNum=configfile["ledconfig"]["ledArrNum"])
130
- self._parent.led.set_ledpin(ledArrPin=configfile["ledconfig"]["ledArrPin"], ledArrNum=configfile["ledconfig"]["ledArrNum"])
131
-
132
-
133
- # set motors
134
- if configfile["motorconfig"][0]["dir"] in notAllowedPins:
135
- configfile["motorconfig"][0]["dir"] = 0
136
- if configfile["motorconfig"][0]["step"] in notAllowedPins:
137
- configfile["motorconfig"][0]["step"] = 0
138
- if configfile["motorconfig"][1]["dir"] in notAllowedPins:
139
- configfile["motorconfig"][1]["dir"] = 0
140
- if configfile["motorconfig"][1]["step"] in notAllowedPins:
141
- configfile["motorconfig"][1]["step"] = 0
142
- if configfile["motorconfig"][2]["dir"] in notAllowedPins:
143
- configfile["motorconfig"][2]["dir"] = 0
144
- if configfile["motorconfig"][2]["step"] in notAllowedPins:
145
- configfile["motorconfig"][2]["step"] = 0
146
- if configfile["motorconfig"][3]["dir"] in notAllowedPins:
147
- configfile["motorconfig"][3]["dir"] = 0
148
- if configfile["motorconfig"][3]["step"] in notAllowedPins:
149
- configfile["motorconfig"][3]["step"] = 0
150
- if configfile["motorconfig"][0]["enable"] in notAllowedPins:
151
- configfile["motorconfig"][0]["enable"] = 0
152
- configfile["motorconfig"][1]["enable"] = 0
153
- configfile["motorconfig"][2]["enable"] = 0
154
- configfile["motorconfig"][3]["enable"] = 0
155
-
156
- motorconfig = {
157
- "motor":{
158
- "steppers":
159
- configfile["motorconfig"]}}
160
- # check if pins are valid
161
-
162
- self._parent.motor.set_motors(settingsdict=motorconfig)
163
-
164
-
@@ -1,104 +0,0 @@
1
- import json
2
-
3
-
4
- class config(object):
5
- def __init__(self, parent, configFilePath=None):
6
- self._parent = parent
7
- self.configFilePath = configFilePath
8
-
9
- if self.configFilePath is not None:
10
- self.configFilePath = "./config.json"
11
- #TODO: read file and load
12
-
13
- self.configFile = self.loadDefaultConfig()
14
-
15
-
16
- '''
17
- default Configuration
18
- '''
19
-
20
- def loadDefaultConfig(self):
21
- self.defaultConfig = {"motorconfig":
22
- [{"stepperid": 0, "dir": 18, "step": 19, "enable": 12, "dir_inverted": False, "step_inverted": False, "enable_inverted": False, "speed": 0, "speedmax": 200000, "max_pos": 100000, "min_pos": -100000},
23
- {"stepperid": 1, "dir": 16, "step": 26, "enable": 12, "dir_inverted": False, "step_inverted": False, "enable_inverted": False, "speed": 0, "speedmax": 200000, "max_pos": 100000, "min_pos": -100000},
24
- {"stepperid": 2, "dir": 27, "step": 25, "enable": 12, "dir_inverted": False, "step_inverted": False, "enable_inverted": False, "speed": 0, "speedmax": 200000, "max_pos": 100000, "min_pos": -100000},
25
- {"stepperid": 3, "dir": 14, "step": 17, "enable": 12, "dir_inverted": False, "step_inverted": False, "enable_inverted": False, "speed": 0, "speedmax": 200000, "max_pos": 100000, "min_pos": -100000}],
26
- "ledconfig": {"ledArrNum": 0, "ledArrPin": 0, "LEDArrMode": [0, 1, 2, 3, 4, 5, 6, 7], "led_ison": False},
27
- "stateconfig": {"identifier_name": "UC2_Feather", "identifier_id": "V1.2", "identifier_date": "Nov 7 202212:52:14", "identifier_author": "BD", "IDENTIFIER_NAME": ""}}
28
- return self.defaultConfig
29
-
30
- def setDefaultConfig(self, configDict=None, configFile=None):
31
- if configDict is not None:
32
- self.defaultConfig = configDict
33
- if configFile is not None:
34
- self.defaultConfig = self.json2dict(configFile)
35
-
36
- # importing the module
37
-
38
-
39
- def json2dict(self, jsonFile):
40
- with open(jsonFile) as f:
41
- data = json.load(f)
42
- return data
43
-
44
-
45
- '''
46
- send configuration to device
47
- '''
48
-
49
- '''################################################################################################################################################
50
- Set Configurations
51
- ################################################################################################################################################'''
52
-
53
- def loadConfigDevice(self, timeout=1):
54
- # load current configuration from device
55
- if 0:
56
- path = '/config_get'
57
- payload = {
58
- }
59
- r = self._parent.post_json(path, payload, timeout=timeout)
60
-
61
- self.setDefaultConfig(r)
62
-
63
- if type(r) != dict:
64
- r = self.loadDefaultConfig()
65
- return r
66
-
67
- else:
68
- motorconfig = self._parent.motor.get_motors()
69
- ledconfig = self._parent.led.get_ledpin()
70
- laserconfig = self._parent.laser.get_laserpins()
71
- stateconfig = self._parent.state.get_state()
72
- self.configfile = {"motorconfig": motorconfig,
73
- "ledconfig": ledconfig,
74
- "laserconfig": laserconfig,
75
- "stateconfig": stateconfig}
76
- return self.configfile
77
-
78
-
79
- def setConfigDevice(self, configfile, timeout=1):
80
- # push changes back to device
81
- if 0:
82
- path = '/config_set'
83
- if type(configfile)==dict:
84
- payload = configfile
85
- else:
86
- return None
87
- r = self._parent.post_json(path, payload, timeout=timeout)
88
- return r
89
- else:
90
- # set all lasers
91
- self._parent.laser.set_laserpin(laserid=1, laserpin=configfile["laserconfig"]["LASER1pin"])
92
- self._parent.laser.set_laserpin(laserid=2, laserpin=configfile["laserconfig"]["LASER2pin"])
93
- self._parent.laser.set_laserpin(laserid=3, laserpin=configfile["laserconfig"]["LASER3pin"])
94
- # set led
95
- self._parent.led.set_ledpin(ledArrPin=configfile["ledconfig"]["ledArrPin"], ledArrNum=configfile["ledconfig"]["ledArrNum"])
96
- # set motors
97
-
98
- motorconfig = {
99
- "motor":{
100
- "steppers":
101
- configfile["motorconfig"]}}
102
- self._parent.motor.set_motors(settingsdict=motorconfig)
103
-
104
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes