Search in sources :

Example 1 with CounterOutputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel in project java-bowler by NeuronRobotics.

the class StepperPrismaticLink method setChannel.

public void setChannel(CounterOutputChannel c) {
    channel = c;
    channel.getChannel().setCachedMode(true);
    channel.addCounterOutputListener(new ICounterOutputListener() {

        @Override
        public void onCounterValueChange(CounterOutputChannel source, int value) {
            if (source == channel) {
                fireLinkListener(value);
            }
        }
    });
}
Also used : ICounterOutputListener(com.neuronrobotics.sdk.dyio.peripherals.ICounterOutputListener) CounterOutputChannel(com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel)

Example 2 with CounterOutputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel 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;
}
Also used : CounterOutputChannel(com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel) IPidControlNamespace(com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace) AnalogInputChannel(com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel) ServoChannel(com.neuronrobotics.sdk.dyio.peripherals.ServoChannel) DyIO(com.neuronrobotics.sdk.dyio.DyIO) VirtualGenericPIDDevice(com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice)

Example 3 with CounterOutputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel in project java-bowler by NeuronRobotics.

the class StepperRotoryLink method setChannel.

public void setChannel(CounterOutputChannel c) {
    channel = c;
    channel.getChannel().setCachedMode(true);
    channel.addCounterOutputListener(new ICounterOutputListener() {

        @Override
        public void onCounterValueChange(CounterOutputChannel source, int value) {
            if (source == channel) {
                fireLinkListener(value);
            }
        }
    });
}
Also used : ICounterOutputListener(com.neuronrobotics.sdk.dyio.peripherals.ICounterOutputListener) CounterOutputChannel(com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel)

Example 4 with CounterOutputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel in project java-bowler by NeuronRobotics.

the class CounterOutputTimedTest method main.

/**
 * @param args
 */
public static void main(String[] args) {
    DyIO dyio = new DyIO();
    if (!ConnectionDialog.getBowlerDevice(dyio)) {
        System.exit(1);
    }
    // Instantiate a new counter input
    CounterOutputChannel stepper = new CounterOutputChannel(dyio.getChannel(21));
    // Move 5 steps
    stepper.SetPosition(10000, 30);
    ThreadUtil.wait(30000);
    stepper.SetPosition(0, 0);
    dyio.disconnect();
    System.exit(0);
}
Also used : CounterOutputChannel(com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel) DyIO(com.neuronrobotics.sdk.dyio.DyIO)

Example 5 with CounterOutputChannel

use of com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel in project java-bowler by NeuronRobotics.

the class CounterStepperTest method main.

/**
 * @param args
 */
public static void main(String[] args) {
    DyIO dyio = new DyIO();
    if (!ConnectionDialog.getBowlerDevice(dyio)) {
        System.exit(1);
    }
    // Instantiate a new counter input
    CounterOutputChannel stepper = new CounterOutputChannel(dyio.getChannel(23));
    // Loop forever printing out the satate of the button
    // Move 5 steps
    stepper.setValue(5);
    dyio.disconnect();
    System.exit(0);
}
Also used : CounterOutputChannel(com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel) DyIO(com.neuronrobotics.sdk.dyio.DyIO)

Aggregations

CounterOutputChannel (com.neuronrobotics.sdk.dyio.peripherals.CounterOutputChannel)5 DyIO (com.neuronrobotics.sdk.dyio.DyIO)3 ICounterOutputListener (com.neuronrobotics.sdk.dyio.peripherals.ICounterOutputListener)2 AnalogInputChannel (com.neuronrobotics.sdk.dyio.peripherals.AnalogInputChannel)1 ServoChannel (com.neuronrobotics.sdk.dyio.peripherals.ServoChannel)1 IPidControlNamespace (com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace)1 VirtualGenericPIDDevice (com.neuronrobotics.sdk.pid.VirtualGenericPIDDevice)1