-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathdata.py
More file actions
228 lines (198 loc) · 6.2 KB
/
Copy pathdata.py
File metadata and controls
228 lines (198 loc) · 6.2 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
import queue
from config.config import Config
from DataStructures.logger import Logger
from DataStructures.loggingQueue import LoggingQueue
from DataStructures.uiQueue import UIQueue
class Data:
"""
Data is a set of variables which are essentially global variables which hold information
about the gcode file opened, the machine which is connected, and the user's settings. These
variables are NOT thread-safe. The queue system should always be used for passing information
between threads.
"""
"""
Data available to all widgets
"""
# Gcodes contains all of the lines of gcode in the opened file
clients = []
gcode = []
gcodeFileUnits = "INCHES"
sentCustomGCode = ""
compressedGCode = None
compressedGCode3D = None
version = "1.27"
stockFirmwareVersion = None
customFirmwareVersion = None
holeyFirmwareVersion = None
controllerFirmwareVersion = 0
"""
Version Updater
"""
lastChecked = -1
pyInstallCurrentVersion = 0.95
pyInstallUpdateAvailable = False
pyInstallUpdateBrowserUrl = ""
pyInstallUpdateVersion = 0
pyInstallPlatform = "rpi"
pyInstallType = "singlefolder"
pyInstallInstalledPath = ""
# all of the available COM ports
comPorts = []
# This defines which COM port is used
comport = ""
# stores value to indicate whether or not fake_servo is enabled
fakeServoStatus = False
# The index of the next unread line of Gcode
gcodeIndex = 0
# Index of changes in z
zMoves = []
# Holds the current value of the feed rate
feedRate = 20
# holds the address of the g-code file so that the gcode can be refreshed
gcodeFile = ""
importFile = ""
# holds the current gcode x,y,z position
currentGcodePost = [0.0, 0.0, 0.0]
# the current position of the cutting head
currentpos = [0.0, 0.0, 0.0]
target = [0.0, 0.0, 0.0]
units = "MM"
# Gcode positioning mode:
# 0 = G90 (Absolute)
# 1 = G91 (Relative)
positioningMode = 0
tolerance = 0.5
gcodeShift = [0.0, 0.0] # the amount that the gcode has been shifted
currentTool = 0 # current tool.. upon startup, 0 is the same value as what the controller would have.
currentZTarget = 0 # current target for Z-Axis move. Need to track so if user pauses, we can move back to that spot.
message = "" # used to update the client
logger = Logger() # the module which records the machines behavior to review later
config = Config()
# Background image stuff, persist but not saved
backgroundFile = None
backgroundTexture = None
backgroundManualReg = []
backgroundRedraw = False
"""
Flags
"""
# sets a flag if the gcode is being uploaded currently
uploadFlag = 0
previousUploadStatus = 0
manualZAxisAdjust = False
# this is used to determine the first time the position is received from the machine
firstTimePosFlag = 0
# report if the serial connection is open
connectionStatus = 0
# is the calibration process currently underway 0 -> false
calibrationInProcess = False
inPIDVelocityTest = False
inPIDPositionTest = False
PIDVelocityTestVersion = 0
PIDPositionTestVersion = 0
"""
Pointers to Objects
"""
serialPort = None # this is a pointer to the program serial port object
requestSerialClose = (
False # this is used to request the serialThread to gracefully close the port
)
triangularCalibration = None # points to the triangular calibration object
holeyCalibration = None # points to the triangular calibration object
opticalCalibration = None # points to the optical calibration object
opticalCalibrationImage = None # stores the current image
opticalCalibrationImageUpdated = False # stores whether its been updated or not
opticalCalibrationTestImage = None # stores the current image
opticalCalibrationTestImageUpdated = False # stores whether its been updated or not
cameraImage = None
cameraImageUpdated = False
continuousCamera = False
gpioActions = None
boardManager = None
"""
Colors
"""
fontColor = "[color=7a7a7a]"
drawingColor = [0.47, 0.47, 0.47]
posIndicatorColor = [0, 0, 0]
targetIndicatorColor = [1, 0, 0]
"""
Misc UI bits that need to be saved between invocations (but not saved)
"""
zPush = None
zPushUnits = "MM"
zReadoutPos = 0.00
zPopupUnits = None
zStepSizeVal = 0.1
"""
Queues
"""
message_queue = LoggingQueue(logger)
ui_controller_queue = queue.Queue()
ui_queue1 = UIQueue()
alog_streamer_queue = queue.Queue(
1000
) # used for sending log to client screen.. limit to 1000 "items"
log_streamer_queue = queue.Queue(
1000
) # used for sending log to client screen.. limit to 1000 "items"
console_queue = queue.Queue() # used for printing to terminal
mcp_queue = queue.Queue() # used for sending messages to WebMCP(if enabled)
webMCPActive = False # start false until WebMCP connects
gcode_queue = queue.Queue()
quick_queue = queue.Queue()
"""
Position and Error values
"""
xval = 0.0
yval = 0.0
zval = 0.0
time = 0.0
xval_prev = -99990.0
yval_prev = -99990.0
zval_prev = -99990.0
time_prev = -99990.0
velocity_prev = 0
velocity_filter = 0.5
wasmoving = 1
leftError = 0.0
rightError = 0.0
leftError_prev = -99999.0
rightError_prev = -99999.9
"""
Chain lengths as reported by controller
"""
leftChain = 1610
rightChain = 1610
"""
Sled position computed from controller reported chain lengths
"""
computedX = 0
computedY = 0
"""
Buffer size as reported by controller
"""
bufferSize = 127
pausedzval = None
pausedPositioningMode = 0
pausedUnits = "INCHES"
"""
GCode Position Values
"""
previousPosX = 0.0
previousPosY = 0.0
previousPosZ = 0.0
"""
Board data
"""
currentBoard = None
shutdown = False
hostAddress = "-"
platform = "RPI"
platformHome = ""
def __init__(self):
"""
Initializations.
"""
self.logger.data = self
self.config.data = self