meerk40t 0.9.3001__py2.py3-none-any.whl → 0.9.7010__py2.py3-none-any.whl

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 (445) hide show
  1. meerk40t/__init__.py +1 -1
  2. meerk40t/balormk/balor_params.py +167 -167
  3. meerk40t/balormk/clone_loader.py +457 -457
  4. meerk40t/balormk/controller.py +1566 -1512
  5. meerk40t/balormk/cylindermod.py +64 -0
  6. meerk40t/balormk/device.py +966 -1959
  7. meerk40t/balormk/driver.py +778 -591
  8. meerk40t/balormk/galvo_commands.py +1195 -0
  9. meerk40t/balormk/gui/balorconfig.py +237 -111
  10. meerk40t/balormk/gui/balorcontroller.py +191 -184
  11. meerk40t/balormk/gui/baloroperationproperties.py +116 -115
  12. meerk40t/balormk/gui/corscene.py +845 -0
  13. meerk40t/balormk/gui/gui.py +179 -147
  14. meerk40t/balormk/livelightjob.py +466 -382
  15. meerk40t/balormk/mock_connection.py +131 -109
  16. meerk40t/balormk/plugin.py +133 -135
  17. meerk40t/balormk/usb_connection.py +306 -301
  18. meerk40t/camera/__init__.py +1 -1
  19. meerk40t/camera/camera.py +514 -397
  20. meerk40t/camera/gui/camerapanel.py +1241 -1095
  21. meerk40t/camera/gui/gui.py +58 -58
  22. meerk40t/camera/plugin.py +441 -399
  23. meerk40t/ch341/__init__.py +27 -27
  24. meerk40t/ch341/ch341device.py +628 -628
  25. meerk40t/ch341/libusb.py +595 -589
  26. meerk40t/ch341/mock.py +171 -171
  27. meerk40t/ch341/windriver.py +157 -157
  28. meerk40t/constants.py +13 -0
  29. meerk40t/core/__init__.py +1 -1
  30. meerk40t/core/bindalias.py +550 -539
  31. meerk40t/core/core.py +47 -47
  32. meerk40t/core/cutcode/cubiccut.py +73 -73
  33. meerk40t/core/cutcode/cutcode.py +315 -312
  34. meerk40t/core/cutcode/cutgroup.py +141 -137
  35. meerk40t/core/cutcode/cutobject.py +192 -185
  36. meerk40t/core/cutcode/dwellcut.py +37 -37
  37. meerk40t/core/cutcode/gotocut.py +29 -29
  38. meerk40t/core/cutcode/homecut.py +29 -29
  39. meerk40t/core/cutcode/inputcut.py +34 -34
  40. meerk40t/core/cutcode/linecut.py +33 -33
  41. meerk40t/core/cutcode/outputcut.py +34 -34
  42. meerk40t/core/cutcode/plotcut.py +335 -335
  43. meerk40t/core/cutcode/quadcut.py +61 -61
  44. meerk40t/core/cutcode/rastercut.py +168 -148
  45. meerk40t/core/cutcode/waitcut.py +34 -34
  46. meerk40t/core/cutplan.py +1843 -1316
  47. meerk40t/core/drivers.py +330 -329
  48. meerk40t/core/elements/align.py +801 -669
  49. meerk40t/core/elements/branches.py +1844 -1507
  50. meerk40t/core/elements/clipboard.py +229 -219
  51. meerk40t/core/elements/element_treeops.py +4561 -2837
  52. meerk40t/core/elements/element_types.py +125 -105
  53. meerk40t/core/elements/elements.py +4329 -3617
  54. meerk40t/core/elements/files.py +117 -64
  55. meerk40t/core/elements/geometry.py +473 -224
  56. meerk40t/core/elements/grid.py +467 -316
  57. meerk40t/core/elements/materials.py +158 -94
  58. meerk40t/core/elements/notes.py +50 -38
  59. meerk40t/core/elements/offset_clpr.py +933 -912
  60. meerk40t/core/elements/offset_mk.py +963 -955
  61. meerk40t/core/elements/penbox.py +339 -267
  62. meerk40t/core/elements/placements.py +300 -83
  63. meerk40t/core/elements/render.py +785 -687
  64. meerk40t/core/elements/shapes.py +2618 -2092
  65. meerk40t/core/elements/trace.py +651 -563
  66. meerk40t/core/elements/tree_commands.py +415 -409
  67. meerk40t/core/elements/undo_redo.py +116 -58
  68. meerk40t/core/elements/wordlist.py +319 -200
  69. meerk40t/core/exceptions.py +9 -9
  70. meerk40t/core/laserjob.py +220 -220
  71. meerk40t/core/logging.py +63 -63
  72. meerk40t/core/node/blobnode.py +83 -86
  73. meerk40t/core/node/bootstrap.py +105 -103
  74. meerk40t/core/node/branch_elems.py +40 -31
  75. meerk40t/core/node/branch_ops.py +45 -38
  76. meerk40t/core/node/branch_regmark.py +48 -41
  77. meerk40t/core/node/cutnode.py +29 -32
  78. meerk40t/core/node/effect_hatch.py +375 -257
  79. meerk40t/core/node/effect_warp.py +398 -0
  80. meerk40t/core/node/effect_wobble.py +441 -309
  81. meerk40t/core/node/elem_ellipse.py +404 -309
  82. meerk40t/core/node/elem_image.py +1082 -801
  83. meerk40t/core/node/elem_line.py +358 -292
  84. meerk40t/core/node/elem_path.py +259 -201
  85. meerk40t/core/node/elem_point.py +129 -102
  86. meerk40t/core/node/elem_polyline.py +310 -246
  87. meerk40t/core/node/elem_rect.py +376 -286
  88. meerk40t/core/node/elem_text.py +445 -418
  89. meerk40t/core/node/filenode.py +59 -40
  90. meerk40t/core/node/groupnode.py +138 -74
  91. meerk40t/core/node/image_processed.py +777 -766
  92. meerk40t/core/node/image_raster.py +156 -113
  93. meerk40t/core/node/layernode.py +31 -31
  94. meerk40t/core/node/mixins.py +135 -107
  95. meerk40t/core/node/node.py +1427 -1304
  96. meerk40t/core/node/nutils.py +117 -114
  97. meerk40t/core/node/op_cut.py +462 -335
  98. meerk40t/core/node/op_dots.py +296 -251
  99. meerk40t/core/node/op_engrave.py +414 -311
  100. meerk40t/core/node/op_image.py +755 -369
  101. meerk40t/core/node/op_raster.py +787 -522
  102. meerk40t/core/node/place_current.py +37 -40
  103. meerk40t/core/node/place_point.py +329 -126
  104. meerk40t/core/node/refnode.py +58 -47
  105. meerk40t/core/node/rootnode.py +225 -219
  106. meerk40t/core/node/util_console.py +48 -48
  107. meerk40t/core/node/util_goto.py +84 -65
  108. meerk40t/core/node/util_home.py +61 -61
  109. meerk40t/core/node/util_input.py +102 -102
  110. meerk40t/core/node/util_output.py +102 -102
  111. meerk40t/core/node/util_wait.py +65 -65
  112. meerk40t/core/parameters.py +709 -707
  113. meerk40t/core/planner.py +875 -785
  114. meerk40t/core/plotplanner.py +656 -652
  115. meerk40t/core/space.py +120 -113
  116. meerk40t/core/spoolers.py +706 -705
  117. meerk40t/core/svg_io.py +1836 -1549
  118. meerk40t/core/treeop.py +534 -445
  119. meerk40t/core/undos.py +278 -124
  120. meerk40t/core/units.py +784 -680
  121. meerk40t/core/view.py +393 -322
  122. meerk40t/core/webhelp.py +62 -62
  123. meerk40t/core/wordlist.py +513 -504
  124. meerk40t/cylinder/cylinder.py +247 -0
  125. meerk40t/cylinder/gui/cylindersettings.py +41 -0
  126. meerk40t/cylinder/gui/gui.py +24 -0
  127. meerk40t/device/__init__.py +1 -1
  128. meerk40t/device/basedevice.py +322 -123
  129. meerk40t/device/devicechoices.py +50 -0
  130. meerk40t/device/dummydevice.py +163 -128
  131. meerk40t/device/gui/defaultactions.py +618 -602
  132. meerk40t/device/gui/effectspanel.py +114 -0
  133. meerk40t/device/gui/formatterpanel.py +253 -290
  134. meerk40t/device/gui/warningpanel.py +337 -260
  135. meerk40t/device/mixins.py +13 -13
  136. meerk40t/dxf/__init__.py +1 -1
  137. meerk40t/dxf/dxf_io.py +766 -554
  138. meerk40t/dxf/plugin.py +47 -35
  139. meerk40t/external_plugins.py +79 -79
  140. meerk40t/external_plugins_build.py +28 -28
  141. meerk40t/extra/cag.py +112 -116
  142. meerk40t/extra/coolant.py +403 -0
  143. meerk40t/extra/encode_detect.py +198 -0
  144. meerk40t/extra/ezd.py +1165 -1165
  145. meerk40t/extra/hershey.py +835 -340
  146. meerk40t/extra/imageactions.py +322 -316
  147. meerk40t/extra/inkscape.py +630 -622
  148. meerk40t/extra/lbrn.py +424 -424
  149. meerk40t/extra/outerworld.py +284 -0
  150. meerk40t/extra/param_functions.py +1542 -1556
  151. meerk40t/extra/potrace.py +257 -253
  152. meerk40t/extra/serial_exchange.py +118 -0
  153. meerk40t/extra/updater.py +602 -453
  154. meerk40t/extra/vectrace.py +147 -146
  155. meerk40t/extra/winsleep.py +83 -83
  156. meerk40t/extra/xcs_reader.py +597 -0
  157. meerk40t/fill/fills.py +781 -335
  158. meerk40t/fill/patternfill.py +1061 -1061
  159. meerk40t/fill/patterns.py +614 -567
  160. meerk40t/grbl/control.py +87 -87
  161. meerk40t/grbl/controller.py +990 -903
  162. meerk40t/grbl/device.py +1081 -768
  163. meerk40t/grbl/driver.py +989 -771
  164. meerk40t/grbl/emulator.py +532 -497
  165. meerk40t/grbl/gcodejob.py +783 -767
  166. meerk40t/grbl/gui/grblconfiguration.py +373 -298
  167. meerk40t/grbl/gui/grblcontroller.py +485 -271
  168. meerk40t/grbl/gui/grblhardwareconfig.py +269 -153
  169. meerk40t/grbl/gui/grbloperationconfig.py +105 -0
  170. meerk40t/grbl/gui/gui.py +147 -116
  171. meerk40t/grbl/interpreter.py +44 -44
  172. meerk40t/grbl/loader.py +22 -22
  173. meerk40t/grbl/mock_connection.py +56 -56
  174. meerk40t/grbl/plugin.py +294 -264
  175. meerk40t/grbl/serial_connection.py +93 -88
  176. meerk40t/grbl/tcp_connection.py +81 -79
  177. meerk40t/grbl/ws_connection.py +112 -0
  178. meerk40t/gui/__init__.py +1 -1
  179. meerk40t/gui/about.py +2042 -296
  180. meerk40t/gui/alignment.py +1644 -1608
  181. meerk40t/gui/autoexec.py +199 -0
  182. meerk40t/gui/basicops.py +791 -670
  183. meerk40t/gui/bufferview.py +77 -71
  184. meerk40t/gui/busy.py +170 -133
  185. meerk40t/gui/choicepropertypanel.py +1673 -1469
  186. meerk40t/gui/consolepanel.py +706 -542
  187. meerk40t/gui/devicepanel.py +687 -581
  188. meerk40t/gui/dialogoptions.py +110 -107
  189. meerk40t/gui/executejob.py +316 -306
  190. meerk40t/gui/fonts.py +90 -90
  191. meerk40t/gui/functionwrapper.py +252 -0
  192. meerk40t/gui/gui_mixins.py +729 -0
  193. meerk40t/gui/guicolors.py +205 -182
  194. meerk40t/gui/help_assets/help_assets.py +218 -201
  195. meerk40t/gui/helper.py +154 -0
  196. meerk40t/gui/hersheymanager.py +1430 -846
  197. meerk40t/gui/icons.py +3422 -2747
  198. meerk40t/gui/imagesplitter.py +555 -508
  199. meerk40t/gui/keymap.py +354 -344
  200. meerk40t/gui/laserpanel.py +892 -806
  201. meerk40t/gui/laserrender.py +1470 -1232
  202. meerk40t/gui/lasertoolpanel.py +805 -793
  203. meerk40t/gui/magnetoptions.py +436 -0
  204. meerk40t/gui/materialmanager.py +2917 -0
  205. meerk40t/gui/materialtest.py +1722 -1694
  206. meerk40t/gui/mkdebug.py +646 -359
  207. meerk40t/gui/mwindow.py +163 -140
  208. meerk40t/gui/navigationpanels.py +2605 -2467
  209. meerk40t/gui/notes.py +143 -142
  210. meerk40t/gui/opassignment.py +414 -410
  211. meerk40t/gui/operation_info.py +310 -299
  212. meerk40t/gui/plugin.py +494 -328
  213. meerk40t/gui/position.py +714 -669
  214. meerk40t/gui/preferences.py +901 -650
  215. meerk40t/gui/propertypanels/attributes.py +1461 -1131
  216. meerk40t/gui/propertypanels/blobproperty.py +117 -114
  217. meerk40t/gui/propertypanels/consoleproperty.py +83 -80
  218. meerk40t/gui/propertypanels/gotoproperty.py +77 -0
  219. meerk40t/gui/propertypanels/groupproperties.py +223 -217
  220. meerk40t/gui/propertypanels/hatchproperty.py +489 -469
  221. meerk40t/gui/propertypanels/imageproperty.py +2244 -1384
  222. meerk40t/gui/propertypanels/inputproperty.py +59 -58
  223. meerk40t/gui/propertypanels/opbranchproperties.py +82 -80
  224. meerk40t/gui/propertypanels/operationpropertymain.py +1890 -1638
  225. meerk40t/gui/propertypanels/outputproperty.py +59 -58
  226. meerk40t/gui/propertypanels/pathproperty.py +389 -380
  227. meerk40t/gui/propertypanels/placementproperty.py +1214 -383
  228. meerk40t/gui/propertypanels/pointproperty.py +140 -136
  229. meerk40t/gui/propertypanels/propertywindow.py +313 -181
  230. meerk40t/gui/propertypanels/rasterwizardpanels.py +996 -912
  231. meerk40t/gui/propertypanels/regbranchproperties.py +76 -0
  232. meerk40t/gui/propertypanels/textproperty.py +770 -755
  233. meerk40t/gui/propertypanels/waitproperty.py +56 -55
  234. meerk40t/gui/propertypanels/warpproperty.py +121 -0
  235. meerk40t/gui/propertypanels/wobbleproperty.py +255 -204
  236. meerk40t/gui/ribbon.py +2468 -2210
  237. meerk40t/gui/scene/scene.py +1100 -1051
  238. meerk40t/gui/scene/sceneconst.py +22 -22
  239. meerk40t/gui/scene/scenepanel.py +439 -349
  240. meerk40t/gui/scene/scenespacewidget.py +365 -365
  241. meerk40t/gui/scene/widget.py +518 -505
  242. meerk40t/gui/scenewidgets/affinemover.py +215 -215
  243. meerk40t/gui/scenewidgets/attractionwidget.py +315 -309
  244. meerk40t/gui/scenewidgets/bedwidget.py +120 -97
  245. meerk40t/gui/scenewidgets/elementswidget.py +137 -107
  246. meerk40t/gui/scenewidgets/gridwidget.py +785 -745
  247. meerk40t/gui/scenewidgets/guidewidget.py +765 -765
  248. meerk40t/gui/scenewidgets/laserpathwidget.py +66 -66
  249. meerk40t/gui/scenewidgets/machineoriginwidget.py +86 -86
  250. meerk40t/gui/scenewidgets/nodeselector.py +28 -28
  251. meerk40t/gui/scenewidgets/rectselectwidget.py +589 -346
  252. meerk40t/gui/scenewidgets/relocatewidget.py +33 -33
  253. meerk40t/gui/scenewidgets/reticlewidget.py +83 -83
  254. meerk40t/gui/scenewidgets/selectionwidget.py +2952 -2756
  255. meerk40t/gui/simpleui.py +357 -333
  256. meerk40t/gui/simulation.py +2431 -2094
  257. meerk40t/gui/snapoptions.py +208 -203
  258. meerk40t/gui/spoolerpanel.py +1227 -1180
  259. meerk40t/gui/statusbarwidgets/defaultoperations.py +480 -353
  260. meerk40t/gui/statusbarwidgets/infowidget.py +520 -483
  261. meerk40t/gui/statusbarwidgets/opassignwidget.py +356 -355
  262. meerk40t/gui/statusbarwidgets/selectionwidget.py +172 -171
  263. meerk40t/gui/statusbarwidgets/shapepropwidget.py +754 -236
  264. meerk40t/gui/statusbarwidgets/statusbar.py +272 -260
  265. meerk40t/gui/statusbarwidgets/statusbarwidget.py +268 -270
  266. meerk40t/gui/statusbarwidgets/strokewidget.py +267 -251
  267. meerk40t/gui/themes.py +200 -78
  268. meerk40t/gui/tips.py +591 -0
  269. meerk40t/gui/toolwidgets/circlebrush.py +35 -35
  270. meerk40t/gui/toolwidgets/toolcircle.py +248 -242
  271. meerk40t/gui/toolwidgets/toolcontainer.py +82 -77
  272. meerk40t/gui/toolwidgets/tooldraw.py +97 -90
  273. meerk40t/gui/toolwidgets/toolellipse.py +219 -212
  274. meerk40t/gui/toolwidgets/toolimagecut.py +25 -132
  275. meerk40t/gui/toolwidgets/toolline.py +39 -144
  276. meerk40t/gui/toolwidgets/toollinetext.py +79 -236
  277. meerk40t/gui/toolwidgets/toollinetext_inline.py +296 -0
  278. meerk40t/gui/toolwidgets/toolmeasure.py +160 -216
  279. meerk40t/gui/toolwidgets/toolnodeedit.py +2088 -2074
  280. meerk40t/gui/toolwidgets/toolnodemove.py +92 -94
  281. meerk40t/gui/toolwidgets/toolparameter.py +754 -668
  282. meerk40t/gui/toolwidgets/toolplacement.py +108 -108
  283. meerk40t/gui/toolwidgets/toolpoint.py +68 -59
  284. meerk40t/gui/toolwidgets/toolpointlistbuilder.py +294 -0
  285. meerk40t/gui/toolwidgets/toolpointmove.py +183 -0
  286. meerk40t/gui/toolwidgets/toolpolygon.py +288 -403
  287. meerk40t/gui/toolwidgets/toolpolyline.py +38 -196
  288. meerk40t/gui/toolwidgets/toolrect.py +211 -207
  289. meerk40t/gui/toolwidgets/toolrelocate.py +72 -72
  290. meerk40t/gui/toolwidgets/toolribbon.py +598 -113
  291. meerk40t/gui/toolwidgets/tooltabedit.py +546 -0
  292. meerk40t/gui/toolwidgets/tooltext.py +98 -89
  293. meerk40t/gui/toolwidgets/toolvector.py +213 -204
  294. meerk40t/gui/toolwidgets/toolwidget.py +39 -39
  295. meerk40t/gui/usbconnect.py +98 -91
  296. meerk40t/gui/utilitywidgets/buttonwidget.py +18 -18
  297. meerk40t/gui/utilitywidgets/checkboxwidget.py +90 -90
  298. meerk40t/gui/utilitywidgets/controlwidget.py +14 -14
  299. meerk40t/gui/utilitywidgets/cyclocycloidwidget.py +343 -340
  300. meerk40t/gui/utilitywidgets/debugwidgets.py +148 -0
  301. meerk40t/gui/utilitywidgets/handlewidget.py +27 -27
  302. meerk40t/gui/utilitywidgets/harmonograph.py +450 -447
  303. meerk40t/gui/utilitywidgets/openclosewidget.py +40 -40
  304. meerk40t/gui/utilitywidgets/rotationwidget.py +54 -54
  305. meerk40t/gui/utilitywidgets/scalewidget.py +75 -75
  306. meerk40t/gui/utilitywidgets/seekbarwidget.py +183 -183
  307. meerk40t/gui/utilitywidgets/togglewidget.py +142 -142
  308. meerk40t/gui/utilitywidgets/toolbarwidget.py +8 -8
  309. meerk40t/gui/wordlisteditor.py +985 -931
  310. meerk40t/gui/wxmeerk40t.py +1444 -1169
  311. meerk40t/gui/wxmmain.py +5578 -4112
  312. meerk40t/gui/wxmribbon.py +1591 -1076
  313. meerk40t/gui/wxmscene.py +1635 -1453
  314. meerk40t/gui/wxmtree.py +2410 -2089
  315. meerk40t/gui/wxutils.py +1769 -1099
  316. meerk40t/gui/zmatrix.py +102 -102
  317. meerk40t/image/__init__.py +1 -1
  318. meerk40t/image/dither.py +429 -0
  319. meerk40t/image/imagetools.py +2778 -2269
  320. meerk40t/internal_plugins.py +150 -130
  321. meerk40t/kernel/__init__.py +63 -12
  322. meerk40t/kernel/channel.py +259 -212
  323. meerk40t/kernel/context.py +538 -538
  324. meerk40t/kernel/exceptions.py +41 -41
  325. meerk40t/kernel/functions.py +463 -414
  326. meerk40t/kernel/jobs.py +100 -100
  327. meerk40t/kernel/kernel.py +3809 -3571
  328. meerk40t/kernel/lifecycles.py +71 -71
  329. meerk40t/kernel/module.py +49 -49
  330. meerk40t/kernel/service.py +147 -147
  331. meerk40t/kernel/settings.py +383 -343
  332. meerk40t/lihuiyu/controller.py +883 -876
  333. meerk40t/lihuiyu/device.py +1181 -1069
  334. meerk40t/lihuiyu/driver.py +1466 -1372
  335. meerk40t/lihuiyu/gui/gui.py +127 -106
  336. meerk40t/lihuiyu/gui/lhyaccelgui.py +377 -363
  337. meerk40t/lihuiyu/gui/lhycontrollergui.py +741 -651
  338. meerk40t/lihuiyu/gui/lhydrivergui.py +470 -446
  339. meerk40t/lihuiyu/gui/lhyoperationproperties.py +238 -237
  340. meerk40t/lihuiyu/gui/tcpcontroller.py +226 -190
  341. meerk40t/lihuiyu/interpreter.py +53 -53
  342. meerk40t/lihuiyu/laserspeed.py +450 -450
  343. meerk40t/lihuiyu/loader.py +90 -90
  344. meerk40t/lihuiyu/parser.py +404 -404
  345. meerk40t/lihuiyu/plugin.py +101 -102
  346. meerk40t/lihuiyu/tcp_connection.py +111 -109
  347. meerk40t/main.py +231 -165
  348. meerk40t/moshi/builder.py +788 -781
  349. meerk40t/moshi/controller.py +505 -499
  350. meerk40t/moshi/device.py +495 -442
  351. meerk40t/moshi/driver.py +862 -696
  352. meerk40t/moshi/gui/gui.py +78 -76
  353. meerk40t/moshi/gui/moshicontrollergui.py +538 -522
  354. meerk40t/moshi/gui/moshidrivergui.py +87 -75
  355. meerk40t/moshi/plugin.py +43 -43
  356. meerk40t/network/console_server.py +102 -57
  357. meerk40t/network/kernelserver.py +10 -9
  358. meerk40t/network/tcp_server.py +142 -140
  359. meerk40t/network/udp_server.py +103 -77
  360. meerk40t/network/web_server.py +390 -0
  361. meerk40t/newly/controller.py +1158 -1144
  362. meerk40t/newly/device.py +874 -732
  363. meerk40t/newly/driver.py +540 -412
  364. meerk40t/newly/gui/gui.py +219 -188
  365. meerk40t/newly/gui/newlyconfig.py +116 -101
  366. meerk40t/newly/gui/newlycontroller.py +193 -186
  367. meerk40t/newly/gui/operationproperties.py +51 -51
  368. meerk40t/newly/mock_connection.py +82 -82
  369. meerk40t/newly/newly_params.py +56 -56
  370. meerk40t/newly/plugin.py +1214 -1246
  371. meerk40t/newly/usb_connection.py +322 -322
  372. meerk40t/rotary/gui/gui.py +52 -46
  373. meerk40t/rotary/gui/rotarysettings.py +240 -232
  374. meerk40t/rotary/rotary.py +202 -98
  375. meerk40t/ruida/control.py +291 -91
  376. meerk40t/ruida/controller.py +138 -1088
  377. meerk40t/ruida/device.py +672 -231
  378. meerk40t/ruida/driver.py +534 -472
  379. meerk40t/ruida/emulator.py +1494 -1491
  380. meerk40t/ruida/exceptions.py +4 -4
  381. meerk40t/ruida/gui/gui.py +71 -76
  382. meerk40t/ruida/gui/ruidaconfig.py +239 -72
  383. meerk40t/ruida/gui/ruidacontroller.py +187 -184
  384. meerk40t/ruida/gui/ruidaoperationproperties.py +48 -47
  385. meerk40t/ruida/loader.py +54 -52
  386. meerk40t/ruida/mock_connection.py +57 -109
  387. meerk40t/ruida/plugin.py +124 -87
  388. meerk40t/ruida/rdjob.py +2084 -945
  389. meerk40t/ruida/serial_connection.py +116 -0
  390. meerk40t/ruida/tcp_connection.py +146 -0
  391. meerk40t/ruida/udp_connection.py +73 -0
  392. meerk40t/svgelements.py +9671 -9669
  393. meerk40t/tools/driver_to_path.py +584 -579
  394. meerk40t/tools/geomstr.py +5583 -4680
  395. meerk40t/tools/jhfparser.py +357 -292
  396. meerk40t/tools/kerftest.py +904 -890
  397. meerk40t/tools/livinghinges.py +1168 -1033
  398. meerk40t/tools/pathtools.py +987 -949
  399. meerk40t/tools/pmatrix.py +234 -0
  400. meerk40t/tools/pointfinder.py +942 -942
  401. meerk40t/tools/polybool.py +940 -940
  402. meerk40t/tools/rasterplotter.py +1660 -547
  403. meerk40t/tools/shxparser.py +989 -901
  404. meerk40t/tools/ttfparser.py +726 -446
  405. meerk40t/tools/zinglplotter.py +595 -593
  406. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/LICENSE +21 -21
  407. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/METADATA +150 -139
  408. meerk40t-0.9.7010.dist-info/RECORD +445 -0
  409. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/WHEEL +1 -1
  410. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/top_level.txt +0 -1
  411. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/zip-safe +1 -1
  412. meerk40t/balormk/elementlightjob.py +0 -159
  413. meerk40t-0.9.3001.dist-info/RECORD +0 -437
  414. test/bootstrap.py +0 -63
  415. test/test_cli.py +0 -12
  416. test/test_core_cutcode.py +0 -418
  417. test/test_core_elements.py +0 -144
  418. test/test_core_plotplanner.py +0 -397
  419. test/test_core_viewports.py +0 -312
  420. test/test_drivers_grbl.py +0 -108
  421. test/test_drivers_lihuiyu.py +0 -443
  422. test/test_drivers_newly.py +0 -113
  423. test/test_element_degenerate_points.py +0 -43
  424. test/test_elements_classify.py +0 -97
  425. test/test_elements_penbox.py +0 -22
  426. test/test_file_svg.py +0 -176
  427. test/test_fill.py +0 -155
  428. test/test_geomstr.py +0 -1523
  429. test/test_geomstr_nodes.py +0 -18
  430. test/test_imagetools_actualize.py +0 -306
  431. test/test_imagetools_wizard.py +0 -258
  432. test/test_kernel.py +0 -200
  433. test/test_laser_speeds.py +0 -3303
  434. test/test_length.py +0 -57
  435. test/test_lifecycle.py +0 -66
  436. test/test_operations.py +0 -251
  437. test/test_operations_hatch.py +0 -57
  438. test/test_ruida.py +0 -19
  439. test/test_spooler.py +0 -22
  440. test/test_tools_rasterplotter.py +0 -29
  441. test/test_wobble.py +0 -133
  442. test/test_zingl.py +0 -124
  443. {test → meerk40t/cylinder}/__init__.py +0 -0
  444. /meerk40t/{core/element_commands.py → cylinder/gui/__init__.py} +0 -0
  445. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7010.dist-info}/entry_points.txt +0 -0
@@ -1,1491 +1,1494 @@
1
- """
2
- Ruida Emulator
3
-
4
- The emulator allows us to listen for connections that send ruida data, we emulate that a ruida controller and turn
5
- the received data into laser commands to be executed by the local driver.
6
- """
7
-
8
- import os
9
- from typing import Tuple, Union
10
-
11
- from meerk40t.kernel import get_safe_path
12
-
13
- from ..core.units import UNITS_PER_MM, UNITS_PER_uM
14
- from .exceptions import RuidaCommandError
15
- from .rdjob import (
16
- RDJob,
17
- abscoord,
18
- decode14,
19
- decodeu35,
20
- encode32,
21
- magic_keys,
22
- parse_commands,
23
- parse_filenumber,
24
- parse_mem,
25
- swizzles_lut,
26
- )
27
-
28
-
29
- class RuidaEmulator:
30
- def __init__(self, device, units_to_device_matrix):
31
- self.device = device
32
- self.units_to_device_matrix = units_to_device_matrix
33
-
34
- self.saving = False
35
-
36
- self.filename = None
37
- self.filestream = None
38
-
39
- self.color = None
40
-
41
- self.magic = 0x88 # 0x11 for the 634XG
42
- # Should automatically shift encoding if wrong.
43
-
44
- # self.magic = 0x38
45
- self.lut_swizzle, self.lut_unswizzle = swizzles_lut(self.magic)
46
-
47
- self.channel = None
48
-
49
- self.program_mode = False
50
- self.reply = None
51
- self.realtime = None
52
-
53
- self.process_commands = True
54
- self.swizzle_mode = True
55
-
56
- self.scale = UNITS_PER_uM
57
-
58
- self.job = RDJob(
59
- driver=device.driver,
60
- priority=0,
61
- channel=self._channel,
62
- units_to_device_matrix=units_to_device_matrix,
63
- )
64
- self.z = 0.0
65
- self.u = 0.0
66
-
67
- self.a = 0.0
68
- self.b = 0.0
69
- self.c = 0.0
70
- self.d = 0.0
71
- self._magic_keys = magic_keys()
72
-
73
- @property
74
- def x(self):
75
- return self.device.current[0]
76
-
77
- @property
78
- def y(self):
79
- return self.device.current[1]
80
-
81
- def __repr__(self):
82
- return f"RuidaEmulator(@{hex(id(self))})"
83
-
84
- def msg_reply(self, response, desc="ACK"):
85
- if self.swizzle_mode:
86
- if self.reply:
87
- self.reply(self.swizzle(response))
88
- else:
89
- if self.realtime:
90
- self.realtime(response)
91
- if self.channel:
92
- self.channel(f"<-- {response.hex()}\t({desc})")
93
-
94
- def _set_magic(self, magic):
95
- self.magic = magic
96
- self.lut_swizzle, self.lut_unswizzle = swizzles_lut(self.magic)
97
- if self.channel:
98
- self.channel(f"Setting magic to 0x{self.magic:02x}")
99
-
100
- def checksum_write(self, sent_data):
101
- """
102
- This is `write` with a checksum and swizzling. This is how the 50200 packets arrive and need to be processed.
103
-
104
- @param sent_data: Packet data.
105
- @return:
106
- """
107
- self.swizzle_mode = True
108
- if len(sent_data) < 2:
109
- return # Cannot contain a checksum.
110
- data = sent_data[2:1472]
111
- checksum_check = (sent_data[0] & 0xFF) << 8 | sent_data[1] & 0xFF
112
- checksum_sum = sum(data) & 0xFFFF
113
- if len(data) == 4:
114
- magic = self._magic_keys.get(data)
115
- if magic is not None:
116
- self._set_magic(magic)
117
- if checksum_check == checksum_sum:
118
- response = b"\xCC"
119
- self.msg_reply(response, desc="Checksum match")
120
- else:
121
- response = b"\xCF"
122
- self.msg_reply(
123
- response, desc=f"Checksum Fail ({checksum_sum} != {checksum_check})"
124
- )
125
- if self.channel:
126
- self.channel("--> " + str(data.hex()))
127
- return
128
- self.write(data)
129
-
130
- def realtime_write(self, bytes_to_write):
131
- """
132
- Real time commands are replied to and sent in realtime. For Ruida devices these are sent along udp 50207.
133
-
134
- @param bytes_to_write:
135
- @return: bytes to write.
136
- """
137
- self.swizzle_mode = False
138
- self.msg_reply(b"\xCC") # Clear ACK.
139
- self.write(bytes_to_write, unswizzle=False)
140
-
141
- def write(self, data, unswizzle=True):
142
- """
143
- Procedural commands sent in large data chunks. This can be through USB or UDP or a loaded file. These are
144
- expected to be unswizzled with the swizzle_mode set for the reply. Write will parse out the individual commands
145
- and send those to the command routine.
146
-
147
- @param data:
148
- @param unswizzle: Whether the given data should be unswizzled
149
- @return:
150
- """
151
- packet = self.unswizzle(data) if unswizzle else data
152
- for array in parse_commands(packet):
153
- try:
154
- if not self._process_realtime(array):
155
- self.job.write_command(array)
156
- self.device.spooler.send(self.job, prevent_duplicate=True)
157
- except (RuidaCommandError, IndexError):
158
- if self.channel:
159
- self.channel(f"Process Failure: {str(bytes(array).hex())}")
160
-
161
- def _channel(self, text):
162
- if self.channel:
163
- self.channel(text)
164
-
165
- def _describe(self, array, desc):
166
- if self.channel:
167
- self.channel(f"--> {str(bytes(array).hex())}\t({desc})")
168
-
169
- def _respond(self, respond, desc=None):
170
- if respond is not None:
171
- self.msg_reply(respond, desc=desc)
172
-
173
- def _process_realtime(self, array):
174
- """
175
- Test whether the given command is realtime or interfacing code. Should return True if the job does not deal
176
- with the given command type.
177
-
178
- @param array:
179
- @return: If realtime or machine interfacing code.
180
- """
181
- if array[0] < 0x80:
182
- if self.channel:
183
- self.channel(f"NOT A COMMAND: {array[0]}")
184
- raise RuidaCommandError
185
- elif array[0] == 0xA5:
186
- # Interface key values. These are de facto realtime. Only seen in android app. UDP: 50207
187
- key = None
188
- if array[1] == 0x50:
189
- key = "Down"
190
- elif array[1] == 0x51:
191
- key = "Up"
192
- if array[1] == 0x53:
193
- if array[2] == 0x00:
194
- self._describe(array, "Interface Frame")
195
- else:
196
- if array[2] == 0x02:
197
- self._describe(array, f"Interface +X {key}")
198
- if key == "Down":
199
- try:
200
- self.device.driver.move_right(True)
201
- except AttributeError:
202
- pass
203
- else:
204
- try:
205
- self.device.driver.move_right(False)
206
- except AttributeError:
207
- pass
208
- elif array[2] == 0x01:
209
- self._describe(array, f"Interface -X {key}")
210
- if key == "Down":
211
- try:
212
- self.device.driver.move_left(True)
213
- except AttributeError:
214
- pass
215
- else:
216
- try:
217
- self.device.driver.move_left(False)
218
- except AttributeError:
219
- pass
220
- if array[2] == 0x03:
221
- self._describe(array, f"Interface +Y {key}")
222
- if key == "Down":
223
- try:
224
- self.device.driver.move_top(True)
225
- except AttributeError:
226
- pass
227
- else:
228
- try:
229
- self.device.driver.move_top(False)
230
- except AttributeError:
231
- pass
232
- elif array[2] == 0x04:
233
- self._describe(array, f"Interface -Y {key}")
234
- if key == "Down":
235
- try:
236
- self.device.driver.move_bottom(True)
237
- except AttributeError:
238
- pass
239
- else:
240
- try:
241
- self.device.driver.move_bottom(False)
242
- except AttributeError:
243
- pass
244
- if array[2] == 0x0A:
245
- self._describe(array, f"Interface +Z {key}")
246
- if key == "Down":
247
- try:
248
- self.device.driver.move_plus_z(True)
249
- except AttributeError:
250
- pass
251
- else:
252
- try:
253
- self.device.driver.move_plus_z(False)
254
- except AttributeError:
255
- pass
256
- elif array[2] == 0x0B:
257
- self._describe(array, f"Interface -Z {key}")
258
- if key == "Down":
259
- try:
260
- self.device.driver.move_minus_z(True)
261
- except AttributeError:
262
- pass
263
- else:
264
- try:
265
- self.device.driver.move_minus_z(False)
266
- except AttributeError:
267
- pass
268
- if array[2] == 0x0C:
269
- self._describe(array, f"Interface +U {key}")
270
- if key == "Down":
271
- try:
272
- self.device.driver.move_plus_u(True)
273
- except AttributeError:
274
- pass
275
- else:
276
- try:
277
- self.device.driver.move_plus_u(False)
278
- except AttributeError:
279
- pass
280
- elif array[2] == 0x0D:
281
- self._describe(array, f"Interface -U {key}")
282
- if key == "Down":
283
- try:
284
- self.device.driver.move_minus_u(True)
285
- except AttributeError:
286
- pass
287
- else:
288
- try:
289
- self.device.driver.move_minus_u(False)
290
- except AttributeError:
291
- pass
292
- elif array[2] == 0x05:
293
- self._describe(array, f"Interface Pulse {key}")
294
- if key == "Down":
295
- try:
296
- self.device.driver.laser_on()
297
- except AttributeError:
298
- pass
299
- else:
300
- try:
301
- self.device.driver.laser_off()
302
- except AttributeError:
303
- pass
304
- elif array[2] == 0x11:
305
- self._describe(array, "Interface Speed")
306
- elif array[2] == 0x06:
307
- self._describe(array, "Interface Start/Pause")
308
- try:
309
- self.device.driver.pause()
310
- except AttributeError:
311
- pass
312
- elif array[2] == 0x09:
313
- self._describe(array, "Interface Stop")
314
- try:
315
- self.device.driver.reset()
316
- except AttributeError:
317
- pass
318
- elif array[2] == 0x5A:
319
- self._describe(array, "Interface Reset")
320
- elif array[2] == 0x0F:
321
- self._describe(array, "Interface Trace On/Off")
322
- elif array[2] == 0x07:
323
- self._describe(array, "Interface ESC")
324
- elif array[2] == 0x12:
325
- self._describe(array, "Interface Laser Gate")
326
- elif array[2] == 0x08:
327
- self._describe(array, "Interface Origin")
328
- try:
329
- self.device.driver.move_abs(0, 0)
330
- except AttributeError:
331
- pass
332
- return True
333
- elif array[0] == 0xCC:
334
- self._describe(array, "ACK from machine")
335
- return True
336
- elif array[0] == 0xCD:
337
- self._describe(array, "ERR from machine")
338
- return True
339
- elif array[0] == 0xCE:
340
- self._describe(array, "Keep Alive")
341
- return True
342
- elif array[0] == 0xD7:
343
- # END OF FILE.
344
- self.filename = None
345
- self.program_mode = False
346
- self._describe(array, "End Of File")
347
- return False
348
- elif array[0] == 0xD8:
349
- if array[1] == 0x00:
350
- self._describe(array, "Start Process")
351
- self.program_mode = True
352
- return False
353
- elif array[1] == 0x01:
354
- self._describe(array, "Stop Process")
355
- try:
356
- self.device.driver.reset()
357
- self.device.driver.home()
358
- except AttributeError:
359
- pass
360
- return True
361
- elif array[1] == 0x02:
362
- self._describe(array, "Pause Process")
363
- try:
364
- self.device.driver.pause()
365
- except AttributeError:
366
- pass
367
- return True
368
- elif array[1] == 0x03:
369
- self._describe(array, "Restore Process")
370
- try:
371
- self.device.driver.resume()
372
- except AttributeError:
373
- pass
374
- return True
375
- elif array[1] == 0x2C:
376
- self._describe(array, "Home Z")
377
- return True
378
- elif array[1] == 0x2D:
379
- self._describe(array, "Home U")
380
- return True
381
- elif array[1] == 0x2A:
382
- self._describe(array, "Home XY")
383
- try:
384
- self.device.driver.home()
385
- except AttributeError:
386
- pass
387
- return True
388
- elif array[1] == 0x2E:
389
- self._describe(array, "FocusZ")
390
- return True
391
- elif array[1] == 0x20:
392
- self._describe(array, "KeyDown -X +Left")
393
- try:
394
- self.device.driver.move_left(True)
395
- except AttributeError:
396
- pass
397
- return True
398
- elif array[1] == 0x21:
399
- self._describe(array, "KeyDown +X +Right")
400
- try:
401
- self.device.driver.move_right(True)
402
- except AttributeError:
403
- pass
404
- return True
405
- elif array[1] == 0x22:
406
- self._describe(array, "KeyDown +Y +Top")
407
- try:
408
- self.device.driver.move_top(True)
409
- except AttributeError:
410
- pass
411
- return True
412
- elif array[1] == 0x23:
413
- self._describe(array, "KeyDown -Y +Bottom")
414
- try:
415
- self.device.driver.move_down(True)
416
- except AttributeError:
417
- pass
418
- return True
419
- elif array[1] == 0x24:
420
- self._describe(array, "KeyDown +Z")
421
- try:
422
- self.device.driver.move_plus_z(True)
423
- except AttributeError:
424
- pass
425
- return True
426
- elif array[1] == 0x25:
427
- self._describe(array, "KeyDown -Z")
428
- try:
429
- self.device.driver.move_minus_z(True)
430
- except AttributeError:
431
- pass
432
- return True
433
- elif array[1] == 0x26:
434
- self._describe(array, "KeyDown +U")
435
- try:
436
- self.device.driver.move_plus_u(True)
437
- except AttributeError:
438
- pass
439
- return True
440
- elif array[1] == 0x27:
441
- self._describe(array, "KeyDown -U")
442
- try:
443
- self.device.driver.move_minus_u(True)
444
- except AttributeError:
445
- pass
446
- return True
447
- elif array[1] == 0x28:
448
- self._describe(array, "KeyDown 0x21")
449
- return True
450
- elif array[1] == 0x30:
451
- self._describe(array, "KeyUp -X +Left")
452
- try:
453
- self.device.driver.move_left(False)
454
- except AttributeError:
455
- pass
456
- return True
457
- elif array[1] == 0x31:
458
- self._describe(array, "KeyUp +X +Right")
459
- try:
460
- self.device.driver.move_right(False)
461
- except AttributeError:
462
- pass
463
- return True
464
- elif array[1] == 0x32:
465
- self._describe(array, "KeyUp +Y +Top")
466
- try:
467
- self.device.driver.move_top(False)
468
- except AttributeError:
469
- pass
470
- return True
471
- elif array[1] == 0x33:
472
- self._describe(array, "KeyUp -Y +Bottom")
473
- try:
474
- self.device.driver.move_down(False)
475
- except AttributeError:
476
- pass
477
- return True
478
- elif array[1] == 0x34:
479
- self._describe(array, "KeyUp +Z")
480
- try:
481
- self.device.driver.move_plus_z(False)
482
- except AttributeError:
483
- pass
484
- return True
485
- elif array[1] == 0x35:
486
- try:
487
- self.device.driver.move_minus_z(False)
488
- except AttributeError:
489
- pass
490
- self._describe(array, "KeyUp -Z")
491
- return True
492
- elif array[1] == 0x36:
493
- self._describe(array, "KeyUp +U")
494
- try:
495
- self.device.driver.move_plus_u(False)
496
- except AttributeError:
497
- pass
498
- return True
499
- elif array[1] == 0x37:
500
- self._describe(array, "KeyUp -U")
501
- try:
502
- self.device.driver.move_minus_u(False)
503
- except AttributeError:
504
- pass
505
- return True
506
- elif array[1] == 0x38:
507
- self._describe(array, "KeyUp 0x20")
508
- return True
509
- elif array[1] == 0x39:
510
- self._describe(array, "Home A")
511
- return True
512
- elif array[1] == 0x3A:
513
- self._describe(array, "Home B")
514
- return True
515
- elif array[1] == 0x3B:
516
- self._describe(array, "Home C")
517
- return True
518
- elif array[1] == 0x3C:
519
- self._describe(array, "Home D")
520
- return True
521
- elif array[1] == 0x40:
522
- self._describe(array, "KeyDown 0x18")
523
- return True
524
- elif array[1] == 0x41:
525
- self._describe(array, "KeyDown 0x19")
526
- return True
527
- elif array[1] == 0x42:
528
- self._describe(array, "KeyDown 0x1A")
529
- return True
530
- elif array[1] == 0x43:
531
- self._describe(array, "KeyDown 0x1B")
532
- return True
533
- elif array[1] == 0x44:
534
- self._describe(array, "KeyDown 0x1C")
535
- return True
536
- elif array[1] == 0x45:
537
- self._describe(array, "KeyDown 0x1D")
538
- return True
539
- elif array[1] == 0x46:
540
- self._describe(array, "KeyDown 0x1E")
541
- return True
542
- elif array[1] == 0x47:
543
- self._describe(array, "KeyDown 0x1F")
544
- return True
545
- elif array[1] == 0x48:
546
- self._describe(array, "KeyUp 0x08")
547
- return True
548
- elif array[1] == 0x49:
549
- self._describe(array, "KeyUp 0x09")
550
- return True
551
- elif array[1] == 0x4A:
552
- self._describe(array, "KeyUp 0x0A")
553
- return True
554
- elif array[1] == 0x4B:
555
- self._describe(array, "KeyUp 0x0B")
556
- return True
557
- elif array[1] == 0x4C:
558
- self._describe(array, "KeyUp 0x0C")
559
- return True
560
- elif array[1] == 0x4D:
561
- self._describe(array, "KeyUp 0x0D")
562
- return True
563
- elif array[1] == 0x4E:
564
- self._describe(array, "KeyUp 0x0E")
565
- return True
566
- elif array[1] == 0x4F:
567
- self._describe(array, "KeyUp 0x0F")
568
- return True
569
- elif array[1] == 0x51:
570
- self._describe(array, "Inhale On/Off")
571
- return True
572
- elif array[0] == 0xD9:
573
- if len(array) == 1:
574
- self._describe(array, "Unknown Directional Setting")
575
- else:
576
- options = array[2]
577
- if options == 0x03:
578
- param = "Light"
579
- elif options == 0x02:
580
- param = ""
581
- elif options == 0x01:
582
- param = "Light/Origin"
583
- else: # options == 0x00:
584
- param = "Origin"
585
-
586
- if array[1] == 0x00 or array[1] == 0x50:
587
- coord = abscoord(array[3:8]) * self.scale
588
- self._describe(
589
- array, f"Move {param} X: {coord} ({self.x},{self.y})"
590
- )
591
- try:
592
- self.device.driver.move_abs(self.x + coord, self.y)
593
- except AttributeError:
594
- pass
595
- elif array[1] == 0x01 or array[1] == 0x51:
596
- coord = abscoord(array[3:8]) * self.scale
597
- self._describe(
598
- array, f"Move {param} Y: {coord} ({self.x},{self.y})"
599
- )
600
- try:
601
- self.device.driver.move_abs(self.x, self.y + coord)
602
- except AttributeError:
603
- pass
604
- elif array[1] == 0x02 or array[1] == 0x52:
605
- coord = abscoord(array[3:8])
606
- self._describe(
607
- array, f"Move {param} Z: {coord} ({self.x},{self.y})"
608
- )
609
- try:
610
- self.device.driver.axis("z", coord)
611
- except AttributeError:
612
- pass
613
- elif array[1] == 0x03 or array[1] == 0x53:
614
- coord = abscoord(array[3:8])
615
- self._describe(
616
- array, f"Move {param} U: {coord} ({self.x},{self.y})"
617
- )
618
- try:
619
- self.device.driver.axis("u", self.u)
620
- except AttributeError:
621
- pass
622
- elif array[1] == 0x0F:
623
- self._describe(array, "Feed Axis Move")
624
- elif array[1] == 0x10 or array[1] == 0x60:
625
- x = abscoord(array[3:8]) * self.scale
626
- y = abscoord(array[8:13]) * self.scale
627
- self._describe(array, f"Move {param} XY ({x}, {y})")
628
- if "Origin" in param:
629
- try:
630
- self.device.driver.move_abs(
631
- f"{x / UNITS_PER_MM}mm",
632
- f"{y / UNITS_PER_MM}mm",
633
- )
634
- except AttributeError:
635
- pass
636
- else:
637
- try:
638
- self.device.driver.home()
639
- except AttributeError:
640
- pass
641
- elif array[1] == 0x30 or array[1] == 0x70:
642
- x = abscoord(array[3:8])
643
- y = abscoord(array[8:13])
644
- self.u = abscoord(array[13 : 13 + 5])
645
- self._describe(
646
- array,
647
- f"Move {param} XYU: {x * UNITS_PER_uM} ({y * UNITS_PER_uM},{self.u * UNITS_PER_uM})",
648
- )
649
- try:
650
- self.device.driver.move_abs(x * UNITS_PER_uM, y * UNITS_PER_uM)
651
- self.device.driver.axis("u", self.u * UNITS_PER_uM)
652
- except AttributeError:
653
- pass
654
- return True
655
- elif array[0] == 0xDA:
656
- # DA commands are usually memory or system processing commands.
657
-
658
- mem = parse_mem(array[2:4])
659
- name, v = self.mem_lookup(mem)
660
- if array[1] == 0x00:
661
- if name is None:
662
- name = "Unmapped"
663
- self._describe(
664
- array,
665
- f"Get {array[2]:02x} {array[3]:02x} (mem: {mem:04x}) ({name})",
666
- )
667
- if isinstance(v, int):
668
- v = int(v)
669
- vencode = encode32(v)
670
- self._respond(
671
- b"\xDA\x01" + bytes(array[2:4]) + bytes(vencode),
672
- desc=f"Respond {array[2]:02x} {array[3]:02x} (mem: {mem:04x}) ({name}) = {v} (0x{v:08x})",
673
- )
674
- else:
675
- vencode = v
676
- self._respond(
677
- b"\xDA\x01" + bytes(array[2:4]) + bytes(vencode),
678
- desc=f"Respond {array[2]:02x} {array[3]:02x} (mem: {mem:04x}) ({name}) = {str(vencode)}",
679
- )
680
- elif array[1] == 0x01:
681
- value0 = array[4:9]
682
- value1 = array[9:14]
683
- v0 = decodeu35(value0)
684
- v1 = decodeu35(value1)
685
- self._describe(
686
- array,
687
- f"Set {array[2]:02x} {array[3]:02x} (mem: {mem:04x}) ({name}) = {v0} (0x{v0:08x}) {v1} (0x{v1:08x})",
688
- )
689
- # MEM SET. This is sometimes inside files to set things like declared filesize
690
- return False
691
- elif array[1] == 0x04:
692
- self._describe(array, "OEM On/Off, CardIO On/OFF")
693
- elif array[1] == 0x05 or array[1] == 0x54:
694
- self._describe(array, "Read Run Info")
695
- self._respond(b"\xda\x05" + b"\x00" * 20, desc="Read Run Response")
696
- elif array[1] == 0x06 or array[1] == 0x52:
697
- self._describe(array, "Unknown/System Time.")
698
- elif array[1] == 0x10 or array[1] == 0x53:
699
- self._describe(array, "Set System Time")
700
- elif array[1] == 0x30:
701
- # Property requested with select document, upload button "fresh property"
702
- filenumber = parse_filenumber(array[2:4])
703
- self._describe(array, f"Upload Info 0x30 Document {filenumber}")
704
- # Response Unverified
705
- self._respond(
706
- b"\xda\x30" + b"\x00" * 20, desc="Upload Info Response 0x30"
707
- )
708
- elif array[1] == 0x31:
709
- # Property requested with select document, upload button "fresh property"
710
- filenumber = parse_filenumber(array[2:4])
711
- self._describe(array, f"Upload Info 0x31 Document {filenumber}")
712
- # Response Unverified
713
- self._respond(
714
- b"\xda\x31" + b"\x00" * 20, desc="Upload Info Response 0x31"
715
- )
716
- elif array[1] == 0x60:
717
- # len: 14
718
- v = decode14(array[2:4])
719
- self._describe(array, f"RD-FUNCTION-UNK1 {v}")
720
- return True
721
- elif array[0] == 0xE5: # 0xE502
722
- if len(array) == 1:
723
- self._describe(array, "Lightburn Swizzle Modulation E5")
724
- return True
725
- if array[1] == 0x00:
726
- # RDWorks File Upload
727
- filenumber = array[2]
728
- self._describe(array, f"Document Page Number {filenumber}")
729
- # Response Unverified
730
- self._respond(b"\xe5\x00" + b"\x00" * 20, desc="Document Page Response")
731
- if array[1] == 0x02:
732
- # len 3
733
- self._describe(array, "Document Data End")
734
- if array[1] == 0x03:
735
- self._describe(array, "Is TblCor Usable")
736
- if array[1] == 0x04:
737
- # Something check in data chunk write
738
- pass
739
- return True
740
- elif array[0] == 0xE7:
741
- # File Layout commands
742
- if array[1] == 0x01:
743
- self.filename = ""
744
- for a in array[2:]:
745
- if a == 0x00:
746
- break
747
- self.filename += chr(a)
748
- self._describe(array, f"Filename: {self.filename}")
749
- # self._respond(b"\xe8\x02", desc="File Packet Ack") # RESPONSE UNKNOWN
750
- if self.saving:
751
- self.filestream = open(get_safe_path(f"{self.filename}.rd"), "wb")
752
- return True
753
- elif array[0] == 0xE8:
754
- # FILE INTERACTIONS
755
- if array[1] == 0x00:
756
- # e8 00 00 00 00 00
757
- v1 = parse_filenumber(array[2:4])
758
- v2 = parse_filenumber(array[4:6])
759
- from glob import glob
760
- from os.path import join, realpath
761
-
762
- files = [
763
- name for name in glob(join(realpath(get_safe_path(".")), "*.rd"))
764
- ]
765
- if v1 == 0:
766
- for f in files:
767
- os.remove(f)
768
- self._describe(array, "Delete All Documents")
769
- else:
770
- name = files[v1 - 1]
771
- os.remove(name)
772
- self._describe(array, f"Delete Document {v1} {v2}")
773
- elif array[1] == 0x01:
774
- filenumber = parse_filenumber(array[2:4])
775
- self._describe(array, f"Document Name {filenumber}")
776
- from glob import glob
777
- from os.path import join, realpath
778
-
779
- files = [
780
- name for name in glob(join(realpath(get_safe_path(".")), "*.rd"))
781
- ]
782
- name = files[filenumber - 1]
783
- name = os.path.split(name)[-1]
784
- name = name.split(".")[0]
785
- name = name.upper()[:8]
786
- self._respond(
787
- bytes(array[:4]) + bytes(name, "utf8") + b"\00",
788
- f"Document {filenumber} Named: {name}",
789
- )
790
- elif array[1] == 0x02:
791
- self.saving = True
792
- self._describe(array, "File transfer")
793
- elif array[1] == 0x03:
794
- filenumber = parse_filenumber(array[2:4])
795
-
796
- from glob import glob
797
- from os.path import join, realpath
798
-
799
- files = [
800
- name for name in glob(join(realpath(get_safe_path(".")), "*.rd"))
801
- ]
802
- name = files[filenumber - 1]
803
- try:
804
- with open(name, "rb") as f:
805
- self.write(f.read())
806
- except OSError:
807
- pass
808
- self._describe(array, f"Start Select Document {filenumber}")
809
- elif array[1] == 0x04:
810
- filenumber = parse_filenumber(array[2:4])
811
- self._describe(array, f"Calculate Document Time {filenumber}")
812
- return True
813
- return False
814
-
815
- def mem_lookup(self, mem) -> Tuple[str, Union[int, bytes]]:
816
- if mem == 0x0002:
817
- return "Laser Info", 0 #
818
- if mem == 0x0003:
819
- return "Machine Def", 0 #
820
- if mem == 0x0004:
821
- return "IOEnable", 0 # 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, bits
822
- if mem == 0x0005:
823
- return "G0 Velocity", 200000 # 200 mm/s
824
- if mem == 0x000B:
825
- return "Eng Facula", 800 # 80%
826
- if mem == 0x000C:
827
- return "Home Velocity", 20000 # 20mm/s
828
- if mem == 0x000E:
829
- return "Eng Vert Velocity", 100000 # 100 mm/s
830
- if mem == 0x0010:
831
- return "System Control Mode", 0
832
- if mem == 0x0011:
833
- return "Laser PWM Frequency 1", 0
834
- if mem == 0x0012:
835
- return "Laser Min Power 1", 0
836
- if mem == 0x0013:
837
- return "Laser Max Power 1", 0
838
- if mem == 0x0016:
839
- return "Laser Attenuation", 0
840
- if mem == 0x0017:
841
- return "Laser PWM Frequency 2", 0
842
- if mem == 0x0018:
843
- return "Laser Min Power 2", 0
844
- if mem == 0x0019:
845
- return "Laser Max Power 2", 0
846
- if mem == 0x001A:
847
- return "Laser Standby Frequency 1", 0
848
- if mem == 0x001B:
849
- return "Laser Standby Pulse 1", 0
850
- if mem == 0x001C:
851
- return "Laser Standby Frequency 2", 0
852
- if mem == 0x001D:
853
- return "Laser Standby Pulse 2", 0
854
- if mem == 0x001E:
855
- return "Auto Type Space", 0
856
- if mem == 0x001F:
857
- return "TriColor", 0
858
- if mem == 0x0020:
859
- return "Axis Control Para 1", 0x4000 # True
860
- if mem == 0x0021:
861
- return "Axis Precision 1", 0
862
- if mem == 0x0023:
863
- return "Axis Max Velocity 1", 0
864
- if mem == 0x0024:
865
- return "Axis Start Velocity 1", 0
866
- if mem == 0x0025:
867
- return "Axis Max Acc 1", 0
868
- if mem == 0x0026:
869
- return "Axis Range 1, Get Frame X", 320000
870
- if mem == 0x0027:
871
- return "Axis Btn Start Velocity 1", 0
872
- if mem == 0x0028:
873
- return "Axis Btn Acc 1", 0
874
- if mem == 0x0029:
875
- return "Axis Estp Acc 1", 0
876
- if mem == 0x002A:
877
- return "Axis Home Offset 1", 0
878
- if mem == 0x002B:
879
- return "Axis Backlash 1", 0 # 0mm
880
-
881
- if mem == 0x0030:
882
- return "Axis Control Para 2", 0x4000 # True
883
- if mem == 0x0031:
884
- return "Axis Precision 2", 0
885
- if mem == 0x0033:
886
- return "Axis Max Velocity 2", 0
887
- if mem == 0x0034:
888
- return "Axis Start Velocity 2", 0
889
- if mem == 0x0035:
890
- return "Axis Max Acc 2", 0
891
- if mem == 0x0036:
892
- return "Axis Range 2, Get Frame Y", 220000
893
- if mem == 0x0037:
894
- return "Axis Btn Start Velocity 2", 0
895
- if mem == 0x0038:
896
- return "Axis Btn Acc 2", 0
897
- if mem == 0x0039:
898
- return "Axis Estp Acc 2", 0
899
- if mem == 0x003A:
900
- return "Axis Home Offset 2", 0
901
- if mem == 0x003B:
902
- return "Axis Backlash 2", 0 # 0 mm
903
-
904
- if mem == 0x0040:
905
- return "Axis Control Para 3", 0 # False
906
- if mem == 0x0041:
907
- return "Axis Precision 3", 0
908
- if mem == 0x0043:
909
- return "Axis Max Velocity 3", 0
910
- if mem == 0x0044:
911
- return "Axis Start Velocity 3", 0
912
- if mem == 0x0045:
913
- return "Axis Max Acc 3", 0
914
- if mem == 0x0046:
915
- return "Axis Range 3, Get Frame Z", 0
916
- if mem == 0x0047:
917
- return "Axis Btn Start Velocity 3", 0
918
- if mem == 0x0048:
919
- return "Axis Btn Acc 3", 0
920
- if mem == 0x0049:
921
- return "Axis Estp Acc 3", 0
922
- if mem == 0x004A:
923
- return "Axis Home Offset 3", 0
924
- if mem == 0x004B:
925
- return "Axis Backlash 3", 0
926
-
927
- if mem == 0x0050:
928
- return "Axis Control Para 4", 0 # False
929
- if mem == 0x0051:
930
- return "Axis Precision 4", 0
931
- if mem == 0x0053:
932
- return "Axis Max Velocity 4", 0
933
- if mem == 0x0054:
934
- return "Axis Start Velocity 4", 0
935
- if mem == 0x0055:
936
- return "Axis Max Acc 4", 0
937
- if mem == 0x0056:
938
- return "Axis Range 4, Get Frame U", 0
939
- if mem == 0x0057:
940
- return "Axis Btn Start Velocity 4", 0
941
- if mem == 0x0058:
942
- return "Axis Btn Acc 4", 0
943
- if mem == 0x0059:
944
- return "Axis Estp Acc 4", 0
945
- if mem == 0x005A:
946
- return "Axis Home Offset 4", 0
947
- if mem == 0x005B:
948
- return "Axis Backlash 4", 0
949
-
950
- if mem == 0x0060:
951
- return "Machine Type", 0
952
-
953
- if mem == 0x0063:
954
- return "Laser Min Power 3", 0
955
- if mem == 0x0064:
956
- return "Laser Max Power 3", 0
957
- if mem == 0x0065:
958
- return "Laser PWM Frequency 3", 0
959
- if mem == 0x0066:
960
- return "Laser Standby Frequency 3", 0
961
- if mem == 0x0067:
962
- return "Laser Standby Pulse 3", 0
963
-
964
- if mem == 0x0068:
965
- return "Laser Min Power 4", 0
966
- if mem == 0x0069:
967
- return "Laser Max Power 4", 0
968
- if mem == 0x006A:
969
- return "Laser PWM Frequency 4", 0
970
- if mem == 0x006B:
971
- return "Laser Standby Frequency 4", 0
972
- if mem == 0x006C:
973
- return "Laser Standby Pulse 4", 0
974
-
975
- if mem == 0x006D:
976
- return "Laser Min Power 5", 0
977
- if mem == 0x006E:
978
- return "Laser Max Power 5", 0
979
- if mem == 0x006F:
980
- return "Laser PWM Frequency 5", 0
981
- if mem == 0x0070:
982
- return "Laser Standby Frequency 5", 0
983
- if mem == 0x0071:
984
- return "Laser Standby Pulse 5", 0
985
-
986
- if mem == 0x0072:
987
- return "Laser Min Power 6", 0
988
- if mem == 0x0073:
989
- return "Laser Max Power 6", 0
990
- if mem == 0x0074:
991
- return "Laser PWM Frequency 6", 0
992
- if mem == 0x0075:
993
- return "Laser Standby Frequency 6", 0
994
- if mem == 0x0076:
995
- return "Laser Standby Pulse 6", 0
996
- if mem == 0x0077:
997
- return "Auto Type Space 2", 0
998
- if mem == 0x0077:
999
- return "Auto Type Space 3", 0
1000
- if mem == 0x0078:
1001
- return "Auto Type Space 4", 0
1002
- if mem == 0x0079:
1003
- return "Auto Type Space 5", 0
1004
- if mem == 0x007A:
1005
- return "Auto Type Space 6", 0
1006
- if mem == 0x0080:
1007
- return "RD-UNKNOWN 2", 0
1008
- if mem == 0x0090:
1009
- return "RD-UNKNOWN 3", 0
1010
- if mem == 0x00A0:
1011
- return "RD-UNKNOWN 4", 0
1012
- if mem == 0x00B0:
1013
- return "RD-UNKNOWN 5", 0
1014
- if mem == 0x0C0:
1015
- return "Offset 8 Start", 0
1016
- if mem == 0x0C1:
1017
- return "Offset 8 End", 0
1018
- if mem == 0x00C2:
1019
- return "Offset 9 Start", 0
1020
- if mem == 0x00C3:
1021
- return "Offset 9 End", 0
1022
- if mem == 0x00C4:
1023
- return "Offset 10 Start", 0
1024
- if mem == 0x00C5:
1025
- return "Offset 10 End", 0
1026
- if mem == 0x00C6:
1027
- return "Offset 7 Start", 0
1028
- if mem == 0x0C7:
1029
- return "Offset 7 End", 0
1030
-
1031
- if mem == 0x00C8:
1032
- return "Axis Home Velocity 1", 0
1033
- if mem == 0x00C9:
1034
- return "Axis Home Velocity 2", 0
1035
- if mem == 0x00CA:
1036
- return "Margin 1", 0
1037
- if mem == 0x00CB:
1038
- return "Margin 2", 0
1039
- if mem == 0x00CC:
1040
- return "Margin 3", 0
1041
- if mem == 0x00CD:
1042
- return "Margin 4", 0
1043
- if mem == 0x00CE:
1044
- return "VWheelRatio", 0
1045
- if mem == 0x00CF:
1046
- return "VPunchRatio", 0
1047
- if mem == 0x00D8:
1048
- return "VSlotRatio", 0
1049
- if mem == 0x00D0:
1050
- return "In Hale Zone", 0
1051
- if mem == 0x00D9:
1052
- return "VSlot Share Home Offset", 0
1053
- if mem == 0x00DA:
1054
- return "VPunch Share Home Offset", 0
1055
- if mem == 0x00E7:
1056
- return "VWheel Share Home Offset", 0
1057
- if mem == 0x0100:
1058
- return "System Settings", 0 # bits 2,2,1,1,1,1,1,1,1,1,1
1059
- if mem == 0x0101:
1060
- return "Turn Velocity", 20000 # 20 m/s
1061
- if mem == 0x0102:
1062
- return "Syn Acc", 3000000 # 3000 mm/s2
1063
- if mem == 0x0103:
1064
- return "G0 Delay", 0 # 0 ms
1065
- if mem == 0x0104:
1066
- return "Scan Step Factor", 0
1067
- if mem == 0x0115:
1068
- return "Dock Point X", 0
1069
- if mem == 0x0116:
1070
- return "Dock Point Y", 0
1071
- if mem == 0x0105:
1072
- return "User Para 5", 0
1073
- if mem == 0x0107:
1074
- return "Feed Delay After", 0 # 0 s
1075
- if mem == 0x0108:
1076
- return "User Key Fast Velocity", 0
1077
- if mem == 0x0109:
1078
- return "Turn Acc", 400000 # 400 mm/s
1079
- if mem == 0x010A:
1080
- return "G0 Acc", 3000000 # 3000 mm/s2
1081
- if mem == 0x010B:
1082
- return "Feed Delay Prior", 0 # 0 ms
1083
- if mem == 0x010C:
1084
- return "Manual Distance", 0
1085
- if mem == 0x010D:
1086
- return "Shut Down Delay", 0
1087
- if mem == 0x010E:
1088
- return "Focus Depth", 5000 # 5mm
1089
- if mem == 0x010F:
1090
- return "Go Scale Blank", 0 # 0 mm
1091
- if mem == 0x0117:
1092
- return "Array Feed Repay", 0 # 0mm
1093
- if mem == 0x0117:
1094
- return "Rotate On Delay", 0
1095
- if mem == 0x0119:
1096
- return "Rotate Off Delay", 0
1097
- if mem == 0x011A:
1098
- return "Acc Ratio", 100 # 100%
1099
- if mem == 0x011B:
1100
- return "Turn Ratio", 100 # 100% (speed factor)
1101
- if mem == 0x011C:
1102
- return "Acc G0 Ratio", 100 # 100%
1103
- if mem == 0x011F:
1104
- return "Rotate Pulse", 0
1105
- if mem == 0x0121:
1106
- return "Rotate D", 0
1107
- if mem == 0x0122:
1108
- return "Eng Facula Replay", 0
1109
- if mem == 0x0124:
1110
- return "X Min Eng Velocity", 10000 # 10mm/s
1111
- if mem == 0x0125:
1112
- return "X Eng Acc", 10000000 # 10000 m/s
1113
- if mem == 0x0126:
1114
- return "User Para 1", 0
1115
- if mem == 0x0128:
1116
- return "Z Home Velocity", 0
1117
- if mem == 0x0129:
1118
- return "Z Work Velocity", 0
1119
- if mem == 0x012A:
1120
- return "Z G0 Velocity", 0
1121
- if mem == 0x012B:
1122
- return "Union Home Distance", 0
1123
- if mem == 0x012C:
1124
- return "U Home Velocity", 0
1125
- if mem == 0x012D:
1126
- return "U Work Velocity", 0 # Axis Dock Position Other
1127
- if mem == 0x012E:
1128
- return "Feed Repay", 0
1129
- if mem == 0x0131:
1130
- return "Manual Fast Speed", 100000 # 100 mm/s
1131
- if mem == 0x0132:
1132
- return "Manual Slow Speed", 10000 # 10 mm/s
1133
- if mem == 0x0134:
1134
- return "Y Minimum Eng Velocity", 10000 # 10mm/s
1135
- if mem == 0x0135:
1136
- return "Y Eng Acc", 3000000 # 3000 mm/s
1137
- if mem == 0x0137:
1138
- return "Eng Acc Ratio", 100 # Engraving factor 100%
1139
- if mem == 0x0138:
1140
- return "Sts Ahead Time", 0
1141
- if mem == 0x0139:
1142
- return "Repeat Delay", 0
1143
- if mem == 0x013B:
1144
- return "User Para 3", 0
1145
- if mem == 0x013D:
1146
- return "User Para 2", 0
1147
- if mem == 0x013F:
1148
- return "User Para 4", 0 # Pressure Monitor Delay
1149
- if mem == 0x0140:
1150
- return "Axis Home Velocity 3", 0
1151
- if mem == 0x0141:
1152
- return "Axis Work Velocity 3", 0
1153
- if mem == 0x0142:
1154
- return "Axis Home Velocity 4", 0
1155
- if mem == 0x0143:
1156
- return "Axis Work Velocity 4", 0
1157
- if mem == 0x0144:
1158
- return "Axis Home Velocity 5", 0
1159
- if mem == 0x0145:
1160
- return "Axis Work Velocity 5", 0
1161
- if mem == 0x0146:
1162
- return "Axis Home Velocity 6", 0
1163
- if mem == 0x0147:
1164
- return "Axis Work Velocity 6", 0
1165
- if mem == 0x0148:
1166
- return "Axis Home Velocity 7", 0
1167
- if mem == 0x0149:
1168
- return "Axis Work Velocity 7", 0
1169
- if mem == 0x014A:
1170
- return "Axis Home Velocity 8", 0
1171
- if mem == 0x014B:
1172
- return "Axis Work Velocity 8", 0
1173
- if mem == 0x014C:
1174
- return "Laser Reset Time", 0
1175
- if mem == 0x014D:
1176
- return "Laser Start Distance", 0
1177
- if mem == 0x014E:
1178
- return "Z Pen Up Pos", 0 # units 0.001
1179
- if mem == 0x014F:
1180
- return "Z Pen Down Pos", 0 # units 0.001
1181
- if mem == 0x0150:
1182
- return "Offset 1 Start", 0
1183
- if mem == 0x0151:
1184
- return "Offset 1 End", 0
1185
- if mem == 0x0152:
1186
- return "Offset 2 Start", 0
1187
- if mem == 0x0153:
1188
- return "Offset 2 End", 0
1189
- if mem == 0x0154:
1190
- return "Offset 3 Start", 0
1191
- if mem == 0x0155:
1192
- return "Offset 3 End", 0
1193
- if mem == 0x0156:
1194
- return "Offset 6 Start", 0
1195
- if mem == 0x0157:
1196
- return "Offset 6 End", 0
1197
- if mem == 0x0158:
1198
- return "Offset 4 Start", 0
1199
- if mem == 0x0159:
1200
- return "Offset 4 End", 0
1201
- if mem == 0x015A:
1202
- return "Offset 5 Start", 0
1203
- if mem == 0x015B:
1204
- return "Offset 5 End", 0
1205
- if mem == 0x15C:
1206
- return "Delay 6 On", 0
1207
- if mem == 0x15D:
1208
- return "Delay 6 Off", 0
1209
- if mem == 0x15E:
1210
- return "Delay 7 On", 0
1211
- if mem == 0x15F:
1212
- return "Delay 7 Off", 0
1213
- if mem == 0x0160:
1214
- return "Inhale On Delay", 0 # Delay 8
1215
- if mem == 0x0161:
1216
- return "Inhale Off Delay", 0 # Delay 8
1217
- if mem == 0x162:
1218
- return "Delay 5 On", 0
1219
- if mem == 0x163:
1220
- return "Delay 5 Off", 0
1221
- if mem == 0x164:
1222
- return "Delay 2 On", 0
1223
- if mem == 0x165:
1224
- return "Delay 2 Off", 0
1225
- if mem == 0x0166:
1226
- return "VSample Distance", 0
1227
- if mem == 0x016D:
1228
- return "VUp Angle", 0
1229
- if mem == 0x016E:
1230
- return "VRotatePulse", 0
1231
- if mem == 0x177:
1232
- return "Delay 9 On", 0
1233
- if mem == 0x178:
1234
- return "Delay 9 Off", 0
1235
- if mem == 0x0169:
1236
- return "Offset 11 Start", 0
1237
- if mem == 0x016A:
1238
- return "Offset 11 End", 0
1239
- if mem == 0x16B:
1240
- return "Tool Up Pos 4", 0
1241
- if mem == 0x16C:
1242
- return "Tool Down Pos 4", 0
1243
- if mem == 0x170:
1244
- return "Delay 1 On", 0
1245
- if mem == 0x171:
1246
- return "VCorner Precision", 0
1247
- if mem == 0x172:
1248
- return "Delay 3 On", 0
1249
- if mem == 0x173:
1250
- return "Delay 4 Off", 0
1251
- if mem == 0x174:
1252
- return "Delay 4 On", 0
1253
- if mem == 0x175:
1254
- return "Delay 1 Off", 0
1255
- if mem == 0x176:
1256
- return "Delay 3 Off", 0
1257
- if mem == 0x0177:
1258
- return "Idle Long Distance", 0
1259
- if mem == 0x178:
1260
- return "Tool Up Pos 3", 0
1261
- if mem == 0x179:
1262
- return "Tool Down Pos 3", 0
1263
- if mem == 0x17A:
1264
- return "Tool Up Pos 2", 0
1265
- if mem == 0x17B:
1266
- return "Tool Down Pos 2", 0
1267
- if mem == 0x017C:
1268
- return "Punch Rotate Delay", 0
1269
- if mem == 0x017D:
1270
- return "VSlot Angle", 0
1271
- if mem == 0x017F:
1272
- return "Tool Up Delay", 0
1273
- if mem == 0x017E:
1274
- return "VTool Rotate Limit", 0
1275
- if mem == 0x0180:
1276
- return "Card Language", 0
1277
- if 0x181 <= mem <= 0x187:
1278
- return f"PC Lock {mem - 0x181}", 0
1279
- if mem == 0x0188:
1280
- return "User Key Slow Velocity", 0
1281
- if mem == 0x0189:
1282
- return "MachineID 2", 0
1283
- if mem == 0x018A:
1284
- return "MachineID 3", 0
1285
- if mem == 0x018B:
1286
- return "MachineID 4", 0
1287
- if mem == 0x018C:
1288
- return "Blow On Delay", 0
1289
- if mem == 0x018D:
1290
- return "Blow Off Delay", 0
1291
- if mem == 0x018F:
1292
- return "User Para 6, Blower", 0
1293
- if mem == 0x0190:
1294
- return "Jet Time", 0
1295
- if mem == 0x0190:
1296
- return "Color Mark Head Max Distance", 0
1297
- if mem == 0x0191:
1298
- return "Color Mark Head Distance", 0
1299
- if mem == 0x0192:
1300
- return "Color Mark Mark Distance", 0
1301
- if mem == 0x0193:
1302
- return "Color Mark Camera Distance", 0 # JetOffset = 0x193 to 0x194
1303
- if mem == 0x0194:
1304
- return "Color Mark Sensor Offset2", 0
1305
- if mem == 0x0195:
1306
- return "Cylinder Down Delay", 0
1307
- if mem == 0x0196:
1308
- return "Cylinder Up Delay", 0
1309
- if mem == 0x0197:
1310
- return "Press Down Delay", 0
1311
- if mem == 0x0198:
1312
- return "Press Up Delay", 0
1313
- if mem == 0x0199:
1314
- return "Drop Position Start", 0
1315
- if mem == 0x019A:
1316
- return "Drop Position End", 0
1317
- if mem == 0x019B:
1318
- return "Drop Interval", 0
1319
- if mem == 0x019C:
1320
- return "Drop Time", 0
1321
- if mem == 0x019D:
1322
- return "Sharpen Delay On", 0
1323
- if mem == 0x019E:
1324
- return "Sharpen Delay Off", 0
1325
- if mem == 0x019F:
1326
- return "Sharpen Time Limit", 0
1327
- if mem == 0x01A0:
1328
- return "Sharpen Travel Limit", 0
1329
- if mem == 0x01A1:
1330
- return "Work End Time", 0
1331
- if mem == 0x01A2:
1332
- return "Color Mark Offset", 0
1333
- if mem == 0x01A3:
1334
- return "Color Mark Count", 0
1335
- if mem == 0x01A4:
1336
- return "Wheel Press Compensation", 0 # Protect IO Status
1337
- if mem == 0x01A5:
1338
- return "Color Mark Filter Length", 0
1339
- if mem == 0x01A6:
1340
- return "VBlow Back On Delay", 0
1341
- if mem == 0x01A7:
1342
- return "VBlow Back Off Delay", 0
1343
- if mem == 0x01AC:
1344
- return "Y U Safe Distance", 0
1345
- if mem == 0x01AD:
1346
- return "Y U Home Distance", 0
1347
- if mem == 0x01AE:
1348
- return "VTool Preset Position X", 0
1349
- if mem == 0x01AF:
1350
- return "VTool Preset Position Y", 0
1351
- if mem == 0x01B1:
1352
- return "VTool Preset Compensation", 0
1353
- if mem == 0x01B2:
1354
- return "VTool Preset Cur Depth", 0
1355
- if mem == 0x0200:
1356
- # 22 ok, 23 paused. 21 running.
1357
- pos, state, minor = self.device.driver.status()
1358
- if state == "idle":
1359
- return "Machine Status", 22
1360
- if state == "hold":
1361
- return "Machine Status", 23
1362
- if state == "busy":
1363
- return "Machine Status", 21
1364
- return "Machine Status", 22
1365
- if mem == 0x0201:
1366
- return "Total Open Time (s)", 0
1367
- if mem == 0x0202:
1368
- return "Total Work Time (s)", 0
1369
- if mem == 0x0203:
1370
- return "Total Work Number", 0
1371
- if mem == 0x0205:
1372
- from glob import glob
1373
- from os.path import join, realpath
1374
-
1375
- files = [name for name in glob(join(realpath(get_safe_path(".")), "*.rd"))]
1376
- v = len(files)
1377
- return "Total Doc Number", v
1378
- if mem == 0x0206:
1379
- from os.path import realpath
1380
- from shutil import disk_usage
1381
-
1382
- total, used, free = disk_usage(realpath(get_safe_path(".")))
1383
- v = min(total, 100000000) # Max 100 megs.
1384
- return "Flash Space", v
1385
- if mem == 0x0207:
1386
- from os.path import realpath
1387
- from shutil import disk_usage
1388
-
1389
- total, used, free = disk_usage(realpath(get_safe_path(".")))
1390
- v = min(free, 100000000) # Max 100 megs.
1391
- return "Flash Space", v
1392
- if mem == 0x0208:
1393
- return "Previous Work Time", 0
1394
- if mem == 0x0211:
1395
- return "Total Laser Work Time", 0
1396
- if mem == 0x0212:
1397
- return "File Custom Flag / Feed Info", 0
1398
- if mem == 0x0217:
1399
- return "Total Laser Work Time 2", 0
1400
- if mem == 0x0218:
1401
- # OEM PULSE ENERGY
1402
- return "Total Laser Work Time 3", 0
1403
- if mem == 0x0219:
1404
- # OEM SET CURRENT
1405
- return "Total Laser Work Time 4", 0
1406
- if mem == 0x021A:
1407
- # OEM SET FREQUENCY
1408
- return "Total Laser Work Time 5", 0
1409
- if mem == 0x021F:
1410
- return "Ring Number", 0
1411
- if mem == 0x0221:
1412
- pos, state, minor = self.device.driver.status()
1413
- x, y = self.units_to_device_matrix.point_in_inverse_space(pos)
1414
- x /= UNITS_PER_uM
1415
- return "Axis Preferred Position 1, Pos X", int(x)
1416
- if mem == 0x0223:
1417
- return "X Total Travel (m)", 0
1418
- if mem == 0x0224:
1419
- return "Position Point 0", 0
1420
- if mem == 0x0231:
1421
- pos, state, minor = self.device.driver.status()
1422
- x, y = self.units_to_device_matrix.point_in_inverse_space(pos)
1423
- y /= UNITS_PER_uM
1424
- return "Axis Preferred Position 2, Pos Y", int(y)
1425
- if mem == 0x0233:
1426
- return "Y Total Travel (m)", 0
1427
- if mem == 0x0234:
1428
- return "Position Point 1", 0
1429
- if mem == 0x0241:
1430
- pos, state, minor = self.device.driver.status()
1431
- if len(pos) >= 3:
1432
- z = pos[2]
1433
- else:
1434
- z = self.job.z
1435
- return "Axis Preferred Position 3, Pos Z", int(z)
1436
- if mem == 0x0243:
1437
- return "Z Total Travel (m)", 0
1438
- if mem == 0x0251:
1439
- return "Axis Preferred Position 4, Pos U", int(self.job.u)
1440
- if mem == 0x0253:
1441
- return "U Total Travel (m)", 0
1442
- if mem == 0x025A:
1443
- return "Axis Preferred Position 5, Pos A", int(self.job.a)
1444
- if mem == 0x025B:
1445
- return "Axis Preferred Position 6, Pos B", int(self.job.b)
1446
- if mem == 0x025C:
1447
- return "Axis Preferred Position 7, Pos C", int(self.job.c)
1448
- if mem == 0x025D:
1449
- return "Axis Preferred Position 8, Pos D", int(self.job.d)
1450
- if mem == 0x0260:
1451
- return "DocumentWorkNum", 0
1452
- if 0x0261 <= mem < 0x02C4:
1453
- # Unsure if this is where the document numbers end.
1454
- return "Document Number", mem - 0x260
1455
- if mem == 0x02C4:
1456
- return "Read Scan Backlash Flag", 0
1457
- if mem == 0x02C5:
1458
- return "Read Scan Backlash 1", 0
1459
- if mem == 0x02D5:
1460
- return "Read Scan Backlash 2", 0
1461
- if mem == 0x02FE:
1462
- return "Card ID", 0x65006500 # RDC6442G
1463
- if mem == 0x02FF:
1464
- return "Mainboard Version", b"MEERK40T\x00"
1465
- if mem == 0x0313:
1466
- return "Material Thickness", 0
1467
- if mem == 0x031C:
1468
- return "File Fault", 0 # Error counter.
1469
- if mem == 0x0320:
1470
- return "File Total Length", 0
1471
- if mem == 0x0321:
1472
- return "File Progress Len", 0
1473
- if mem == 0x033B:
1474
- return "Read Process Feed Length", 0
1475
- if mem == 0x0340:
1476
- return "Stop Time", 0
1477
- if 0x0391 <= mem < 0x0420:
1478
- return f"Time for File {mem - 0x00390} to Run", 100
1479
- if mem == 0x0591:
1480
- return "Card Lock", 0 # 0x55aaaa55
1481
- if mem == 0x05C0:
1482
- return "Laser Life", 0
1483
- if 0x05C0 <= mem < 0x600:
1484
- pass
1485
- return "Unknown", 0
1486
-
1487
- def unswizzle(self, data):
1488
- return bytes([self.lut_unswizzle[b] for b in data])
1489
-
1490
- def swizzle(self, data):
1491
- return bytes([self.lut_swizzle[b] for b in data])
1
+ """
2
+ Ruida Emulator
3
+
4
+ The emulator allows us to listen for connections that send ruida data, we emulate that a ruida controller and turn
5
+ the received data into laser commands to be executed by the local driver.
6
+ """
7
+
8
+ import os
9
+ from typing import Tuple, Union
10
+
11
+ from meerk40t.kernel import get_safe_path
12
+
13
+ from ..core.units import UNITS_PER_uM
14
+ from .exceptions import RuidaCommandError
15
+ from .rdjob import (
16
+ RDJob,
17
+ abscoord,
18
+ decode14,
19
+ decodeu35,
20
+ encode32,
21
+ magic_keys,
22
+ parse_commands,
23
+ parse_filenumber,
24
+ parse_mem,
25
+ swizzles_lut,
26
+ )
27
+
28
+
29
+ class RuidaEmulator:
30
+ def __init__(self, device, units_to_device_matrix):
31
+ self.device = device
32
+ self.units_to_device_matrix = units_to_device_matrix
33
+
34
+ self.saving = False
35
+
36
+ self.filename = None
37
+ self.filestream = None
38
+
39
+ self.color = None
40
+
41
+ self.magic = 0x88 # 0x11 for the 634XG
42
+ # Should automatically shift encoding if wrong.
43
+
44
+ # self.magic = 0x38
45
+ self.lut_swizzle, self.lut_unswizzle = swizzles_lut(self.magic)
46
+
47
+ self.channel = None
48
+
49
+ self.program_mode = False
50
+ self.reply = None
51
+ self.realtime = None
52
+
53
+ self.process_commands = True
54
+ self.swizzle_mode = True
55
+
56
+ self.scale = UNITS_PER_uM
57
+
58
+ self.job = RDJob(
59
+ driver=device.driver,
60
+ priority=0,
61
+ channel=self._channel,
62
+ units_to_device_matrix=units_to_device_matrix,
63
+ magic=self.magic,
64
+ )
65
+ self.z = 0.0
66
+ self.u = 0.0
67
+
68
+ self.a = 0.0
69
+ self.b = 0.0
70
+ self.c = 0.0
71
+ self.d = 0.0
72
+ self._magic_keys = magic_keys()
73
+
74
+ @property
75
+ def x(self):
76
+ return self.device.current[0]
77
+
78
+ @property
79
+ def y(self):
80
+ return self.device.current[1]
81
+
82
+ def __repr__(self):
83
+ return f"RuidaEmulator(@{hex(id(self))})"
84
+
85
+ def msg_reply(self, response, desc="ACK"):
86
+ if self.swizzle_mode:
87
+ if self.reply:
88
+ self.reply(self.swizzle(response))
89
+ else:
90
+ if self.realtime:
91
+ self.realtime(response)
92
+ if self.channel:
93
+ self.channel(f"<-- {response.hex()}\t({desc})")
94
+
95
+ def _set_magic(self, magic):
96
+ self.magic = magic
97
+ self.job.set_magic(magic)
98
+ self.lut_swizzle, self.lut_unswizzle = swizzles_lut(self.magic)
99
+ if self.channel:
100
+ self.channel(f"Setting magic to 0x{self.magic:02x}")
101
+
102
+ def checksum_write(self, sent_data):
103
+ """
104
+ This is `write` with a checksum and swizzling. This is how the 50200 packets arrive and need to be processed.
105
+
106
+ @param sent_data: Packet data.
107
+ @return:
108
+ """
109
+ self.swizzle_mode = True
110
+ if len(sent_data) < 2:
111
+ return # Cannot contain a checksum.
112
+ data = sent_data[2:1472]
113
+ checksum_check = (sent_data[0] & 0xFF) << 8 | sent_data[1] & 0xFF
114
+ checksum_sum = sum(data) & 0xFFFF
115
+ if len(data) == 4:
116
+ magic = self._magic_keys.get(data)
117
+ if magic is not None:
118
+ self._set_magic(magic)
119
+ if checksum_check == checksum_sum:
120
+ response = b"\xCC"
121
+ self.msg_reply(response, desc="Checksum match")
122
+ else:
123
+ response = b"\xCF"
124
+ self.msg_reply(
125
+ response, desc=f"Checksum Fail ({checksum_sum} != {checksum_check})"
126
+ )
127
+ if self.channel:
128
+ self.channel("--> " + str(data.hex()))
129
+ return
130
+ self.write(data)
131
+
132
+ def realtime_write(self, bytes_to_write):
133
+ """
134
+ Real time commands are replied to and sent in realtime. For Ruida devices these are sent along udp 50207.
135
+
136
+ @param bytes_to_write:
137
+ @return: bytes to write.
138
+ """
139
+ self.swizzle_mode = False
140
+ self.msg_reply(b"\xCC") # Clear ACK.
141
+ self.write(bytes_to_write, unswizzle=False)
142
+
143
+ def write(self, data, unswizzle=True):
144
+ """
145
+ Procedural commands sent in large data chunks. This can be through USB or UDP or a loaded file. These are
146
+ expected to be unswizzled with the swizzle_mode set for the reply. Write will parse out the individual commands
147
+ and send those to the command routine.
148
+
149
+ @param data:
150
+ @param unswizzle: Whether the given data should be unswizzled
151
+ @return:
152
+ """
153
+ packet = self.unswizzle(data) if unswizzle else data
154
+ for command in parse_commands(packet):
155
+ array = list(command)
156
+ try:
157
+ if not self._process_realtime(array):
158
+ self.job.write_command(command)
159
+ self.device.spooler.send(self.job, prevent_duplicate=True)
160
+ except (RuidaCommandError, IndexError):
161
+ if self.channel:
162
+ self.channel(f"Process Failure: {str(bytes(array).hex())}")
163
+
164
+ def _channel(self, text):
165
+ if self.channel:
166
+ self.channel(text)
167
+
168
+ def _describe(self, array, desc):
169
+ if self.channel:
170
+ self.channel(f"--> {str(bytes(array).hex())}\t({desc})")
171
+
172
+ def _respond(self, respond, desc=None):
173
+ if respond is not None:
174
+ self.msg_reply(respond, desc=desc)
175
+
176
+ def _process_realtime(self, array):
177
+ """
178
+ Test whether the given command is realtime or interfacing code. Should return True if the job does not deal
179
+ with the given command type.
180
+
181
+ @param array:
182
+ @return: If realtime or machine interfacing code.
183
+ """
184
+ if array[0] < 0x80:
185
+ if self.channel:
186
+ self.channel(f"NOT A COMMAND: {array[0]}")
187
+ raise RuidaCommandError
188
+ elif array[0] == 0xA5:
189
+ # Interface key values. These are de facto realtime. Only seen in android app. UDP: 50207
190
+ key = None
191
+ if array[1] == 0x50:
192
+ key = "Down"
193
+ elif array[1] == 0x51:
194
+ key = "Up"
195
+ if array[1] == 0x53:
196
+ if array[2] == 0x00:
197
+ self._describe(array, "Interface Frame")
198
+ else:
199
+ if array[2] == 0x02:
200
+ self._describe(array, f"Interface +X {key}")
201
+ if key == "Down":
202
+ try:
203
+ self.device.driver.move_right(True)
204
+ except AttributeError:
205
+ pass
206
+ else:
207
+ try:
208
+ self.device.driver.move_right(False)
209
+ except AttributeError:
210
+ pass
211
+ elif array[2] == 0x01:
212
+ self._describe(array, f"Interface -X {key}")
213
+ if key == "Down":
214
+ try:
215
+ self.device.driver.move_left(True)
216
+ except AttributeError:
217
+ pass
218
+ else:
219
+ try:
220
+ self.device.driver.move_left(False)
221
+ except AttributeError:
222
+ pass
223
+ if array[2] == 0x03:
224
+ self._describe(array, f"Interface +Y {key}")
225
+ if key == "Down":
226
+ try:
227
+ self.device.driver.move_top(True)
228
+ except AttributeError:
229
+ pass
230
+ else:
231
+ try:
232
+ self.device.driver.move_top(False)
233
+ except AttributeError:
234
+ pass
235
+ elif array[2] == 0x04:
236
+ self._describe(array, f"Interface -Y {key}")
237
+ if key == "Down":
238
+ try:
239
+ self.device.driver.move_bottom(True)
240
+ except AttributeError:
241
+ pass
242
+ else:
243
+ try:
244
+ self.device.driver.move_bottom(False)
245
+ except AttributeError:
246
+ pass
247
+ if array[2] == 0x0A:
248
+ self._describe(array, f"Interface +Z {key}")
249
+ if key == "Down":
250
+ try:
251
+ self.device.driver.move_plus_z(True)
252
+ except AttributeError:
253
+ pass
254
+ else:
255
+ try:
256
+ self.device.driver.move_plus_z(False)
257
+ except AttributeError:
258
+ pass
259
+ elif array[2] == 0x0B:
260
+ self._describe(array, f"Interface -Z {key}")
261
+ if key == "Down":
262
+ try:
263
+ self.device.driver.move_minus_z(True)
264
+ except AttributeError:
265
+ pass
266
+ else:
267
+ try:
268
+ self.device.driver.move_minus_z(False)
269
+ except AttributeError:
270
+ pass
271
+ if array[2] == 0x0C:
272
+ self._describe(array, f"Interface +U {key}")
273
+ if key == "Down":
274
+ try:
275
+ self.device.driver.move_plus_u(True)
276
+ except AttributeError:
277
+ pass
278
+ else:
279
+ try:
280
+ self.device.driver.move_plus_u(False)
281
+ except AttributeError:
282
+ pass
283
+ elif array[2] == 0x0D:
284
+ self._describe(array, f"Interface -U {key}")
285
+ if key == "Down":
286
+ try:
287
+ self.device.driver.move_minus_u(True)
288
+ except AttributeError:
289
+ pass
290
+ else:
291
+ try:
292
+ self.device.driver.move_minus_u(False)
293
+ except AttributeError:
294
+ pass
295
+ elif array[2] == 0x05:
296
+ self._describe(array, f"Interface Pulse {key}")
297
+ if key == "Down":
298
+ try:
299
+ self.device.driver.laser_on()
300
+ except AttributeError:
301
+ pass
302
+ else:
303
+ try:
304
+ self.device.driver.laser_off()
305
+ except AttributeError:
306
+ pass
307
+ elif array[2] == 0x11:
308
+ self._describe(array, "Interface Speed")
309
+ elif array[2] == 0x06:
310
+ self._describe(array, "Interface Start/Pause")
311
+ try:
312
+ self.device.driver.pause()
313
+ except AttributeError:
314
+ pass
315
+ elif array[2] == 0x09:
316
+ self._describe(array, "Interface Stop")
317
+ try:
318
+ self.device.driver.reset()
319
+ except AttributeError:
320
+ pass
321
+ elif array[2] == 0x5A:
322
+ self._describe(array, "Interface Reset")
323
+ elif array[2] == 0x0F:
324
+ self._describe(array, "Interface Trace On/Off")
325
+ elif array[2] == 0x07:
326
+ self._describe(array, "Interface ESC")
327
+ elif array[2] == 0x12:
328
+ self._describe(array, "Interface Laser Gate")
329
+ elif array[2] == 0x08:
330
+ self._describe(array, "Interface Origin")
331
+ try:
332
+ self.device.driver.move_abs(0, 0)
333
+ except AttributeError:
334
+ pass
335
+ return True
336
+ elif array[0] == 0xCC:
337
+ self._describe(array, "ACK from machine")
338
+ return True
339
+ elif array[0] == 0xCD:
340
+ self._describe(array, "ERR from machine")
341
+ return True
342
+ elif array[0] == 0xCE:
343
+ self._describe(array, "Keep Alive")
344
+ return True
345
+ elif array[0] == 0xD7:
346
+ # END OF FILE.
347
+ self.filename = None
348
+ self.program_mode = False
349
+ self._describe(array, "End Of File")
350
+ return False
351
+ elif array[0] == 0xD8:
352
+ if array[1] == 0x00:
353
+ self._describe(array, "Start Process")
354
+ self.program_mode = True
355
+ return False
356
+ elif array[1] == 0x01:
357
+ self._describe(array, "Stop Process")
358
+ try:
359
+ self.device.driver.reset()
360
+ self.device.driver.home()
361
+ except AttributeError:
362
+ pass
363
+ return True
364
+ elif array[1] == 0x02:
365
+ self._describe(array, "Pause Process")
366
+ try:
367
+ self.device.driver.pause()
368
+ except AttributeError:
369
+ pass
370
+ return True
371
+ elif array[1] == 0x03:
372
+ self._describe(array, "Restore Process")
373
+ try:
374
+ self.device.driver.resume()
375
+ except AttributeError:
376
+ pass
377
+ return True
378
+ elif array[1] == 0x2C:
379
+ self._describe(array, "Home Z")
380
+ return True
381
+ elif array[1] == 0x2D:
382
+ self._describe(array, "Home U")
383
+ return True
384
+ elif array[1] == 0x2A:
385
+ self._describe(array, "Home XY")
386
+ try:
387
+ self.device.driver.home()
388
+ except AttributeError:
389
+ pass
390
+ return True
391
+ elif array[1] == 0x2E:
392
+ self._describe(array, "FocusZ")
393
+ return True
394
+ elif array[1] == 0x20:
395
+ self._describe(array, "KeyDown -X +Left")
396
+ try:
397
+ self.device.driver.move_left(True)
398
+ except AttributeError:
399
+ pass
400
+ return True
401
+ elif array[1] == 0x21:
402
+ self._describe(array, "KeyDown +X +Right")
403
+ try:
404
+ self.device.driver.move_right(True)
405
+ except AttributeError:
406
+ pass
407
+ return True
408
+ elif array[1] == 0x22:
409
+ self._describe(array, "KeyDown +Y +Top")
410
+ try:
411
+ self.device.driver.move_top(True)
412
+ except AttributeError:
413
+ pass
414
+ return True
415
+ elif array[1] == 0x23:
416
+ self._describe(array, "KeyDown -Y +Bottom")
417
+ try:
418
+ self.device.driver.move_down(True)
419
+ except AttributeError:
420
+ pass
421
+ return True
422
+ elif array[1] == 0x24:
423
+ self._describe(array, "KeyDown +Z")
424
+ try:
425
+ self.device.driver.move_plus_z(True)
426
+ except AttributeError:
427
+ pass
428
+ return True
429
+ elif array[1] == 0x25:
430
+ self._describe(array, "KeyDown -Z")
431
+ try:
432
+ self.device.driver.move_minus_z(True)
433
+ except AttributeError:
434
+ pass
435
+ return True
436
+ elif array[1] == 0x26:
437
+ self._describe(array, "KeyDown +U")
438
+ try:
439
+ self.device.driver.move_plus_u(True)
440
+ except AttributeError:
441
+ pass
442
+ return True
443
+ elif array[1] == 0x27:
444
+ self._describe(array, "KeyDown -U")
445
+ try:
446
+ self.device.driver.move_minus_u(True)
447
+ except AttributeError:
448
+ pass
449
+ return True
450
+ elif array[1] == 0x28:
451
+ self._describe(array, "KeyDown 0x21")
452
+ return True
453
+ elif array[1] == 0x30:
454
+ self._describe(array, "KeyUp -X +Left")
455
+ try:
456
+ self.device.driver.move_left(False)
457
+ except AttributeError:
458
+ pass
459
+ return True
460
+ elif array[1] == 0x31:
461
+ self._describe(array, "KeyUp +X +Right")
462
+ try:
463
+ self.device.driver.move_right(False)
464
+ except AttributeError:
465
+ pass
466
+ return True
467
+ elif array[1] == 0x32:
468
+ self._describe(array, "KeyUp +Y +Top")
469
+ try:
470
+ self.device.driver.move_top(False)
471
+ except AttributeError:
472
+ pass
473
+ return True
474
+ elif array[1] == 0x33:
475
+ self._describe(array, "KeyUp -Y +Bottom")
476
+ try:
477
+ self.device.driver.move_down(False)
478
+ except AttributeError:
479
+ pass
480
+ return True
481
+ elif array[1] == 0x34:
482
+ self._describe(array, "KeyUp +Z")
483
+ try:
484
+ self.device.driver.move_plus_z(False)
485
+ except AttributeError:
486
+ pass
487
+ return True
488
+ elif array[1] == 0x35:
489
+ try:
490
+ self.device.driver.move_minus_z(False)
491
+ except AttributeError:
492
+ pass
493
+ self._describe(array, "KeyUp -Z")
494
+ return True
495
+ elif array[1] == 0x36:
496
+ self._describe(array, "KeyUp +U")
497
+ try:
498
+ self.device.driver.move_plus_u(False)
499
+ except AttributeError:
500
+ pass
501
+ return True
502
+ elif array[1] == 0x37:
503
+ self._describe(array, "KeyUp -U")
504
+ try:
505
+ self.device.driver.move_minus_u(False)
506
+ except AttributeError:
507
+ pass
508
+ return True
509
+ elif array[1] == 0x38:
510
+ self._describe(array, "KeyUp 0x20")
511
+ return True
512
+ elif array[1] == 0x39:
513
+ self._describe(array, "Home A")
514
+ return True
515
+ elif array[1] == 0x3A:
516
+ self._describe(array, "Home B")
517
+ return True
518
+ elif array[1] == 0x3B:
519
+ self._describe(array, "Home C")
520
+ return True
521
+ elif array[1] == 0x3C:
522
+ self._describe(array, "Home D")
523
+ return True
524
+ elif array[1] == 0x40:
525
+ self._describe(array, "KeyDown 0x18")
526
+ return True
527
+ elif array[1] == 0x41:
528
+ self._describe(array, "KeyDown 0x19")
529
+ return True
530
+ elif array[1] == 0x42:
531
+ self._describe(array, "KeyDown 0x1A")
532
+ return True
533
+ elif array[1] == 0x43:
534
+ self._describe(array, "KeyDown 0x1B")
535
+ return True
536
+ elif array[1] == 0x44:
537
+ self._describe(array, "KeyDown 0x1C")
538
+ return True
539
+ elif array[1] == 0x45:
540
+ self._describe(array, "KeyDown 0x1D")
541
+ return True
542
+ elif array[1] == 0x46:
543
+ self._describe(array, "KeyDown 0x1E")
544
+ return True
545
+ elif array[1] == 0x47:
546
+ self._describe(array, "KeyDown 0x1F")
547
+ return True
548
+ elif array[1] == 0x48:
549
+ self._describe(array, "KeyUp 0x08")
550
+ return True
551
+ elif array[1] == 0x49:
552
+ self._describe(array, "KeyUp 0x09")
553
+ return True
554
+ elif array[1] == 0x4A:
555
+ self._describe(array, "KeyUp 0x0A")
556
+ return True
557
+ elif array[1] == 0x4B:
558
+ self._describe(array, "KeyUp 0x0B")
559
+ return True
560
+ elif array[1] == 0x4C:
561
+ self._describe(array, "KeyUp 0x0C")
562
+ return True
563
+ elif array[1] == 0x4D:
564
+ self._describe(array, "KeyUp 0x0D")
565
+ return True
566
+ elif array[1] == 0x4E:
567
+ self._describe(array, "KeyUp 0x0E")
568
+ return True
569
+ elif array[1] == 0x4F:
570
+ self._describe(array, "KeyUp 0x0F")
571
+ return True
572
+ elif array[1] == 0x51:
573
+ self._describe(array, "Inhale On/Off")
574
+ return True
575
+ elif array[0] == 0xD9:
576
+ if len(array) == 1:
577
+ self._describe(array, "Unknown Directional Setting")
578
+ else:
579
+ options = array[2]
580
+ if options == 0x03:
581
+ param = "Light"
582
+ elif options == 0x02:
583
+ param = ""
584
+ elif options == 0x01:
585
+ param = "Light/Origin"
586
+ else: # options == 0x00:
587
+ param = "Origin"
588
+
589
+ if array[1] == 0x00 or array[1] == 0x50:
590
+ coord = abscoord(array[3:8])
591
+ self._describe(
592
+ array, f"Move {param} X: {coord:+}μm ({self.x},{self.y})"
593
+ )
594
+ try:
595
+ self.device.driver.move_abs(self.x + coord * self.scale, self.y)
596
+ except AttributeError:
597
+ pass
598
+ elif array[1] == 0x01 or array[1] == 0x51:
599
+ coord = abscoord(array[3:8])
600
+ self._describe(
601
+ array, f"Move {param} Y: {coord:+}μm ({self.x},{self.y})"
602
+ )
603
+ try:
604
+ self.device.driver.move_abs(self.x, self.y + coord * self.scale)
605
+ except AttributeError:
606
+ pass
607
+ elif array[1] == 0x02 or array[1] == 0x52:
608
+ coord = abscoord(array[3:8])
609
+ self._describe(
610
+ array, f"Move {param} Z: {coord:+}μm ({self.x},{self.y})"
611
+ )
612
+ try:
613
+ self.device.driver.axis("z", coord * self.scale)
614
+ except AttributeError:
615
+ pass
616
+ elif array[1] == 0x03 or array[1] == 0x53:
617
+ coord = abscoord(array[3:8])
618
+ self._describe(
619
+ array, f"Move {param} U: {coord:+}μm ({self.x},{self.y})"
620
+ )
621
+ try:
622
+ self.device.driver.axis("u", coord * self.scale)
623
+ except AttributeError:
624
+ pass
625
+ elif array[1] == 0x0F:
626
+ self._describe(array, "Feed Axis Move")
627
+ elif array[1] == 0x10 or array[1] == 0x60:
628
+ x = abscoord(array[3:8])
629
+ y = abscoord(array[8:13])
630
+ self._describe(array, f"Move {param} XY ({x}μm, {y}μm)")
631
+ if "Origin" in param:
632
+ try:
633
+ self.device.driver.move_abs(
634
+ f"{x / 1000}mm",
635
+ f"{y / 1000}mm",
636
+ )
637
+ except AttributeError:
638
+ pass
639
+ else:
640
+ try:
641
+ self.device.driver.home()
642
+ except AttributeError:
643
+ pass
644
+ elif array[1] == 0x30 or array[1] == 0x70:
645
+ x = abscoord(array[3:8])
646
+ y = abscoord(array[8:13])
647
+ self.u = abscoord(array[13 : 13 + 5])
648
+ self._describe(
649
+ array,
650
+ f"Move {param} XYU: {x}μm ({y}μm, {self.u}μm)",
651
+ )
652
+ try:
653
+ self.device.driver.move_abs(x * self.scale, y * self.scale)
654
+ self.device.driver.axis("u", self.u * self.scale)
655
+ except AttributeError:
656
+ pass
657
+ return True
658
+ elif array[0] == 0xDA:
659
+ # DA commands are usually memory or system processing commands.
660
+
661
+ mem = parse_mem(array[2:4])
662
+ name, v = self.mem_lookup(mem)
663
+ if array[1] == 0x00:
664
+ if name is None:
665
+ name = "Unmapped"
666
+ self._describe(
667
+ array,
668
+ f"Get {array[2]:02x} {array[3]:02x} (mem: {mem:04x}) ({name})",
669
+ )
670
+ if isinstance(v, int):
671
+ v = int(v)
672
+ vencode = encode32(v)
673
+ self._respond(
674
+ b"\xDA\x01" + bytes(array[2:4]) + bytes(vencode),
675
+ desc=f"Respond {array[2]:02x} {array[3]:02x} (mem: {mem:04x}) ({name}) = {v} (0x{v:08x})",
676
+ )
677
+ else:
678
+ vencode = v
679
+ self._respond(
680
+ b"\xDA\x01" + bytes(array[2:4]) + bytes(vencode),
681
+ desc=f"Respond {array[2]:02x} {array[3]:02x} (mem: {mem:04x}) ({name}) = {str(vencode)}",
682
+ )
683
+ elif array[1] == 0x01:
684
+ value0 = array[4:9]
685
+ value1 = array[9:14]
686
+ v0 = decodeu35(value0)
687
+ v1 = decodeu35(value1)
688
+ self._describe(
689
+ array,
690
+ f"Set {array[2]:02x} {array[3]:02x} (mem: {mem:04x}) ({name}) = {v0} (0x{v0:08x}) {v1} (0x{v1:08x})",
691
+ )
692
+ # MEM SET. This is sometimes inside files to set things like declared filesize
693
+ return False
694
+ elif array[1] == 0x04:
695
+ self._describe(array, "OEM On/Off, CardIO On/OFF")
696
+ elif array[1] == 0x05 or array[1] == 0x54:
697
+ self._describe(array, "Read Run Info")
698
+ self._respond(b"\xda\x05" + b"\x00" * 20, desc="Read Run Response")
699
+ elif array[1] == 0x06 or array[1] == 0x52:
700
+ self._describe(array, "Unknown/System Time.")
701
+ elif array[1] == 0x10 or array[1] == 0x53:
702
+ self._describe(array, "Set System Time")
703
+ elif array[1] == 0x30:
704
+ # Property requested with select document, upload button "fresh property"
705
+ filenumber = parse_filenumber(array[2:4])
706
+ self._describe(array, f"Upload Info 0x30 Document {filenumber}")
707
+ # Response Unverified
708
+ self._respond(
709
+ b"\xda\x30" + b"\x00" * 20, desc="Upload Info Response 0x30"
710
+ )
711
+ elif array[1] == 0x31:
712
+ # Property requested with select document, upload button "fresh property"
713
+ filenumber = parse_filenumber(array[2:4])
714
+ self._describe(array, f"Upload Info 0x31 Document {filenumber}")
715
+ # Response Unverified
716
+ self._respond(
717
+ b"\xda\x31" + b"\x00" * 20, desc="Upload Info Response 0x31"
718
+ )
719
+ elif array[1] == 0x60:
720
+ # len: 14
721
+ v = decode14(array[2:4])
722
+ self._describe(array, f"RD-FUNCTION-UNK1 {v}")
723
+ return True
724
+ elif array[0] == 0xE5: # 0xE502
725
+ if len(array) == 1:
726
+ self._describe(array, "Lightburn Swizzle Modulation E5")
727
+ return True
728
+ if array[1] == 0x00:
729
+ # RDWorks File Upload
730
+ filenumber = array[2]
731
+ self._describe(array, f"Document Page Number {filenumber}")
732
+ # Response Unverified
733
+ self._respond(b"\xe5\x00" + b"\x00" * 20, desc="Document Page Response")
734
+ if array[1] == 0x02:
735
+ # len 3
736
+ self._describe(array, "Document Data End")
737
+ if array[1] == 0x03:
738
+ self._describe(array, "Is TblCor Usable")
739
+ if array[1] == 0x04:
740
+ # Something check in data chunk write
741
+ pass
742
+ return True
743
+ elif array[0] == 0xE7:
744
+ # File Layout commands
745
+ if array[1] == 0x01:
746
+ self.filename = ""
747
+ for a in array[2:]:
748
+ if a == 0x00:
749
+ break
750
+ self.filename += chr(a)
751
+ self._describe(array, f"Filename: {self.filename}")
752
+ # self._respond(b"\xe8\x02", desc="File Packet Ack") # RESPONSE UNKNOWN
753
+ if self.saving:
754
+ self.filestream = open(get_safe_path(f"{self.filename}.rd"), "wb")
755
+ return True
756
+ elif array[0] == 0xE8:
757
+ # FILE INTERACTIONS
758
+ if array[1] == 0x00:
759
+ # e8 00 00 00 00 00
760
+ v1 = parse_filenumber(array[2:4])
761
+ v2 = parse_filenumber(array[4:6])
762
+ from glob import glob
763
+ from os.path import join, realpath
764
+
765
+ files = [
766
+ name for name in glob(join(realpath(get_safe_path(".")), "*.rd"))
767
+ ]
768
+ if v1 == 0:
769
+ for f in files:
770
+ os.remove(f)
771
+ self._describe(array, "Delete All Documents")
772
+ else:
773
+ name = files[v1 - 1]
774
+ os.remove(name)
775
+ self._describe(array, f"Delete Document {v1} {v2}")
776
+ elif array[1] == 0x01:
777
+ filenumber = parse_filenumber(array[2:4])
778
+ self._describe(array, f"Document Name {filenumber}")
779
+ from glob import glob
780
+ from os.path import join, realpath
781
+
782
+ files = [
783
+ name for name in glob(join(realpath(get_safe_path(".")), "*.rd"))
784
+ ]
785
+ name = files[filenumber - 1]
786
+ name = os.path.split(name)[-1]
787
+ name = name.split(".")[0]
788
+ name = name.upper()[:8]
789
+ self._respond(
790
+ bytes(array[:4]) + bytes(name, "utf8") + b"\00",
791
+ f"Document {filenumber} Named: {name}",
792
+ )
793
+ elif array[1] == 0x02:
794
+ self.saving = True
795
+ self._describe(array, "File transfer")
796
+ elif array[1] == 0x03:
797
+ filenumber = parse_filenumber(array[2:4])
798
+
799
+ from glob import glob
800
+ from os.path import join, realpath
801
+
802
+ files = [
803
+ name for name in glob(join(realpath(get_safe_path(".")), "*.rd"))
804
+ ]
805
+ name = files[filenumber - 1]
806
+ try:
807
+ with open(name, "rb") as f:
808
+ self.write(f.read())
809
+ except OSError:
810
+ pass
811
+ self._describe(array, f"Start Select Document {filenumber}")
812
+ elif array[1] == 0x04:
813
+ filenumber = parse_filenumber(array[2:4])
814
+ self._describe(array, f"Calculate Document Time {filenumber}")
815
+ return True
816
+ return False
817
+
818
+ def mem_lookup(self, mem) -> Tuple[str, Union[int, bytes]]:
819
+ if mem == 0x0002:
820
+ return "Laser Info", 0 #
821
+ if mem == 0x0003:
822
+ return "Machine Def", 0 #
823
+ if mem == 0x0004:
824
+ return "IOEnable", 0 # 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, bits
825
+ if mem == 0x0005:
826
+ return "G0 Velocity", 200000 # 200 mm/s
827
+ if mem == 0x000B:
828
+ return "Eng Facula", 800 # 80%
829
+ if mem == 0x000C:
830
+ return "Home Velocity", 20000 # 20mm/s
831
+ if mem == 0x000E:
832
+ return "Eng Vert Velocity", 100000 # 100 mm/s
833
+ if mem == 0x0010:
834
+ return "System Control Mode", 0
835
+ if mem == 0x0011:
836
+ return "Laser PWM Frequency 1", 0
837
+ if mem == 0x0012:
838
+ return "Laser Min Power 1", 0
839
+ if mem == 0x0013:
840
+ return "Laser Max Power 1", 0
841
+ if mem == 0x0016:
842
+ return "Laser Attenuation", 0
843
+ if mem == 0x0017:
844
+ return "Laser PWM Frequency 2", 0
845
+ if mem == 0x0018:
846
+ return "Laser Min Power 2", 0
847
+ if mem == 0x0019:
848
+ return "Laser Max Power 2", 0
849
+ if mem == 0x001A:
850
+ return "Laser Standby Frequency 1", 0
851
+ if mem == 0x001B:
852
+ return "Laser Standby Pulse 1", 0
853
+ if mem == 0x001C:
854
+ return "Laser Standby Frequency 2", 0
855
+ if mem == 0x001D:
856
+ return "Laser Standby Pulse 2", 0
857
+ if mem == 0x001E:
858
+ return "Auto Type Space", 0
859
+ if mem == 0x001F:
860
+ return "TriColor", 0
861
+ if mem == 0x0020:
862
+ return "Axis Control Para 1", 0x4000 # True
863
+ if mem == 0x0021:
864
+ return "Axis Precision 1", 0
865
+ if mem == 0x0023:
866
+ return "Axis Max Velocity 1", 0
867
+ if mem == 0x0024:
868
+ return "Axis Start Velocity 1", 0
869
+ if mem == 0x0025:
870
+ return "Axis Max Acc 1", 0
871
+ if mem == 0x0026:
872
+ return "Axis Range 1, Get Frame X", 320000
873
+ if mem == 0x0027:
874
+ return "Axis Btn Start Velocity 1", 0
875
+ if mem == 0x0028:
876
+ return "Axis Btn Acc 1", 0
877
+ if mem == 0x0029:
878
+ return "Axis Estp Acc 1", 0
879
+ if mem == 0x002A:
880
+ return "Axis Home Offset 1", 0
881
+ if mem == 0x002B:
882
+ return "Axis Backlash 1", 0 # 0mm
883
+
884
+ if mem == 0x0030:
885
+ return "Axis Control Para 2", 0x4000 # True
886
+ if mem == 0x0031:
887
+ return "Axis Precision 2", 0
888
+ if mem == 0x0033:
889
+ return "Axis Max Velocity 2", 0
890
+ if mem == 0x0034:
891
+ return "Axis Start Velocity 2", 0
892
+ if mem == 0x0035:
893
+ return "Axis Max Acc 2", 0
894
+ if mem == 0x0036:
895
+ return "Axis Range 2, Get Frame Y", 220000
896
+ if mem == 0x0037:
897
+ return "Axis Btn Start Velocity 2", 0
898
+ if mem == 0x0038:
899
+ return "Axis Btn Acc 2", 0
900
+ if mem == 0x0039:
901
+ return "Axis Estp Acc 2", 0
902
+ if mem == 0x003A:
903
+ return "Axis Home Offset 2", 0
904
+ if mem == 0x003B:
905
+ return "Axis Backlash 2", 0 # 0 mm
906
+
907
+ if mem == 0x0040:
908
+ return "Axis Control Para 3", 0 # False
909
+ if mem == 0x0041:
910
+ return "Axis Precision 3", 0
911
+ if mem == 0x0043:
912
+ return "Axis Max Velocity 3", 0
913
+ if mem == 0x0044:
914
+ return "Axis Start Velocity 3", 0
915
+ if mem == 0x0045:
916
+ return "Axis Max Acc 3", 0
917
+ if mem == 0x0046:
918
+ return "Axis Range 3, Get Frame Z", 0
919
+ if mem == 0x0047:
920
+ return "Axis Btn Start Velocity 3", 0
921
+ if mem == 0x0048:
922
+ return "Axis Btn Acc 3", 0
923
+ if mem == 0x0049:
924
+ return "Axis Estp Acc 3", 0
925
+ if mem == 0x004A:
926
+ return "Axis Home Offset 3", 0
927
+ if mem == 0x004B:
928
+ return "Axis Backlash 3", 0
929
+
930
+ if mem == 0x0050:
931
+ return "Axis Control Para 4", 0 # False
932
+ if mem == 0x0051:
933
+ return "Axis Precision 4", 0
934
+ if mem == 0x0053:
935
+ return "Axis Max Velocity 4", 0
936
+ if mem == 0x0054:
937
+ return "Axis Start Velocity 4", 0
938
+ if mem == 0x0055:
939
+ return "Axis Max Acc 4", 0
940
+ if mem == 0x0056:
941
+ return "Axis Range 4, Get Frame U", 0
942
+ if mem == 0x0057:
943
+ return "Axis Btn Start Velocity 4", 0
944
+ if mem == 0x0058:
945
+ return "Axis Btn Acc 4", 0
946
+ if mem == 0x0059:
947
+ return "Axis Estp Acc 4", 0
948
+ if mem == 0x005A:
949
+ return "Axis Home Offset 4", 0
950
+ if mem == 0x005B:
951
+ return "Axis Backlash 4", 0
952
+
953
+ if mem == 0x0060:
954
+ return "Machine Type", 0
955
+
956
+ if mem == 0x0063:
957
+ return "Laser Min Power 3", 0
958
+ if mem == 0x0064:
959
+ return "Laser Max Power 3", 0
960
+ if mem == 0x0065:
961
+ return "Laser PWM Frequency 3", 0
962
+ if mem == 0x0066:
963
+ return "Laser Standby Frequency 3", 0
964
+ if mem == 0x0067:
965
+ return "Laser Standby Pulse 3", 0
966
+
967
+ if mem == 0x0068:
968
+ return "Laser Min Power 4", 0
969
+ if mem == 0x0069:
970
+ return "Laser Max Power 4", 0
971
+ if mem == 0x006A:
972
+ return "Laser PWM Frequency 4", 0
973
+ if mem == 0x006B:
974
+ return "Laser Standby Frequency 4", 0
975
+ if mem == 0x006C:
976
+ return "Laser Standby Pulse 4", 0
977
+
978
+ if mem == 0x006D:
979
+ return "Laser Min Power 5", 0
980
+ if mem == 0x006E:
981
+ return "Laser Max Power 5", 0
982
+ if mem == 0x006F:
983
+ return "Laser PWM Frequency 5", 0
984
+ if mem == 0x0070:
985
+ return "Laser Standby Frequency 5", 0
986
+ if mem == 0x0071:
987
+ return "Laser Standby Pulse 5", 0
988
+
989
+ if mem == 0x0072:
990
+ return "Laser Min Power 6", 0
991
+ if mem == 0x0073:
992
+ return "Laser Max Power 6", 0
993
+ if mem == 0x0074:
994
+ return "Laser PWM Frequency 6", 0
995
+ if mem == 0x0075:
996
+ return "Laser Standby Frequency 6", 0
997
+ if mem == 0x0076:
998
+ return "Laser Standby Pulse 6", 0
999
+ if mem == 0x0077:
1000
+ return "Auto Type Space 2", 0
1001
+ if mem == 0x0077:
1002
+ return "Auto Type Space 3", 0
1003
+ if mem == 0x0078:
1004
+ return "Auto Type Space 4", 0
1005
+ if mem == 0x0079:
1006
+ return "Auto Type Space 5", 0
1007
+ if mem == 0x007A:
1008
+ return "Auto Type Space 6", 0
1009
+ if mem == 0x0080:
1010
+ return "RD-UNKNOWN 2", 0
1011
+ if mem == 0x0090:
1012
+ return "RD-UNKNOWN 3", 0
1013
+ if mem == 0x00A0:
1014
+ return "RD-UNKNOWN 4", 0
1015
+ if mem == 0x00B0:
1016
+ return "RD-UNKNOWN 5", 0
1017
+ if mem == 0x0C0:
1018
+ return "Offset 8 Start", 0
1019
+ if mem == 0x0C1:
1020
+ return "Offset 8 End", 0
1021
+ if mem == 0x00C2:
1022
+ return "Offset 9 Start", 0
1023
+ if mem == 0x00C3:
1024
+ return "Offset 9 End", 0
1025
+ if mem == 0x00C4:
1026
+ return "Offset 10 Start", 0
1027
+ if mem == 0x00C5:
1028
+ return "Offset 10 End", 0
1029
+ if mem == 0x00C6:
1030
+ return "Offset 7 Start", 0
1031
+ if mem == 0x0C7:
1032
+ return "Offset 7 End", 0
1033
+
1034
+ if mem == 0x00C8:
1035
+ return "Axis Home Velocity 1", 0
1036
+ if mem == 0x00C9:
1037
+ return "Axis Home Velocity 2", 0
1038
+ if mem == 0x00CA:
1039
+ return "Margin 1", 0
1040
+ if mem == 0x00CB:
1041
+ return "Margin 2", 0
1042
+ if mem == 0x00CC:
1043
+ return "Margin 3", 0
1044
+ if mem == 0x00CD:
1045
+ return "Margin 4", 0
1046
+ if mem == 0x00CE:
1047
+ return "VWheelRatio", 0
1048
+ if mem == 0x00CF:
1049
+ return "VPunchRatio", 0
1050
+ if mem == 0x00D8:
1051
+ return "VSlotRatio", 0
1052
+ if mem == 0x00D0:
1053
+ return "In Hale Zone", 0
1054
+ if mem == 0x00D9:
1055
+ return "VSlot Share Home Offset", 0
1056
+ if mem == 0x00DA:
1057
+ return "VPunch Share Home Offset", 0
1058
+ if mem == 0x00E7:
1059
+ return "VWheel Share Home Offset", 0
1060
+ if mem == 0x0100:
1061
+ return "System Settings", 0 # bits 2,2,1,1,1,1,1,1,1,1,1
1062
+ if mem == 0x0101:
1063
+ return "Turn Velocity", 20000 # 20 m/s
1064
+ if mem == 0x0102:
1065
+ return "Syn Acc", 3000000 # 3000 mm/s2
1066
+ if mem == 0x0103:
1067
+ return "G0 Delay", 0 # 0 ms
1068
+ if mem == 0x0104:
1069
+ return "Scan Step Factor", 0
1070
+ if mem == 0x0115:
1071
+ return "Dock Point X", 0
1072
+ if mem == 0x0116:
1073
+ return "Dock Point Y", 0
1074
+ if mem == 0x0105:
1075
+ return "User Para 5", 0
1076
+ if mem == 0x0107:
1077
+ return "Feed Delay After", 0 # 0 s
1078
+ if mem == 0x0108:
1079
+ return "User Key Fast Velocity", 0
1080
+ if mem == 0x0109:
1081
+ return "Turn Acc", 400000 # 400 mm/s
1082
+ if mem == 0x010A:
1083
+ return "G0 Acc", 3000000 # 3000 mm/s2
1084
+ if mem == 0x010B:
1085
+ return "Feed Delay Prior", 0 # 0 ms
1086
+ if mem == 0x010C:
1087
+ return "Manual Distance", 0
1088
+ if mem == 0x010D:
1089
+ return "Shut Down Delay", 0
1090
+ if mem == 0x010E:
1091
+ return "Focus Depth", 5000 # 5mm
1092
+ if mem == 0x010F:
1093
+ return "Go Scale Blank", 0 # 0 mm
1094
+ if mem == 0x0117:
1095
+ return "Array Feed Repay", 0 # 0mm
1096
+ if mem == 0x0117:
1097
+ return "Rotate On Delay", 0
1098
+ if mem == 0x0119:
1099
+ return "Rotate Off Delay", 0
1100
+ if mem == 0x011A:
1101
+ return "Acc Ratio", 100 # 100%
1102
+ if mem == 0x011B:
1103
+ return "Turn Ratio", 100 # 100% (speed factor)
1104
+ if mem == 0x011C:
1105
+ return "Acc G0 Ratio", 100 # 100%
1106
+ if mem == 0x011F:
1107
+ return "Rotate Pulse", 0
1108
+ if mem == 0x0121:
1109
+ return "Rotate D", 0
1110
+ if mem == 0x0122:
1111
+ return "Eng Facula Replay", 0
1112
+ if mem == 0x0124:
1113
+ return "X Min Eng Velocity", 10000 # 10mm/s
1114
+ if mem == 0x0125:
1115
+ return "X Eng Acc", 10000000 # 10000 m/s
1116
+ if mem == 0x0126:
1117
+ return "User Para 1", 0
1118
+ if mem == 0x0128:
1119
+ return "Z Home Velocity", 0
1120
+ if mem == 0x0129:
1121
+ return "Z Work Velocity", 0
1122
+ if mem == 0x012A:
1123
+ return "Z G0 Velocity", 0
1124
+ if mem == 0x012B:
1125
+ return "Union Home Distance", 0
1126
+ if mem == 0x012C:
1127
+ return "U Home Velocity", 0
1128
+ if mem == 0x012D:
1129
+ return "U Work Velocity", 0 # Axis Dock Position Other
1130
+ if mem == 0x012E:
1131
+ return "Feed Repay", 0
1132
+ if mem == 0x0131:
1133
+ return "Manual Fast Speed", 100000 # 100 mm/s
1134
+ if mem == 0x0132:
1135
+ return "Manual Slow Speed", 10000 # 10 mm/s
1136
+ if mem == 0x0134:
1137
+ return "Y Minimum Eng Velocity", 10000 # 10mm/s
1138
+ if mem == 0x0135:
1139
+ return "Y Eng Acc", 3000000 # 3000 mm/s
1140
+ if mem == 0x0137:
1141
+ return "Eng Acc Ratio", 100 # Engraving factor 100%
1142
+ if mem == 0x0138:
1143
+ return "Sts Ahead Time", 0
1144
+ if mem == 0x0139:
1145
+ return "Repeat Delay", 0
1146
+ if mem == 0x013B:
1147
+ return "User Para 3", 0
1148
+ if mem == 0x013D:
1149
+ return "User Para 2", 0
1150
+ if mem == 0x013F:
1151
+ return "User Para 4", 0 # Pressure Monitor Delay
1152
+ if mem == 0x0140:
1153
+ return "Axis Home Velocity 3", 0
1154
+ if mem == 0x0141:
1155
+ return "Axis Work Velocity 3", 0
1156
+ if mem == 0x0142:
1157
+ return "Axis Home Velocity 4", 0
1158
+ if mem == 0x0143:
1159
+ return "Axis Work Velocity 4", 0
1160
+ if mem == 0x0144:
1161
+ return "Axis Home Velocity 5", 0
1162
+ if mem == 0x0145:
1163
+ return "Axis Work Velocity 5", 0
1164
+ if mem == 0x0146:
1165
+ return "Axis Home Velocity 6", 0
1166
+ if mem == 0x0147:
1167
+ return "Axis Work Velocity 6", 0
1168
+ if mem == 0x0148:
1169
+ return "Axis Home Velocity 7", 0
1170
+ if mem == 0x0149:
1171
+ return "Axis Work Velocity 7", 0
1172
+ if mem == 0x014A:
1173
+ return "Axis Home Velocity 8", 0
1174
+ if mem == 0x014B:
1175
+ return "Axis Work Velocity 8", 0
1176
+ if mem == 0x014C:
1177
+ return "Laser Reset Time", 0
1178
+ if mem == 0x014D:
1179
+ return "Laser Start Distance", 0
1180
+ if mem == 0x014E:
1181
+ return "Z Pen Up Pos", 0 # units 0.001
1182
+ if mem == 0x014F:
1183
+ return "Z Pen Down Pos", 0 # units 0.001
1184
+ if mem == 0x0150:
1185
+ return "Offset 1 Start", 0
1186
+ if mem == 0x0151:
1187
+ return "Offset 1 End", 0
1188
+ if mem == 0x0152:
1189
+ return "Offset 2 Start", 0
1190
+ if mem == 0x0153:
1191
+ return "Offset 2 End", 0
1192
+ if mem == 0x0154:
1193
+ return "Offset 3 Start", 0
1194
+ if mem == 0x0155:
1195
+ return "Offset 3 End", 0
1196
+ if mem == 0x0156:
1197
+ return "Offset 6 Start", 0
1198
+ if mem == 0x0157:
1199
+ return "Offset 6 End", 0
1200
+ if mem == 0x0158:
1201
+ return "Offset 4 Start", 0
1202
+ if mem == 0x0159:
1203
+ return "Offset 4 End", 0
1204
+ if mem == 0x015A:
1205
+ return "Offset 5 Start", 0
1206
+ if mem == 0x015B:
1207
+ return "Offset 5 End", 0
1208
+ if mem == 0x15C:
1209
+ return "Delay 6 On", 0
1210
+ if mem == 0x15D:
1211
+ return "Delay 6 Off", 0
1212
+ if mem == 0x15E:
1213
+ return "Delay 7 On", 0
1214
+ if mem == 0x15F:
1215
+ return "Delay 7 Off", 0
1216
+ if mem == 0x0160:
1217
+ return "Inhale On Delay", 0 # Delay 8
1218
+ if mem == 0x0161:
1219
+ return "Inhale Off Delay", 0 # Delay 8
1220
+ if mem == 0x162:
1221
+ return "Delay 5 On", 0
1222
+ if mem == 0x163:
1223
+ return "Delay 5 Off", 0
1224
+ if mem == 0x164:
1225
+ return "Delay 2 On", 0
1226
+ if mem == 0x165:
1227
+ return "Delay 2 Off", 0
1228
+ if mem == 0x0166:
1229
+ return "VSample Distance", 0
1230
+ if mem == 0x016D:
1231
+ return "VUp Angle", 0
1232
+ if mem == 0x016E:
1233
+ return "VRotatePulse", 0
1234
+ if mem == 0x177:
1235
+ return "Delay 9 On", 0
1236
+ if mem == 0x178:
1237
+ return "Delay 9 Off", 0
1238
+ if mem == 0x0169:
1239
+ return "Offset 11 Start", 0
1240
+ if mem == 0x016A:
1241
+ return "Offset 11 End", 0
1242
+ if mem == 0x16B:
1243
+ return "Tool Up Pos 4", 0
1244
+ if mem == 0x16C:
1245
+ return "Tool Down Pos 4", 0
1246
+ if mem == 0x170:
1247
+ return "Delay 1 On", 0
1248
+ if mem == 0x171:
1249
+ return "VCorner Precision", 0
1250
+ if mem == 0x172:
1251
+ return "Delay 3 On", 0
1252
+ if mem == 0x173:
1253
+ return "Delay 4 Off", 0
1254
+ if mem == 0x174:
1255
+ return "Delay 4 On", 0
1256
+ if mem == 0x175:
1257
+ return "Delay 1 Off", 0
1258
+ if mem == 0x176:
1259
+ return "Delay 3 Off", 0
1260
+ if mem == 0x0177:
1261
+ return "Idle Long Distance", 0
1262
+ if mem == 0x178:
1263
+ return "Tool Up Pos 3", 0
1264
+ if mem == 0x179:
1265
+ return "Tool Down Pos 3", 0
1266
+ if mem == 0x17A:
1267
+ return "Tool Up Pos 2", 0
1268
+ if mem == 0x17B:
1269
+ return "Tool Down Pos 2", 0
1270
+ if mem == 0x017C:
1271
+ return "Punch Rotate Delay", 0
1272
+ if mem == 0x017D:
1273
+ return "VSlot Angle", 0
1274
+ if mem == 0x017F:
1275
+ return "Tool Up Delay", 0
1276
+ if mem == 0x017E:
1277
+ return "VTool Rotate Limit", 0
1278
+ if mem == 0x0180:
1279
+ return "Card Language", 0
1280
+ if 0x181 <= mem <= 0x187:
1281
+ return f"PC Lock {mem - 0x181}", 0
1282
+ if mem == 0x0188:
1283
+ return "User Key Slow Velocity", 0
1284
+ if mem == 0x0189:
1285
+ return "MachineID 2", 0
1286
+ if mem == 0x018A:
1287
+ return "MachineID 3", 0
1288
+ if mem == 0x018B:
1289
+ return "MachineID 4", 0
1290
+ if mem == 0x018C:
1291
+ return "Blow On Delay", 0
1292
+ if mem == 0x018D:
1293
+ return "Blow Off Delay", 0
1294
+ if mem == 0x018F:
1295
+ return "User Para 6, Blower", 0
1296
+ if mem == 0x0190:
1297
+ return "Jet Time", 0
1298
+ if mem == 0x0190:
1299
+ return "Color Mark Head Max Distance", 0
1300
+ if mem == 0x0191:
1301
+ return "Color Mark Head Distance", 0
1302
+ if mem == 0x0192:
1303
+ return "Color Mark Mark Distance", 0
1304
+ if mem == 0x0193:
1305
+ return "Color Mark Camera Distance", 0 # JetOffset = 0x193 to 0x194
1306
+ if mem == 0x0194:
1307
+ return "Color Mark Sensor Offset2", 0
1308
+ if mem == 0x0195:
1309
+ return "Cylinder Down Delay", 0
1310
+ if mem == 0x0196:
1311
+ return "Cylinder Up Delay", 0
1312
+ if mem == 0x0197:
1313
+ return "Press Down Delay", 0
1314
+ if mem == 0x0198:
1315
+ return "Press Up Delay", 0
1316
+ if mem == 0x0199:
1317
+ return "Drop Position Start", 0
1318
+ if mem == 0x019A:
1319
+ return "Drop Position End", 0
1320
+ if mem == 0x019B:
1321
+ return "Drop Interval", 0
1322
+ if mem == 0x019C:
1323
+ return "Drop Time", 0
1324
+ if mem == 0x019D:
1325
+ return "Sharpen Delay On", 0
1326
+ if mem == 0x019E:
1327
+ return "Sharpen Delay Off", 0
1328
+ if mem == 0x019F:
1329
+ return "Sharpen Time Limit", 0
1330
+ if mem == 0x01A0:
1331
+ return "Sharpen Travel Limit", 0
1332
+ if mem == 0x01A1:
1333
+ return "Work End Time", 0
1334
+ if mem == 0x01A2:
1335
+ return "Color Mark Offset", 0
1336
+ if mem == 0x01A3:
1337
+ return "Color Mark Count", 0
1338
+ if mem == 0x01A4:
1339
+ return "Wheel Press Compensation", 0 # Protect IO Status
1340
+ if mem == 0x01A5:
1341
+ return "Color Mark Filter Length", 0
1342
+ if mem == 0x01A6:
1343
+ return "VBlow Back On Delay", 0
1344
+ if mem == 0x01A7:
1345
+ return "VBlow Back Off Delay", 0
1346
+ if mem == 0x01AC:
1347
+ return "Y U Safe Distance", 0
1348
+ if mem == 0x01AD:
1349
+ return "Y U Home Distance", 0
1350
+ if mem == 0x01AE:
1351
+ return "VTool Preset Position X", 0
1352
+ if mem == 0x01AF:
1353
+ return "VTool Preset Position Y", 0
1354
+ if mem == 0x01B1:
1355
+ return "VTool Preset Compensation", 0
1356
+ if mem == 0x01B2:
1357
+ return "VTool Preset Cur Depth", 0
1358
+ if mem == 0x0200:
1359
+ # 22 ok, 23 paused. 21 running.
1360
+ pos, state, minor = self.device.driver.status()
1361
+ if state == "idle":
1362
+ return "Machine Status", 22
1363
+ if state == "hold":
1364
+ return "Machine Status", 23
1365
+ if state == "busy":
1366
+ return "Machine Status", 21
1367
+ return "Machine Status", 22
1368
+ if mem == 0x0201:
1369
+ return "Total Open Time (s)", 0
1370
+ if mem == 0x0202:
1371
+ return "Total Work Time (s)", 0
1372
+ if mem == 0x0203:
1373
+ return "Total Work Number", 0
1374
+ if mem == 0x0205:
1375
+ from glob import glob
1376
+ from os.path import join, realpath
1377
+
1378
+ files = [name for name in glob(join(realpath(get_safe_path(".")), "*.rd"))]
1379
+ v = len(files)
1380
+ return "Total Doc Number", v
1381
+ if mem == 0x0206:
1382
+ from os.path import realpath
1383
+ from shutil import disk_usage
1384
+
1385
+ total, used, free = disk_usage(realpath(get_safe_path(".")))
1386
+ v = min(total, 100000000) # Max 100 megs.
1387
+ return "Flash Space", v
1388
+ if mem == 0x0207:
1389
+ from os.path import realpath
1390
+ from shutil import disk_usage
1391
+
1392
+ total, used, free = disk_usage(realpath(get_safe_path(".")))
1393
+ v = min(free, 100000000) # Max 100 megs.
1394
+ return "Flash Space", v
1395
+ if mem == 0x0208:
1396
+ return "Previous Work Time", 0
1397
+ if mem == 0x0211:
1398
+ return "Total Laser Work Time", 0
1399
+ if mem == 0x0212:
1400
+ return "File Custom Flag / Feed Info", 0
1401
+ if mem == 0x0217:
1402
+ return "Total Laser Work Time 2", 0
1403
+ if mem == 0x0218:
1404
+ # OEM PULSE ENERGY
1405
+ return "Total Laser Work Time 3", 0
1406
+ if mem == 0x0219:
1407
+ # OEM SET CURRENT
1408
+ return "Total Laser Work Time 4", 0
1409
+ if mem == 0x021A:
1410
+ # OEM SET FREQUENCY
1411
+ return "Total Laser Work Time 5", 0
1412
+ if mem == 0x021F:
1413
+ return "Ring Number", 0
1414
+ if mem == 0x0221:
1415
+ pos, state, minor = self.device.driver.status()
1416
+ x, y = self.units_to_device_matrix.point_in_inverse_space(pos)
1417
+ x /= self.scale
1418
+ return "Axis Preferred Position 1, Pos X", int(x)
1419
+ if mem == 0x0223:
1420
+ return "X Total Travel (m)", 0
1421
+ if mem == 0x0224:
1422
+ return "Position Point 0", 0
1423
+ if mem == 0x0231:
1424
+ pos, state, minor = self.device.driver.status()
1425
+ x, y = self.units_to_device_matrix.point_in_inverse_space(pos)
1426
+ y /= self.scale
1427
+ return "Axis Preferred Position 2, Pos Y", int(y)
1428
+ if mem == 0x0233:
1429
+ return "Y Total Travel (m)", 0
1430
+ if mem == 0x0234:
1431
+ return "Position Point 1", 0
1432
+ if mem == 0x0241:
1433
+ pos, state, minor = self.device.driver.status()
1434
+ if len(pos) >= 3:
1435
+ z = pos[2]
1436
+ else:
1437
+ z = self.job.z
1438
+ return "Axis Preferred Position 3, Pos Z", int(z)
1439
+ if mem == 0x0243:
1440
+ return "Z Total Travel (m)", 0
1441
+ if mem == 0x0251:
1442
+ return "Axis Preferred Position 4, Pos U", int(self.job.u)
1443
+ if mem == 0x0253:
1444
+ return "U Total Travel (m)", 0
1445
+ if mem == 0x025A:
1446
+ return "Axis Preferred Position 5, Pos A", int(self.job.a)
1447
+ if mem == 0x025B:
1448
+ return "Axis Preferred Position 6, Pos B", int(self.job.b)
1449
+ if mem == 0x025C:
1450
+ return "Axis Preferred Position 7, Pos C", int(self.job.c)
1451
+ if mem == 0x025D:
1452
+ return "Axis Preferred Position 8, Pos D", int(self.job.d)
1453
+ if mem == 0x0260:
1454
+ return "DocumentWorkNum", 0
1455
+ if 0x0261 <= mem < 0x02C4:
1456
+ # Unsure if this is where the document numbers end.
1457
+ return "Document Number", mem - 0x260
1458
+ if mem == 0x02C4:
1459
+ return "Read Scan Backlash Flag", 0
1460
+ if mem == 0x02C5:
1461
+ return "Read Scan Backlash 1", 0
1462
+ if mem == 0x02D5:
1463
+ return "Read Scan Backlash 2", 0
1464
+ if mem == 0x02FE:
1465
+ return "Card ID", 0x65006500 # RDC6442G
1466
+ if mem == 0x02FF:
1467
+ return "Mainboard Version", b"MEERK40T\x00"
1468
+ if mem == 0x0313:
1469
+ return "Material Thickness", 0
1470
+ if mem == 0x031C:
1471
+ return "File Fault", 0 # Error counter.
1472
+ if mem == 0x0320:
1473
+ return "File Total Length", 0
1474
+ if mem == 0x0321:
1475
+ return "File Progress Len", 0
1476
+ if mem == 0x033B:
1477
+ return "Read Process Feed Length", 0
1478
+ if mem == 0x0340:
1479
+ return "Stop Time", 0
1480
+ if 0x0391 <= mem < 0x0420:
1481
+ return f"Time for File {mem - 0x00390} to Run", 100
1482
+ if mem == 0x0591:
1483
+ return "Card Lock", 0 # 0x55aaaa55
1484
+ if mem == 0x05C0:
1485
+ return "Laser Life", 0
1486
+ if 0x05C0 <= mem < 0x600:
1487
+ pass
1488
+ return "Unknown", 0
1489
+
1490
+ def unswizzle(self, data):
1491
+ return bytes([self.lut_unswizzle[b] for b in data])
1492
+
1493
+ def swizzle(self, data):
1494
+ return bytes([self.lut_swizzle[b] for b in data])