Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LibLaserCut
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Elektronikföreningen Admittansen
LibLaserCut
Commits
257425fc
Commit
257425fc
authored
11 years ago
by
Thomas Oster
Browse files
Options
Downloads
Patches
Plain Diff
Code cleanup
parent
57565d51
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/com/t_oster/liblasercut/drivers/IModelaMill.java
+69
-54
69 additions, 54 deletions
src/com/t_oster/liblasercut/drivers/IModelaMill.java
with
69 additions
and
54 deletions
src/com/t_oster/liblasercut/drivers/IModelaMill.java
+
69
−
54
View file @
257425fc
...
...
@@ -69,6 +69,7 @@ public class IModelaMill extends LaserCutter
private
static
String
PORT
=
"port"
;
private
static
String
BED_WIDTH
=
"bed width"
;
private
static
String
BED_HEIGHT
=
"bed height"
;
private
static
String
HOME_ON_END
=
"move home after job"
;
private
Map
<
String
,
Object
>
properties
=
new
LinkedHashMap
<
String
,
Object
>();
public
IModelaMill
()
...
...
@@ -77,6 +78,7 @@ public class IModelaMill extends LaserCutter
properties
.
put
(
BED_HEIGHT
,
(
Double
)
55
d
);
properties
.
put
(
HOSTNAME
,
"file:///dev/usb/lp0"
);
properties
.
put
(
PORT
,
(
Integer
)
5000
);
properties
.
put
(
HOME_ON_END
,
(
Boolean
)
true
);
}
private
void
writeInitializationCode
(
PrintStream
out
)
...
...
@@ -92,22 +94,77 @@ public class IModelaMill extends LaserCutter
{
out
.
println
(
"M05"
);
//stop spindle
out
.
println
(
"G0 Z0"
);
//head up
out
.
println
(
"G0 X0 Y0"
);
//go back to home
if
((
Boolean
)
properties
.
get
(
HOME_ON_END
))
{
out
.
println
(
"G0 X0 Y0"
);
//go back to home
}
out
.
println
(
"M02"
);
//END_OF_PROGRAM
out
.
println
(
"%"
);
}
//all depth values are positive, 0 is top
private
double
movedepth
=
0
;
private
double
linedepth
=
0
;
private
double
headdepth
=
0
;
private
double
spindleSpeed
=
0
;
private
double
feedRate
=
0
;
private
int
tool
=
0
;
//is applied to next G command
private
String
parameters
=
""
;
private
void
moveHead
(
PrintStream
out
,
double
depth
)
{
if
(
headdepth
>
depth
)
{
//move up fast
out
.
println
(
String
.
format
(
Locale
.
ENGLISH
,
"G00 Z%f%s\n"
,
-
depth
,
parameters
));
parameters
=
""
;
}
else
if
(
headdepth
<
depth
)
{
//move down slow
out
.
println
(
String
.
format
(
Locale
.
ENGLISH
,
"G01 Z%f%s\n"
,
-
depth
,
parameters
));
parameters
=
""
;
}
headdepth
=
depth
;
}
private
void
move
(
PrintStream
out
,
double
x
,
double
y
)
{
moveHead
(
out
,
movedepth
);
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"G00 X%f Y%f%s\n"
,
x
,
y
,
parameters
));
parameters
=
""
;
}
private
void
line
(
PrintStream
out
,
double
x
,
double
y
)
{
moveHead
(
out
,
linedepth
);
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"G01 X%f Y%f%s\n"
,
x
,
y
,
parameters
));
parameters
=
""
;
}
private
void
applyProperty
(
PrintStream
out
,
IModelaProperty
pr
)
{
linedepth
=
pr
.
getDepth
();
if
(
pr
.
getSpindleSpeed
()
!=
spindleSpeed
)
{
spindleSpeed
=
pr
.
getSpindleSpeed
();
parameters
+=
String
.
format
(
Locale
.
ENGLISH
,
" S%d\n"
,
spindleSpeed
);
}
if
(
pr
.
getFeedRate
()
!=
feedRate
)
{
feedRate
=
pr
.
getFeedRate
();
parameters
+=
String
.
format
(
Locale
.
ENGLISH
,
" F%f\n"
,
feedRate
);
}
if
(
pr
.
getTool
()
!=
tool
)
{
tool
=
pr
.
getTool
();
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"M06T0\n"
));
//return current tool
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"M06T%d\n"
,
tool
));
}
}
private
void
writeVectorCode
(
VectorPart
p
,
PrintStream
out
)
{
double
dpi
=
p
.
getDPI
();
boolean
headDown
=
false
;
double
olddepth
=
0
;
double
depth
=
0
;
int
spindleSpeed
=
-
1
;
double
feedRate
=
-
1
;
int
tool
=
-
1
;
boolean
feedRateWasUpdated
=
false
;
for
(
VectorCommand
c
:
p
.
getCommandList
())
{
switch
(
c
.
getType
())
...
...
@@ -116,66 +173,24 @@ public class IModelaMill extends LaserCutter
{
double
x
=
Util
.
px2mm
(
c
.
getX
(),
dpi
);
double
y
=
getBedHeight
()
-
Util
.
px2mm
(
c
.
getY
(),
dpi
);
//mill origin is bottom left, so we have to mirror y coordinates
if
(
headDown
)
{
out
.
println
(
"G00 Z0"
);
headDown
=
false
;
}
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"G00 X%f Y%f\n"
,
x
,
y
));
move
(
out
,
x
,
y
);
break
;
}
case
LINETO:
{
double
x
=
Util
.
px2mm
(
c
.
getX
(),
dpi
);
double
y
=
getBedHeight
()
-
Util
.
px2mm
(
c
.
getY
(),
dpi
);
//mill origin is bottom left, so we have to mirror y coordinates
if
(!
headDown
||
depth
!=
olddepth
)
{
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"G01 Z%f\n"
,
-
depth
));
headDown
=
true
;
olddepth
=
depth
;
}
//update feedrate if needed
if
(
feedRateWasUpdated
)
{
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"G01 X%f Y%f F%f\n"
,
x
,
y
,
feedRate
));
feedRateWasUpdated
=
false
;
}
else
{
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"G01 X%f Y%f\n"
,
x
,
y
));
}
line
(
out
,
x
,
y
);
break
;
}
case
SETPROPERTY:
{
IModelaProperty
pr
=
(
IModelaProperty
)
c
.
getProperty
();
depth
=
pr
.
getDepth
();
if
(
pr
.
getSpindleSpeed
()
!=
spindleSpeed
)
{
spindleSpeed
=
pr
.
getSpindleSpeed
();
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"S%d\n"
,
spindleSpeed
));
}
if
(
pr
.
getFeedRate
()
!=
feedRate
)
{
feedRate
=
pr
.
getFeedRate
();
//F goes with the G commands and is not a command on its own.
//out.print(String.format(Locale.ENGLISH, "F%f\n", feedRate));
feedRateWasUpdated
=
true
;
}
if
(
pr
.
getTool
()
!=
tool
)
{
tool
=
pr
.
getTool
();
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"M06T0\n"
));
//return current tool
out
.
print
(
String
.
format
(
Locale
.
ENGLISH
,
"M06T%d\n"
,
tool
));
}
applyProperty
(
out
,
pr
);
break
;
}
}
}
out
.
println
(
"M05"
);
out
.
println
(
"G0Z0.0"
);
}
@Override
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment