public class SensorPort extends Object
Constructor and Description |
---|
SensorPort() |
Modifier and Type | Method and Description |
---|---|
static long[] |
alarmingDeviceList()
This method requests the enumeration of external devices in the alarm state.
|
void |
close()
Closes an open Sensor Port.
|
static int |
CRC16(byte[] data,
int offset,
int count,
int seed)
Perform CRC16 on an array of data elements based on the provided seed.
|
static int |
CRC8(byte[] data,
int offset,
int count,
int seed)
Perform CRC8 on an array of data elements based on the provided seed.
|
void |
data(byte[] buf,
int ofs,
int len)
Performs 1-wire data exchange.
|
static long[] |
externalDeviceList()
This method requests the enumeration of external devices.
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
static double |
get10vIn(int chan)
*
This method is used to read the value of one 10 volt module input.
|
static double |
get10vOut(int chan)
*
This method is used to read the value of one 10 volt module output.
|
static double |
get420In(int chan) |
static double |
get420Out(int chan) |
long[] |
getAlarmingDeviceList()
This method requests the enumeration of external devices in the alarm state.
|
static int |
getDeviceType(long addr)
Obtains the external device type from a device address.
|
long[] |
getExternalDeviceList()
This method requests the enumeration of external devices.
|
static int |
getOutputStates()
Obtains the state of all relay outputs as a single bit-mapped integer.
|
static double |
getRtdIn(int chan)
This method will return the RTD value for the given channel.
|
static double |
getTemp(int chan)
Returns the temperature value.
|
static boolean |
isOutputSet(int chan)
Obtains the state of a specified Relay Output.
|
void |
open()
Opens the Sensor Port providing exclusive access to external devices.
|
static int[] |
readAnalogInputs(long addr)
Obtain 16-bit raw values from a Type 20/FE/FD Quad Analog module.
|
static byte[] |
readDeviceBlock(long addr)
Obtains the Read Device Block from the external device.
|
void |
reset()
Issues the one-wire RESET pulse.
|
void |
select(long address)
Selects the external device by address.
|
static void |
set10vOut(int chan,
double value)
sets the value of the output of a 10v module at the given channel.
|
static void |
set420Out(int chan,
double value)
sets the value of the output of a 10v module at the given channel.
|
static boolean |
setOutputPulsed(int bits,
int mask,
int milliseconds)
Establishes a temporary condition for the specified output relays.
|
static void |
setOutputRelay(int chan,
boolean state)
Establish the state of the specified output relay.
|
static void |
setOutputStates(int bits,
int mask)
Establishes the condition for the specified output relays.
|
static void |
writeDeviceBlock(long addr,
byte[] block)
Writes the Write Device Block to the external device.
|
public static int CRC8(byte[] data, int offset, int count, int seed)
data
- - byte array of data elementsoffset
- - starting offset in the byte arraycount
- - count of data elements to be included in the calculationseed
- - initial CRC8 valuepublic static int CRC16(byte[] data, int offset, int count, int seed)
data
- data byte arrayoffset
- starting offset in the byte arraycount
- count of data elements to be included in the calculationseed
- initial CRC16 valuepublic long[] getExternalDeviceList() throws IOException
IOException
- The system must have access to the port.public long[] getAlarmingDeviceList() throws IOException
IOException
- The system must have access to the port.public static int getDeviceType(long addr)
addr
- the device address as returned by enumeration.public void open() throws IOException
IOException
- If the port is already open.public void close() throws IOException
IOException
- if the port is not openpublic void reset() throws IOException
IOException
- If the port is not open.public void select(long address) throws IOException
address
- Device address obtained by enumeration.IOException
- If the port is not open.public void data(byte[] buf, int ofs, int len) throws IOException
buf
- byte array with transmit/return dataofs
- offset into byte arraylen
- length of communicationsIOException
- if the port is not openpublic static double getTemp(int chan) throws IOException
chan
- Selects the temperature sensor channel.IOException
- if the port is openpublic static double get10vIn(int chan) throws IOException
chan
- the channel of the 10 volt input. You can have 2 external 10 volt modules giving you 8 inputs. The channel
must be 0 - 7.IOException
- if the port is openpublic static double get10vOut(int chan) throws IOException
chan
- the channel of the 10 volt output. You can have 2 external 10 volt modules giving you 4 outputs. The channel
must be 0 - 3.IOException
- if the port is openpublic static void set10vOut(int chan, double value) throws IOException
chan
- ?value
- ?IOException
- if the port is openpublic static double get420In(int chan) throws IOException
chan
- channel to readIOException
- if the port is openpublic static double get420Out(int chan) throws IOException
chan
- channel to readIOException
- if the port is openpublic static void set420Out(int chan, double value) throws IOException
chan
- channel to setvalue
- percentageIOException
- if channel is openpublic static double getRtdIn(int chan) throws IOException
chan
- channel to readIOException
- if port is openpublic static long[] externalDeviceList() throws IOException
IOException
- if port is openpublic static long[] alarmingDeviceList() throws IOException
IOException
- if port is openpublic static int[] readAnalogInputs(long addr) throws IOException
addr
- the device address as returned by enumeration. Note that full scale is 65520
for Type FD & FE 12-bit modules.IOException
- if the device is not an analog module with 4 input channelspublic static byte[] readDeviceBlock(long addr) throws IOException
addr
- the device address as obtained by enumeration.IOException
- if port is openpublic static void writeDeviceBlock(long addr, byte[] block) throws IOException
addr
- the device address as obtained by enumeration.block
- the Write Device Block as defined in the v2 JNIOR Communications Protocol for the specific device type.IOException
- if port is openpublic static int getOutputStates()
For the Model 410 the least significant 8 bits D0-D7 represent the state of ROUT1 through ROUT8. Bits D8-D11 will reflect the status of an option external 4ROUT module for relay outputs ROUT9 through ROUT12. A second external 4ROUT module if present is represented by bits D12-D15 for ROUT13 through ROUT16.
For the Model 412 the least significant 12 bits D0-D11 represent the state of ROUT1 through ROUT12. Bits D12-D15 will reflect the status of an option external 4ROUT module for relay outputs ROUT13 through ROUT16.
Note that some relays may be hardware jumper configured for Normally-Closed operation. These are set to Normally-Open by default. If a relay is set for normally-closed operation a '1' will indicate the OPRN condition.
public static boolean isOutputSet(int chan)
The channel is 0-based with 0 specifying ROUT1, 1 for ROUT2, etc. The Model 410 uses channels 0-7 as it supports ROUT1 through ROUT8. The Model 412 has 12 relay outputs which are specified as channels 0-11.
Additional relay outputs may be available if external 4ROUT modules are present. For the Model 410 two external 4ROUT modules may be used. These can be addressed here as channels 8-15 representing ROUT9 through ROUT16. The Model 412 can use a single external module providing channels 12-15 for ROUT13 through ROUT16.
chan
- 0-based value specifying a relay output channeltrue
if the relay output is CLOSED. Returns false
otherwise.public static void setOutputStates(int bits, int mask) throws IOException
bits
- Integer where the bits indicate the desired output condition. A '1' resulting in a
closed relaymask
- Integer where the indicate which output relays are to be affected by the command. Those relays
selected by a '1' will change to the state indicated by the bits parameter. Those corresponding
with '0' bits will remain unchanged.IOException
- if port is openpublic static void setOutputRelay(int chan, boolean state) throws IOException
chan
- 0-based value specifying a relay output channelstate
- true
closes the associated relay illuminating the corresponding LED. false
opens the relay. This opposite would be the case if a relay is hardware jumper configured for Normally-Closed
operation.IOException
- if port is openpublic static boolean setOutputPulsed(int bits, int mask, int milliseconds) throws IOException
bits
- Integer where the least significant eight bits indicate the desired output condition. A '1' resulting in a
closed relaymask
- Integer where the least significant eight bits indicate which output relays are to be affected by the
command. Those relays selected by a '1' will change to the state indicated by the data parameter. Those corresponding
with '0' bits will remain unchanged.milliseconds
- Integer specifying the duration that the new condition will be held. The pulse duration is to within
1 millisecond +0.2/-0.8true
if the pulse is successfully executed and false
otherwise.IOException
- if port is openprotected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
The finalize
method in Object
does
nothing.