-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathExtendGenericPID.java
More file actions
86 lines (78 loc) · 1.94 KB
/
ExtendGenericPID.java
File metadata and controls
86 lines (78 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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;
// Auto-generated Javadoc
/**
* The Class ExtendGenericPID.
*/
public class ExtendGenericPID {
/**
* Instantiates a new extend generic pid.
*/
private ExtendGenericPID(){
Log.enableDebugPrint();
ExtendedPID pid = new ExtendedPID();
if (!ConnectionDialog.getBowlerDevice(pid)){
System.exit(1);
}
try {
com.neuronrobotics.sdk.common.Log.error("Extended get position: "+pid.getExtendedValue(0));
pid.GetAllPIDPosition();
pid.GetPIDPosition(2);
pid.disconnect();
com.neuronrobotics.sdk.common.Log.error("All OK!");
System.exit(0);
} catch (Exception e) {
// Auto-generated catch block
e.printStackTrace();
pid.disconnect();
System.exit(1);
}
}
/**
* The Class ExtendedPID.
*/
private class ExtendedPID extends GenericPIDDevice{
/**
* Gets the extended value.
*
* @param group the group
* @return the extended value
*/
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;
}
}
/**
* The Class ExtendPIDCommand.
*/
private class ExtendPIDCommand extends BowlerAbstractCommand{
/**
* Instantiates a new extend pid command.
*
* @param group the group
*/
public ExtendPIDCommand(int group) {
setOpCode("_pid");
setMethod(BowlerMethod.GET);
getCallingDataStorage().add(group);
}
}
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
new ExtendGenericPID();
}
}