Skip to content

Commit 798a05c

Browse files
author
Gauthier
committed
20 février 2018
1 parent beac09f commit 798a05c

33 files changed

+20286
-14832
lines changed

cn5X.geany

+14-13
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,21 @@ long_line_behaviour=1
2828
long_line_column=72
2929

3030
[files]
31-
current_page=0
32-
FILE_NAME_0=0;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2Fcn5X.py;0;2
33-
FILE_NAME_1=0;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblAlarm.py;0;2
34-
FILE_NAME_2=7404;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblCommunicator.py;0;2
35-
FILE_NAME_3=14135;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblDecode.py;0;2
36-
FILE_NAME_4=0;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblError.py;0;2
37-
FILE_NAME_5=0;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblSettings.py;0;2
38-
FILE_NAME_6=0;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2Fmsgbox.py;0;2
39-
FILE_NAME_7=0;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgcodeQLineEdit.py;0;2
40-
FILE_NAME_8=2216;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FcnQPushButton.py;0;2
41-
FILE_NAME_9=0;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblCommunicator_serial.py;0;2
42-
FILE_NAME_10=0;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblCommunicator_timer.py;0;2
31+
current_page=2
32+
FILE_NAME_0=17035;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2Fcn5X.py;0;2
33+
FILE_NAME_1=1545;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblAlarm.py;0;2
34+
FILE_NAME_2=8508;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblCommunicator.py;0;2
35+
FILE_NAME_3=1545;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblDecode.py;0;2
36+
FILE_NAME_4=1543;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblError.py;0;2
37+
FILE_NAME_5=1543;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblSettings.py;0;2
38+
FILE_NAME_6=1545;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2Fmsgbox.py;0;2
39+
FILE_NAME_7=1545;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgcodeQLineEdit.py;0;2
40+
FILE_NAME_8=4309;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FcnQPushButton.py;0;2
41+
FILE_NAME_9=6780;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblCommunicator_serial.py;0;2
42+
FILE_NAME_10=1545;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FgrblCommunicator_timer.py;0;2
4343
FILE_NAME_11=0;Conf;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2Fcn5X.qrc;0;2
44-
FILE_NAME_12=16548;XML;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FmainWindow.ui;0;2
44+
FILE_NAME_12=402;XML;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FmainWindow.ui;0;2
45+
FILE_NAME_13=2050;Python;0;EUTF-8;0;1;0;%2Fhome%2Fgauthier%2Fsrc%2Fcn5X%2FcnQLabel.py;0;2
4546

4647
[VTE]
4748
last_dir=/home/gauthier

cn5X.py

+95-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
# !/usr/bin/env python
22
# -*- coding: UTF-8 -*-
3-
3+
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
4+
' '
5+
' Copyright 2018 Gauthier Brière (gauthier.briere "at" gmail.com) '
6+
' '
7+
' This file is part of cn5X '
8+
' '
9+
' cn5X is free software: you can redistribute it and/or modify it '
10+
' under the terms of the GNU General Public License as published by '
11+
' the Free Software Foundation, either version 3 of the License, or '
12+
' (at your option) any later version. '
13+
' '
14+
' cn5X is distributed in the hope that it will be useful, but '
15+
' WITHOUT ANY WARRANTY; without even the implied warranty of '
16+
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '
17+
' GNU General Public License for more details. '
18+
' '
19+
' You should have received a copy of the GNU General Public License '
20+
' along with this program. If not, see <http://www.gnu.org/licenses/>. '
21+
' '
22+
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
423
import sys, os, datetime
524
from PyQt5 import QtCore, QtGui, QtWidgets
6-
from PyQt5.QtCore import QThread, pyqtSignal, pyqtSlot
7-
from PyQt5.QtGui import QKeySequence
25+
from PyQt5.QtCore import QThread, pyqtSignal, pyqtSlot, QModelIndex, QItemSelectionModel
26+
from PyQt5.QtGui import QKeySequence, QStandardItemModel, QStandardItem
827
from PyQt5.QtSerialPort import QSerialPortInfo
928
import mainWindow
1029
from msgbox import *
@@ -29,6 +48,8 @@ def __init__(self, parent=None):
2948
self.logCn5X.document().setMaximumBlockCount(2000) # Limite la taille des logs à 2000 lignes
3049
self.logDebug.document().setMaximumBlockCount(2000) # Limite la taille des logs à 2000 lignes
3150

51+
self.gcodeFileContent = QStandardItemModel(self.ui.listGCodeFile)
52+
3253
self.timerDblClic = QtCore.QTimer()
3354
self.decode = grblDecode(self.ui)
3455

@@ -69,7 +90,7 @@ def __init__(self, parent=None):
6990
self.setEnableDisableGroupes()
7091

7192
"""---------- Connections des évennements traités ----------"""
72-
self.ui.btnUrgence.pressed.connect(self.on_arretUrgence) # Evenements du bouton d'arrêt d'urgence
93+
self.ui.btnUrgence.pressed.connect(self.on_arretUrgence) # Evenements du bouton d'arrêt d'urgence
7394
self.ui.cmbPort.currentIndexChanged.connect(self.on_cmbPort_changed) # un clic sur un élément de la liste appellera la méthode 'on_cmbPort_changed'
7495
self.ui.mnuAppOuvrir.triggered.connect(self.on_mnuAppOuvrir) # Connexions des routines du menu application
7596
self.ui.mnuAppQuitter.triggered.connect(self.on_mnuAppQuitter)
@@ -84,9 +105,18 @@ def __init__(self, parent=None):
84105
self.ui.btnStartTimer.clicked.connect(self.startTimer)
85106
self.ui.btnStopTimer.clicked.connect(self.stopTimer)
86107
self.ui.btnClearDebug.clicked.connect(self.clearDebug)
108+
self.ui.btnSpinM3.clicked.connect(self.on_btnSpinM3)
109+
self.ui.btnSpinM4.clicked.connect(self.on_btnSpinM4)
110+
self.ui.btnSpinM5.clicked.connect(self.on_btnSpinM5)
87111
self.ui.btnFloodM7.clicked.connect(self.on_btnFloodM7)
88112
self.ui.btnFloodM8.clicked.connect(self.on_btnFloodM8)
89113
self.ui.btnFloodM9.clicked.connect(self.on_btnFloodM9)
114+
self.ui.lblG54.clicked.connect(self.on_lblG5xClick)
115+
self.ui.lblG55.clicked.connect(self.on_lblG5xClick)
116+
self.ui.lblG56.clicked.connect(self.on_lblG5xClick)
117+
self.ui.lblG57.clicked.connect(self.on_lblG5xClick)
118+
self.ui.lblG58.clicked.connect(self.on_lblG5xClick)
119+
self.ui.lblG59.clicked.connect(self.on_lblG5xClick)
90120

91121
def populatePortList(self):
92122
''' Rempli la liste des ports série '''
@@ -143,6 +173,7 @@ def setEnableDisableGroupes(self):
143173
self.ui.grpJog.setEnabled(False)
144174
self.ui.frmGcodeInput.setEnabled(False)
145175
self.ui.frmBoutons.setEnabled(False)
176+
self.ui.frmCoordOffsets.setEnabled(False)
146177
elif self.__arretUrgence:
147178
# Connecté mais sous arrêt d'urgence : Tout est désactivé sauf l'arrêt d'urgence
148179
self.ui.btnUrgence.setIcon(QtGui.QIcon('images/btnUrgenceOff.svg'))
@@ -152,6 +183,7 @@ def setEnableDisableGroupes(self):
152183
self.ui.grpJog.setEnabled(False)
153184
self.ui.frmGcodeInput.setEnabled(False)
154185
self.ui.frmBoutons.setEnabled(False)
186+
self.ui.frmCoordOffsets.setEnabled(False)
155187
else:
156188
# Tout est en ordre, on active tout
157189
self.ui.btnUrgence.setIcon(QtGui.QIcon('images/btnUrgence.svg'))
@@ -161,10 +193,47 @@ def setEnableDisableGroupes(self):
161193
self.ui.grpJog.setEnabled(True)
162194
self.ui.frmGcodeInput.setEnabled(True)
163195
self.ui.frmBoutons.setEnabled(True)
196+
self.ui.frmCoordOffsets.setEnabled(True)
164197

165198
@pyqtSlot()
166199
def on_mnuAppOuvrir(self):
167-
pass
200+
# Affiche la boite de dialogue
201+
opt = QtWidgets.QFileDialog.Options()
202+
opt |= QtWidgets.QFileDialog.DontUseNativeDialog
203+
fileName = QtWidgets.QFileDialog.getOpenFileName(self, "Ouvrir un fichier GCode", "", "Fichier GCode (*.gcode *.ngc *.nc *.gc *.cnc)", options=opt)
204+
if fileName[0] != "":
205+
# Lecture du fichier
206+
self.logCn5X.append("Lecture du fichier : " + fileName[0])
207+
try:
208+
f = open(fileName[0],'r')
209+
lignes = f.readlines()
210+
f.close()
211+
# Envoi du contenu dans la liste
212+
self.gcodeFileContent.clear()
213+
for l in lignes:
214+
#print("["+l.strip()+"]")
215+
item = QStandardItem(l.strip())
216+
#item.setCheckable(True)
217+
self.gcodeFileContent.appendRow(item)
218+
self.ui.listGCodeFile.setModel(self.gcodeFileContent)
219+
# Sélectionne la premiere ligne du fichier dans la liste
220+
self.selectGCodeFileLine(0)
221+
# Sélectionne l'onglet du fichier
222+
self.ui.grpConsole.setCurrentIndex(1)
223+
except Exception as e:
224+
self.logCn5X.append("Erreur lecture du fichier : " + fileName[0])
225+
self.logCn5X.append(str(e))
226+
# Sélectionne l'onglet de la console pour que le message s'affiche
227+
self.ui.grpConsole.setCurrentIndex(2)
228+
229+
def selectGCodeFileLine(self, num: int):
230+
# Selectionne un élément de la liste du fichier GCode
231+
idx = self.gcodeFileContent.index(num, 0, QModelIndex())
232+
self.ui.listGCodeFile.selectionModel().setCurrentIndex(idx, QItemSelectionModel.SelectCurrent)
233+
234+
def getGCodeSelectedLine(self):
235+
indexes = self.ui.listGCodeFile.selectionModel().selectedIndexes()
236+
return self.gcodeFileContent.data(indexes[0])
168237

169238
@pyqtSlot()
170239
def on_mnuAppQuitter(self):
@@ -246,6 +315,22 @@ def action_btnConnect(self):
246315
def on_cmbPort_changed(self):
247316
self.setEnableDisableConnectControls()
248317

318+
def on_btnSpinM3(self):
319+
#self.logGrbl.append("M3")
320+
self.__grblCom.sendLine("M3", True)
321+
self.ui.btnSpinM4.setEnabled(False) # Interdit un changement de sens de rotation direct
322+
323+
def on_btnSpinM4(self):
324+
#self.logGrbl.append("M4")
325+
self.__grblCom.sendLine("M4", True)
326+
self.ui.btnSpinM3.setEnabled(False) # Interdit un changement de sens de rotation direct
327+
328+
def on_btnSpinM5(self):
329+
#self.logGrbl.append("M5")
330+
self.__grblCom.sendLine("M5", True)
331+
self.ui.btnSpinM3.setEnabled(True)
332+
self.ui.btnSpinM4.setEnabled(True)
333+
249334
def on_btnFloodM7(self):
250335
if self.decode.get_etatArrosage() != "M7" and self.decode.get_etatArrosage() != "M78":
251336
# Envoi "Real Time Command" plutôt que self.__grblCom.enQueue("M7")
@@ -264,6 +349,11 @@ def on_btnFloodM9(self):
264349
# Envoi "Real Time Command" plutôt que self.__grblCom.enQueue("M9")
265350
self.__grblCom.sendData(chr(0xA0))
266351

352+
@pyqtSlot(str, QtGui.QMouseEvent)
353+
def on_lblG5xClick(self, lblText, e):
354+
#self.logGrbl.append(lblText)
355+
self.__grblCom.sendLine(lblText, True)
356+
267357
def sendCmd(self):
268358
if self.ui.txtGCode.text() != "":
269359
self.logGrbl.append(self.ui.txtGCode.text().upper())

cn5X.qrc

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
<RCC>
22
<qresource prefix="cn5X">
3+
<file>images/btnPause.svg</file>
4+
<file>images/btnPause_down.svg</file>
5+
<file>images/btnPause_light.svg</file>
6+
<file>images/btnJogPlusB.svg</file>
7+
<file>images/btnJogMoinsB.svg</file>
8+
<file>images/btnJogMoinsA.svg</file>
9+
<file>images/btnJogPlusA.svg</file>
10+
<file>images/btnJogMoinsX.svg</file>
11+
<file>images/btnJogMoinsY.svg</file>
12+
<file>images/btnJogMoinsZ.svg</file>
13+
<file>images/btnJogPlusX.svg</file>
14+
<file>images/btnJogPlusY.svg</file>
15+
<file>images/btnJogPlusZ.svg</file>
316
<file>images/btnJogPlusX.svg</file>
417
<file>images/btnJogStop.svg</file>
518
<file>images/btnFloodM7_down.svg</file>

0 commit comments

Comments
 (0)