-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0ab54d
commit a20ab6b
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
src/main/java/com/neuronrobotics/sdk/addons/kinematics/gcodebridge/GcodePrismatic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.neuronrobotics.sdk.addons.kinematics.gcodebridge; | ||
|
||
import com.neuronrobotics.sdk.addons.kinematics.AbstractPrismaticLink; | ||
import com.neuronrobotics.sdk.addons.kinematics.LinkConfiguration; | ||
|
||
public class GcodePrismatic extends AbstractPrismaticLink { | ||
private GcodeDevice device; | ||
private String axis = ""; | ||
double value =0; | ||
public GcodePrismatic(LinkConfiguration conf, GcodeDevice device, String linkAxis) { | ||
super(conf); | ||
// TODO Auto-generated constructor stub | ||
this.device = device; | ||
axis=linkAxis; | ||
} | ||
|
||
@Override | ||
public void cacheTargetValueDevice() { | ||
//value | ||
} | ||
|
||
@Override | ||
public void flushDevice(double time) { | ||
String[] currentPosStr = device.runLine("M114").split(" ");// get the current position | ||
for(String s:currentPosStr){ | ||
if(s.contains(getAxis())){ | ||
String [] parts = s.split(":"); | ||
value = Double.parseDouble(parts[1]); | ||
} | ||
} | ||
double distance = getTargetValue()-value; | ||
if(distance !=0){ | ||
int feedrate = (int)(distance/(time/60));//mm/min | ||
device.runLine("G1 "+getAxis()+""+getTargetValue()+" F"+feedrate); | ||
} | ||
} | ||
|
||
@Override | ||
public void flushAllDevice(double time) { | ||
device.flush(time); | ||
} | ||
|
||
@Override | ||
public double getCurrentPosition() { | ||
// TODO Auto-generated method stub | ||
return value; | ||
} | ||
|
||
public String getAxis() { | ||
return axis; | ||
} | ||
|
||
public void setAxis(String axis) { | ||
this.axis = axis; | ||
} | ||
|
||
} |