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,651 +1,741 @@
1
- #
2
- # generated by wxGlade 0.9.3 on Fri Jun 28 16:25:14 2019
3
- #
4
- import threading
5
-
6
- import wx
7
-
8
- from meerk40t.gui.icons import (
9
- get_default_icon_size,
10
- icons8_circled_play,
11
- icons8_connected,
12
- icons8_disconnected,
13
- icons8_emergency_stop_button,
14
- icons8_laser_beam_hazard,
15
- icons8_pause,
16
- )
17
- from meerk40t.gui.mwindow import MWindow
18
- from meerk40t.gui.wxutils import ScrolledPanel, StaticBoxSizer, dip_size
19
- from meerk40t.kernel import signal_listener
20
-
21
- _ = wx.GetTranslation
22
-
23
- _simple_width = 500
24
- _advanced_width = 952
25
- _default_height = 584
26
-
27
-
28
- class LihuiyuControllerPanel(ScrolledPanel):
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
- self.context = context.device
33
-
34
- self.button_device_connect = wx.Button(self, wx.ID_ANY, _("Connection"))
35
- self.text_connection_status = wx.TextCtrl(
36
- self, wx.ID_ANY, "", style=wx.TE_READONLY
37
- )
38
- self.button_controller_control = wx.Button(
39
- self, wx.ID_ANY, _("Start Controller")
40
- )
41
- self.button_controller_control.function = lambda: self.context("start\n")
42
- self.text_controller_status = wx.TextCtrl(
43
- self, wx.ID_ANY, "", style=wx.TE_READONLY
44
- )
45
- self.packet_count_text = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
46
- self.rejected_packet_count_text = wx.TextCtrl(
47
- self, wx.ID_ANY, "", style=wx.TE_READONLY
48
- )
49
- self.packet_text_text = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
50
- self.text_byte_0 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
51
- self.text_byte_1 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
52
- self.text_desc = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
53
- self.text_byte_2 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
54
- self.text_byte_3 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
55
- self.text_byte_4 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
56
- self.text_byte_5 = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
57
- self.checkbox_show_usb_log = wx.CheckBox(self, wx.ID_ANY, _("Show USB Log"))
58
- self.text_usb_log = wx.TextCtrl(
59
- self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY
60
- )
61
- self.button_clear_stats = wx.Button(self, wx.ID_ANY, _("Reset\nstatistics"))
62
-
63
- self.__set_properties()
64
- self.__do_layout()
65
-
66
- self.Bind(wx.EVT_BUTTON, self.on_button_start_usb, self.button_device_connect)
67
- self.Bind(wx.EVT_BUTTON, self.on_button_reset_stats, self.button_clear_stats)
68
- self.Bind(
69
- wx.EVT_BUTTON,
70
- self.on_button_start_controller,
71
- self.button_controller_control,
72
- )
73
- self.Bind(
74
- wx.EVT_CHECKBOX, self.on_check_show_usb_log, self.checkbox_show_usb_log
75
- )
76
- self.last_control_state = None
77
- self.retries = 0
78
- self._buffer = ""
79
- self._buffer_lock = threading.Lock()
80
- self.set_widgets()
81
- self.SetupScrolling()
82
- self._channel_watching = None
83
-
84
- def __set_properties(self):
85
- self.SetFont(
86
- wx.Font(
87
- 9,
88
- wx.FONTFAMILY_DEFAULT,
89
- wx.FONTSTYLE_NORMAL,
90
- wx.FONTWEIGHT_NORMAL,
91
- 0,
92
- "Segoe UI",
93
- )
94
- )
95
- self.button_device_connect.SetBackgroundColour(wx.Colour(102, 255, 102))
96
- self.button_device_connect.SetForegroundColour(wx.BLACK)
97
- self.button_device_connect.SetFont(
98
- wx.Font(
99
- 12,
100
- wx.FONTFAMILY_DEFAULT,
101
- wx.FONTSTYLE_NORMAL,
102
- wx.FONTWEIGHT_NORMAL,
103
- 0,
104
- "Segoe UI",
105
- )
106
- )
107
- self.button_device_connect.SetToolTip(
108
- _("Force connection/disconnection from the device.")
109
- )
110
- self.text_connection_status.SetToolTip(_("Connection status"))
111
-
112
- self.button_controller_control.SetBackgroundColour(wx.Colour(102, 255, 102))
113
- self.button_controller_control.SetForegroundColour(wx.BLACK)
114
- self.button_controller_control.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_controller_control.SetToolTip(
125
- _("Change the currently performed operation.")
126
- )
127
- self.text_controller_status.SetToolTip(
128
- _("Displays the controller's current process.")
129
- )
130
- self.packet_count_text.SetMinSize(dip_size(self, 77, 23))
131
- self.packet_count_text.SetToolTip(_("Total number of packets sent"))
132
- self.rejected_packet_count_text.SetMinSize(dip_size(self, 77, 23))
133
- self.rejected_packet_count_text.SetToolTip(
134
- _("Total number of packets rejected")
135
- )
136
- self.packet_text_text.SetToolTip(_("Last packet information sent"))
137
- self.text_byte_0.SetMinSize(dip_size(self, 77, 23))
138
- self.text_byte_1.SetMinSize(dip_size(self, 77, 23))
139
- self.text_desc.SetMinSize(dip_size(self, 75, 23))
140
- self.text_desc.SetToolTip(_("The meaning of Byte 1"))
141
- self.text_byte_2.SetMinSize(dip_size(self, 77, 23))
142
- self.text_byte_3.SetMinSize(dip_size(self, 77, 23))
143
- self.text_byte_4.SetMinSize(dip_size(self, 77, 23))
144
- self.text_byte_5.SetMinSize(dip_size(self, 77, 23))
145
- self.checkbox_show_usb_log.SetValue(1)
146
- self.button_device_connect.SetBitmap(
147
- icons8_disconnected.GetBitmap(
148
- use_theme=False, resize=get_default_icon_size()
149
- )
150
- )
151
- self.button_controller_control.SetBitmap(
152
- icons8_circled_play.GetBitmap(
153
- use_theme=False, resize=get_default_icon_size()
154
- )
155
- )
156
- # end wxGlade
157
-
158
- def __do_layout(self):
159
- sizer_main = wx.BoxSizer(wx.HORIZONTAL)
160
- sizer_main_vertical = wx.BoxSizer(wx.VERTICAL)
161
- sizer_show_usb_log = wx.BoxSizer(wx.HORIZONTAL)
162
- packet_count = StaticBoxSizer(self, wx.ID_ANY, _("Packet Info"), wx.VERTICAL)
163
- byte_data_status = StaticBoxSizer(
164
- self, wx.ID_ANY, _("Byte Data Status"), wx.HORIZONTAL
165
- )
166
- byte5sizer = wx.BoxSizer(wx.VERTICAL)
167
- byte4sizer = wx.BoxSizer(wx.VERTICAL)
168
- byte3sizer = wx.BoxSizer(wx.VERTICAL)
169
- byte2sizer = wx.BoxSizer(wx.VERTICAL)
170
- byte1sizer = wx.BoxSizer(wx.VERTICAL)
171
- byte0sizer = wx.BoxSizer(wx.VERTICAL)
172
- packet_info = StaticBoxSizer(self, wx.ID_ANY, _("Last Packet"), wx.HORIZONTAL)
173
- sizer_statistics = wx.BoxSizer(wx.HORIZONTAL)
174
- sizer_count_rejected = StaticBoxSizer(
175
- self, wx.ID_ANY, _("Rejected Packets"), wx.VERTICAL
176
- )
177
- sizer_count_packets = StaticBoxSizer(
178
- self, wx.ID_ANY, _("Packet Count"), wx.VERTICAL
179
- )
180
- sizer_controller = StaticBoxSizer(self, wx.ID_ANY, _("Controller"), wx.VERTICAL)
181
- sizer_usb_settings = StaticBoxSizer(
182
- self, wx.ID_ANY, _("USB Settings"), wx.VERTICAL
183
- )
184
- sizer_23 = wx.BoxSizer(wx.HORIZONTAL)
185
- sizer_12 = StaticBoxSizer(self, wx.ID_ANY, _("Chip Version"), wx.HORIZONTAL)
186
- sizer_11 = StaticBoxSizer(self, wx.ID_ANY, _("Device Bus:"), wx.HORIZONTAL)
187
- sizer_10 = StaticBoxSizer(self, wx.ID_ANY, _("Device Address:"), wx.HORIZONTAL)
188
- sizer_3 = StaticBoxSizer(self, wx.ID_ANY, _("Device Index:"), wx.HORIZONTAL)
189
- sizer_usb_connect = StaticBoxSizer(
190
- self, wx.ID_ANY, _("USB Connection"), wx.VERTICAL
191
- )
192
- sizer_usb_connect.Add(self.button_device_connect, 0, wx.EXPAND, 0)
193
- sizer_usb_connect.Add(self.text_connection_status, 0, wx.EXPAND, 0)
194
- sizer_main_vertical.Add(sizer_usb_connect, 0, wx.EXPAND, 0)
195
- sizer_controller.Add(self.button_controller_control, 0, wx.EXPAND, 0)
196
- sizer_controller.Add(self.text_controller_status, 0, wx.EXPAND, 0)
197
- sizer_main_vertical.Add(sizer_controller, 0, wx.EXPAND, 0)
198
- sizer_count_packets.Add(self.packet_count_text, 0, wx.EXPAND, 0)
199
- sizer_statistics.Add(sizer_count_packets, 1, wx.EXPAND, 0)
200
- sizer_count_rejected.Add(self.rejected_packet_count_text, 0, wx.EXPAND, 0)
201
- sizer_statistics.Add(sizer_count_rejected, 1, wx.EXPAND, 0)
202
- sizer_statistics.Add(self.button_clear_stats, 0, wx.EXPAND, 0)
203
- packet_count.Add(sizer_statistics, 1, wx.EXPAND, 0)
204
- packet_info.Add(self.packet_text_text, 11, wx.EXPAND, 0)
205
- packet_count.Add(packet_info, 0, wx.EXPAND, 0)
206
- byte0sizer.Add(self.text_byte_0, 0, 0, 0)
207
- label_1 = wx.StaticText(self, wx.ID_ANY, _("Byte 0"))
208
- byte0sizer.Add(label_1, 0, 0, 0)
209
- byte_data_status.Add(byte0sizer, 1, wx.EXPAND, 0)
210
- byte1sizer.Add(self.text_byte_1, 0, 0, 0)
211
- label_2 = wx.StaticText(self, wx.ID_ANY, _("Byte 1"))
212
- byte1sizer.Add(label_2, 0, 0, 0)
213
- byte1sizer.Add(self.text_desc, 0, 0, 0)
214
- byte_data_status.Add(byte1sizer, 1, wx.EXPAND, 0)
215
- byte2sizer.Add(self.text_byte_2, 0, 0, 0)
216
- label_3 = wx.StaticText(self, wx.ID_ANY, _("Byte 2"))
217
- byte2sizer.Add(label_3, 0, 0, 0)
218
- byte_data_status.Add(byte2sizer, 1, wx.EXPAND, 0)
219
- byte3sizer.Add(self.text_byte_3, 0, 0, 0)
220
- label_4 = wx.StaticText(self, wx.ID_ANY, _("Byte 3"))
221
- byte3sizer.Add(label_4, 0, 0, 0)
222
- byte_data_status.Add(byte3sizer, 1, wx.EXPAND, 0)
223
- byte4sizer.Add(self.text_byte_4, 0, 0, 0)
224
- label_5 = wx.StaticText(self, wx.ID_ANY, _("Byte 4"))
225
- byte4sizer.Add(label_5, 0, 0, 0)
226
- byte_data_status.Add(byte4sizer, 1, wx.EXPAND, 0)
227
- byte5sizer.Add(self.text_byte_5, 0, 0, 0)
228
- label_18 = wx.StaticText(self, wx.ID_ANY, _("Byte 5"))
229
- byte5sizer.Add(label_18, 0, 0, 0)
230
- byte_data_status.Add(byte5sizer, 1, wx.EXPAND, 0)
231
- packet_count.Add(byte_data_status, 0, wx.EXPAND, 0)
232
- sizer_main_vertical.Add(packet_count, 0, 0, 0)
233
- label_6 = wx.StaticText(self, wx.ID_ANY, "")
234
- sizer_show_usb_log.Add(label_6, 10, wx.EXPAND, 0)
235
- sizer_show_usb_log.Add(self.checkbox_show_usb_log, 0, 0, 0)
236
- sizer_main_vertical.Add(sizer_show_usb_log, 1, wx.EXPAND, 0)
237
- sizer_main.Add(sizer_main_vertical, 1, 0, 0)
238
- sizer_main.Add(self.text_usb_log, 2, wx.EXPAND, 0)
239
- self.SetSizer(sizer_main)
240
- self.Layout()
241
- # end wxGlade
242
-
243
- def module_open(self, *args, **kwargs):
244
- self.pane_show()
245
-
246
- def module_close(self, *args, **kwargs):
247
- self.pane_hide()
248
-
249
- def pane_show(self):
250
- # Channel watching is to make sure we unwatch the channel we watched even if label changes.
251
- self._channel_watching = f"{self.context.label}/usb"
252
- self.context.channel(self._channel_watching, buffer_size=500).watch(
253
- self.update_text
254
- )
255
- self.on_network_update()
256
-
257
- def pane_hide(self):
258
- self.context.channel(self._channel_watching).unwatch(self.update_text)
259
-
260
- def on_button_reset_stats(self, event):
261
- self.context.packet_count = 0
262
- self.context.rejected_count = 0
263
- self.packet_count_text.SetValue(str(self.context.packet_count))
264
- self.rejected_packet_count_text.SetValue(str(self.context.rejected_count))
265
-
266
- @signal_listener("network_update")
267
- def on_network_update(self, origin=None, *args):
268
- try:
269
- if self.context.networked:
270
- self.button_device_connect.Enable(False)
271
- else:
272
- self.button_device_connect.Enable(True)
273
- except AttributeError:
274
- pass
275
-
276
- def restore(self, *args, **kwargs):
277
- self.set_widgets()
278
-
279
- def update_text(self, text):
280
- with self._buffer_lock:
281
- self._buffer += f"{text}\n"
282
- self.context.signal("lihuiyu_controller_update", True)
283
-
284
- @signal_listener("lihuiyu_controller_update")
285
- def update_text_gui(self, origin, *args):
286
- try:
287
- with self._buffer_lock:
288
- buffer = self._buffer
289
- self._buffer = ""
290
- if self.text_usb_log.IsShown():
291
- self.text_usb_log.AppendText(buffer)
292
- except RuntimeError:
293
- pass
294
-
295
- def set_widgets(self):
296
- try:
297
- show_log = self.context.show_usb_log
298
- except AttributeError:
299
- show_log = True
300
- self.checkbox_show_usb_log.SetValue(show_log)
301
- self.on_check_show_usb_log()
302
-
303
- def device_execute(self, control_name):
304
- def menu_element(event=None):
305
- self.context.execute(control_name)
306
-
307
- return menu_element
308
-
309
- @signal_listener("pipe;status")
310
- def update_status(self, origin, status_data, code_string):
311
- if origin != self.context.path:
312
- return
313
- try:
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
- self.packet_count_text.SetValue(str(self.context.packet_count))
328
- self.rejected_packet_count_text.SetValue(str(self.context.rejected_count))
329
- except RuntimeError:
330
- # This should be handled when the controller window is closed.
331
- pass
332
-
333
- @signal_listener("pipe;packet_text")
334
- def update_packet_text(self, origin, string_data):
335
- if origin != self.context._path:
336
- return
337
- if string_data is not None and len(string_data) != 0:
338
- self.packet_text_text.SetValue(str(string_data))
339
-
340
- @signal_listener("pipe;usb_status")
341
- def on_connection_status_change(self, origin, status):
342
- if origin != self.context._path:
343
- return
344
- try:
345
- self.text_connection_status.SetValue(str(status))
346
- except RuntimeError:
347
- pass
348
-
349
- @signal_listener("pipe;state")
350
- def on_connection_state_change(self, origin, state):
351
- if origin != self.context._path:
352
- return
353
- if state == "STATE_CONNECTION_FAILED":
354
- self.button_device_connect.SetBackgroundColour("#dfdf00")
355
- origin, usb_status = self.context.last_signal("pipe;usb_status")
356
- self.button_device_connect.SetLabel(_("Connect failed"))
357
- self.button_device_connect.SetBitmap(
358
- icons8_disconnected.GetBitmap(
359
- use_theme=False, resize=get_default_icon_size()
360
- )
361
- )
362
- self.button_device_connect.Enable()
363
- elif state == "STATE_FAILED_RETRYING":
364
- self.button_device_connect.SetBackgroundColour("#df0000")
365
- origin, usb_status = self.context.last_signal("pipe;usb_status")
366
- self.button_device_connect.SetLabel(_("Retrying..."))
367
- self.button_device_connect.SetBitmap(
368
- icons8_disconnected.GetBitmap(
369
- use_theme=False, resize=get_default_icon_size()
370
- )
371
- )
372
- self.button_device_connect.Enable()
373
- elif state == "STATE_FAILED_SUSPENDED":
374
- self.button_device_connect.SetBackgroundColour("#0000df")
375
- origin, usb_status = self.context.last_signal("pipe;usb_status")
376
- self.button_device_connect.SetLabel(_("Suspended Retrying"))
377
- self.button_device_connect.SetBitmap(
378
- icons8_disconnected.GetBitmap(
379
- use_theme=False, resize=get_default_icon_size()
380
- )
381
- )
382
- self.button_device_connect.Enable()
383
- elif state == "STATE_DRIVER_NO_BACKEND":
384
- self.button_device_connect.SetBackgroundColour("#dfdf00")
385
- origin, usb_status = self.context.last_signal("pipe;usb_status")
386
- self.button_device_connect.SetLabel(_("No Backend"))
387
- self.button_device_connect.SetBitmap(
388
- icons8_disconnected.GetBitmap(
389
- use_theme=False, resize=get_default_icon_size()
390
- )
391
- )
392
- self.button_device_connect.Enable()
393
- elif state == "STATE_UNINITIALIZED" or state == "STATE_USB_DISCONNECTED":
394
- self.button_device_connect.SetBackgroundColour("#ffff00")
395
- self.button_device_connect.SetLabel(_("Connect"))
396
- self.button_device_connect.SetBitmap(
397
- icons8_connected.GetBitmap(
398
- use_theme=False, resize=get_default_icon_size()
399
- )
400
- )
401
- self.button_device_connect.Enable()
402
- elif state == "STATE_USB_SET_DISCONNECTING":
403
- self.button_device_connect.SetBackgroundColour("#ffff00")
404
- self.button_device_connect.SetLabel(_("Disconnecting..."))
405
- self.button_device_connect.SetBitmap(
406
- icons8_disconnected.GetBitmap(
407
- use_theme=False, resize=get_default_icon_size()
408
- )
409
- )
410
- self.button_device_connect.Disable()
411
- elif state == "STATE_USB_CONNECTED" or state == "STATE_CONNECTED":
412
- self.button_device_connect.SetBackgroundColour("#00ff00")
413
- self.button_device_connect.SetLabel(_("Disconnect"))
414
- self.button_device_connect.SetBitmap(
415
- icons8_connected.GetBitmap(
416
- use_theme=False, resize=get_default_icon_size()
417
- )
418
- )
419
- self.button_device_connect.Enable()
420
- elif state == "STATE_CONNECTING":
421
- self.button_device_connect.SetBackgroundColour("#ffff00")
422
- self.button_device_connect.SetLabel(_("Connecting..."))
423
- self.button_device_connect.SetBitmap(
424
- icons8_connected.GetBitmap(
425
- use_theme=False, resize=get_default_icon_size()
426
- )
427
- )
428
- self.button_device_connect.Disable()
429
-
430
- def on_button_start_usb(self, event=None): # wxGlade: Controller.<event_handler>
431
- origin, state = self.context.last_signal("pipe;state")
432
- if state is not None and isinstance(state, tuple):
433
- state = state[0]
434
-
435
- if state == "STATE_FAILED_RETRYING":
436
- self.retries = 0
437
- self.context("usb_abort\n")
438
- elif state == "STATE_FAILED_SUSPENDED":
439
- self.context("usb_continue\n")
440
- elif state in (
441
- "STATE_USB_DISCONNECTED",
442
- "STATE_UNINITIALIZED",
443
- "STATE_CONNECTION_FAILED",
444
- "STATE_DRIVER_MOCK",
445
- None,
446
- ):
447
- try:
448
- self.context("usb_connect\n")
449
- except ConnectionRefusedError:
450
- dlg = wx.MessageDialog(
451
- None,
452
- _("Connection Refused. See USB Log for detailed information."),
453
- _("Manual Connection"),
454
- wx.OK | wx.ICON_WARNING,
455
- )
456
- result = dlg.ShowModal()
457
- dlg.Destroy()
458
- elif state in ("STATE_CONNECTED", "STATE_USB_CONNECTED"):
459
- self.context("usb_disconnect\n")
460
-
461
- @signal_listener("pipe;thread")
462
- def on_control_state(self, origin, state):
463
- if origin != self.context._path:
464
- return
465
-
466
- if self.last_control_state == state:
467
- return
468
- self.last_control_state = state
469
- button = self.button_controller_control
470
- if self.text_controller_status is None:
471
- return
472
- value = self.context.kernel.get_text_thread_state(state)
473
- self.text_controller_status.SetValue(str(value))
474
- if state in ("init", "end", "idle"):
475
-
476
- def f(event=None):
477
- self.context("start\n")
478
- self.context("hold\n")
479
-
480
- button.function = f
481
- button.SetBackgroundColour("#009900")
482
- button.SetLabel(_("Hold Controller"))
483
- button.SetBitmap(
484
- icons8_circled_play.GetBitmap(
485
- use_theme=False, resize=get_default_icon_size()
486
- )
487
- )
488
- button.Enable(True)
489
- elif state == "busy":
490
- button.SetBackgroundColour("#00dd00")
491
- button.SetLabel(_("LOCKED"))
492
- button.SetBitmap(
493
- icons8_circled_play.GetBitmap(
494
- use_theme=False, resize=get_default_icon_size()
495
- )
496
- )
497
- button.Enable(False)
498
- elif state == "wait":
499
-
500
- def f(event=None):
501
- self.context("continue\n")
502
-
503
- button.function = f
504
- button.SetBackgroundColour("#dddd00")
505
- button.SetLabel(_("Force Continue"))
506
- button.SetBitmap(
507
- icons8_laser_beam_hazard.GetBitmap(
508
- use_theme=False, resize=get_default_icon_size()
509
- )
510
- )
511
- button.Enable(True)
512
- elif state == "pause":
513
-
514
- def f(event=None):
515
- self.context("resume\n")
516
-
517
- button.function = f
518
- button.SetBackgroundColour("#00dd00")
519
- button.SetLabel(_("Resume Controller"))
520
- button.SetBitmap(
521
- icons8_circled_play.GetBitmap(
522
- use_theme=False, resize=get_default_icon_size()
523
- )
524
- )
525
- button.Enable(True)
526
- elif state == "active":
527
-
528
- def f(event=None):
529
- self.context("hold\n")
530
-
531
- button.function = f
532
- button.SetBackgroundColour("#00ff00")
533
- button.SetLabel(_("Pause Controller"))
534
- button.SetBitmap(
535
- icons8_pause.GetBitmap(use_theme=False, resize=get_default_icon_size())
536
- )
537
- button.Enable(True)
538
- elif state == "terminate":
539
-
540
- def f(event=None):
541
- self.context("abort\n")
542
-
543
- button.function = f
544
- button.SetBackgroundColour("#00ffff")
545
- button.SetLabel(_("Manual Reset"))
546
- button.SetBitmap(
547
- icons8_emergency_stop_button.GetBitmap(
548
- use_theme=False, resize=get_default_icon_size()
549
- )
550
- )
551
- button.Enable(True)
552
-
553
- @signal_listener("pipe;failing")
554
- def on_usb_failing(self, origin, count):
555
- self.retries = count
556
-
557
- def on_button_start_controller(self, event=None):
558
- event.Skip()
559
- self.button_controller_control.function()
560
-
561
- def on_check_show_usb_log(self, event=None):
562
- on = self.checkbox_show_usb_log.GetValue()
563
- self.text_usb_log.Show(on)
564
- self.context.show_usb_log = bool(on)
565
- if on:
566
- self.GetParent().SetSize((_advanced_width, _default_height))
567
- else:
568
- self.GetParent().SetSize((_simple_width, _default_height))
569
-
570
-
571
- class LihuiyuControllerGui(MWindow):
572
- def __init__(self, *args, **kwds):
573
- super().__init__(_advanced_width, _default_height, *args, **kwds)
574
-
575
- # ==========
576
- # MENU BAR
577
- # ==========
578
- from platform import system as _sys
579
-
580
- if _sys() != "Darwin":
581
- self.LihuiyuController_menubar = wx.MenuBar()
582
- self.create_menu(self.LihuiyuController_menubar.Append)
583
- self.SetMenuBar(self.LihuiyuController_menubar)
584
- # ==========
585
- # MENUBAR END
586
- # ==========
587
-
588
- self.panel = LihuiyuControllerPanel(self, wx.ID_ANY, context=self.context)
589
- self.add_module_delegate(self.panel)
590
- _icon = wx.NullIcon
591
- _icon.CopyFromBitmap(icons8_connected.GetBitmap())
592
- self.SetIcon(_icon)
593
- self.SetTitle(_("Lihuiyu-Controller"))
594
-
595
- def create_menu(self, append):
596
- wxglade_tmp_menu = wx.Menu()
597
- item = wxglade_tmp_menu.Append(
598
- wx.ID_ANY, _("Reset USB"), _("Reset USB connection")
599
- )
600
- self.Bind(wx.EVT_MENU, self.on_menu_usb_reset, id=item.GetId())
601
- item = wxglade_tmp_menu.Append(
602
- wx.ID_ANY, _("Release USB"), _("Release USB resources")
603
- )
604
- self.Bind(wx.EVT_MENU, self.on_menu_usb_release, id=item.GetId())
605
- append(wxglade_tmp_menu, _("Tools"))
606
- wxglade_tmp_menu = wx.Menu()
607
- item = wxglade_tmp_menu.Append(wx.ID_ANY, _("Pause"), "")
608
- self.Bind(wx.EVT_MENU, self.on_menu_pause, id=item.GetId())
609
- item = wxglade_tmp_menu.Append(wx.ID_ANY, _("Stop"), "")
610
- self.Bind(wx.EVT_MENU, self.on_menu_stop, id=item.GetId())
611
- append(wxglade_tmp_menu, _("Commands"))
612
- wxglade_tmp_menu = wx.Menu()
613
- item = wxglade_tmp_menu.Append(
614
- wx.ID_ANY, _("BufferView"), _("Views the Controller Buffer")
615
- )
616
- self.Bind(wx.EVT_MENU, self.on_menu_bufferview, id=item.GetId())
617
- append(wxglade_tmp_menu, _("Views"))
618
-
619
- def window_preserve(self):
620
- return False
621
-
622
- def on_menu_usb_reset(self, event):
623
- try:
624
- self.context("usb_reset\n")
625
- except AttributeError:
626
- pass
627
-
628
- def on_menu_usb_release(self, event):
629
- try:
630
- self.context("usb_release\n")
631
- except AttributeError:
632
- pass
633
-
634
- def on_menu_pause(self, event=None):
635
- try:
636
- self.context("pause\n")
637
- except AttributeError:
638
- pass
639
-
640
- def on_menu_stop(self, event=None):
641
- try:
642
- self.context("estop\n")
643
- except AttributeError:
644
- pass
645
-
646
- def on_menu_bufferview(self, event=None):
647
- self.context("window open BufferView\n")
648
-
649
- @staticmethod
650
- def submenu():
651
- return "Device-Control", "Controller"
1
+ #
2
+ # generated by wxGlade 0.9.3 on Fri Jun 28 16:25:14 2019
3
+ #
4
+ import threading
5
+
6
+ import wx
7
+
8
+ from meerk40t.gui.icons import (
9
+ get_default_icon_size,
10
+ icons8_connected,
11
+ icons8_disconnected,
12
+ )
13
+ from meerk40t.gui.mwindow import MWindow
14
+ from meerk40t.gui.wxutils import (
15
+ ScrolledPanel,
16
+ StaticBoxSizer,
17
+ TextCtrl,
18
+ dip_size,
19
+ wxButton,
20
+ wxCheckBox,
21
+ wxStaticText,
22
+ )
23
+ from meerk40t.kernel import signal_listener
24
+
25
+ _ = wx.GetTranslation
26
+
27
+ _simple_width = 565
28
+ _advanced_width = 952
29
+ _default_height = 570
30
+
31
+
32
+ class LihuiyuControllerPanel(ScrolledPanel):
33
+ def __init__(self, *args, context=None, **kwds):
34
+ kwds["style"] = kwds.get("style", 0) | wx.TAB_TRAVERSAL
35
+ wx.Panel.__init__(self, *args, **kwds)
36
+ self.context = context.device
37
+ self.SetHelpText("k40controller")
38
+
39
+ self.button_device_connect = wxButton(self, wx.ID_ANY, _("Connection"))
40
+ if self.context.mock:
41
+ connectivity = "Mock-Device"
42
+ elif self.context.networked:
43
+ connectivity = f"Network: {self.context.address}:{self.context.port}"
44
+ else:
45
+ connectivity = "USB"
46
+ self.text_connection_status = TextCtrl(
47
+ self, wx.ID_ANY, connectivity, style=wx.TE_READONLY
48
+ )
49
+ # self.button_controller_control = wxButton(
50
+ # self, wx.ID_ANY, _("Start Controller")
51
+ # )
52
+ # self.button_controller_control.function = lambda: self.context("start\n")
53
+ # self.text_controller_status = TextCtrl(
54
+ # self, wx.ID_ANY, "", style=wx.TE_READONLY
55
+ # )
56
+ self.packet_count_text = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
57
+ self.rejected_packet_count_text = TextCtrl(
58
+ self, wx.ID_ANY, "", style=wx.TE_READONLY
59
+ )
60
+ self.text_packet_info = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
61
+ self.text_byte_0 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
62
+ self.text_byte_1 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
63
+ self.text_desc = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
64
+ self.text_byte_2 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
65
+ self.text_byte_3 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
66
+ self.text_byte_4 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
67
+ self.text_byte_5 = TextCtrl(self, wx.ID_ANY, "", style=wx.TE_READONLY)
68
+ self.checkbox_show_usb_log = wxCheckBox(self, wx.ID_ANY, _("Show USB Log"))
69
+ self.text_usb_log = TextCtrl(
70
+ self, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_READONLY
71
+ )
72
+ self.button_clear_stats = wxButton(self, wx.ID_ANY, _("Reset\nstatistics"))
73
+
74
+ self.__set_properties()
75
+ self.__do_layout()
76
+
77
+ self.Bind(wx.EVT_BUTTON, self.on_button_start_usb, self.button_device_connect)
78
+ self.Bind(wx.EVT_BUTTON, self.on_button_reset_stats, self.button_clear_stats)
79
+ # self.Bind(
80
+ # wx.EVT_BUTTON,
81
+ # self.on_button_start_controller,
82
+ # self.button_controller_control,
83
+ # )
84
+ self.Bind(
85
+ wx.EVT_CHECKBOX, self.on_check_show_usb_log, self.checkbox_show_usb_log
86
+ )
87
+ # Test the color combos...
88
+ # self.Bind(wx.EVT_RIGHT_DOWN, self.debug_colors)
89
+ # self._debug_counter = 0
90
+
91
+ self.last_control_state = None
92
+ self.retries = 0
93
+ self._buffer = ""
94
+ self._buffer_lock = threading.Lock()
95
+ self.set_widgets()
96
+ self.SetupScrolling()
97
+ self._channel_watching = None
98
+
99
+ # def debug_colors(self, event):
100
+ # states = (
101
+ # "STATE_CONNECTION_FAILED",
102
+ # "STATE_FAILED_RETRYING",
103
+ # "STATE_FAILED_SUSPENDED",
104
+ # "STATE_DRIVER_NO_BACKEND",
105
+ # "STATE_UNINITIALIZED",
106
+ # "STATE_USB_DISCONNECTED",
107
+ # "STATE_USB_SET_DISCONNECTING",
108
+ # "STATE_USB_CONNECTED",
109
+ # "STATE_CONNECTED",
110
+ # "STATE_CONNECTING",
111
+ # )
112
+ # if self._debug_counter >= len(states):
113
+ # self._debug_counter = 0
114
+ # self.context.signal("pipe;state", states[self._debug_counter])
115
+ # self._debug_counter += 1
116
+
117
+ def __set_properties(self):
118
+ self.SetFont(
119
+ wx.Font(
120
+ 9,
121
+ wx.FONTFAMILY_DEFAULT,
122
+ wx.FONTSTYLE_NORMAL,
123
+ wx.FONTWEIGHT_NORMAL,
124
+ 0,
125
+ "Segoe UI",
126
+ )
127
+ )
128
+ self.set_color_according_to_state("", self.button_device_connect)
129
+ self.button_device_connect.SetFont(
130
+ wx.Font(
131
+ 11,
132
+ wx.FONTFAMILY_DEFAULT,
133
+ wx.FONTSTYLE_NORMAL,
134
+ wx.FONTWEIGHT_NORMAL,
135
+ 0,
136
+ "Segoe UI",
137
+ )
138
+ )
139
+ self.button_device_connect.SetToolTip(
140
+ _("Force connection/disconnection from the device.")
141
+ )
142
+ self.text_connection_status.SetToolTip(_("Connection status"))
143
+
144
+ # self.button_controller_control.SetBackgroundColour(wx.Colour(102, 255, 102))
145
+ # self.button_controller_control.SetForegroundColour(wx.BLACK)
146
+ # self.button_controller_control.SetFont(
147
+ # wx.Font(
148
+ # 11,
149
+ # wx.FONTFAMILY_DEFAULT,
150
+ # wx.FONTSTYLE_NORMAL,
151
+ # wx.FONTWEIGHT_NORMAL,
152
+ # 0,
153
+ # "Segoe UI",
154
+ # )
155
+ # )
156
+ # self.button_controller_control.SetToolTip(
157
+ # _("Change the currently performed operation.")
158
+ # )
159
+ # self.text_controller_status.SetToolTip(
160
+ # _("Displays the controller's current process.")
161
+ # )
162
+ self.packet_count_text.SetMinSize(dip_size(self, 35, -1))
163
+ self.packet_count_text.SetToolTip(_("Total number of packets sent"))
164
+ self.rejected_packet_count_text.SetMinSize(dip_size(self, 35, -1))
165
+ self.rejected_packet_count_text.SetToolTip(
166
+ _("Total number of packets rejected")
167
+ )
168
+ self.text_packet_info.SetToolTip(_("Last packet information sent"))
169
+ self.text_byte_0.SetMinSize(dip_size(self, 35, -1))
170
+ self.text_byte_1.SetMinSize(dip_size(self, 35, -1))
171
+ self.text_desc.SetMinSize(dip_size(self, 35, -1))
172
+ self.text_desc.SetToolTip(_("The meaning of Byte 1"))
173
+ self.text_byte_2.SetMinSize(dip_size(self, 35, -1))
174
+ self.text_byte_3.SetMinSize(dip_size(self, 35, -1))
175
+ self.text_byte_4.SetMinSize(dip_size(self, 35, -1))
176
+ self.text_byte_5.SetMinSize(dip_size(self, 35, -1))
177
+ self.checkbox_show_usb_log.SetValue(1)
178
+ self.button_device_connect.SetBitmap(
179
+ icons8_disconnected.GetBitmap(
180
+ use_theme=False, resize=0.75 * get_default_icon_size(self.context)
181
+ )
182
+ )
183
+ # self.button_controller_control.SetBitmap(
184
+ # icons8_circled_play.GetBitmap(
185
+ # use_theme=False, resize=0.75 * get_default_icon_size(self.context)
186
+ # )
187
+ # )
188
+ # end wxGlade
189
+
190
+ def __do_layout(self):
191
+ sizer_main = wx.BoxSizer(wx.HORIZONTAL)
192
+ sizer_main_vertical = wx.BoxSizer(wx.VERTICAL)
193
+ sizer_show_usb_log = wx.BoxSizer(wx.HORIZONTAL)
194
+ packet_count = StaticBoxSizer(self, wx.ID_ANY, _("Packet Info"), wx.VERTICAL)
195
+ byte_data_status = StaticBoxSizer(
196
+ self, wx.ID_ANY, _("Byte Data Status"), wx.HORIZONTAL
197
+ )
198
+ byte5sizer = wx.BoxSizer(wx.VERTICAL)
199
+ byte4sizer = wx.BoxSizer(wx.VERTICAL)
200
+ byte3sizer = wx.BoxSizer(wx.VERTICAL)
201
+ byte2sizer = wx.BoxSizer(wx.VERTICAL)
202
+ byte1sizer = wx.BoxSizer(wx.VERTICAL)
203
+ byte0sizer = wx.BoxSizer(wx.VERTICAL)
204
+ packet_info = StaticBoxSizer(self, wx.ID_ANY, _("Last Packet"), wx.HORIZONTAL)
205
+ sizer_statistics = wx.BoxSizer(wx.HORIZONTAL)
206
+ sizer_count_rejected = StaticBoxSizer(
207
+ self, wx.ID_ANY, _("Rejected Packets"), wx.VERTICAL
208
+ )
209
+ sizer_count_packets = StaticBoxSizer(
210
+ self, wx.ID_ANY, _("Packet Count"), wx.VERTICAL
211
+ )
212
+ # sizer_controller = StaticBoxSizer(self, wx.ID_ANY, _("Controller"), wx.VERTICAL)
213
+ # sizer_usb_settings = StaticBoxSizer(
214
+ # self, wx.ID_ANY, _("USB Settings"), wx.VERTICAL
215
+ # )
216
+ # sizer_23 = wx.BoxSizer(wx.HORIZONTAL)
217
+ # sizer_12 = StaticBoxSizer(self, wx.ID_ANY, _("Chip Version"), wx.HORIZONTAL)
218
+ # sizer_11 = StaticBoxSizer(self, wx.ID_ANY, _("Device Bus:"), wx.HORIZONTAL)
219
+ # sizer_10 = StaticBoxSizer(self, wx.ID_ANY, _("Device Address:"), wx.HORIZONTAL)
220
+ # sizer_3 = StaticBoxSizer(self, wx.ID_ANY, _("Device Index:"), wx.HORIZONTAL)
221
+ button_sizer = wx.BoxSizer(wx.HORIZONTAL)
222
+ sizer_usb_connect = StaticBoxSizer(
223
+ self, wx.ID_ANY, _("USB Connection"), wx.VERTICAL
224
+ )
225
+ sizer_usb_connect.Add(self.button_device_connect, 0, wx.EXPAND, 0)
226
+ sizer_usb_connect.Add(self.text_connection_status, 0, wx.EXPAND, 0)
227
+ button_sizer.Add(sizer_usb_connect, 1, wx.EXPAND, 0)
228
+
229
+ # sizer_controller.Add(self.button_controller_control, 0, wx.EXPAND, 0)
230
+ # sizer_controller.Add(self.text_controller_status, 0, wx.EXPAND, 0)
231
+ # button_sizer.Add(sizer_controller, 1, wx.EXPAND, 0)
232
+
233
+ sizer_main_vertical.Add(button_sizer, 0, wx.EXPAND, 0)
234
+
235
+ sizer_count_packets.Add(self.packet_count_text, 0, wx.EXPAND, 0)
236
+ sizer_statistics.Add(sizer_count_packets, 1, wx.EXPAND, 0)
237
+ sizer_count_rejected.Add(self.rejected_packet_count_text, 0, wx.EXPAND, 0)
238
+ sizer_statistics.Add(sizer_count_rejected, 1, wx.EXPAND, 0)
239
+ sizer_statistics.Add(self.button_clear_stats, 0, wx.EXPAND, 0)
240
+ packet_count.Add(sizer_statistics, 1, wx.EXPAND, 0)
241
+ packet_info.Add(self.text_packet_info, 11, wx.EXPAND, 0)
242
+ packet_count.Add(packet_info, 0, wx.EXPAND, 0)
243
+ byte0sizer.Add(self.text_byte_0, 0, 0, 0)
244
+ label_1 = wxStaticText(self, wx.ID_ANY, _("Byte 0"))
245
+ byte0sizer.Add(label_1, 0, 0, 0)
246
+ byte_data_status.Add(byte0sizer, 1, wx.EXPAND, 0)
247
+ byte1sizer.Add(self.text_byte_1, 0, 0, 0)
248
+ label_2 = wxStaticText(self, wx.ID_ANY, _("Byte 1"))
249
+ byte1sizer.Add(label_2, 0, 0, 0)
250
+ byte1sizer.Add(self.text_desc, 0, 0, 0)
251
+ byte_data_status.Add(byte1sizer, 1, wx.EXPAND, 0)
252
+ byte2sizer.Add(self.text_byte_2, 0, 0, 0)
253
+ label_3 = wxStaticText(self, wx.ID_ANY, _("Byte 2"))
254
+ byte2sizer.Add(label_3, 0, 0, 0)
255
+ byte_data_status.Add(byte2sizer, 1, wx.EXPAND, 0)
256
+ byte3sizer.Add(self.text_byte_3, 0, 0, 0)
257
+ label_4 = wxStaticText(self, wx.ID_ANY, _("Byte 3"))
258
+ byte3sizer.Add(label_4, 0, 0, 0)
259
+ byte_data_status.Add(byte3sizer, 1, wx.EXPAND, 0)
260
+ byte4sizer.Add(self.text_byte_4, 0, 0, 0)
261
+ label_5 = wxStaticText(self, wx.ID_ANY, _("Byte 4"))
262
+ byte4sizer.Add(label_5, 0, 0, 0)
263
+ byte_data_status.Add(byte4sizer, 1, wx.EXPAND, 0)
264
+ byte5sizer.Add(self.text_byte_5, 0, 0, 0)
265
+ label_18 = wxStaticText(self, wx.ID_ANY, _("Byte 5"))
266
+ byte5sizer.Add(label_18, 0, 0, 0)
267
+ byte_data_status.Add(byte5sizer, 1, wx.EXPAND, 0)
268
+ packet_count.Add(byte_data_status, 0, wx.EXPAND, 0)
269
+ sizer_main_vertical.Add(packet_count, 0, 0, 0)
270
+ label_6 = wxStaticText(self, wx.ID_ANY, "")
271
+ sizer_show_usb_log.Add(label_6, 10, wx.EXPAND, 0)
272
+ sizer_show_usb_log.Add(self.checkbox_show_usb_log, 0, 0, 0)
273
+ sizer_main_vertical.Add(sizer_show_usb_log, 1, wx.EXPAND, 0)
274
+ sizer_main.Add(sizer_main_vertical, 1, 0, 0)
275
+ sizer_main.Add(self.text_usb_log, 1, wx.EXPAND, 0)
276
+ self.SetSizer(sizer_main)
277
+ sizer_main.Fit(self)
278
+ self.Layout()
279
+ # end wxGlade
280
+
281
+ def set_color_according_to_state(self, stateval, control):
282
+ def color_distance(c1, c2):
283
+ from math import sqrt
284
+
285
+ red_mean = int((c1.red + c2.red) / 2.0)
286
+ r = c1.red - c2.red
287
+ g = c1.green - c2.green
288
+ b = c1.blue - c2.blue
289
+ distance_sq = (
290
+ (((512 + red_mean) * r * r) >> 8)
291
+ + (4 * g * g)
292
+ + (((767 - red_mean) * b * b) >> 8)
293
+ )
294
+ return sqrt(distance_sq)
295
+
296
+ state_colors = {
297
+ "STATE_CONNECTION_FAILED": wx.Colour("#dfdf00"),
298
+ "STATE_FAILED_RETRYING": wx.Colour("#df0000"),
299
+ "STATE_FAILED_SUSPENDED": wx.Colour("#0000df"),
300
+ "STATE_DRIVER_NO_BACKEND": wx.Colour("#dfdf00"),
301
+ "STATE_UNINITIALIZED": wx.Colour("#ffff00"),
302
+ "STATE_USB_DISCONNECTED": wx.Colour("#ffff00"),
303
+ "STATE_USB_SET_DISCONNECTING": wx.Colour("#ffff00"),
304
+ "STATE_USB_CONNECTED": wx.Colour("#00ff00"),
305
+ "STATE_CONNECTED": wx.Colour("#00ff00"),
306
+ "STATE_CONNECTING": wx.Colour("#ffff00"),
307
+ }
308
+ if stateval in state_colors:
309
+ bgcol = state_colors[stateval]
310
+ else:
311
+ bgcol = wx.Colour("#66ff66")
312
+ d1 = color_distance(bgcol, wx.BLACK)
313
+ d2 = color_distance(bgcol, wx.WHITE)
314
+ # print(f"state={stateval}, to black={d1}, to_white={d2}")
315
+ if d1 <= d2:
316
+ fgcol = wx.WHITE
317
+ else:
318
+ fgcol = wx.BLACK
319
+ control.SetBackgroundColour(bgcol)
320
+ control.SetForegroundColour(fgcol)
321
+
322
+ def module_open(self, *args, **kwargs):
323
+ self.pane_show()
324
+
325
+ def module_close(self, *args, **kwargs):
326
+ self.pane_hide()
327
+
328
+ def pane_show(self):
329
+ # Channel watching is to make sure we unwatch the channel we watched even if label changes.
330
+ self._channel_watching = f"{self.context.safe_label}/usb"
331
+ self.context.channel(self._channel_watching, buffer_size=500).watch(
332
+ self.update_text
333
+ )
334
+ self.on_network_update()
335
+
336
+ def pane_hide(self):
337
+ self.context.channel(self._channel_watching).unwatch(self.update_text)
338
+
339
+ def on_button_reset_stats(self, event):
340
+ self.context.packet_count = 0
341
+ self.context.rejected_count = 0
342
+ self.packet_count_text.SetValue(str(self.context.packet_count))
343
+ self.rejected_packet_count_text.SetValue(str(self.context.rejected_count))
344
+
345
+ @signal_listener("network_update")
346
+ def on_network_update(self, origin=None, *args):
347
+ try:
348
+ if self.context.networked:
349
+ self.button_device_connect.Enable(False)
350
+ else:
351
+ self.button_device_connect.Enable(True)
352
+ except AttributeError:
353
+ pass
354
+
355
+ def restore(self, *args, **kwargs):
356
+ self.set_widgets()
357
+
358
+ def update_text(self, text):
359
+ with self._buffer_lock:
360
+ self._buffer += f"{text}\n"
361
+ self.context.signal("lihuiyu_controller_update", True)
362
+
363
+ @signal_listener("lihuiyu_controller_update")
364
+ def update_text_gui(self, origin, *args):
365
+ try:
366
+ with self._buffer_lock:
367
+ buffer = self._buffer
368
+ self._buffer = ""
369
+ if self.text_usb_log.IsShown():
370
+ self.text_usb_log.AppendText(buffer)
371
+ except RuntimeError:
372
+ pass
373
+
374
+ def set_widgets(self):
375
+ try:
376
+ show_log = self.context.show_usb_log
377
+ except AttributeError:
378
+ show_log = True
379
+ self.checkbox_show_usb_log.SetValue(show_log)
380
+ self.on_check_show_usb_log()
381
+
382
+ def device_execute(self, control_name):
383
+ def menu_element(event=None):
384
+ self.context.execute(control_name)
385
+
386
+ return menu_element
387
+
388
+ @signal_listener("pipe;status")
389
+ def update_status(self, origin, status_data, code_string):
390
+ if origin != self.context.path:
391
+ return
392
+ try:
393
+ if status_data is not None:
394
+ if isinstance(status_data, int):
395
+ self.text_desc.SetValue(str(status_data))
396
+ self.text_desc.SetValue(code_string)
397
+ else:
398
+ if len(status_data) == 6:
399
+ self.text_byte_0.SetValue(str(status_data[0]))
400
+ self.text_byte_1.SetValue(str(status_data[1]))
401
+ self.text_byte_2.SetValue(str(status_data[2]))
402
+ self.text_byte_3.SetValue(str(status_data[3]))
403
+ self.text_byte_4.SetValue(str(status_data[4]))
404
+ self.text_byte_5.SetValue(str(status_data[5]))
405
+ self.text_desc.SetValue(code_string)
406
+ self.packet_count_text.SetValue(str(self.context.packet_count))
407
+ self.rejected_packet_count_text.SetValue(str(self.context.rejected_count))
408
+ except RuntimeError:
409
+ # This should be handled when the controller window is closed.
410
+ pass
411
+
412
+ @signal_listener("pipe;packet_text")
413
+ def update_packet_text(self, origin, string_data):
414
+ if origin != self.context._path:
415
+ return
416
+ if string_data is not None and len(string_data) != 0:
417
+ self.text_packet_info.SetValue(str(string_data))
418
+
419
+ @signal_listener("pipe;usb_status")
420
+ def on_connection_status_change(self, origin, status):
421
+ if origin != self.context._path:
422
+ return
423
+ try:
424
+ self.text_connection_status.SetValue(str(status))
425
+ except RuntimeError:
426
+ pass
427
+
428
+ @signal_listener("pipe;state")
429
+ def on_connection_state_change(self, origin, state):
430
+ if origin != self.context._path:
431
+ return
432
+ self.set_color_according_to_state(state, self.button_device_connect)
433
+ if state == "STATE_CONNECTION_FAILED":
434
+ self.button_device_connect.SetLabel(_("Connect failed"))
435
+ self.button_device_connect.SetBitmap(
436
+ icons8_disconnected.GetBitmap(
437
+ use_theme=False, resize=0.75 * get_default_icon_size(self.context)
438
+ )
439
+ )
440
+ self.button_device_connect.Enable()
441
+ elif state == "STATE_FAILED_RETRYING":
442
+ self.button_device_connect.SetLabel(_("Retrying..."))
443
+ self.button_device_connect.SetBitmap(
444
+ icons8_disconnected.GetBitmap(
445
+ use_theme=False, resize=0.75 * get_default_icon_size(self.context)
446
+ )
447
+ )
448
+ self.button_device_connect.Enable()
449
+ elif state == "STATE_FAILED_SUSPENDED":
450
+ self.button_device_connect.SetLabel(_("Suspended Retrying"))
451
+ self.button_device_connect.SetBitmap(
452
+ icons8_disconnected.GetBitmap(
453
+ use_theme=False, resize=0.75 * get_default_icon_size(self.context)
454
+ )
455
+ )
456
+ self.button_device_connect.Enable()
457
+ elif state == "STATE_DRIVER_NO_BACKEND":
458
+ self.button_device_connect.SetLabel(_("No Backend"))
459
+ self.button_device_connect.SetBitmap(
460
+ icons8_disconnected.GetBitmap(
461
+ use_theme=False, resize=0.75 * get_default_icon_size(self.context)
462
+ )
463
+ )
464
+ self.button_device_connect.Enable()
465
+ elif state == "STATE_UNINITIALIZED" or state == "STATE_USB_DISCONNECTED":
466
+ self.button_device_connect.SetLabel(_("Connect"))
467
+ self.button_device_connect.SetBitmap(
468
+ icons8_connected.GetBitmap(
469
+ use_theme=False, resize=0.75 * get_default_icon_size(self.context)
470
+ )
471
+ )
472
+ self.button_device_connect.Enable()
473
+ elif state == "STATE_USB_SET_DISCONNECTING":
474
+ self.button_device_connect.SetLabel(_("Disconnecting..."))
475
+ self.button_device_connect.SetBitmap(
476
+ icons8_disconnected.GetBitmap(
477
+ use_theme=False, resize=0.75 * get_default_icon_size(self.context)
478
+ )
479
+ )
480
+ self.button_device_connect.Disable()
481
+ elif state == "STATE_USB_CONNECTED" or state == "STATE_CONNECTED":
482
+ self.button_device_connect.SetLabel(_("Disconnect"))
483
+ self.button_device_connect.SetBitmap(
484
+ icons8_connected.GetBitmap(
485
+ use_theme=False, resize=0.75 * get_default_icon_size(self.context)
486
+ )
487
+ )
488
+ self.button_device_connect.Enable()
489
+ elif state == "STATE_CONNECTING":
490
+ self.button_device_connect.SetLabel(_("Connecting..."))
491
+ self.button_device_connect.SetBitmap(
492
+ icons8_connected.GetBitmap(
493
+ use_theme=False, resize=0.75 * get_default_icon_size(self.context)
494
+ )
495
+ )
496
+ self.button_device_connect.Disable()
497
+
498
+ def on_button_start_usb(self, event=None): # wxGlade: Controller.<event_handler>
499
+ origin, state = self.context.last_signal("pipe;state")
500
+ if state is not None and isinstance(state, tuple):
501
+ state = state[0]
502
+
503
+ if state == "STATE_FAILED_RETRYING":
504
+ self.retries = 0
505
+ self.context("usb_abort\n")
506
+ elif state == "STATE_FAILED_SUSPENDED":
507
+ self.context("usb_continue\n")
508
+ elif state in (
509
+ "STATE_USB_DISCONNECTED",
510
+ "STATE_UNINITIALIZED",
511
+ "STATE_CONNECTION_FAILED",
512
+ "STATE_DRIVER_MOCK",
513
+ None,
514
+ ):
515
+ try:
516
+ self.context("usb_connect\n")
517
+ except ConnectionRefusedError:
518
+ dlg = wx.MessageDialog(
519
+ None,
520
+ _("Connection Refused. See USB Log for detailed information."),
521
+ _("Manual Connection"),
522
+ wx.OK | wx.ICON_WARNING,
523
+ )
524
+ result = dlg.ShowModal()
525
+ dlg.Destroy()
526
+ except NotImplementedError:
527
+ dlg = wx.MessageDialog(
528
+ None,
529
+ _("Connection Refused. See USB Log for detailed information.") + "\n" + _("You may run an incompatible version of libusb, have you tried the 32-bit version?"),
530
+ _("Manual Connection"),
531
+ wx.OK | wx.ICON_WARNING,
532
+ )
533
+ result = dlg.ShowModal()
534
+ dlg.Destroy()
535
+ elif state in ("STATE_CONNECTED", "STATE_USB_CONNECTED"):
536
+ self.context("usb_disconnect\n")
537
+
538
+ # @signal_listener("pipe;thread")
539
+ # def on_control_state(self, origin, state):
540
+ # if origin != self.context._path:
541
+ # return
542
+ #
543
+ # if self.last_control_state == state:
544
+ # return
545
+ # self.last_control_state = state
546
+ # button = self.button_controller_control
547
+ # if self.text_controller_status is None:
548
+ # return
549
+ # value = self.context.kernel.get_text_thread_state(state)
550
+ # self.text_controller_status.SetValue(str(value))
551
+ # if state in ("init", "end", "idle"):
552
+ #
553
+ # def f(event=None):
554
+ # self.context("start\n")
555
+ # self.context("hold\n")
556
+ #
557
+ # button.function = f
558
+ # button.SetBackgroundColour("#009900")
559
+ # button.SetLabel(_("Hold Controller"))
560
+ # button.SetBitmap(
561
+ # icons8_circled_play.GetBitmap(
562
+ # use_theme=False, resize=0.75 * get_default_icon_size(self.context)
563
+ # )
564
+ # )
565
+ # button.Enable(True)
566
+ # elif state == "busy":
567
+ # button.SetBackgroundColour("#00dd00")
568
+ # button.SetLabel(_("LOCKED"))
569
+ # button.SetBitmap(
570
+ # icons8_circled_play.GetBitmap(
571
+ # use_theme=False, resize=0.75 * get_default_icon_size(self.context)
572
+ # )
573
+ # )
574
+ # button.Enable(False)
575
+ # elif state == "wait":
576
+ #
577
+ # def f(event=None):
578
+ # self.context("continue\n")
579
+ #
580
+ # button.function = f
581
+ # button.SetBackgroundColour("#dddd00")
582
+ # button.SetLabel(_("Force Continue"))
583
+ # button.SetBitmap(
584
+ # icons8_laser_beam_hazard.GetBitmap(
585
+ # use_theme=False, resize=0.75 * get_default_icon_size(self.context)
586
+ # )
587
+ # )
588
+ # button.Enable(True)
589
+ # elif state == "pause":
590
+ #
591
+ # def f(event=None):
592
+ # self.context("resume\n")
593
+ #
594
+ # button.function = f
595
+ # button.SetBackgroundColour("#00dd00")
596
+ # button.SetLabel(_("Resume Controller"))
597
+ # button.SetBitmap(
598
+ # icons8_circled_play.GetBitmap(
599
+ # use_theme=False, resize=0.75 * get_default_icon_size(self.context)
600
+ # )
601
+ # )
602
+ # button.Enable(True)
603
+ # elif state == "active":
604
+ #
605
+ # def f(event=None):
606
+ # self.context("hold\n")
607
+ #
608
+ # button.function = f
609
+ # button.SetBackgroundColour("#00ff00")
610
+ # button.SetLabel(_("Pause Controller"))
611
+ # button.SetBitmap(
612
+ # icons8_pause.GetBitmap(use_theme=False, resize=0.75 * get_default_icon_size(self.context))
613
+ # )
614
+ # button.Enable(True)
615
+ # elif state == "terminate":
616
+ #
617
+ # def f(event=None):
618
+ # self.context("abort\n")
619
+ #
620
+ # button.function = f
621
+ # button.SetBackgroundColour("#00ffff")
622
+ # button.SetLabel(_("Manual Reset"))
623
+ # button.SetBitmap(
624
+ # icons8_emergency_stop_button.GetBitmap(
625
+ # use_theme=False, resize=0.75 * get_default_icon_size(self.context)
626
+ # )
627
+ # )
628
+ # button.Enable(True)
629
+
630
+ @signal_listener("pipe;failing")
631
+ def on_usb_failing(self, origin, count):
632
+ self.retries = count
633
+
634
+ # def on_button_start_controller(self, event=None):
635
+ # event.Skip()
636
+ # self.button_controller_control.function()
637
+
638
+ def on_check_show_usb_log(self, event=None):
639
+ on = self.checkbox_show_usb_log.GetValue()
640
+ self.text_usb_log.Show(on)
641
+ self.context.show_usb_log = bool(on)
642
+ if on:
643
+ self.GetParent().SetSize((_advanced_width, _default_height))
644
+ else:
645
+ self.GetParent().SetSize((_simple_width, _default_height))
646
+
647
+
648
+ class LihuiyuControllerGui(MWindow):
649
+ def __init__(self, *args, **kwds):
650
+ super().__init__(_simple_width, _default_height, *args, **kwds)
651
+
652
+ # ==========
653
+ # MENU BAR
654
+ # ==========
655
+ from platform import system as _sys
656
+
657
+ if _sys() != "Darwin":
658
+ self.LihuiyuController_menubar = wx.MenuBar()
659
+ self.create_menu(self.LihuiyuController_menubar.Append)
660
+ self.SetMenuBar(self.LihuiyuController_menubar)
661
+ # ==========
662
+ # MENUBAR END
663
+ # ==========
664
+ self.restore_aspect(honor_initial_values=True)
665
+ self.panel = LihuiyuControllerPanel(self, wx.ID_ANY, context=self.context)
666
+ self.sizer.Add(self.panel, 1, wx.EXPAND, 0)
667
+ self.add_module_delegate(self.panel)
668
+ _icon = wx.NullIcon
669
+ _icon.CopyFromBitmap(icons8_connected.GetBitmap())
670
+ self.SetIcon(_icon)
671
+ self.SetTitle(_("Lihuiyu-Controller"))
672
+ self.Layout()
673
+
674
+ def create_menu(self, append):
675
+ wxglade_tmp_menu = wx.Menu()
676
+ item = wxglade_tmp_menu.Append(
677
+ wx.ID_ANY, _("Reset USB"), _("Reset USB connection")
678
+ )
679
+ self.Bind(wx.EVT_MENU, self.on_menu_usb_reset, id=item.GetId())
680
+ item = wxglade_tmp_menu.Append(
681
+ wx.ID_ANY, _("Release USB"), _("Release USB resources")
682
+ )
683
+ self.Bind(wx.EVT_MENU, self.on_menu_usb_release, id=item.GetId())
684
+ append(wxglade_tmp_menu, _("Tools"))
685
+ wxglade_tmp_menu = wx.Menu()
686
+ item = wxglade_tmp_menu.Append(wx.ID_ANY, _("Pause"), "")
687
+ self.Bind(wx.EVT_MENU, self.on_menu_pause, id=item.GetId())
688
+ item = wxglade_tmp_menu.Append(wx.ID_ANY, _("Stop"), "")
689
+ self.Bind(wx.EVT_MENU, self.on_menu_stop, id=item.GetId())
690
+ wxglade_tmp_menu.AppendSeparator()
691
+ item = wxglade_tmp_menu.Append(wx.ID_ANY, _("Configuration"), "")
692
+ self.Bind(wx.EVT_MENU, self.on_menu_config, id=item.GetId())
693
+
694
+ append(wxglade_tmp_menu, _("Commands"))
695
+ wxglade_tmp_menu = wx.Menu()
696
+ item = wxglade_tmp_menu.Append(
697
+ wx.ID_ANY, _("BufferView"), _("Views the Controller Buffer")
698
+ )
699
+ self.Bind(wx.EVT_MENU, self.on_menu_bufferview, id=item.GetId())
700
+ append(wxglade_tmp_menu, _("Views"))
701
+
702
+ def window_preserve(self):
703
+ return False
704
+
705
+ def on_menu_config(self, event):
706
+ self.context("window open Configuration\n")
707
+
708
+ def on_menu_usb_reset(self, event):
709
+ try:
710
+ self.context("usb_reset\n")
711
+ except AttributeError:
712
+ pass
713
+
714
+ def on_menu_usb_release(self, event):
715
+ try:
716
+ self.context("usb_release\n")
717
+ except AttributeError:
718
+ pass
719
+
720
+ def on_menu_pause(self, event=None):
721
+ try:
722
+ self.context("pause\n")
723
+ except AttributeError:
724
+ pass
725
+
726
+ def on_menu_stop(self, event=None):
727
+ try:
728
+ self.context("estop\n")
729
+ except AttributeError:
730
+ pass
731
+
732
+ def on_menu_bufferview(self, event=None):
733
+ self.context("window open BufferView\n")
734
+
735
+ @staticmethod
736
+ def submenu():
737
+ return "Device-Control", "Controller"
738
+
739
+ @staticmethod
740
+ def helptext():
741
+ return _("Display the device controller window")