Skip to content

Commit

Permalink
loading current values working #26
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed May 14, 2016
1 parent 9762df2 commit a6cf479
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,18 @@ public void flush(double seconds) {
IGCodeChannel thisLink = links.get(l);
run +=thisLink.getAxis()+""+((AbstractLink)thisLink).getTargetValue()+" ";
}
loadCurrent();
AbstractLink firstLink = (AbstractLink)links.get(links.keySet().toArray()[0]);
double distance = firstLink.getTargetValue()-firstLink.getCurrentPosition();
if(distance !=0){
int feedrate = (int)Math.abs((distance/(seconds/60)));//mm/min
run +=" F"+feedrate;
}

runLine(run);
}

public void loadCurrent(){
String m114 =runLine("M114");
String[] currentPosStr = m114.split("Count")[0].split(" ");// get the current position
//System.out.println("Fush with current = "+m114);
Expand All @@ -229,14 +241,6 @@ public void flush(double seconds) {
}
}
}
AbstractLink firstLink = (AbstractLink)links.get(links.keySet().toArray()[0]);
double distance = firstLink.getTargetValue()-firstLink.getCurrentPosition();
if(distance !=0){
int feedrate = (int)Math.abs((distance/(seconds/60)));//mm/min
run +=" F"+feedrate;
}

runLine(run);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,7 @@ public void cacheTargetValueDevice() {
}

private void loadCurrent(){
String m114 =device.runLine("M114");
String[] currentPosStr = m114.split("Count")[0].split(" ");// get the current position
//System.out.println("Fush with current = "+m114);
for(String s:currentPosStr){
if(s.contains(getAxis())){
String [] parts = s.split(":");
//System.out.println("Found axis = "+s);
setValue(Double.parseDouble(parts[1]));
return;
}
}
device.loadCurrent();
}

@Override
Expand Down

0 comments on commit a6cf479

Please sign in to comment.