Class SimDevice
- All Implemented Interfaces:
AutoCloseable
public class SimDevice extends Object implements AutoCloseable
Teams: if you are using this class, you are likely confusing it for SimDeviceSim.
Vendors: This class should be used from inside the device class to define the
properties/fields of the device. Use create(java.lang.String) to get a SimDevice object, then use createDouble(String, Direction, double) or similar to define the device's fields. See ADXRS450_Gyro for an example implementation.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSimDevice.Direction -
Constructor Summary
Constructors Constructor Description SimDevice(int handle)Wraps a simulated device handle as returned by SimDeviceJNI.createSimDevice(). -
Method Summary
Modifier and Type Method Description voidclose()static SimDevicecreate(String name)Creates a simulated device.static SimDevicecreate(String name, int index)Creates a simulated device.static SimDevicecreate(String name, int index, int channel)Creates a simulated device.SimBooleancreateBoolean(String name, boolean readonly, boolean initialValue)Deprecated.Use direction function insteadSimBooleancreateBoolean(String name, SimDevice.Direction direction, boolean initialValue)Creates a boolean value on the simulated device.SimDoublecreateDouble(String name, boolean readonly, double initialValue)Deprecated.Use direction function insteadSimDoublecreateDouble(String name, SimDevice.Direction direction, double initialValue)Creates a double value on the simulated device.SimEnumcreateEnum(String name, boolean readonly, String[] options, int initialValue)Deprecated.Use direction function insteadSimEnumcreateEnum(String name, SimDevice.Direction direction, String[] options, int initialValue)Creates an enumerated value on the simulated device.SimEnumcreateEnumDouble(String name, SimDevice.Direction direction, String[] options, double[] optionValues, int initialValue)Creates an enumerated value on the simulated device with double values.SimIntcreateInt(String name, SimDevice.Direction direction, int initialValue)Creates an int value on the simulated device.SimLongcreateLong(String name, SimDevice.Direction direction, long initialValue)Creates a long value on the simulated device.SimValuecreateValue(String name, boolean readonly, HALValue initialValue)Deprecated.Use direction function insteadSimValuecreateValue(String name, SimDevice.Direction direction, HALValue initialValue)Creates a value on the simulated device.intgetNativeHandle()Get the internal device handle.
-
Constructor Details
-
SimDevice
Wraps a simulated device handle as returned by SimDeviceJNI.createSimDevice().- Parameters:
handle- simulated device handle
-
-
Method Details
-
create
Creates a simulated device.The device name must be unique. Returns null if the device name already exists. If multiple instances of the same device are desired, recommend appending the instance/unique identifer in brackets to the base name, e.g. "device[1]".
null is returned if not in simulation.
- Parameters:
name- device name- Returns:
- simulated device object
-
create
Creates a simulated device.The device name must be unique. Returns null if the device name already exists. This is a convenience method that appends index in brackets to the device name, e.g. passing index=1 results in "device[1]" for the device name.
null is returned if not in simulation.
- Parameters:
name- device nameindex- device index number to append to name- Returns:
- simulated device object
-
create
Creates a simulated device.The device name must be unique. Returns null if the device name already exists. This is a convenience method that appends index and channel in brackets to the device name, e.g. passing index=1 and channel=2 results in "device[1,2]" for the device name.
null is returned if not in simulation.
- Parameters:
name- device nameindex- device index number to append to namechannel- device channel number to append to name- Returns:
- simulated device object
-
close
- Specified by:
closein interfaceAutoCloseable
-
getNativeHandle
Get the internal device handle.- Returns:
- internal handle
-
createValue
Deprecated.Use direction function insteadCreates a value on the simulated device.Returns null if not in simulation.
- Parameters:
name- value namereadonly- if the value should not be written from simulation sideinitialValue- initial value- Returns:
- simulated value object
-
createValue
Creates a value on the simulated device.Returns null if not in simulation.
- Parameters:
name- value namedirection- input/output/bidir (from perspective of user code)initialValue- initial value- Returns:
- simulated value object
-
createInt
Creates an int value on the simulated device.Returns null if not in simulation.
- Parameters:
name- value namedirection- input/output/bidir (from perspective of user code)initialValue- initial value- Returns:
- simulated double value object
-
createLong
Creates a long value on the simulated device.Returns null if not in simulation.
- Parameters:
name- value namedirection- input/output/bidir (from perspective of user code)initialValue- initial value- Returns:
- simulated double value object
-
createDouble
Deprecated.Use direction function insteadCreates a double value on the simulated device.Returns null if not in simulation.
- Parameters:
name- value namereadonly- if the value should not be written from simulation sideinitialValue- initial value- Returns:
- simulated double value object
-
createDouble
Creates a double value on the simulated device.Returns null if not in simulation.
- Parameters:
name- value namedirection- input/output/bidir (from perspective of user code)initialValue- initial value- Returns:
- simulated double value object
-
createEnum
@Deprecated public SimEnum createEnum(String name, boolean readonly, String[] options, int initialValue)Deprecated.Use direction function insteadCreates an enumerated value on the simulated device.Enumerated values are always in the range 0 to numOptions-1.
Returns null if not in simulation.
- Parameters:
name- value namereadonly- if the value should not be written from simulation sideoptions- array of option descriptionsinitialValue- initial value (selection)- Returns:
- simulated enum value object
-
createEnum
public SimEnum createEnum(String name, SimDevice.Direction direction, String[] options, int initialValue)Creates an enumerated value on the simulated device.Enumerated values are always in the range 0 to numOptions-1.
Returns null if not in simulation.
- Parameters:
name- value namedirection- input/output/bidir (from perspective of user code)options- array of option descriptionsinitialValue- initial value (selection)- Returns:
- simulated enum value object
-
createEnumDouble
public SimEnum createEnumDouble(String name, SimDevice.Direction direction, String[] options, double[] optionValues, int initialValue)Creates an enumerated value on the simulated device with double values.Enumerated values are always in the range 0 to numOptions-1.
Returns null if not in simulation.
- Parameters:
name- value namedirection- input/output/bidir (from perspective of user code)options- array of option descriptionsoptionValues- array of option values (must be the same size as options)initialValue- initial value (selection)- Returns:
- simulated enum value object
-
createBoolean
Deprecated.Use direction function insteadCreates a boolean value on the simulated device.Returns null if not in simulation.
- Parameters:
name- value namereadonly- if the value should not be written from simulation sideinitialValue- initial value- Returns:
- simulated boolean value object
-
createBoolean
Creates a boolean value on the simulated device.Returns null if not in simulation.
- Parameters:
name- value namedirection- input/output/bidir (from perspective of user code)initialValue- initial value- Returns:
- simulated boolean value object
-