With Device Link API that I've implemented, it should be relatively easy to create a DeviceLink Client (or even Server) that is capable of sending or responding to requests. The API basically consist of two main interfaces:
- DeviceLinkPacket - which could be a request or a response and may carry a list of parameters
- DeviceLinkParameter - carrying the numerical id of the parameter and marks the parameter as either a getter or a setter parameter and may carry a value of the parameter's type
A central utility class (DeviceLink) provides methods for creating request and response packets of the API types as well as parse a string into a DeviceLinkParameterSet. The DeviceLinkClient allows to connect to a DeviceLinkServer, such as the Enemy Engaged CommServer. With the listener interface, functionality can be added to the client to react upon incoming packets.
For Enemy Engaged I defined an implementation of the DeviceLinkParameterSet (HelicopterType) and for the according DeviceLinkParameterDefinitions (EECHParameter) carrying the various parameters for the helicopters. Connecting to Enemy Engaged is rather simple and I implemented an example client (for my testing purposes).
try (DeviceLinkClient client =
new DeviceLinkClient(HelicopterType.Any)){
//eechhost is mapped to localhost in hosts file, port is 10000
client.connect("eechhost", 10000);
//output all packets to console
client.addPacketListener(new DeviceLinkPacketListener(){
public void onReceive(DeviceLinkPacket incoming) {
for(DeviceLinkParameter p : incoming.getParameters()){
System.out.println(p);
}
}
});
//poll the server periodically for values
while(...){
DeviceLinkPacket packet;
...
final List
//request all telemetry parameters
for(EECHParameter.Common c : EECHParameter.Common.values()){
params.add(DeviceLink.createParameter(c));
}
packet = DeviceLink.createRequest(params);
System.out.printf("\t --> (%s)\n", packet);
client.send(packet);
}
} catch (IOException e) {
...
}
To test and play with API you may download the source code from (Simulation Interconnect Bus) - its not packaged yet.
I'd be happy to know what you think of it.
No comments:
Post a Comment