Skip to content

Instantly share code, notes, and snippets.

@madhephaestus
Created December 15, 2014 00:04
Show Gist options
  • Save madhephaestus/9ae4321d17f8ba66fe29 to your computer and use it in GitHub Desktop.
Save madhephaestus/9ae4321d17f8ba66fe29 to your computer and use it in GitHub Desktop.
package com.neuronrobotics.test.nrdk;
import com.neuronrobotics.sdk.common.BowlerAbstractCommand;
import com.neuronrobotics.sdk.common.BowlerDatagram;
import com.neuronrobotics.sdk.common.BowlerMethod;
import com.neuronrobotics.sdk.common.ByteList;
import com.neuronrobotics.sdk.common.Log;
import com.neuronrobotics.sdk.pid.GenericPIDDevice;
import com.neuronrobotics.sdk.ui.ConnectionDialog;
public class ExtendGenericPID {
private ExtendGenericPID(){
Log.enableDebugPrint();
ExtendedPID pid = new ExtendedPID();
if (!ConnectionDialog.getBowlerDevice(pid)){
System.exit(1);
}
try {
System.out.println("Extended get position: "+pid.getExtendedValue(0));
pid.GetAllPIDPosition();
pid.GetPIDPosition(2);
pid.disconnect();
System.out.println("All OK!");
System.exit(0);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
pid.disconnect();
System.exit(1);
}
}
private class ExtendedPID extends GenericPIDDevice{
public int getExtendedValue(int group){
BowlerDatagram bd = send(new ExtendPIDCommand(group));
if(bd != null){
return ByteList.convertToInt(bd.getData().getBytes(1, 4),true);
}
return 0;
}
}
private class ExtendPIDCommand extends BowlerAbstractCommand{
public ExtendPIDCommand(int group) {
setOpCode("_pid");
setMethod(BowlerMethod.GET);
getCallingDataStorage().add(group);
}
}
/**
* @param args
*/
public static void main(String[] args) {
new ExtendGenericPID();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment