use of com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice in project java-bowler by NeuronRobotics.
the class LinkFactory method getLinkLocal.
private AbstractLink getLinkLocal(LinkConfiguration c) {
if (dyio == null)
dyio = (DyIO) DeviceManager.getSpecificDevice(DyIO.class, c.getDeviceScriptingName());
if (pid == null)
pid = (IPidControlNamespace) DeviceManager.getSpecificDevice(IPidControlNamespace.class, c.getDeviceScriptingName());
AbstractLink tmp = null;
Log.info("Loading link: " + c.getName() + " type = " + c.getType() + " device= " + c.getDeviceScriptingName());
switch(c.getType()) {
case ANALOG_PRISMATIC:
if (dyio != null) {
tmp = new AnalogPrismaticLink(new AnalogInputChannel(dyio.getChannel(c.getHardwareIndex())), c);
tmp.setUseLimits(false);
}
break;
case ANALOG_ROTORY:
if (dyio != null) {
tmp = new AnalogRotoryLink(new AnalogInputChannel(dyio.getChannel(c.getHardwareIndex())), c);
tmp.setUseLimits(false);
}
break;
case PID_TOOL:
case PID:
if (pid != null) {
tmp = new PidRotoryLink(pid.getPIDChannel(c.getHardwareIndex()), c);
}
break;
case PID_PRISMATIC:
if (pid != null) {
tmp = new PidPrismaticLink(pid.getPIDChannel(c.getHardwareIndex()), c);
}
break;
case SERVO_PRISMATIC:
if (dyio != null) {
tmp = new ServoPrismaticLink(new ServoChannel(dyio.getChannel(c.getHardwareIndex())), c);
}
break;
case SERVO_ROTORY:
case SERVO_TOOL:
if (dyio != null) {
tmp = new ServoRotoryLink(new ServoChannel(dyio.getChannel(c.getHardwareIndex())), c);
}
break;
case STEPPER_PRISMATIC:
if (dyio != null) {
tmp = new StepperPrismaticLink(new CounterOutputChannel(dyio.getChannel(c.getHardwareIndex())), c);
}
break;
case STEPPER_TOOL:
case STEPPER_ROTORY:
if (dyio != null) {
tmp = new StepperRotoryLink(new CounterOutputChannel(dyio.getChannel(c.getHardwareIndex())), c);
}
break;
case DUMMY:
case VIRTUAL:
String myVirtualDevName = c.getDeviceScriptingName();
virtual = (VirtualGenericPIDDevice) DeviceManager.getSpecificDevice(VirtualGenericPIDDevice.class, myVirtualDevName);
if (virtual == null) {
virtual = new VirtualGenericPIDDevice();
DeviceManager.addConnection(virtual, myVirtualDevName);
}
tmp = new PidRotoryLink(virtual.getPIDChannel(c.getHardwareIndex()), c);
break;
}
if (tmp == null) {
String myVirtualDevName = "virtual_" + c.getDeviceScriptingName();
virtual = (VirtualGenericPIDDevice) DeviceManager.getSpecificDevice(VirtualGenericPIDDevice.class, myVirtualDevName);
if (virtual == null) {
virtual = new VirtualGenericPIDDevice();
DeviceManager.addConnection(virtual, myVirtualDevName);
}
if (!c.getType().isPrismatic()) {
tmp = new PidRotoryLink(virtual.getPIDChannel(c.getHardwareIndex()), c);
} else {
tmp = new PidPrismaticLink(virtual.getPIDChannel(c.getHardwareIndex()), c);
}
}
tmp.setLinkConfiguration(c);
links.add(tmp);
if (!getLinkConfigurations().contains(c))
getLinkConfigurations().add(c);
return tmp;
}
use of com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice in project java-bowler by NeuronRobotics.
the class VirtualPuckBot method init.
private void init(VirtualWorld w, int botStartX, int botStartY) {
world = w;
world.addRobot(this, botStartX, botStartY);
controller = new VirtualGenericPIDDevice(getMaxTicksPerSeconds());
controller.addPIDEventListener(new IPIDEventListener() {
public void onPIDReset(int group, int currentValue) {
}
public void onPIDLimitEvent(PIDLimitEvent e) {
}
public void onPIDEvent(PIDEvent e) {
world.updateMap();
}
});
setPIDChanels(controller.getPIDChannel(0), controller.getPIDChannel(1));
}
use of com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice in project java-bowler by NeuronRobotics.
the class VirtualAckermanBot method init.
private void init(VirtualWorld w, int botStartX, int botStartY) {
world = w;
world.addRobot(this, botStartX, botStartY);
controller = new VirtualGenericPIDDevice(getMaxTicksPerSecond());
controller.addPIDEventListener(new IPIDEventListener() {
public void onPIDReset(int group, int currentValue) {
}
public void onPIDLimitEvent(PIDLimitEvent e) {
}
public void onPIDEvent(PIDEvent e) {
world.updateMap();
}
});
setPIDChanel(controller.getPIDChannel(0));
}
use of com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice in project java-bowler by NeuronRobotics.
the class PidDeviceServer method main.
public static void main(String[] args) {
Log.enableInfoPrint();
PidDeviceServer srv = new PidDeviceServer(new MACAddress(), new VirtualGenericPIDDevice(10000));
}
Aggregations