Search in sources :

Example 1 with I2cDeviceSynch

use of com.qualcomm.robotcore.hardware.I2cDeviceSynch in project robotcode by OutoftheBoxFTC.

the class UserI2cSensorType method createInstance.

// ----------------------------------------------------------------------------------------------
// Instance creation
// ----------------------------------------------------------------------------------------------
@NonNull
public HardwareDevice createInstance(RobotCoreLynxModule lynxModule, Func<I2cDeviceSynchSimple> simpleSynchFunc, Func<I2cDeviceSynch> synchFunc) throws InvocationTargetException {
    try {
        Constructor ctor;
        ctor = findMatch(ctorI2cDeviceSynchSimple);
        if (null != ctor) {
            I2cDeviceSynchSimple i2cDeviceSynchSimple = simpleSynchFunc.value();
            return (HardwareDevice) ctor.newInstance(i2cDeviceSynchSimple);
        }
        ctor = findMatch(ctorI2cDeviceSynch);
        if (null != ctor) {
            I2cDeviceSynch i2cDeviceSynch = synchFunc.value();
            return (HardwareDevice) ctor.newInstance(i2cDeviceSynch);
        }
    } catch (IllegalAccessException | InstantiationException e) {
        throw new RuntimeException("internal error: exception");
    }
    throw new RuntimeException("internal error: unable to locate constructor for user sensor type");
}
Also used : I2cDeviceSynchSimple(com.qualcomm.robotcore.hardware.I2cDeviceSynchSimple) Constructor(java.lang.reflect.Constructor) I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch) HardwareDevice(com.qualcomm.robotcore.hardware.HardwareDevice) NonNull(android.support.annotation.NonNull)

Example 2 with I2cDeviceSynch

use of com.qualcomm.robotcore.hardware.I2cDeviceSynch in project robotcode by OutoftheBoxFTC.

the class HardwareDeviceManager method createI2cDeviceSynch.

@Override
public I2cDeviceSynch createI2cDeviceSynch(RobotCoreLynxModule lynxModule, DeviceConfiguration.I2cChannel channel, String name) {
    RobotLog.v("Creating I2cDeviceSynch (Lynx) - mod=%d bus=%d", lynxModule.getModuleAddress(), channel.channel);
    I2cDeviceSynchSimple i2cDeviceSynchSimple = createI2cDeviceSynchSimple(lynxModule, channel, name);
    I2cDeviceSynch result = new I2cDeviceSynchImplOnSimple(i2cDeviceSynchSimple, true);
    return result;
}
Also used : I2cDeviceSynchSimple(com.qualcomm.robotcore.hardware.I2cDeviceSynchSimple) LynxI2cDeviceSynch(com.qualcomm.hardware.lynx.LynxI2cDeviceSynch) I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch) I2cDeviceSynchImplOnSimple(com.qualcomm.robotcore.hardware.I2cDeviceSynchImplOnSimple)

Example 3 with I2cDeviceSynch

use of com.qualcomm.robotcore.hardware.I2cDeviceSynch in project robotcode by OutoftheBoxFTC.

the class HardwareDeviceManager method createI2cDeviceSynch.

protected I2cDeviceSynch createI2cDeviceSynch(I2cController controller, int channel, String name) {
    I2cDevice i2cDevice = new I2cDeviceImpl(controller, channel);
    I2cDeviceSynch i2cDeviceSynch = new I2cDeviceSynchImpl(i2cDevice, true);
    i2cDeviceSynch.setUserConfiguredName(name);
    return i2cDeviceSynch;
}
Also used : I2cDeviceSynchImpl(com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl) I2cDevice(com.qualcomm.robotcore.hardware.I2cDevice) LynxI2cDeviceSynch(com.qualcomm.hardware.lynx.LynxI2cDeviceSynch) I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch) I2cDeviceImpl(com.qualcomm.robotcore.hardware.I2cDeviceImpl)

Example 4 with I2cDeviceSynch

use of com.qualcomm.robotcore.hardware.I2cDeviceSynch in project robotcode by OutoftheBoxFTC.

the class HardwareFactory method mapI2cDeviceSynch.

private void mapI2cDeviceSynch(HardwareMap map, DeviceManager deviceMgr, I2cController i2cController, DeviceConfiguration devConf) {
    if (!devConf.isEnabled()) {
        return;
    }
    I2cDevice i2cDevice = deviceMgr.createI2cDevice(i2cController, devConf.getI2cChannel(), devConf.getName());
    I2cDeviceSynch i2cDeviceSynch = new I2cDeviceSynchImpl(i2cDevice, true);
    map.i2cDeviceSynch.put(devConf.getName(), i2cDeviceSynch);
}
Also used : I2cDeviceSynchImpl(com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl) I2cDevice(com.qualcomm.robotcore.hardware.I2cDevice) I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch)

Example 5 with I2cDeviceSynch

use of com.qualcomm.robotcore.hardware.I2cDeviceSynch in project robotcode by OutoftheBoxFTC.

the class HardwareFactory method mapI2cDeviceSynch.

private void mapI2cDeviceSynch(HardwareMap map, DeviceManager deviceMgr, LynxModule module, DeviceConfiguration devConf) {
    I2cDeviceSynch i2cDeviceSynch = deviceMgr.createI2cDeviceSynch(module, devConf.getI2cChannel(), devConf.getName());
    map.i2cDeviceSynch.put(devConf.getName(), i2cDeviceSynch);
}
Also used : I2cDeviceSynch(com.qualcomm.robotcore.hardware.I2cDeviceSynch)

Aggregations

I2cDeviceSynch (com.qualcomm.robotcore.hardware.I2cDeviceSynch)7 I2cDevice (com.qualcomm.robotcore.hardware.I2cDevice)3 I2cDeviceSynchImpl (com.qualcomm.robotcore.hardware.I2cDeviceSynchImpl)3 NonNull (android.support.annotation.NonNull)2 LynxI2cDeviceSynch (com.qualcomm.hardware.lynx.LynxI2cDeviceSynch)2 HardwareDevice (com.qualcomm.robotcore.hardware.HardwareDevice)2 I2cDeviceImpl (com.qualcomm.robotcore.hardware.I2cDeviceImpl)2 I2cDeviceSynchSimple (com.qualcomm.robotcore.hardware.I2cDeviceSynchSimple)2 Constructor (java.lang.reflect.Constructor)2 I2cDeviceSynchImplOnSimple (com.qualcomm.robotcore.hardware.I2cDeviceSynchImplOnSimple)1