Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
Printrun
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
Printrun
Commits
3232cad5
Commit
3232cad5
authored
Oct 14, 2014
by
Guillaume Seguin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Truly fix #584, refactor a bit command parsing
Use precmd() method instead of adding our own layer of preprocessing
parent
40742d31
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
14 deletions
+15
-14
pronsole.py
printrun/pronsole.py
+12
-5
pronterface.py
printrun/pronterface.py
+3
-9
No files found.
printrun/pronsole.py
View file @
3232cad5
...
...
@@ -62,6 +62,7 @@ tempreading_exp = re.compile("(^T:| T:)")
REPORT_NONE
=
0
REPORT_POS
=
1
REPORT_TEMP
=
2
REPORT_MANUAL
=
4
class
Status
(
object
):
...
...
@@ -327,8 +328,12 @@ class pronsole(cmd.Cmd):
def
help_gcodes
(
self
):
self
.
log
(
"Gcodes are passed through to the printer as they are"
)
def
parseusercmd
(
self
,
line
):
pass
def
precmd
(
self
,
line
):
if
line
.
upper
()
.
startswith
(
"M114"
):
self
.
userm114
+=
1
elif
line
.
upper
()
.
startswith
(
"M105"
):
self
.
userm105
+=
1
return
line
def
help_shell
(
self
):
self
.
log
(
"Executes a python command. Example:"
)
...
...
@@ -439,7 +444,7 @@ class pronsole(cmd.Cmd):
return
ws
+
ls
[
1
:]
+
"
\n
"
# python mode
else
:
ls
=
ls
.
replace
(
'"'
,
'
\\
"'
)
# need to escape double quotes
ret
=
ws
+
'self.p
arseuser
cmd("'
+
ls
+
'".format(*arg))
\n
'
# parametric command mode
ret
=
ws
+
'self.p
re
cmd("'
+
ls
+
'".format(*arg))
\n
'
# parametric command mode
return
ret
+
ws
+
'self.onecmd("'
+
ls
+
'".format(*arg))
\n
'
def
compile_macro
(
self
,
macro_name
,
macro_def
):
...
...
@@ -1196,24 +1201,26 @@ class pronsole(cmd.Cmd):
isreport
=
REPORT_POS
if
self
.
userm114
>
0
:
self
.
userm114
-=
1
isreport
|=
REPORT_MANUAL
if
"ok T:"
in
l
or
tempreading_exp
.
findall
(
l
):
self
.
tempreadings
=
l
isreport
=
REPORT_TEMP
if
self
.
userm105
>
0
:
self
.
userm105
-=
1
isreport
|=
REPORT_MANUAL
else
:
self
.
m105_waitcycles
=
0
return
isreport
def
recvcb
(
self
,
l
):
report_type
=
self
.
recvcb_report
(
l
)
if
report_type
==
REPORT_TEMP
:
if
report_type
&
REPORT_TEMP
:
self
.
status
.
update_tempreading
(
l
)
tstring
=
l
.
rstrip
()
for
listener
in
self
.
recvlisteners
:
listener
(
l
)
if
tstring
!=
"ok"
and
not
self
.
sdlisting
\
and
not
self
.
monitoring
and
report_type
==
REPORT_NONE
:
and
not
self
.
monitoring
and
(
report_type
==
REPORT_NONE
or
report_type
&
REPORT_MANUAL
)
:
if
tstring
[:
5
]
==
"echo:"
:
tstring
=
tstring
[
5
:]
.
lstrip
()
if
self
.
silent
is
False
:
print
"
\r
"
+
tstring
.
ljust
(
15
)
...
...
printrun/pronterface.py
View file @
3232cad5
...
...
@@ -655,19 +655,13 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def
set_verbose_communications
(
self
,
e
):
self
.
p
.
loud
=
e
.
IsChecked
()
def
parseusercmd
(
self
,
line
):
if
line
.
upper
()
.
startswith
(
"M114"
):
self
.
userm114
+=
1
elif
line
.
upper
()
.
startswith
(
"M105"
):
self
.
userm105
+=
1
def
sendline
(
self
,
e
):
command
=
self
.
commandbox
.
GetValue
()
if
not
len
(
command
):
return
wx
.
CallAfter
(
self
.
addtexttolog
,
">>> "
+
command
+
"
\n
"
)
self
.
parseuser
cmd
(
str
(
command
))
self
.
onecmd
(
str
(
command
)
)
line
=
self
.
pre
cmd
(
str
(
command
))
self
.
onecmd
(
line
)
self
.
commandbox
.
SetSelection
(
0
,
len
(
command
))
self
.
commandbox
.
history
.
append
(
command
)
self
.
commandbox
.
histindex
=
len
(
self
.
commandbox
.
history
)
...
...
@@ -2005,7 +1999,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
return
self
.
editbutton
(
e
)
self
.
cur_button
=
e
.
GetEventObject
()
.
custombutton
command
=
e
.
GetEventObject
()
.
properties
.
command
self
.
parseuser
cmd
(
command
)
command
=
self
.
pre
cmd
(
command
)
self
.
onecmd
(
command
)
self
.
cur_button
=
None
except
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment