meerk40t 0.9.3001__py2.py3-none-any.whl → 0.9.7020__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 (446) 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 +1194 -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 +1858 -1507
  50. meerk40t/core/elements/clipboard.py +229 -219
  51. meerk40t/core/elements/element_treeops.py +4595 -2837
  52. meerk40t/core/elements/element_types.py +125 -105
  53. meerk40t/core/elements/elements.py +4315 -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 +934 -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/testcases.py +105 -0
  66. meerk40t/core/elements/trace.py +651 -563
  67. meerk40t/core/elements/tree_commands.py +415 -409
  68. meerk40t/core/elements/undo_redo.py +116 -58
  69. meerk40t/core/elements/wordlist.py +319 -200
  70. meerk40t/core/exceptions.py +9 -9
  71. meerk40t/core/laserjob.py +220 -220
  72. meerk40t/core/logging.py +63 -63
  73. meerk40t/core/node/blobnode.py +83 -86
  74. meerk40t/core/node/bootstrap.py +105 -103
  75. meerk40t/core/node/branch_elems.py +40 -31
  76. meerk40t/core/node/branch_ops.py +45 -38
  77. meerk40t/core/node/branch_regmark.py +48 -41
  78. meerk40t/core/node/cutnode.py +29 -32
  79. meerk40t/core/node/effect_hatch.py +375 -257
  80. meerk40t/core/node/effect_warp.py +398 -0
  81. meerk40t/core/node/effect_wobble.py +441 -309
  82. meerk40t/core/node/elem_ellipse.py +404 -309
  83. meerk40t/core/node/elem_image.py +1082 -801
  84. meerk40t/core/node/elem_line.py +358 -292
  85. meerk40t/core/node/elem_path.py +259 -201
  86. meerk40t/core/node/elem_point.py +129 -102
  87. meerk40t/core/node/elem_polyline.py +310 -246
  88. meerk40t/core/node/elem_rect.py +376 -286
  89. meerk40t/core/node/elem_text.py +445 -418
  90. meerk40t/core/node/filenode.py +59 -40
  91. meerk40t/core/node/groupnode.py +138 -74
  92. meerk40t/core/node/image_processed.py +777 -766
  93. meerk40t/core/node/image_raster.py +156 -113
  94. meerk40t/core/node/layernode.py +31 -31
  95. meerk40t/core/node/mixins.py +135 -107
  96. meerk40t/core/node/node.py +1427 -1304
  97. meerk40t/core/node/nutils.py +117 -114
  98. meerk40t/core/node/op_cut.py +463 -335
  99. meerk40t/core/node/op_dots.py +296 -251
  100. meerk40t/core/node/op_engrave.py +414 -311
  101. meerk40t/core/node/op_image.py +755 -369
  102. meerk40t/core/node/op_raster.py +787 -522
  103. meerk40t/core/node/place_current.py +37 -40
  104. meerk40t/core/node/place_point.py +329 -126
  105. meerk40t/core/node/refnode.py +58 -47
  106. meerk40t/core/node/rootnode.py +225 -219
  107. meerk40t/core/node/util_console.py +48 -48
  108. meerk40t/core/node/util_goto.py +84 -65
  109. meerk40t/core/node/util_home.py +61 -61
  110. meerk40t/core/node/util_input.py +102 -102
  111. meerk40t/core/node/util_output.py +102 -102
  112. meerk40t/core/node/util_wait.py +65 -65
  113. meerk40t/core/parameters.py +709 -707
  114. meerk40t/core/planner.py +875 -785
  115. meerk40t/core/plotplanner.py +656 -652
  116. meerk40t/core/space.py +120 -113
  117. meerk40t/core/spoolers.py +706 -705
  118. meerk40t/core/svg_io.py +1836 -1549
  119. meerk40t/core/treeop.py +534 -445
  120. meerk40t/core/undos.py +278 -124
  121. meerk40t/core/units.py +784 -680
  122. meerk40t/core/view.py +393 -322
  123. meerk40t/core/webhelp.py +62 -62
  124. meerk40t/core/wordlist.py +513 -504
  125. meerk40t/cylinder/cylinder.py +247 -0
  126. meerk40t/cylinder/gui/cylindersettings.py +41 -0
  127. meerk40t/cylinder/gui/gui.py +24 -0
  128. meerk40t/device/__init__.py +1 -1
  129. meerk40t/device/basedevice.py +322 -123
  130. meerk40t/device/devicechoices.py +50 -0
  131. meerk40t/device/dummydevice.py +163 -128
  132. meerk40t/device/gui/defaultactions.py +618 -602
  133. meerk40t/device/gui/effectspanel.py +114 -0
  134. meerk40t/device/gui/formatterpanel.py +253 -290
  135. meerk40t/device/gui/warningpanel.py +337 -260
  136. meerk40t/device/mixins.py +13 -13
  137. meerk40t/dxf/__init__.py +1 -1
  138. meerk40t/dxf/dxf_io.py +766 -554
  139. meerk40t/dxf/plugin.py +47 -35
  140. meerk40t/external_plugins.py +79 -79
  141. meerk40t/external_plugins_build.py +28 -28
  142. meerk40t/extra/cag.py +112 -116
  143. meerk40t/extra/coolant.py +403 -0
  144. meerk40t/extra/encode_detect.py +204 -0
  145. meerk40t/extra/ezd.py +1165 -1165
  146. meerk40t/extra/hershey.py +834 -340
  147. meerk40t/extra/imageactions.py +322 -316
  148. meerk40t/extra/inkscape.py +628 -622
  149. meerk40t/extra/lbrn.py +424 -424
  150. meerk40t/extra/outerworld.py +283 -0
  151. meerk40t/extra/param_functions.py +1542 -1556
  152. meerk40t/extra/potrace.py +257 -253
  153. meerk40t/extra/serial_exchange.py +118 -0
  154. meerk40t/extra/updater.py +602 -453
  155. meerk40t/extra/vectrace.py +147 -146
  156. meerk40t/extra/winsleep.py +83 -83
  157. meerk40t/extra/xcs_reader.py +597 -0
  158. meerk40t/fill/fills.py +781 -335
  159. meerk40t/fill/patternfill.py +1061 -1061
  160. meerk40t/fill/patterns.py +614 -567
  161. meerk40t/grbl/control.py +87 -87
  162. meerk40t/grbl/controller.py +990 -903
  163. meerk40t/grbl/device.py +1084 -768
  164. meerk40t/grbl/driver.py +989 -771
  165. meerk40t/grbl/emulator.py +532 -497
  166. meerk40t/grbl/gcodejob.py +783 -767
  167. meerk40t/grbl/gui/grblconfiguration.py +373 -298
  168. meerk40t/grbl/gui/grblcontroller.py +485 -271
  169. meerk40t/grbl/gui/grblhardwareconfig.py +269 -153
  170. meerk40t/grbl/gui/grbloperationconfig.py +105 -0
  171. meerk40t/grbl/gui/gui.py +147 -116
  172. meerk40t/grbl/interpreter.py +44 -44
  173. meerk40t/grbl/loader.py +22 -22
  174. meerk40t/grbl/mock_connection.py +56 -56
  175. meerk40t/grbl/plugin.py +294 -264
  176. meerk40t/grbl/serial_connection.py +93 -88
  177. meerk40t/grbl/tcp_connection.py +81 -79
  178. meerk40t/grbl/ws_connection.py +112 -0
  179. meerk40t/gui/__init__.py +1 -1
  180. meerk40t/gui/about.py +2042 -296
  181. meerk40t/gui/alignment.py +1644 -1608
  182. meerk40t/gui/autoexec.py +199 -0
  183. meerk40t/gui/basicops.py +791 -670
  184. meerk40t/gui/bufferview.py +77 -71
  185. meerk40t/gui/busy.py +232 -133
  186. meerk40t/gui/choicepropertypanel.py +1662 -1469
  187. meerk40t/gui/consolepanel.py +706 -542
  188. meerk40t/gui/devicepanel.py +687 -581
  189. meerk40t/gui/dialogoptions.py +110 -107
  190. meerk40t/gui/executejob.py +316 -306
  191. meerk40t/gui/fonts.py +90 -90
  192. meerk40t/gui/functionwrapper.py +252 -0
  193. meerk40t/gui/gui_mixins.py +729 -0
  194. meerk40t/gui/guicolors.py +205 -182
  195. meerk40t/gui/help_assets/help_assets.py +218 -201
  196. meerk40t/gui/helper.py +154 -0
  197. meerk40t/gui/hersheymanager.py +1440 -846
  198. meerk40t/gui/icons.py +3422 -2747
  199. meerk40t/gui/imagesplitter.py +555 -508
  200. meerk40t/gui/keymap.py +354 -344
  201. meerk40t/gui/laserpanel.py +897 -806
  202. meerk40t/gui/laserrender.py +1470 -1232
  203. meerk40t/gui/lasertoolpanel.py +805 -793
  204. meerk40t/gui/magnetoptions.py +436 -0
  205. meerk40t/gui/materialmanager.py +2944 -0
  206. meerk40t/gui/materialtest.py +1722 -1694
  207. meerk40t/gui/mkdebug.py +646 -359
  208. meerk40t/gui/mwindow.py +163 -140
  209. meerk40t/gui/navigationpanels.py +2605 -2467
  210. meerk40t/gui/notes.py +143 -142
  211. meerk40t/gui/opassignment.py +414 -410
  212. meerk40t/gui/operation_info.py +310 -299
  213. meerk40t/gui/plugin.py +500 -328
  214. meerk40t/gui/position.py +714 -669
  215. meerk40t/gui/preferences.py +901 -650
  216. meerk40t/gui/propertypanels/attributes.py +1461 -1131
  217. meerk40t/gui/propertypanels/blobproperty.py +117 -114
  218. meerk40t/gui/propertypanels/consoleproperty.py +83 -80
  219. meerk40t/gui/propertypanels/gotoproperty.py +77 -0
  220. meerk40t/gui/propertypanels/groupproperties.py +223 -217
  221. meerk40t/gui/propertypanels/hatchproperty.py +489 -469
  222. meerk40t/gui/propertypanels/imageproperty.py +2244 -1384
  223. meerk40t/gui/propertypanels/inputproperty.py +59 -58
  224. meerk40t/gui/propertypanels/opbranchproperties.py +82 -80
  225. meerk40t/gui/propertypanels/operationpropertymain.py +1890 -1638
  226. meerk40t/gui/propertypanels/outputproperty.py +59 -58
  227. meerk40t/gui/propertypanels/pathproperty.py +389 -380
  228. meerk40t/gui/propertypanels/placementproperty.py +1214 -383
  229. meerk40t/gui/propertypanels/pointproperty.py +140 -136
  230. meerk40t/gui/propertypanels/propertywindow.py +313 -181
  231. meerk40t/gui/propertypanels/rasterwizardpanels.py +996 -912
  232. meerk40t/gui/propertypanels/regbranchproperties.py +76 -0
  233. meerk40t/gui/propertypanels/textproperty.py +770 -755
  234. meerk40t/gui/propertypanels/waitproperty.py +56 -55
  235. meerk40t/gui/propertypanels/warpproperty.py +121 -0
  236. meerk40t/gui/propertypanels/wobbleproperty.py +255 -204
  237. meerk40t/gui/ribbon.py +2471 -2210
  238. meerk40t/gui/scene/scene.py +1100 -1051
  239. meerk40t/gui/scene/sceneconst.py +22 -22
  240. meerk40t/gui/scene/scenepanel.py +439 -349
  241. meerk40t/gui/scene/scenespacewidget.py +365 -365
  242. meerk40t/gui/scene/widget.py +518 -505
  243. meerk40t/gui/scenewidgets/affinemover.py +215 -215
  244. meerk40t/gui/scenewidgets/attractionwidget.py +315 -309
  245. meerk40t/gui/scenewidgets/bedwidget.py +120 -97
  246. meerk40t/gui/scenewidgets/elementswidget.py +137 -107
  247. meerk40t/gui/scenewidgets/gridwidget.py +785 -745
  248. meerk40t/gui/scenewidgets/guidewidget.py +765 -765
  249. meerk40t/gui/scenewidgets/laserpathwidget.py +66 -66
  250. meerk40t/gui/scenewidgets/machineoriginwidget.py +86 -86
  251. meerk40t/gui/scenewidgets/nodeselector.py +28 -28
  252. meerk40t/gui/scenewidgets/rectselectwidget.py +592 -346
  253. meerk40t/gui/scenewidgets/relocatewidget.py +33 -33
  254. meerk40t/gui/scenewidgets/reticlewidget.py +83 -83
  255. meerk40t/gui/scenewidgets/selectionwidget.py +2958 -2756
  256. meerk40t/gui/simpleui.py +362 -333
  257. meerk40t/gui/simulation.py +2451 -2094
  258. meerk40t/gui/snapoptions.py +208 -203
  259. meerk40t/gui/spoolerpanel.py +1227 -1180
  260. meerk40t/gui/statusbarwidgets/defaultoperations.py +480 -353
  261. meerk40t/gui/statusbarwidgets/infowidget.py +520 -483
  262. meerk40t/gui/statusbarwidgets/opassignwidget.py +356 -355
  263. meerk40t/gui/statusbarwidgets/selectionwidget.py +172 -171
  264. meerk40t/gui/statusbarwidgets/shapepropwidget.py +754 -236
  265. meerk40t/gui/statusbarwidgets/statusbar.py +272 -260
  266. meerk40t/gui/statusbarwidgets/statusbarwidget.py +268 -270
  267. meerk40t/gui/statusbarwidgets/strokewidget.py +267 -251
  268. meerk40t/gui/themes.py +200 -78
  269. meerk40t/gui/tips.py +590 -0
  270. meerk40t/gui/toolwidgets/circlebrush.py +35 -35
  271. meerk40t/gui/toolwidgets/toolcircle.py +248 -242
  272. meerk40t/gui/toolwidgets/toolcontainer.py +82 -77
  273. meerk40t/gui/toolwidgets/tooldraw.py +97 -90
  274. meerk40t/gui/toolwidgets/toolellipse.py +219 -212
  275. meerk40t/gui/toolwidgets/toolimagecut.py +25 -132
  276. meerk40t/gui/toolwidgets/toolline.py +39 -144
  277. meerk40t/gui/toolwidgets/toollinetext.py +79 -236
  278. meerk40t/gui/toolwidgets/toollinetext_inline.py +296 -0
  279. meerk40t/gui/toolwidgets/toolmeasure.py +163 -216
  280. meerk40t/gui/toolwidgets/toolnodeedit.py +2088 -2074
  281. meerk40t/gui/toolwidgets/toolnodemove.py +92 -94
  282. meerk40t/gui/toolwidgets/toolparameter.py +754 -668
  283. meerk40t/gui/toolwidgets/toolplacement.py +108 -108
  284. meerk40t/gui/toolwidgets/toolpoint.py +68 -59
  285. meerk40t/gui/toolwidgets/toolpointlistbuilder.py +294 -0
  286. meerk40t/gui/toolwidgets/toolpointmove.py +183 -0
  287. meerk40t/gui/toolwidgets/toolpolygon.py +288 -403
  288. meerk40t/gui/toolwidgets/toolpolyline.py +38 -196
  289. meerk40t/gui/toolwidgets/toolrect.py +211 -207
  290. meerk40t/gui/toolwidgets/toolrelocate.py +72 -72
  291. meerk40t/gui/toolwidgets/toolribbon.py +598 -113
  292. meerk40t/gui/toolwidgets/tooltabedit.py +546 -0
  293. meerk40t/gui/toolwidgets/tooltext.py +98 -89
  294. meerk40t/gui/toolwidgets/toolvector.py +213 -204
  295. meerk40t/gui/toolwidgets/toolwidget.py +39 -39
  296. meerk40t/gui/usbconnect.py +98 -91
  297. meerk40t/gui/utilitywidgets/buttonwidget.py +18 -18
  298. meerk40t/gui/utilitywidgets/checkboxwidget.py +90 -90
  299. meerk40t/gui/utilitywidgets/controlwidget.py +14 -14
  300. meerk40t/gui/utilitywidgets/cyclocycloidwidget.py +343 -340
  301. meerk40t/gui/utilitywidgets/debugwidgets.py +148 -0
  302. meerk40t/gui/utilitywidgets/handlewidget.py +27 -27
  303. meerk40t/gui/utilitywidgets/harmonograph.py +450 -447
  304. meerk40t/gui/utilitywidgets/openclosewidget.py +40 -40
  305. meerk40t/gui/utilitywidgets/rotationwidget.py +54 -54
  306. meerk40t/gui/utilitywidgets/scalewidget.py +75 -75
  307. meerk40t/gui/utilitywidgets/seekbarwidget.py +183 -183
  308. meerk40t/gui/utilitywidgets/togglewidget.py +142 -142
  309. meerk40t/gui/utilitywidgets/toolbarwidget.py +8 -8
  310. meerk40t/gui/wordlisteditor.py +985 -931
  311. meerk40t/gui/wxmeerk40t.py +1447 -1169
  312. meerk40t/gui/wxmmain.py +5644 -4112
  313. meerk40t/gui/wxmribbon.py +1591 -1076
  314. meerk40t/gui/wxmscene.py +1631 -1453
  315. meerk40t/gui/wxmtree.py +2416 -2089
  316. meerk40t/gui/wxutils.py +1769 -1099
  317. meerk40t/gui/zmatrix.py +102 -102
  318. meerk40t/image/__init__.py +1 -1
  319. meerk40t/image/dither.py +429 -0
  320. meerk40t/image/imagetools.py +2793 -2269
  321. meerk40t/internal_plugins.py +150 -130
  322. meerk40t/kernel/__init__.py +63 -12
  323. meerk40t/kernel/channel.py +259 -212
  324. meerk40t/kernel/context.py +538 -538
  325. meerk40t/kernel/exceptions.py +41 -41
  326. meerk40t/kernel/functions.py +463 -414
  327. meerk40t/kernel/jobs.py +100 -100
  328. meerk40t/kernel/kernel.py +3828 -3571
  329. meerk40t/kernel/lifecycles.py +71 -71
  330. meerk40t/kernel/module.py +49 -49
  331. meerk40t/kernel/service.py +147 -147
  332. meerk40t/kernel/settings.py +383 -343
  333. meerk40t/lihuiyu/controller.py +883 -876
  334. meerk40t/lihuiyu/device.py +1181 -1069
  335. meerk40t/lihuiyu/driver.py +1466 -1372
  336. meerk40t/lihuiyu/gui/gui.py +127 -106
  337. meerk40t/lihuiyu/gui/lhyaccelgui.py +377 -363
  338. meerk40t/lihuiyu/gui/lhycontrollergui.py +741 -651
  339. meerk40t/lihuiyu/gui/lhydrivergui.py +470 -446
  340. meerk40t/lihuiyu/gui/lhyoperationproperties.py +238 -237
  341. meerk40t/lihuiyu/gui/tcpcontroller.py +226 -190
  342. meerk40t/lihuiyu/interpreter.py +53 -53
  343. meerk40t/lihuiyu/laserspeed.py +450 -450
  344. meerk40t/lihuiyu/loader.py +90 -90
  345. meerk40t/lihuiyu/parser.py +404 -404
  346. meerk40t/lihuiyu/plugin.py +101 -102
  347. meerk40t/lihuiyu/tcp_connection.py +111 -109
  348. meerk40t/main.py +231 -165
  349. meerk40t/moshi/builder.py +788 -781
  350. meerk40t/moshi/controller.py +505 -499
  351. meerk40t/moshi/device.py +495 -442
  352. meerk40t/moshi/driver.py +862 -696
  353. meerk40t/moshi/gui/gui.py +78 -76
  354. meerk40t/moshi/gui/moshicontrollergui.py +538 -522
  355. meerk40t/moshi/gui/moshidrivergui.py +87 -75
  356. meerk40t/moshi/plugin.py +43 -43
  357. meerk40t/network/console_server.py +140 -57
  358. meerk40t/network/kernelserver.py +10 -9
  359. meerk40t/network/tcp_server.py +142 -140
  360. meerk40t/network/udp_server.py +103 -77
  361. meerk40t/network/web_server.py +404 -0
  362. meerk40t/newly/controller.py +1158 -1144
  363. meerk40t/newly/device.py +874 -732
  364. meerk40t/newly/driver.py +540 -412
  365. meerk40t/newly/gui/gui.py +219 -188
  366. meerk40t/newly/gui/newlyconfig.py +116 -101
  367. meerk40t/newly/gui/newlycontroller.py +193 -186
  368. meerk40t/newly/gui/operationproperties.py +51 -51
  369. meerk40t/newly/mock_connection.py +82 -82
  370. meerk40t/newly/newly_params.py +56 -56
  371. meerk40t/newly/plugin.py +1214 -1246
  372. meerk40t/newly/usb_connection.py +322 -322
  373. meerk40t/rotary/gui/gui.py +52 -46
  374. meerk40t/rotary/gui/rotarysettings.py +240 -232
  375. meerk40t/rotary/rotary.py +202 -98
  376. meerk40t/ruida/control.py +291 -91
  377. meerk40t/ruida/controller.py +138 -1088
  378. meerk40t/ruida/device.py +676 -231
  379. meerk40t/ruida/driver.py +534 -472
  380. meerk40t/ruida/emulator.py +1494 -1491
  381. meerk40t/ruida/exceptions.py +4 -4
  382. meerk40t/ruida/gui/gui.py +71 -76
  383. meerk40t/ruida/gui/ruidaconfig.py +239 -72
  384. meerk40t/ruida/gui/ruidacontroller.py +187 -184
  385. meerk40t/ruida/gui/ruidaoperationproperties.py +48 -47
  386. meerk40t/ruida/loader.py +54 -52
  387. meerk40t/ruida/mock_connection.py +57 -109
  388. meerk40t/ruida/plugin.py +124 -87
  389. meerk40t/ruida/rdjob.py +2084 -945
  390. meerk40t/ruida/serial_connection.py +116 -0
  391. meerk40t/ruida/tcp_connection.py +146 -0
  392. meerk40t/ruida/udp_connection.py +73 -0
  393. meerk40t/svgelements.py +9671 -9669
  394. meerk40t/tools/driver_to_path.py +584 -579
  395. meerk40t/tools/geomstr.py +5583 -4680
  396. meerk40t/tools/jhfparser.py +357 -292
  397. meerk40t/tools/kerftest.py +904 -890
  398. meerk40t/tools/livinghinges.py +1168 -1033
  399. meerk40t/tools/pathtools.py +987 -949
  400. meerk40t/tools/pmatrix.py +234 -0
  401. meerk40t/tools/pointfinder.py +942 -942
  402. meerk40t/tools/polybool.py +941 -940
  403. meerk40t/tools/rasterplotter.py +1660 -547
  404. meerk40t/tools/shxparser.py +1047 -901
  405. meerk40t/tools/ttfparser.py +726 -446
  406. meerk40t/tools/zinglplotter.py +595 -593
  407. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/LICENSE +21 -21
  408. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/METADATA +150 -139
  409. meerk40t-0.9.7020.dist-info/RECORD +446 -0
  410. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/WHEEL +1 -1
  411. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/top_level.txt +0 -1
  412. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/zip-safe +1 -1
  413. meerk40t/balormk/elementlightjob.py +0 -159
  414. meerk40t-0.9.3001.dist-info/RECORD +0 -437
  415. test/bootstrap.py +0 -63
  416. test/test_cli.py +0 -12
  417. test/test_core_cutcode.py +0 -418
  418. test/test_core_elements.py +0 -144
  419. test/test_core_plotplanner.py +0 -397
  420. test/test_core_viewports.py +0 -312
  421. test/test_drivers_grbl.py +0 -108
  422. test/test_drivers_lihuiyu.py +0 -443
  423. test/test_drivers_newly.py +0 -113
  424. test/test_element_degenerate_points.py +0 -43
  425. test/test_elements_classify.py +0 -97
  426. test/test_elements_penbox.py +0 -22
  427. test/test_file_svg.py +0 -176
  428. test/test_fill.py +0 -155
  429. test/test_geomstr.py +0 -1523
  430. test/test_geomstr_nodes.py +0 -18
  431. test/test_imagetools_actualize.py +0 -306
  432. test/test_imagetools_wizard.py +0 -258
  433. test/test_kernel.py +0 -200
  434. test/test_laser_speeds.py +0 -3303
  435. test/test_length.py +0 -57
  436. test/test_lifecycle.py +0 -66
  437. test/test_operations.py +0 -251
  438. test/test_operations_hatch.py +0 -57
  439. test/test_ruida.py +0 -19
  440. test/test_spooler.py +0 -22
  441. test/test_tools_rasterplotter.py +0 -29
  442. test/test_wobble.py +0 -133
  443. test/test_zingl.py +0 -124
  444. {test → meerk40t/cylinder}/__init__.py +0 -0
  445. /meerk40t/{core/element_commands.py → cylinder/gui/__init__.py} +0 -0
  446. {meerk40t-0.9.3001.dist-info → meerk40t-0.9.7020.dist-info}/entry_points.txt +0 -0
@@ -1,522 +1,538 @@
1
- import threading
2
-
3
- import wx
4
-
5
- from meerk40t.gui.icons import (
6
- get_default_icon_size,
7
- icons8_connected,
8
- icons8_disconnected,
9
- )
10
- from meerk40t.gui.mwindow import MWindow
11
- from meerk40t.gui.wxutils import StaticBoxSizer, dip_size
12
- from meerk40t.kernel import signal_listener
13
-
14
- _ = wx.GetTranslation
15
-
16
- _simple_width = 500
17
- _advanced_width = 855
18
- _default_height = 389
19
-
20
-
21
- class MoshiControllerPanel(wx.Panel):
22
- def __init__(self, *args, context=None, **kwds):
23
- kwds["style"] = kwds.get("style", 0) | wx.TAB_TRAVERSAL
24
- wx.Panel.__init__(self, *args, **kwds)
25
- self.context = context.device
26
-
27
- self.button_device_connect = wx.Button(self, wx.ID_ANY, _("Connection"))
28
- self.text_connection_status = wx.TextCtrl(
29
- self, wx.ID_ANY, "", style=wx.TE_READONLY
30
- )
31
- self.checkbox_mock_usb = wx.CheckBox(
32
- self, wx.ID_ANY, _("Mock USB Connection Mode")
33
- )
34
- self.text_device_index = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
35
- self.spin_device_index = wx.SpinCtrl(self, wx.ID_ANY, "-1", min=-1)
36
- self.text_device_address = wx.TextCtrl(
37
- self, wx.ID_ANY, "", style=wx.TE_READONLY
38
- )
39
- self.spin_device_address = wx.SpinCtrl(self, wx.ID_ANY, "-1", min=-1)
40
- self.text_device_bus = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
41
- self.spin_device_bus = wx.SpinCtrl(self, wx.ID_ANY, "-1", min=-1)
42
- self.text_device_version = wx.TextCtrl(
43
- self, wx.ID_ANY, "", style=wx.TE_READONLY
44
- )
45
- self.spin_device_version = wx.SpinCtrl(self, wx.ID_ANY, "-1", min=-1)
46
- self.text_byte_0 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
47
- self.text_byte_1 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
48
- self.text_desc = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
49
- self.text_byte_2 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
50
- self.text_byte_3 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
51
- self.text_byte_4 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
52
- self.text_byte_5 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
53
- self.checkbox_show_usb_log = wx.CheckBox(self, wx.ID_ANY, _("Show USB Log"))
54
- self.text_usb_log = wx.TextCtrl(
55
- self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY
56
- )
57
-
58
- self.__set_properties()
59
- self.__do_layout()
60
-
61
- self.Bind(wx.EVT_BUTTON, self.on_button_start_usb, self.button_device_connect)
62
- self.Bind(wx.EVT_CHECKBOX, self.on_check_mock_usb, self.checkbox_mock_usb)
63
- self.Bind(wx.EVT_SPINCTRL, self.spin_on_device_index, self.spin_device_index)
64
- self.Bind(wx.EVT_TEXT_ENTER, self.spin_on_device_index, self.spin_device_index)
65
- self.Bind(
66
- wx.EVT_SPINCTRL, self.spin_on_device_address, self.spin_device_address
67
- )
68
- self.Bind(
69
- wx.EVT_TEXT_ENTER, self.spin_on_device_address, self.spin_device_address
70
- )
71
- self.Bind(wx.EVT_SPINCTRL, self.spin_on_device_bus, self.spin_device_bus)
72
- self.Bind(wx.EVT_TEXT_ENTER, self.spin_on_device_bus, self.spin_device_bus)
73
- self.Bind(
74
- wx.EVT_SPINCTRL, self.spin_on_device_version, self.spin_device_version
75
- )
76
- self.Bind(
77
- wx.EVT_TEXT_ENTER, self.spin_on_device_version, self.spin_device_version
78
- )
79
- self.Bind(
80
- wx.EVT_CHECKBOX, self.on_check_show_usb_log, self.checkbox_show_usb_log
81
- )
82
- self.last_control_state = None
83
- self._buffer = ""
84
- self._buffer_lock = threading.Lock()
85
- self.set_widgets()
86
-
87
- def __set_properties(self):
88
- self.SetFont(
89
- wx.Font(
90
- 9,
91
- wx.FONTFAMILY_DEFAULT,
92
- wx.FONTSTYLE_NORMAL,
93
- wx.FONTWEIGHT_NORMAL,
94
- 0,
95
- "Segoe UI",
96
- )
97
- )
98
- self.button_device_connect.SetBackgroundColour(wx.Colour(102, 255, 102))
99
- self.button_device_connect.SetForegroundColour(wx.BLACK)
100
- self.button_device_connect.SetBitmap(
101
- icons8_disconnected.GetBitmap(
102
- use_theme=False, resize=get_default_icon_size()
103
- )
104
- )
105
- self.button_device_connect.SetFont(
106
- wx.Font(
107
- 12,
108
- wx.FONTFAMILY_DEFAULT,
109
- wx.FONTSTYLE_NORMAL,
110
- wx.FONTWEIGHT_NORMAL,
111
- 0,
112
- "Segoe UI",
113
- )
114
- )
115
- self.button_device_connect.SetToolTip(
116
- _("Force connection/disconnection from the device.")
117
- )
118
- self.text_connection_status.SetToolTip(_("Connection status"))
119
- self.checkbox_mock_usb.SetToolTip(
120
- _(
121
- "DEBUG. Without a K40 connected continue to process things as if there was one."
122
- )
123
- )
124
- self.text_device_index.SetMinSize(dip_size(self, 55, -1))
125
- self.spin_device_index.SetMinSize(dip_size(self, 40, -1))
126
- self.spin_device_index.SetToolTip(
127
- _(
128
- "Optional: Distinguish between different lasers using the match criteria below.\n"
129
- "-1 match anything. 0+ match exactly that value."
130
- )
131
- )
132
- self.text_device_address.SetMinSize(dip_size(self, 55, -1))
133
- self.spin_device_address.SetMinSize(dip_size(self, 40, -1))
134
- self.spin_device_address.SetToolTip(
135
- _(
136
- "Optional: Distinguish between different lasers using the match criteria below.\n"
137
- "-1 match anything. 0+ match exactly that value."
138
- )
139
- )
140
- self.text_device_bus.SetMinSize(dip_size(self, 55, -1))
141
- self.spin_device_bus.SetMinSize(dip_size(self, 40, -1))
142
- self.spin_device_bus.SetToolTip(
143
- _(
144
- "Optional: Distinguish between different lasers using the match criteria below.\n"
145
- "-1 match anything. 0+ match exactly that value."
146
- )
147
- )
148
- self.text_device_version.SetMinSize(dip_size(self, 55, -1))
149
- self.spin_device_version.SetMinSize(dip_size(self, 40, -1))
150
- self.spin_device_version.SetToolTip(
151
- _(
152
- "Optional: Distinguish between different lasers using the match criteria below.\n"
153
- "-1 match anything. 0+ match exactly that value."
154
- )
155
- )
156
- self.text_byte_0.SetMinSize(dip_size(self, 77, -1))
157
- self.text_byte_1.SetMinSize(dip_size(self, 77, -1))
158
- self.text_desc.SetMinSize(dip_size(self, 75, 23))
159
- self.text_desc.SetToolTip(_("The meaning of Byte 1"))
160
- self.text_byte_2.SetMinSize(dip_size(self, 77, -1))
161
- self.text_byte_3.SetMinSize(dip_size(self, 77, -1))
162
- self.text_byte_4.SetMinSize(dip_size(self, 77, -1))
163
- self.text_byte_5.SetMinSize(dip_size(self, 77, -1))
164
- self.checkbox_show_usb_log.SetValue(1)
165
- # end wxGlade
166
-
167
- def __do_layout(self):
168
- # begin wxGlade: MoshiControllerGui.__do_layout
169
- sizer_24 = wx.BoxSizer(wx.HORIZONTAL)
170
- sizer_1 = wx.BoxSizer(wx.VERTICAL)
171
- sizer_show_usb_log = wx.BoxSizer(wx.HORIZONTAL)
172
- packet_count = StaticBoxSizer(self, wx.ID_ANY, _("Packet Info"), wx.VERTICAL)
173
- byte_data_status = StaticBoxSizer(
174
- self, wx.ID_ANY, _("Byte Data Status"), wx.HORIZONTAL
175
- )
176
- byte5sizer = wx.BoxSizer(wx.VERTICAL)
177
- byte4sizer = wx.BoxSizer(wx.VERTICAL)
178
- byte3sizer = wx.BoxSizer(wx.VERTICAL)
179
- byte2sizer = wx.BoxSizer(wx.VERTICAL)
180
- byte1sizer = wx.BoxSizer(wx.VERTICAL)
181
- byte0sizer = wx.BoxSizer(wx.VERTICAL)
182
- sizer_usb_settings = StaticBoxSizer(
183
- self, wx.ID_ANY, _("USB Settings"), wx.VERTICAL
184
- )
185
- sizer_23 = wx.BoxSizer(wx.HORIZONTAL)
186
- sizer_12 = StaticBoxSizer(self, wx.ID_ANY, _("Chip Version"), wx.HORIZONTAL)
187
- sizer_11 = StaticBoxSizer(self, wx.ID_ANY, _("Device Bus:"), wx.HORIZONTAL)
188
- sizer_10 = StaticBoxSizer(self, wx.ID_ANY, _("Device Address:"), wx.HORIZONTAL)
189
- sizer_3 = StaticBoxSizer(self, wx.ID_ANY, _("Device Index:"), wx.HORIZONTAL)
190
- sizer_usb_connect = StaticBoxSizer(
191
- self, wx.ID_ANY, _("USB Connection"), wx.VERTICAL
192
- )
193
- sizer_usb_connect.Add(self.button_device_connect, 0, wx.EXPAND, 0)
194
- sizer_usb_connect.Add(self.text_connection_status, 0, wx.EXPAND, 0)
195
- sizer_1.Add(sizer_usb_connect, 0, wx.EXPAND, 0)
196
- sizer_usb_settings.Add(self.checkbox_mock_usb, 0, 0, 0)
197
- sizer_3.Add(self.text_device_index, 0, 0, 0)
198
- sizer_3.Add(self.spin_device_index, 0, 0, 0)
199
- sizer_23.Add(sizer_3, 0, wx.EXPAND, 0)
200
- sizer_10.Add(self.text_device_address, 0, 0, 0)
201
- sizer_10.Add(self.spin_device_address, 0, 0, 0)
202
- sizer_23.Add(sizer_10, 0, wx.EXPAND, 0)
203
- sizer_11.Add(self.text_device_bus, 0, 0, 0)
204
- sizer_11.Add(self.spin_device_bus, 0, 0, 0)
205
- sizer_23.Add(sizer_11, 0, wx.EXPAND, 0)
206
- sizer_12.Add(self.text_device_version, 0, 0, 0)
207
- sizer_12.Add(self.spin_device_version, 0, 0, 0)
208
- sizer_23.Add(sizer_12, 0, wx.EXPAND, 0)
209
- sizer_usb_settings.Add(sizer_23, 1, wx.EXPAND, 0)
210
- sizer_1.Add(sizer_usb_settings, 0, wx.EXPAND, 0)
211
- byte0sizer.Add(self.text_byte_0, 0, 0, 0)
212
- label_1 = wx.StaticText(self, wx.ID_ANY, _("Byte 0"))
213
- byte0sizer.Add(label_1, 0, 0, 0)
214
- byte_data_status.Add(byte0sizer, 1, wx.EXPAND, 0)
215
- byte1sizer.Add(self.text_byte_1, 0, 0, 0)
216
- label_2 = wx.StaticText(self, wx.ID_ANY, _("Byte 1"))
217
- byte1sizer.Add(label_2, 0, 0, 0)
218
- byte1sizer.Add(self.text_desc, 0, 0, 0)
219
- byte_data_status.Add(byte1sizer, 1, wx.EXPAND, 0)
220
- byte2sizer.Add(self.text_byte_2, 0, 0, 0)
221
- label_3 = wx.StaticText(self, wx.ID_ANY, _("Byte 2"))
222
- byte2sizer.Add(label_3, 0, 0, 0)
223
- byte_data_status.Add(byte2sizer, 1, wx.EXPAND, 0)
224
- byte3sizer.Add(self.text_byte_3, 0, 0, 0)
225
- label_4 = wx.StaticText(self, wx.ID_ANY, _("Byte 3"))
226
- byte3sizer.Add(label_4, 0, 0, 0)
227
- byte_data_status.Add(byte3sizer, 1, wx.EXPAND, 0)
228
- byte4sizer.Add(self.text_byte_4, 0, 0, 0)
229
- label_5 = wx.StaticText(self, wx.ID_ANY, _("Byte 4"))
230
- byte4sizer.Add(label_5, 0, 0, 0)
231
- byte_data_status.Add(byte4sizer, 1, wx.EXPAND, 0)
232
- byte5sizer.Add(self.text_byte_5, 0, 0, 0)
233
- label_18 = wx.StaticText(self, wx.ID_ANY, _("Byte 5"))
234
- byte5sizer.Add(label_18, 0, 0, 0)
235
- byte_data_status.Add(byte5sizer, 1, wx.EXPAND, 0)
236
- packet_count.Add(byte_data_status, 0, wx.EXPAND, 0)
237
- sizer_1.Add(packet_count, 0, 0, 0)
238
- label_6 = wx.StaticText(self, wx.ID_ANY, "")
239
- sizer_show_usb_log.Add(label_6, 10, wx.EXPAND, 0)
240
- sizer_show_usb_log.Add(self.checkbox_show_usb_log, 0, 0, 0)
241
- sizer_1.Add(sizer_show_usb_log, 1, wx.EXPAND, 0)
242
- sizer_24.Add(sizer_1, 1, 0, 0)
243
- sizer_24.Add(self.text_usb_log, 2, wx.EXPAND, 0)
244
- self.SetSizer(sizer_24)
245
- self.Layout()
246
- # end wxGlade
247
-
248
- def pane_show(self):
249
- active = self.context.path.split("/")[-1]
250
- self.context.channel(f"{active}/usb", buffer_size=500).watch(self.update_text)
251
- self.context.listen("pipe;status", self.update_status)
252
- self.context.listen("pipe;usb_status", self.on_connection_status_change)
253
- self.context.listen("pipe;state", self.on_connection_state_change)
254
- self.context.listen("active", self.on_active_change)
255
-
256
- def pane_hide(self):
257
- active = self.context.path.split("/")[-1]
258
- self.context.channel(f"{active}/usb").unwatch(self.update_text)
259
- self.context.unlisten("pipe;status", self.update_status)
260
- self.context.unlisten("pipe;usb_status", self.on_connection_status_change)
261
- self.context.unlisten("pipe;state", self.on_connection_state_change)
262
- self.context.unlisten("active", self.on_active_change)
263
-
264
- def on_active_change(self, origin, active):
265
- # self.Close()
266
- pass
267
-
268
- def update_text(self, text):
269
- with self._buffer_lock:
270
- self._buffer += f"{text}\n"
271
- self.context.signal("moshi_controller_update")
272
-
273
- @signal_listener("moshi_controller_update")
274
- def update_text_gui(self, origin, *args):
275
- with self._buffer_lock:
276
- buffer = self._buffer
277
- self._buffer = ""
278
- self.text_usb_log.AppendText(buffer)
279
-
280
- def set_widgets(self):
281
- self.context.setting(bool, "show_usb_log", False)
282
- self.context.setting(int, "usb_index", -1)
283
- self.context.setting(int, "usb_bus", -1)
284
- self.context.setting(int, "usb_address", -1)
285
- self.context.setting(int, "usb_version", -1)
286
- self.context.setting(bool, "mock", False)
287
-
288
- self.checkbox_show_usb_log.SetValue(self.context.show_usb_log)
289
- self.checkbox_mock_usb.SetValue(self.context.mock)
290
- self.spin_device_index.SetValue(self.context.usb_index)
291
- self.spin_device_bus.SetValue(self.context.usb_bus)
292
- self.spin_device_address.SetValue(self.context.usb_address)
293
- self.spin_device_version.SetValue(self.context.usb_version)
294
-
295
- self.on_check_show_usb_log()
296
-
297
- def device_execute(self, control_name):
298
- def menu_element(event=None):
299
- self.context.execute(control_name)
300
-
301
- return menu_element
302
-
303
- def update_status(self, origin, status_data, code_string):
304
- if status_data is not None:
305
- if isinstance(status_data, int):
306
- self.text_desc.SetValue(str(status_data))
307
- self.text_desc.SetValue(code_string)
308
- else:
309
- if len(status_data) == 6:
310
- self.text_byte_0.SetValue(str(status_data[0]))
311
- self.text_byte_1.SetValue(str(status_data[1]))
312
- self.text_byte_2.SetValue(str(status_data[2]))
313
- self.text_byte_3.SetValue(str(status_data[3]))
314
- self.text_byte_4.SetValue(str(status_data[4]))
315
- self.text_byte_5.SetValue(str(status_data[5]))
316
- self.text_desc.SetValue(code_string)
317
-
318
- def on_connection_status_change(self, origin, status):
319
- self.text_connection_status.SetValue(str(status))
320
-
321
- def on_connection_state_change(self, origin, state):
322
- if state == "STATE_CONNECTION_FAILED" or state == "STATE_DRIVER_NO_BACKEND":
323
- self.button_device_connect.SetBackgroundColour("#dfdf00")
324
- origin, usb_status = self.context.last_signal("pipe;usb_status")
325
- if usb_status is not None:
326
- self.button_device_connect.SetLabel(str(usb_status[0]))
327
- self.button_device_connect.SetBitmap(
328
- icons8_disconnected.GetBitmap(
329
- use_theme=False, resize=get_default_icon_size()
330
- )
331
- )
332
- self.button_device_connect.Enable()
333
- elif state == "STATE_UNINITIALIZED" or state == "STATE_USB_DISCONNECTED":
334
- self.button_device_connect.SetBackgroundColour("#ffff00")
335
- self.button_device_connect.SetLabel(_("Connect"))
336
- self.button_device_connect.SetBitmap(
337
- icons8_connected.GetBitmap(
338
- use_theme=False, resize=get_default_icon_size()
339
- )
340
- )
341
- self.button_device_connect.Enable()
342
- elif state == "STATE_USB_SET_DISCONNECTING":
343
- self.button_device_connect.SetBackgroundColour("#ffff00")
344
- self.button_device_connect.SetLabel(_("Disconnecting..."))
345
- self.button_device_connect.SetBitmap(
346
- icons8_disconnected.GetBitmap(
347
- use_theme=False, resize=get_default_icon_size()
348
- )
349
- )
350
- self.button_device_connect.Disable()
351
- elif state == "STATE_USB_CONNECTED" or state == "STATE_CONNECTED":
352
- self.button_device_connect.SetBackgroundColour("#00ff00")
353
- self.button_device_connect.SetLabel(_("Disconnect"))
354
- self.button_device_connect.SetBitmap(
355
- icons8_connected.GetBitmap(
356
- use_theme=False, resize=get_default_icon_size()
357
- )
358
- )
359
- self.button_device_connect.Enable()
360
- elif state == "STATE_CONNECTING":
361
- self.button_device_connect.SetBackgroundColour("#ffff00")
362
- self.button_device_connect.SetLabel(_("Connecting..."))
363
- self.button_device_connect.SetBitmap(
364
- icons8_connected.GetBitmap(
365
- use_theme=False, resize=get_default_icon_size()
366
- )
367
- )
368
- self.button_device_connect.Disable()
369
-
370
- def on_button_start_usb(self, event=None): # wxGlade: Controller.<event_handler>
371
- origin, state = self.context.last_signal("pipe;state")
372
- if state is not None and isinstance(state, tuple):
373
- state = state[0]
374
- if state in (
375
- "STATE_USB_DISCONNECTED",
376
- "STATE_UNINITIALIZED",
377
- "STATE_CONNECTION_FAILED",
378
- "STATE_DRIVER_MOCK",
379
- None,
380
- ):
381
- try:
382
- self.context("usb_connect\n")
383
- except ConnectionRefusedError:
384
- dlg = wx.MessageDialog(
385
- None,
386
- _("Connection Refused. See USB Log for detailed information."),
387
- _("Manual Connection"),
388
- wx.OK | wx.ICON_WARNING,
389
- )
390
- result = dlg.ShowModal()
391
- dlg.Destroy()
392
- elif state in ("STATE_CONNECTED", "STATE_USB_CONNECTED"):
393
- self.context("usb_disconnect\n")
394
-
395
- def spin_on_device_index(self, event=None):
396
- self.context.usb_index = int(self.spin_device_index.GetValue())
397
-
398
- def spin_on_device_address(self, event=None):
399
- self.context.usb_address = int(self.spin_device_address.GetValue())
400
-
401
- def spin_on_device_bus(self, event=None):
402
- self.context.usb_bus = int(self.spin_device_bus.GetValue())
403
-
404
- def spin_on_device_version(self, event=None):
405
- self.context.usb_version = int(self.spin_device_version.GetValue())
406
-
407
- def on_check_mock_usb(self, event=None):
408
- self.context.mock = self.checkbox_mock_usb.GetValue()
409
-
410
- def on_button_start_controller(self, event=None):
411
- print("Event handler 'on_button_start_controller' not implemented!")
412
- event.Skip()
413
-
414
- def on_check_show_usb_log(self, event=None):
415
- on = self.checkbox_show_usb_log.GetValue()
416
- self.text_usb_log.Show(on)
417
- self.context.show_usb_log = bool(on)
418
- if on:
419
- self.GetParent().SetSize((_advanced_width, _default_height))
420
- else:
421
- self.GetParent().SetSize((_simple_width, _default_height))
422
-
423
-
424
- class MoshiControllerGui(MWindow):
425
- def __init__(self, *args, **kwds):
426
- super().__init__(_advanced_width, _default_height, *args, **kwds)
427
-
428
- # ==========
429
- # MENU BAR
430
- # ==========
431
- from platform import system as _sys
432
-
433
- if _sys() != "Darwin":
434
- self.MoshiController_menubar = wx.MenuBar()
435
- self.create_menu(self.MoshiController_menubar.Append)
436
- self.SetMenuBar(self.MoshiController_menubar)
437
- # ==========
438
- # MENUBAR END
439
- # ==========
440
-
441
- self.panel = MoshiControllerPanel(self, wx.ID_ANY, context=self.context)
442
- self.add_module_delegate(self.panel)
443
- _icon = wx.NullIcon
444
- _icon.CopyFromBitmap(icons8_connected.GetBitmap())
445
- self.SetIcon(_icon)
446
- self.SetTitle(_("Moshiboard-Controller"))
447
-
448
- def create_menu(self, append):
449
- wxglade_tmp_menu = wx.Menu()
450
- item = wxglade_tmp_menu.Append(
451
- wx.ID_ANY, _("Reset USB"), _("Reset USB connection")
452
- )
453
- self.Bind(wx.EVT_MENU, self.on_menu_usb_reset, id=item.GetId())
454
- item = wxglade_tmp_menu.Append(
455
- wx.ID_ANY, _("Release USB"), _("Release USB resources")
456
- )
457
- self.Bind(wx.EVT_MENU, self.on_menu_usb_release, id=item.GetId())
458
- append(wxglade_tmp_menu, _("Tools"))
459
- wxglade_tmp_menu = wx.Menu()
460
- item = wxglade_tmp_menu.Append(wx.ID_ANY, _("Stop"), _("Sends Stop command"))
461
- self.Bind(wx.EVT_MENU, self.on_menu_stop, id=item.GetId())
462
- item = wxglade_tmp_menu.Append(
463
- wx.ID_ANY, _("Free Motor"), _("Sends Free Motor (Unlock Rail) command")
464
- )
465
- self.Bind(wx.EVT_MENU, self.on_menu_freemotor, id=item.GetId())
466
- append(wxglade_tmp_menu, _("Commands"))
467
- wxglade_tmp_menu = wx.Menu()
468
- item = wxglade_tmp_menu.Append(
469
- wx.ID_ANY, _("BufferView"), _("Views the Controller Buffer")
470
- )
471
- self.Bind(wx.EVT_MENU, self.on_menu_bufferview, id=item.GetId())
472
- append(wxglade_tmp_menu, _("Views"))
473
- self.SetMenuBar(self.MoshiController_menubar)
474
-
475
- def restore(self, *args, **kwargs):
476
- self.panel.set_widgets()
477
-
478
- def window_open(self):
479
- self.panel.pane_show()
480
-
481
- def window_close(self):
482
- self.panel.pane_hide()
483
-
484
- def window_preserve(self):
485
- return False
486
-
487
- def on_menu_usb_reset(self, event):
488
- try:
489
- self.context("usb_reset\n")
490
- except AttributeError:
491
- pass
492
-
493
- def on_menu_usb_release(self, event):
494
- try:
495
- self.context("usb_release\n")
496
- except AttributeError:
497
- pass
498
-
499
- def on_menu_pause(self, event=None):
500
- try:
501
- self.context("pause\n")
502
- except AttributeError:
503
- pass
504
-
505
- def on_menu_stop(self, event=None):
506
- try:
507
- self.context("estop\n")
508
- except AttributeError:
509
- pass
510
-
511
- def on_menu_bufferview(self, event=None):
512
- self.context("window open BufferView\n")
513
-
514
- def on_menu_freemotor(self, event): # wxGlade: MoshiControllerGui.<event_handler>
515
- try:
516
- self.context("unlock\n")
517
- except AttributeError:
518
- pass
519
-
520
- @staticmethod
521
- def submenu():
522
- return "Device-Control", "Controller"
1
+ import threading
2
+
3
+ import wx
4
+
5
+ from meerk40t.gui.icons import (
6
+ get_default_icon_size,
7
+ icons8_connected,
8
+ icons8_disconnected,
9
+ )
10
+ from meerk40t.gui.mwindow import MWindow
11
+ from meerk40t.gui.wxutils import (
12
+ StaticBoxSizer,
13
+ TextCtrl,
14
+ dip_size,
15
+ wxButton,
16
+ wxCheckBox,
17
+ wxStaticText,
18
+ )
19
+ from meerk40t.kernel import signal_listener
20
+
21
+ _ = wx.GetTranslation
22
+
23
+ _simple_width = 500
24
+ _advanced_width = 855
25
+ _default_height = 389
26
+
27
+
28
+ class MoshiControllerPanel(wx.Panel):
29
+ def __init__(self, *args, context=None, **kwds):
30
+ kwds["style"] = kwds.get("style", 0) | wx.TAB_TRAVERSAL
31
+ wx.Panel.__init__(self, *args, **kwds)
32
+ context.themes.set_window_colors(self)
33
+ self.context = context.device
34
+ self.SetHelpText("moshicontroller")
35
+
36
+ self.button_device_connect = wxButton(self, wx.ID_ANY, _("Connection"))
37
+ self.text_connection_status = TextCtrl(
38
+ self, wx.ID_ANY, "", style=wx.TE_READONLY
39
+ )
40
+ self.checkbox_mock_usb = wxCheckBox(
41
+ self, wx.ID_ANY, _("Mock USB Connection Mode")
42
+ )
43
+ self.text_device_index = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
44
+ self.spin_device_index = wx.SpinCtrl(self, wx.ID_ANY, "-1", min=-1)
45
+ self.text_device_address = TextCtrl(
46
+ self, wx.ID_ANY, "", style=wx.TE_READONLY
47
+ )
48
+ self.spin_device_address = wx.SpinCtrl(self, wx.ID_ANY, "-1", min=-1)
49
+ self.text_device_bus = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
50
+ self.spin_device_bus = wx.SpinCtrl(self, wx.ID_ANY, "-1", min=-1)
51
+ self.text_device_version = TextCtrl(
52
+ self, wx.ID_ANY, "", style=wx.TE_READONLY
53
+ )
54
+ self.spin_device_version = wx.SpinCtrl(self, wx.ID_ANY, "-1", min=-1)
55
+ self.text_byte_0 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
56
+ self.text_byte_1 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
57
+ self.text_desc = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
58
+ self.text_byte_2 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
59
+ self.text_byte_3 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
60
+ self.text_byte_4 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
61
+ self.text_byte_5 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
62
+ self.checkbox_show_usb_log = wxCheckBox(self, wx.ID_ANY, _("Show USB Log"))
63
+ self.text_usb_log = TextCtrl(
64
+ self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY
65
+ )
66
+
67
+ self.__set_properties()
68
+ self.__do_layout()
69
+
70
+ self.Bind(wx.EVT_BUTTON, self.on_button_start_usb, self.button_device_connect)
71
+ self.Bind(wx.EVT_CHECKBOX, self.on_check_mock_usb, self.checkbox_mock_usb)
72
+ self.Bind(wx.EVT_SPINCTRL, self.spin_on_device_index, self.spin_device_index)
73
+ self.Bind(wx.EVT_TEXT_ENTER, self.spin_on_device_index, self.spin_device_index)
74
+ self.Bind(
75
+ wx.EVT_SPINCTRL, self.spin_on_device_address, self.spin_device_address
76
+ )
77
+ self.Bind(
78
+ wx.EVT_TEXT_ENTER, self.spin_on_device_address, self.spin_device_address
79
+ )
80
+ self.Bind(wx.EVT_SPINCTRL, self.spin_on_device_bus, self.spin_device_bus)
81
+ self.Bind(wx.EVT_TEXT_ENTER, self.spin_on_device_bus, self.spin_device_bus)
82
+ self.Bind(
83
+ wx.EVT_SPINCTRL, self.spin_on_device_version, self.spin_device_version
84
+ )
85
+ self.Bind(
86
+ wx.EVT_TEXT_ENTER, self.spin_on_device_version, self.spin_device_version
87
+ )
88
+ self.Bind(
89
+ wx.EVT_CHECKBOX, self.on_check_show_usb_log, self.checkbox_show_usb_log
90
+ )
91
+ self.last_control_state = None
92
+ self._buffer = ""
93
+ self._buffer_lock = threading.Lock()
94
+ self.set_widgets()
95
+
96
+ def __set_properties(self):
97
+ self.SetFont(
98
+ wx.Font(
99
+ 9,
100
+ wx.FONTFAMILY_DEFAULT,
101
+ wx.FONTSTYLE_NORMAL,
102
+ wx.FONTWEIGHT_NORMAL,
103
+ 0,
104
+ "Segoe UI",
105
+ )
106
+ )
107
+ self.button_device_connect.SetBackgroundColour(wx.Colour(102, 255, 102))
108
+ self.button_device_connect.SetForegroundColour(wx.BLACK)
109
+ self.button_device_connect.SetBitmap(
110
+ icons8_disconnected.GetBitmap(
111
+ use_theme=False, resize=get_default_icon_size(self.context)
112
+ )
113
+ )
114
+ self.button_device_connect.SetFont(
115
+ wx.Font(
116
+ 12,
117
+ wx.FONTFAMILY_DEFAULT,
118
+ wx.FONTSTYLE_NORMAL,
119
+ wx.FONTWEIGHT_NORMAL,
120
+ 0,
121
+ "Segoe UI",
122
+ )
123
+ )
124
+ self.button_device_connect.SetToolTip(
125
+ _("Force connection/disconnection from the device.")
126
+ )
127
+ self.text_connection_status.SetToolTip(_("Connection status"))
128
+ self.checkbox_mock_usb.SetToolTip(
129
+ _(
130
+ "DEBUG. Without a K40 connected continue to process things as if there was one."
131
+ )
132
+ )
133
+ self.text_device_index.SetMinSize(dip_size(self, 55, -1))
134
+ self.spin_device_index.SetMinSize(dip_size(self, 40, -1))
135
+ self.spin_device_index.SetToolTip(
136
+ _(
137
+ "Optional: Distinguish between different lasers using the match criteria below.\n"
138
+ "-1 match anything. 0+ match exactly that value."
139
+ )
140
+ )
141
+ self.text_device_address.SetMinSize(dip_size(self, 55, -1))
142
+ self.spin_device_address.SetMinSize(dip_size(self, 40, -1))
143
+ self.spin_device_address.SetToolTip(
144
+ _(
145
+ "Optional: Distinguish between different lasers using the match criteria below.\n"
146
+ "-1 match anything. 0+ match exactly that value."
147
+ )
148
+ )
149
+ self.text_device_bus.SetMinSize(dip_size(self, 55, -1))
150
+ self.spin_device_bus.SetMinSize(dip_size(self, 40, -1))
151
+ self.spin_device_bus.SetToolTip(
152
+ _(
153
+ "Optional: Distinguish between different lasers using the match criteria below.\n"
154
+ "-1 match anything. 0+ match exactly that value."
155
+ )
156
+ )
157
+ self.text_device_version.SetMinSize(dip_size(self, 55, -1))
158
+ self.spin_device_version.SetMinSize(dip_size(self, 40, -1))
159
+ self.spin_device_version.SetToolTip(
160
+ _(
161
+ "Optional: Distinguish between different lasers using the match criteria below.\n"
162
+ "-1 match anything. 0+ match exactly that value."
163
+ )
164
+ )
165
+ self.text_byte_0.SetMinSize(dip_size(self, 77, -1))
166
+ self.text_byte_1.SetMinSize(dip_size(self, 77, -1))
167
+ self.text_desc.SetMinSize(dip_size(self, 75, 23))
168
+ self.text_desc.SetToolTip(_("The meaning of Byte 1"))
169
+ self.text_byte_2.SetMinSize(dip_size(self, 77, -1))
170
+ self.text_byte_3.SetMinSize(dip_size(self, 77, -1))
171
+ self.text_byte_4.SetMinSize(dip_size(self, 77, -1))
172
+ self.text_byte_5.SetMinSize(dip_size(self, 77, -1))
173
+ self.checkbox_show_usb_log.SetValue(1)
174
+ # end wxGlade
175
+
176
+ def __do_layout(self):
177
+ # begin wxGlade: MoshiControllerGui.__do_layout
178
+ sizer_24 = wx.BoxSizer(wx.HORIZONTAL)
179
+ sizer_1 = wx.BoxSizer(wx.VERTICAL)
180
+ sizer_show_usb_log = wx.BoxSizer(wx.HORIZONTAL)
181
+ packet_count = StaticBoxSizer(self, wx.ID_ANY, _("Packet Info"), wx.VERTICAL)
182
+ byte_data_status = StaticBoxSizer(
183
+ self, wx.ID_ANY, _("Byte Data Status"), wx.HORIZONTAL
184
+ )
185
+ byte5sizer = wx.BoxSizer(wx.VERTICAL)
186
+ byte4sizer = wx.BoxSizer(wx.VERTICAL)
187
+ byte3sizer = wx.BoxSizer(wx.VERTICAL)
188
+ byte2sizer = wx.BoxSizer(wx.VERTICAL)
189
+ byte1sizer = wx.BoxSizer(wx.VERTICAL)
190
+ byte0sizer = wx.BoxSizer(wx.VERTICAL)
191
+ sizer_usb_settings = StaticBoxSizer(
192
+ self, wx.ID_ANY, _("USB Settings"), wx.VERTICAL
193
+ )
194
+ sizer_23 = wx.BoxSizer(wx.HORIZONTAL)
195
+ sizer_12 = StaticBoxSizer(self, wx.ID_ANY, _("Chip Version"), wx.HORIZONTAL)
196
+ sizer_11 = StaticBoxSizer(self, wx.ID_ANY, _("Device Bus:"), wx.HORIZONTAL)
197
+ sizer_10 = StaticBoxSizer(self, wx.ID_ANY, _("Device Address:"), wx.HORIZONTAL)
198
+ sizer_3 = StaticBoxSizer(self, wx.ID_ANY, _("Device Index:"), wx.HORIZONTAL)
199
+ sizer_usb_connect = StaticBoxSizer(
200
+ self, wx.ID_ANY, _("USB Connection"), wx.VERTICAL
201
+ )
202
+ sizer_usb_connect.Add(self.button_device_connect, 0, wx.EXPAND, 0)
203
+ sizer_usb_connect.Add(self.text_connection_status, 0, wx.EXPAND, 0)
204
+ sizer_1.Add(sizer_usb_connect, 0, wx.EXPAND, 0)
205
+ sizer_usb_settings.Add(self.checkbox_mock_usb, 0, 0, 0)
206
+ sizer_3.Add(self.text_device_index, 0, 0, 0)
207
+ sizer_3.Add(self.spin_device_index, 0, 0, 0)
208
+ sizer_23.Add(sizer_3, 0, wx.EXPAND, 0)
209
+ sizer_10.Add(self.text_device_address, 0, 0, 0)
210
+ sizer_10.Add(self.spin_device_address, 0, 0, 0)
211
+ sizer_23.Add(sizer_10, 0, wx.EXPAND, 0)
212
+ sizer_11.Add(self.text_device_bus, 0, 0, 0)
213
+ sizer_11.Add(self.spin_device_bus, 0, 0, 0)
214
+ sizer_23.Add(sizer_11, 0, wx.EXPAND, 0)
215
+ sizer_12.Add(self.text_device_version, 0, 0, 0)
216
+ sizer_12.Add(self.spin_device_version, 0, 0, 0)
217
+ sizer_23.Add(sizer_12, 0, wx.EXPAND, 0)
218
+ sizer_usb_settings.Add(sizer_23, 1, wx.EXPAND, 0)
219
+ sizer_1.Add(sizer_usb_settings, 0, wx.EXPAND, 0)
220
+ byte0sizer.Add(self.text_byte_0, 0, 0, 0)
221
+ label_1 = wxStaticText(self, wx.ID_ANY, _("Byte 0"))
222
+ byte0sizer.Add(label_1, 0, 0, 0)
223
+ byte_data_status.Add(byte0sizer, 1, wx.EXPAND, 0)
224
+ byte1sizer.Add(self.text_byte_1, 0, 0, 0)
225
+ label_2 = wxStaticText(self, wx.ID_ANY, _("Byte 1"))
226
+ byte1sizer.Add(label_2, 0, 0, 0)
227
+ byte1sizer.Add(self.text_desc, 0, 0, 0)
228
+ byte_data_status.Add(byte1sizer, 1, wx.EXPAND, 0)
229
+ byte2sizer.Add(self.text_byte_2, 0, 0, 0)
230
+ label_3 = wxStaticText(self, wx.ID_ANY, _("Byte 2"))
231
+ byte2sizer.Add(label_3, 0, 0, 0)
232
+ byte_data_status.Add(byte2sizer, 1, wx.EXPAND, 0)
233
+ byte3sizer.Add(self.text_byte_3, 0, 0, 0)
234
+ label_4 = wxStaticText(self, wx.ID_ANY, _("Byte 3"))
235
+ byte3sizer.Add(label_4, 0, 0, 0)
236
+ byte_data_status.Add(byte3sizer, 1, wx.EXPAND, 0)
237
+ byte4sizer.Add(self.text_byte_4, 0, 0, 0)
238
+ label_5 = wxStaticText(self, wx.ID_ANY, _("Byte 4"))
239
+ byte4sizer.Add(label_5, 0, 0, 0)
240
+ byte_data_status.Add(byte4sizer, 1, wx.EXPAND, 0)
241
+ byte5sizer.Add(self.text_byte_5, 0, 0, 0)
242
+ label_18 = wxStaticText(self, wx.ID_ANY, _("Byte 5"))
243
+ byte5sizer.Add(label_18, 0, 0, 0)
244
+ byte_data_status.Add(byte5sizer, 1, wx.EXPAND, 0)
245
+ packet_count.Add(byte_data_status, 0, wx.EXPAND, 0)
246
+ sizer_1.Add(packet_count, 0, 0, 0)
247
+ label_6 = wxStaticText(self, wx.ID_ANY, "")
248
+ sizer_show_usb_log.Add(label_6, 10, wx.EXPAND, 0)
249
+ sizer_show_usb_log.Add(self.checkbox_show_usb_log, 0, 0, 0)
250
+ sizer_1.Add(sizer_show_usb_log, 1, wx.EXPAND, 0)
251
+ sizer_24.Add(sizer_1, 1, 0, 0)
252
+ sizer_24.Add(self.text_usb_log, 2, wx.EXPAND, 0)
253
+ self.SetSizer(sizer_24)
254
+ self.Layout()
255
+ # end wxGlade
256
+
257
+ def pane_show(self):
258
+ self._channel_watch = f"{self.context.safe_label}/usb"
259
+ self.context.channel(self._channel_watch, buffer_size=500).watch(
260
+ self.update_text
261
+ )
262
+ self.context.listen("pipe;status", self.update_status)
263
+ self.context.listen("pipe;usb_status", self.on_connection_status_change)
264
+ self.context.listen("pipe;state", self.on_connection_state_change)
265
+ self.context.listen("active", self.on_active_change)
266
+
267
+ def pane_hide(self):
268
+ self.context.channel(self._channel_watch).unwatch(self.update_text)
269
+ self.context.unlisten("pipe;status", self.update_status)
270
+ self.context.unlisten("pipe;usb_status", self.on_connection_status_change)
271
+ self.context.unlisten("pipe;state", self.on_connection_state_change)
272
+ self.context.unlisten("active", self.on_active_change)
273
+
274
+ def on_active_change(self, origin, active):
275
+ # self.Close()
276
+ pass
277
+
278
+ def update_text(self, text):
279
+ with self._buffer_lock:
280
+ self._buffer += f"{text}\n"
281
+ self.context.signal("moshi_controller_update")
282
+
283
+ @signal_listener("moshi_controller_update")
284
+ def update_text_gui(self, origin, *args):
285
+ with self._buffer_lock:
286
+ buffer = self._buffer
287
+ self._buffer = ""
288
+ self.text_usb_log.AppendText(buffer)
289
+
290
+ def set_widgets(self):
291
+ self.context.setting(bool, "show_usb_log", False)
292
+ self.context.setting(int, "usb_index", -1)
293
+ self.context.setting(int, "usb_bus", -1)
294
+ self.context.setting(int, "usb_address", -1)
295
+ self.context.setting(int, "usb_version", -1)
296
+ self.context.setting(bool, "mock", False)
297
+
298
+ self.checkbox_show_usb_log.SetValue(self.context.show_usb_log)
299
+ self.checkbox_mock_usb.SetValue(self.context.mock)
300
+ self.spin_device_index.SetValue(self.context.usb_index)
301
+ self.spin_device_bus.SetValue(self.context.usb_bus)
302
+ self.spin_device_address.SetValue(self.context.usb_address)
303
+ self.spin_device_version.SetValue(self.context.usb_version)
304
+
305
+ self.on_check_show_usb_log()
306
+
307
+ def device_execute(self, control_name):
308
+ def menu_element(event=None):
309
+ self.context.execute(control_name)
310
+
311
+ return menu_element
312
+
313
+ def update_status(self, origin, status_data, code_string):
314
+ if status_data is not None:
315
+ if isinstance(status_data, int):
316
+ self.text_desc.SetValue(str(status_data))
317
+ self.text_desc.SetValue(code_string)
318
+ else:
319
+ if len(status_data) == 6:
320
+ self.text_byte_0.SetValue(str(status_data[0]))
321
+ self.text_byte_1.SetValue(str(status_data[1]))
322
+ self.text_byte_2.SetValue(str(status_data[2]))
323
+ self.text_byte_3.SetValue(str(status_data[3]))
324
+ self.text_byte_4.SetValue(str(status_data[4]))
325
+ self.text_byte_5.SetValue(str(status_data[5]))
326
+ self.text_desc.SetValue(code_string)
327
+
328
+ def on_connection_status_change(self, origin, status):
329
+ self.text_connection_status.SetValue(str(status))
330
+
331
+ def on_connection_state_change(self, origin, state):
332
+ if state == "STATE_CONNECTION_FAILED" or state == "STATE_DRIVER_NO_BACKEND":
333
+ self.button_device_connect.SetBackgroundColour("#dfdf00")
334
+ origin, usb_status = self.context.last_signal("pipe;usb_status")
335
+ if usb_status is not None:
336
+ self.button_device_connect.SetLabel(str(usb_status[0]))
337
+ self.button_device_connect.SetBitmap(
338
+ icons8_disconnected.GetBitmap(
339
+ use_theme=False, resize=get_default_icon_size(self.context)
340
+ )
341
+ )
342
+ self.button_device_connect.Enable()
343
+ elif state == "STATE_UNINITIALIZED" or state == "STATE_USB_DISCONNECTED":
344
+ self.button_device_connect.SetBackgroundColour("#ffff00")
345
+ self.button_device_connect.SetLabel(_("Connect"))
346
+ self.button_device_connect.SetBitmap(
347
+ icons8_connected.GetBitmap(
348
+ use_theme=False, resize=get_default_icon_size(self.context)
349
+ )
350
+ )
351
+ self.button_device_connect.Enable()
352
+ elif state == "STATE_USB_SET_DISCONNECTING":
353
+ self.button_device_connect.SetBackgroundColour("#ffff00")
354
+ self.button_device_connect.SetLabel(_("Disconnecting..."))
355
+ self.button_device_connect.SetBitmap(
356
+ icons8_disconnected.GetBitmap(
357
+ use_theme=False, resize=get_default_icon_size(self.context)
358
+ )
359
+ )
360
+ self.button_device_connect.Disable()
361
+ elif state == "STATE_USB_CONNECTED" or state == "STATE_CONNECTED":
362
+ self.button_device_connect.SetBackgroundColour("#00ff00")
363
+ self.button_device_connect.SetLabel(_("Disconnect"))
364
+ self.button_device_connect.SetBitmap(
365
+ icons8_connected.GetBitmap(
366
+ use_theme=False, resize=get_default_icon_size(self.context)
367
+ )
368
+ )
369
+ self.button_device_connect.Enable()
370
+ elif state == "STATE_CONNECTING":
371
+ self.button_device_connect.SetBackgroundColour("#ffff00")
372
+ self.button_device_connect.SetLabel(_("Connecting..."))
373
+ self.button_device_connect.SetBitmap(
374
+ icons8_connected.GetBitmap(
375
+ use_theme=False, resize=get_default_icon_size(self.context)
376
+ )
377
+ )
378
+ self.button_device_connect.Disable()
379
+
380
+ def on_button_start_usb(self, event=None): # wxGlade: Controller.<event_handler>
381
+ origin, state = self.context.last_signal("pipe;state")
382
+ if state is not None and isinstance(state, tuple):
383
+ state = state[0]
384
+ if state in (
385
+ "STATE_USB_DISCONNECTED",
386
+ "STATE_UNINITIALIZED",
387
+ "STATE_CONNECTION_FAILED",
388
+ "STATE_DRIVER_MOCK",
389
+ None,
390
+ ):
391
+ try:
392
+ self.context("usb_connect\n")
393
+ except ConnectionRefusedError:
394
+ dlg = wx.MessageDialog(
395
+ None,
396
+ _("Connection Refused. See USB Log for detailed information."),
397
+ _("Manual Connection"),
398
+ wx.OK | wx.ICON_WARNING,
399
+ )
400
+ result = dlg.ShowModal()
401
+ dlg.Destroy()
402
+ elif state in ("STATE_CONNECTED", "STATE_USB_CONNECTED"):
403
+ self.context("usb_disconnect\n")
404
+
405
+ def spin_on_device_index(self, event=None):
406
+ self.context.usb_index = int(self.spin_device_index.GetValue())
407
+
408
+ def spin_on_device_address(self, event=None):
409
+ self.context.usb_address = int(self.spin_device_address.GetValue())
410
+
411
+ def spin_on_device_bus(self, event=None):
412
+ self.context.usb_bus = int(self.spin_device_bus.GetValue())
413
+
414
+ def spin_on_device_version(self, event=None):
415
+ self.context.usb_version = int(self.spin_device_version.GetValue())
416
+
417
+ def on_check_mock_usb(self, event=None):
418
+ self.context.mock = self.checkbox_mock_usb.GetValue()
419
+
420
+ def on_button_start_controller(self, event=None):
421
+ print("Event handler 'on_button_start_controller' not implemented!")
422
+ event.Skip()
423
+
424
+ def on_check_show_usb_log(self, event=None):
425
+ on = self.checkbox_show_usb_log.GetValue()
426
+ self.text_usb_log.Show(on)
427
+ self.context.show_usb_log = bool(on)
428
+ if on:
429
+ self.GetParent().SetSize((_advanced_width, _default_height))
430
+ else:
431
+ self.GetParent().SetSize((_simple_width, _default_height))
432
+
433
+
434
+ class MoshiControllerGui(MWindow):
435
+ def __init__(self, *args, **kwds):
436
+ super().__init__(_advanced_width, _default_height, *args, **kwds)
437
+
438
+ # ==========
439
+ # MENU BAR
440
+ # ==========
441
+ from platform import system as _sys
442
+
443
+ if _sys() != "Darwin":
444
+ self.MoshiController_menubar = wx.MenuBar()
445
+ self.create_menu(self.MoshiController_menubar.Append)
446
+ self.SetMenuBar(self.MoshiController_menubar)
447
+ # ==========
448
+ # MENUBAR END
449
+ # ==========
450
+
451
+ self.panel = MoshiControllerPanel(self, wx.ID_ANY, context=self.context)
452
+ self.sizer.Add(self.panel, 1, wx.EXPAND, 0)
453
+ self.add_module_delegate(self.panel)
454
+ _icon = wx.NullIcon
455
+ _icon.CopyFromBitmap(icons8_connected.GetBitmap())
456
+ self.SetIcon(_icon)
457
+ self.SetTitle(_("Moshiboard-Controller"))
458
+ self.restore_aspect()
459
+
460
+ def create_menu(self, append):
461
+ wxglade_tmp_menu = wx.Menu()
462
+ item = wxglade_tmp_menu.Append(
463
+ wx.ID_ANY, _("Reset USB"), _("Reset USB connection")
464
+ )
465
+ self.Bind(wx.EVT_MENU, self.on_menu_usb_reset, id=item.GetId())
466
+ item = wxglade_tmp_menu.Append(
467
+ wx.ID_ANY, _("Release USB"), _("Release USB resources")
468
+ )
469
+ self.Bind(wx.EVT_MENU, self.on_menu_usb_release, id=item.GetId())
470
+ append(wxglade_tmp_menu, _("Tools"))
471
+ wxglade_tmp_menu = wx.Menu()
472
+ item = wxglade_tmp_menu.Append(wx.ID_ANY, _("Stop"), _("Sends Stop command"))
473
+ self.Bind(wx.EVT_MENU, self.on_menu_stop, id=item.GetId())
474
+ item = wxglade_tmp_menu.Append(
475
+ wx.ID_ANY, _("Free Motor"), _("Sends Free Motor (Unlock Rail) command")
476
+ )
477
+ self.Bind(wx.EVT_MENU, self.on_menu_freemotor, id=item.GetId())
478
+ append(wxglade_tmp_menu, _("Commands"))
479
+ wxglade_tmp_menu = wx.Menu()
480
+ item = wxglade_tmp_menu.Append(
481
+ wx.ID_ANY, _("BufferView"), _("Views the Controller Buffer")
482
+ )
483
+ self.Bind(wx.EVT_MENU, self.on_menu_bufferview, id=item.GetId())
484
+ append(wxglade_tmp_menu, _("Views"))
485
+ self.SetMenuBar(self.MoshiController_menubar)
486
+
487
+ def restore(self, *args, **kwargs):
488
+ self.panel.set_widgets()
489
+
490
+ def window_open(self):
491
+ self.panel.pane_show()
492
+
493
+ def window_close(self):
494
+ self.panel.pane_hide()
495
+
496
+ def window_preserve(self):
497
+ return False
498
+
499
+ def on_menu_usb_reset(self, event):
500
+ try:
501
+ self.context("usb_reset\n")
502
+ except AttributeError:
503
+ pass
504
+
505
+ def on_menu_usb_release(self, event):
506
+ try:
507
+ self.context("usb_release\n")
508
+ except AttributeError:
509
+ pass
510
+
511
+ def on_menu_pause(self, event=None):
512
+ try:
513
+ self.context("pause\n")
514
+ except AttributeError:
515
+ pass
516
+
517
+ def on_menu_stop(self, event=None):
518
+ try:
519
+ self.context("estop\n")
520
+ except AttributeError:
521
+ pass
522
+
523
+ def on_menu_bufferview(self, event=None):
524
+ self.context("window open BufferView\n")
525
+
526
+ def on_menu_freemotor(self, event): # wxGlade: MoshiControllerGui.<event_handler>
527
+ try:
528
+ self.context("unlock\n")
529
+ except AttributeError:
530
+ pass
531
+
532
+ @staticmethod
533
+ def submenu():
534
+ return "Device-Control", "Controller"
535
+
536
+ @staticmethod
537
+ def helptext():
538
+ return _("Display the device controller window")