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
10c3c999
Commit
10c3c999
authored
12 years ago
by
Thomas Oster
Browse files
Options
Downloads
Patches
Plain Diff
iModela: Add file and TCP support
parent
c04f0d89
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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
+47
-12
47 additions, 12 deletions
src/com/t_oster/liblasercut/drivers/IModelaMill.java
with
47 additions
and
12 deletions
src/com/t_oster/liblasercut/drivers/IModelaMill.java
+
47
−
12
View file @
10c3c999
...
@@ -29,12 +29,16 @@ import com.t_oster.liblasercut.VectorCommand;
...
@@ -29,12 +29,16 @@ import com.t_oster.liblasercut.VectorCommand;
import
com.t_oster.liblasercut.VectorPart
;
import
com.t_oster.liblasercut.VectorPart
;
import
com.t_oster.liblasercut.platform.Util
;
import
com.t_oster.liblasercut.platform.Util
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.PrintStream
;
import
java.io.PrintStream
;
import
java.net.InetSocketAddress
;
import
java.net.Socket
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
java.util.logging.Level
;
import
java.util.logging.Logger
;
/**
/**
*
*
...
@@ -43,6 +47,12 @@ import java.util.logging.Logger;
...
@@ -43,6 +47,12 @@ import java.util.logging.Logger;
public
class
IModelaMill
extends
LaserCutter
public
class
IModelaMill
extends
LaserCutter
{
{
private
static
String
HOSTNAME
=
"Hostname/IP"
;
private
static
String
PORT
=
"port"
;
private
String
hostname
=
"localhost"
;
private
int
port
=
5000
;
private
void
writeInitializationCode
(
PrintStream
out
)
private
void
writeInitializationCode
(
PrintStream
out
)
{
{
out
.
println
(
"%"
);
out
.
println
(
"%"
);
...
@@ -102,8 +112,6 @@ public class IModelaMill extends LaserCutter
...
@@ -102,8 +112,6 @@ public class IModelaMill extends LaserCutter
return
new
IModelaProperty
();
return
new
IModelaProperty
();
}
}
@Override
@Override
public
void
sendJob
(
LaserJob
job
,
ProgressListener
pl
,
List
<
String
>
warnings
)
throws
IllegalJobException
,
Exception
public
void
sendJob
(
LaserJob
job
,
ProgressListener
pl
,
List
<
String
>
warnings
)
throws
IllegalJobException
,
Exception
{
{
...
@@ -127,10 +135,9 @@ public class IModelaMill extends LaserCutter
...
@@ -127,10 +135,9 @@ public class IModelaMill extends LaserCutter
writeFinalizationCode
(
out
);
writeFinalizationCode
(
out
);
pl
.
progressChanged
(
this
,
50
);
pl
.
progressChanged
(
this
,
50
);
pl
.
taskChanged
(
this
,
"sending..."
);
pl
.
taskChanged
(
this
,
"sending..."
);
sendGCode
(
result
.
toByteArray
());
sendGCode
(
result
.
toByteArray
()
,
pl
,
warnings
);
pl
.
progressChanged
(
this
,
100
);
pl
.
progressChanged
(
this
,
100
);
pl
.
taskChanged
(
this
,
"done"
);
pl
.
taskChanged
(
this
,
"done"
);
warnings
.
add
(
"WARNING: THE iModela driver only outputs to command line"
);
}
}
@Override
@Override
...
@@ -171,29 +178,57 @@ public class IModelaMill extends LaserCutter
...
@@ -171,29 +178,57 @@ public class IModelaMill extends LaserCutter
@Override
@Override
public
String
[]
getPropertyKeys
()
public
String
[]
getPropertyKeys
()
{
{
return
new
String
[
0
];
return
new
String
[]
{
HOSTNAME
,
PORT
}
;
}
}
@Override
@Override
public
void
setProperty
(
String
key
,
Object
value
)
public
void
setProperty
(
String
key
,
Object
value
)
{
{
if
(
HOSTNAME
.
equals
(
key
))
{
hostname
=
(
String
)
value
;
}
else
if
(
PORT
.
equals
(
key
))
{
port
=
(
Integer
)
value
;
}
}
}
@Override
@Override
public
Object
getProperty
(
String
key
)
public
Object
getProperty
(
String
key
)
{
{
if
(
HOSTNAME
.
equals
(
key
))
{
return
hostname
;
}
else
if
(
PORT
.
equals
(
key
))
{
return
(
Integer
)
port
;
}
return
null
;
return
null
;
}
}
private
void
sendGCode
(
byte
[]
toByteArray
)
private
void
sendGCode
(
byte
[]
gcode
,
ProgressListener
pl
,
List
<
String
>
warnings
)
throws
IOException
,
URISyntaxException
{
{
try
pl
.
taskChanged
(
this
,
"connecting..."
);
if
(
"stdout"
.
equals
(
hostname
))
{
pl
.
taskChanged
(
this
,
"sending..."
);
System
.
out
.
write
(
gcode
);
}
else
if
(
hostname
.
startsWith
(
"file://"
))
{
{
System
.
out
.
write
(
toByteArray
);
PrintStream
w
=
new
PrintStream
(
new
FileOutputStream
(
new
File
(
new
URI
(
hostname
))));
pl
.
taskChanged
(
this
,
"sending..."
);
w
.
write
(
gcode
);
}
}
catch
(
IOException
ex
)
else
{
{
Logger
.
getLogger
(
IModelaMill
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
Socket
s
=
new
Socket
();
s
.
connect
(
new
InetSocketAddress
(
hostname
,
port
),
3000
);
pl
.
taskChanged
(
this
,
"sending..."
);
s
.
getOutputStream
().
write
(
gcode
);
s
.
close
();
}
}
}
}
...
...
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