How to obtain a list of ALL the IOs on the robot using the URCap Java API

I created the function below.
I could list all IOs into one collection.

    private ArrayList<IO> getAllIOs(URCapAPI api) {

    IOModel ioModel = api.getInstallationAPIProvider().getInstallationAPI().getIOModel();

    Collection<AnalogIO> AnalogIOs = ioModel.getIOs(AnalogIO.class);
    Collection<DigitalIO> DigitalIOs = ioModel.getIOs(DigitalIO.class);
    Collection<ModbusIO> ModbusIOs = ioModel.getIOs(ModbusIO.class);
    Collection<BooleanRegister> BooleanRegisters = ioModel.getIOs(BooleanRegister.class);
    Collection<IntegerRegister> IntegerRegisters = ioModel.getIOs(IntegerRegister.class);
    Collection<FloatRegister> FloatRegisters = ioModel.getIOs(FloatRegister.class);

    ArrayList<IO> ios = new ArrayList<IO>();

    ios.addAll(AnalogIOs);
    ios.addAll(DigitalIOs);
    ios.addAll(ModbusIOs);
    ios.addAll(BooleanRegisters);
    ios.addAll(IntegerRegisters);
    ios.addAll(FloatRegisters);

    return ios;
}

2 Likes