Skip to content

Commit

Permalink
creating a GcodePrismatic link #26
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed May 14, 2016
1 parent c0ab54d commit a20ab6b
Showing 1 changed file with 57 additions and 0 deletions.
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;
}

}

0 comments on commit a20ab6b

Please sign in to comment.