Skip to content

Commit

Permalink
allowing for engineering units of links to be doudles #26
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed May 14, 2016
1 parent a6cf479 commit ef81002
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public double toEngineeringUnits(double value){
* @param euValue the eu value
* @return the int
*/
public int toLinkUnits(double euValue){
return ((int) (euValue/getScale()))+getHome();
public double toLinkUnits(double euValue){
return (euValue/getScale())+getHome();
}

/**
Expand Down Expand Up @@ -306,7 +306,7 @@ public boolean isMinEngineeringUnits() {
*
* @param val the new position
*/
protected void setPosition(int val) {
protected void setPosition(double val) {
//if(getTargetValue() != val){
setTargetValue(val);
//}
Expand Down Expand Up @@ -439,26 +439,26 @@ public double getScale() {
*
* @return the upper limit
*/
public int getUpperLimit() {
return (int) conf.getUpperLimit();
public double getUpperLimit() {
return (double) conf.getUpperLimit();
}

/**
* Gets the lower limit.
*
* @return the lower limit
*/
public int getLowerLimit() {
return (int) conf.getLowerLimit();
public double getLowerLimit() {
return conf.getLowerLimit();
}

/**
* Gets the home.
*
* @return the home
*/
public int getHome() {
return (int) conf.getStaticOffset();
public double getHome() {
return conf.getStaticOffset();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,12 @@ private AbstractLink getLinkLocal(LinkConfiguration c){
case GCODE_HEATER_TOOL:
break;
case GCODE_STEPPER_PRISMATIC:
case GCODE_STEPPER_ROTORY:
case GCODE_STEPPER_TOOL:
if(getGCODE(c)!=null){
tmp = getGCODE(c).getLink(c);
}
break;
case GCODE_STEPPER_ROTORY:
break;
case GCODE_STEPPER_TOOL:
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public GcodeDevice(NRSerialPort serial){

public AbstractLink getLink(LinkConfiguration axis){
String gcodeAxis = "";
GcodePrismatic tmp=null;
AbstractLink tmp=null;
switch(axis.getType()){
case GCODE_STEPPER_PRISMATIC:
case GCODE_STEPPER_ROTORY:
Expand All @@ -65,21 +65,26 @@ public AbstractLink getLink(LinkConfiguration axis){
break;
}
switch(axis.getType()){
case GCODE_HEATER_TOOL:
break;
case GCODE_STEPPER_PRISMATIC:
if(getGCODE(axis)!=null){
tmp = new GcodePrismatic(axis,getGCODE(axis),gcodeAxis);
}
break;
case GCODE_STEPPER_ROTORY:
if(getGCODE(axis)!=null){
tmp = new GcodeRotory(axis,getGCODE(axis),gcodeAxis);
}
break;
case GCODE_STEPPER_TOOL:
default:
if(getGCODE(axis)!=null){
tmp = new GcodeRotory(axis,getGCODE(axis),gcodeAxis);
}
break;
default:
break;
}
if(tmp!=null){
links.put(axis,tmp);
links.put(axis,(IGCodeChannel) tmp);
}
return tmp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void onPIDLimitEvent(PIDLimitEvent e) {
new Object[]{
new Byte((byte) e.getGroup()),
new Byte( e.getLimitType().getValue()),
new Integer(e.getValue()),
new Integer((int) e.getValue()),
new Integer((int) e.getTimeStamp()),
},
new BowlerDataType[]{
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/neuronrobotics/sdk/pid/PIDLimitEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class PIDLimitEvent {
private int channel;

/** The ticks. */
private int ticks;
private double ticks;

/** The time stamp. */
private long timeStamp;
Expand All @@ -29,7 +29,7 @@ public class PIDLimitEvent {
* @param type the type
* @param time the time
*/
public PIDLimitEvent(int chan,int tick,PIDLimitEventType type,long time){
public PIDLimitEvent(int chan,double tick,PIDLimitEventType type,long time){
setGroup(chan);
setLimitType(type);
setValue(tick);
Expand Down Expand Up @@ -75,7 +75,7 @@ public int getGroup() {
*
* @param ticks the new value
*/
public void setValue(int ticks) {
public void setValue(double ticks) {
this.ticks = ticks;
}

Expand All @@ -84,7 +84,7 @@ public void setValue(int ticks) {
*
* @return the value
*/
public int getValue() {
public double getValue() {
return ticks;
}

Expand Down
48 changes: 24 additions & 24 deletions test/java/src/junit/test/neuronrobotics/utilities/GCODETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void linkFactoryPrismatic(){
confp.setScale(1);
AbstractLink link = lf.getLink(confp);
assertEquals(link.getClass(), GcodePrismatic.class);// checks to see a real device was created
link.setTargetEngineeringUnits(100);
link.setTargetEngineeringUnits(100.5);
link.flush(2);//take 2 seconds to flush

LinkConfiguration confp2 = new LinkConfiguration();
Expand All @@ -89,7 +89,7 @@ public void linkFactoryPrismatic(){
confp2.setScale(1);
AbstractLink link2 = lf.getLink(confp2);
assertEquals(link2.getClass(), GcodePrismatic.class);// checks to see a real device was created
link2.setTargetEngineeringUnits(100);
link2.setTargetEngineeringUnits(100.5);
link2.flush(2);//take 2 seconds to flush

link2.setTargetEngineeringUnits(0);
Expand All @@ -103,28 +103,28 @@ public void linkFactoryPrismatic(){
@Test
public void G1() {

// if (hasPort) {
// GcodeDevice device = GCODECONTOLLER.cast(DeviceManager.getSpecificDevice(GCODECONTOLLER, GCODE));
// String response = device.runLine("G90");// Absolute mode
// if (response.length() > 0)
// System.out.println("Gcode line run: " + response);
// else {
// fail("No response");
// }
// response = device.runLine("G1 X100 Y100 Z0 E10 F6000");
// if (response.length() > 0)
// System.out.println("Gcode line run: " + response);
// else {
// fail("No response");
// }
// response = device.runLine("G1 X0 Y0 Z0 E0 F3000");
// if (response.length() > 0)
// System.out.println("Gcode line run: " + response);
// else {
// fail("No response");
// }
//
// }
if (hasPort) {
GcodeDevice device = GCODECONTOLLER.cast(DeviceManager.getSpecificDevice(GCODECONTOLLER, GCODE));
String response = device.runLine("G90");// Absolute mode
if (response.length() > 0)
System.out.println("Gcode line run: " + response);
else {
fail("No response");
}
response = device.runLine("G1 X100.2 Y100.2 Z0 E10 F6000");
if (response.length() > 0)
System.out.println("Gcode line run: " + response);
else {
fail("No response");
}
response = device.runLine("G1 X0 Y0 Z0 E0 F3000");
if (response.length() > 0)
System.out.println("Gcode line run: " + response);
else {
fail("No response");
}

}
}

}

0 comments on commit ef81002

Please sign in to comment.