public final class AcrComm extends Object
logging.properties file to control the driver's logger
org.lsst.ccs.drivers.parker. AcrComm can also write some output
to an open PrintStream if you give it one, for example System.out
if you're using the driver in an interactive session as does the TestAcrComm
class
Note that there's a 200 ms timeout set on all reception of replies from the controller. That's more than 100 times the time it usually takes for the controller to start sending a reply, unless you send a command that takes longer to execute. In particular you should avoid long sleeps using the dwell command DWL, long waits for flags using the inhibit command INH, or long waits for other events using the capture command INTCAP.
This version of the driver doesn't implement watchdog requests for the TCP connection to the controller. This may be added when we figure out how to use it and if we can make good use of it.
For most LSST-related work you should use only the get() and set() methods
that take enumerations as arguments, plus the sendStr() method that sends
ASCII commands and cleanup() that gracefully terminates the connection to the
controller. The lower-level methods such as getLongParameter() that
take simple parameter index numbers should be used only if the parameters
you want don't have names in any of the public enumeration classes. The low-level
methods may one day be split off into another class, as AcrComm has gotten
rather large. It's probably best to have the maintainer of this package add the names
you need.
| Modifier and Type | Class and Description |
|---|---|
static class |
AcrComm.Exception
Inner exception class for laundering non-runtime exceptions.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup()
Drains and closes sockets, closes logs.
|
double[] |
decodeDoubles(byte... value)
Decodes as a double each 8-byte section of a byte string.
|
long[] |
decodeLongs(byte... value)
Decode a byte sequence sent from the controller as a series of signed 32-bit
integer values.
|
double[] |
decodeSingles(byte... value)
Decodes a series of float values sent from the controller
as bytes.
|
String[] |
decodeStrings(int elementWordCount,
byte... value)
Reverses the encoding performed by
encodeStrings(int, java.lang.String...),
turning AcroBasic strings represented a byte sequences into Java Strings. |
long[] |
decodeUnsigneds(byte... value)
Decode a byte sequence sent from the controller as a series of unsigned 32-bit
integer values.
|
void |
drain()
Discards any unread input from the controller socket.
|
byte[] |
encodeDoubles(double... value)
Encodes as bytes a series of double values.
|
byte[] |
encodeLongs(long... value)
Encodes as bytes a series of 32-bit signed integer values.
|
byte[] |
encodeSingles(double... value)
Encodes as bytes a series of double values after conversion
to floats.
|
byte[] |
encodeStrings(int elementWordCount,
String... value)
Encodes a series of Strings as a byte sequence.
|
byte[] |
encodeUnsigneds(long... value)
Encodes as bytes a series of 32-bit unsigned integer values.
|
boolean |
get(AxisName axis,
AxisBit axbit)
Gets from the controller an axis flag bit's state for a given axis.
|
long |
get(AxisName axis,
AxisLong axlong)
Gets from the controller a signed 32-bit integer axis parameter for a given axis.
|
double |
get(AxisName axis,
AxisSingle axsingle)
Gets from the controller a single-float axis parameter for the given axis.
|
long |
get(AxisName axis,
AxisUnsigned axunsigned)
Gets from the controller an unsigned 32-bit integer axis parameter for a given axis.
|
long |
get(ConnectionName conn,
ConnectionUnsigned connunsigned)
Gets from the controller one of the unsigned 32-bit parameters associated with
a communications connection.
|
long |
get(EncoderName encoder,
EncoderLong enclong)
Gets from the controller a 32-bit signed encoder parameter for a given encoder.
|
boolean |
get(MasterName master,
MasterBit mbit)
Gets from the controller the state of a flag bit for a given master.
|
long |
get(MasterName master,
MasterUnsigned munsigned)
Gets from the controller the value of an unsigned 32-bit parameter for a given master.
|
double |
get(ProgramName program,
LocalDouble locdouble)
Gets from the controller the value of a double-float local scalar variable
for a given program.
|
double[] |
get(ProgramName program,
LocalDoubleArray ldarray)
Gets from the controller all the elements of a double-float local array variable
for a given program.
|
long |
get(ProgramName program,
LocalLong loclong)
Gets from the controller the value of a local long scalar variable for a given program.
|
long[] |
get(ProgramName program,
LocalLongArray llarray)
Gets from the controller all the elements of a local long array for a given
program.
|
double |
get(ProgramName program,
LocalSingle locsingle)
Gets from the controller the value of a single-float local scalar variable for a given
program.
|
double[] |
get(ProgramName program,
LocalSingleArray lsarray)
Gets from the controller the values of a single-float local array for a given program.
|
String |
get(ProgramName program,
LocalString locstring)
Gets from the controller the value of a local ASCII string scalar variable for a given
program.
|
String[] |
get(ProgramName program,
LocalStringArray lstrarray)
Gets from the controller the values of a local string array for a given program.
|
boolean |
get(ProgramName program,
ProgramBit progbit)
Gets from the controller an program bit's state for a given program.
|
long |
get(ProgramName program,
ProgramUnsigned progunsigned)
Gets from the controller a 32-bit unsigned program-related parameter.
|
boolean |
get(SystemBit sysbit)
Gets from the controller the value of a system flag bit.
|
long |
get(SystemUnsigned sysul)
Gets from the controller the value of an unsigned 32-bit system parameter.
|
double |
get(UserParameter uparam)
Gets from the controller the value of a user parameter (always a double-float).
|
long |
getLongParameter(int parameterIndex)
Gets a controller LONG parameter as a signed value.
|
double |
getSingleParameter(int parameterIndex)
Gets a controller FP32 (single-float) parameter.
|
long |
getUnsignedParameter(int parameterIndex)
Gets a controller LONG parameter as an unsigned value.
|
long |
globalAddress(UserParameter uparam)
Uses the controller's System Pointer to calculate the address in controller memory
of a given user parameter.
|
void |
kick()
Waits for unsolicited output from the controller and if none is
forthcoming attempts to generate some by sending a VER command.
|
long |
localAddress(int programNumber,
byte typeCode,
int arrayNumber,
int arrayIndex)
Gets the address in controller memory of an element in a local array.
|
static AcrComm |
newInstance(ControllerType ctrlType,
String controllerHost,
Optional<PrintStream> out)
Opens a TCP connection to the controller and makes a new instance of this class.
|
byte[] |
peek(long address,
int wordCount,
byte conversion)
Uses the controller's binary-peek operation to get a number of 32-bit words
from memory.
|
void |
poke(long address,
byte conversion,
byte... value)
Uses the controller's binary-poke operation to set a number of 32-bit words
from memory.
|
int |
receiveAscii()
Collects ASCII data coming from the controller, relaying it to the console
and, if logging is enabled, logging it.
|
byte[] |
receiveBinary(int leng)
Receives a binary reply from the controller
|
void |
sendBinary(byte[] cmnd)
Sends a binary command to the controller.
|
void |
sendFile(String fName,
boolean echo)
Reads a file line by line and sends each line to the controller.
|
int |
sendStr(String cmnd)
Sends an ASCII line to the controller and receives any reply, which is sent to the console.
|
void |
set(AxisName axis,
AxisBit axbit,
boolean value)
Sets or clears a controller axis flag bit.
|
void |
set(AxisName axis,
AxisLong axlong,
long value)
Sets the value of a controller axis parameter that's a signed long.
|
void |
set(AxisName axis,
AxisSingle axsingle,
double value)
Sets the value of a controller axis parameter that's a single-float (FP32).
|
void |
set(EncoderName encoder,
EncoderLong enclong,
long value)
Sets the value of an controller encoder parameter that's a signed 32-bit long.
|
void |
set(MasterName master,
MasterBit mbit,
boolean value)
Sets or clears a controller flag bit belonging to a master.
|
void |
set(ProgramName program,
LocalDoubleArray ldarray,
double[] value)
Sets the value of a double array local to a controller program.
|
void |
set(ProgramName program,
LocalDouble locdouble,
double value)
Sets the value of double scalar local to a controller program.
|
void |
set(ProgramName program,
LocalLongArray llarray,
long[] value)
Sets the values of a long (signed 32-bit) array local to a controller program.
|
void |
set(ProgramName program,
LocalLong loclong,
long value)
Sets the value of a long (signed 32-bit) scalar local to a controller program.
|
void |
set(ProgramName program,
LocalSingleArray lsarray,
double[] value)
Sets the values of a single-float array local to a controller program.
|
void |
set(ProgramName program,
LocalSingle locsingle,
double value)
Sets the value of a single-float scalar local to a controller program.
|
void |
set(ProgramName program,
LocalStringArray lstrarray,
String[] value)
Sets the value of a string array local to a controller program.
|
void |
set(ProgramName program,
LocalString locstring,
String value)
Sets the value of a string scalar local to a controller program.
|
void |
set(SystemBit sysbit,
boolean value)
Set or clear a system flag bit in the controller.
|
void |
set(SystemUnsigned sysul,
long value)
Set in the controller a system parameter that is an unsigned 32-bit long.
|
void |
set(UserParameter uparam,
double... value)
Sets a sequence of user parameters in the controller (always double-float).
|
void |
setLongParameter(int parameterIndex,
long value)
Sets a controller LONG parameter as a signed value.
|
void |
setOrClearBit(int bitIndex,
boolean value)
Sets or clears a controller bit according to a boolean value.
|
void |
setSingleParameter(int parameterIndex,
double value)
Sets a controller FP32 (single-float) parameter.
|
void |
setUnsignedParameter(int parameterIndex,
long value)
Sets a controller LONG parameter as an unsigned value.
|
public static AcrComm newInstance(ControllerType ctrlType, String controllerHost, Optional<PrintStream> out) throws IOException
ctrlType - the controller type.controllerHost - the host name or dotted IPv4 address of the controller.out - the optional console output stream. Use a non-empty value
when using the driver interactively.AcrComm instance.IOException - if there's a problem creating or managing the socket.public void kick()
newInstance(org.lsst.ccs.drivers.parker.ControllerType,
java.lang.String, java.util.Optional) does this automatically.public void cleanup()
public boolean get(AxisName axis, AxisBit axbit)
axis - the axis.axbit - the flag bit to get.public long get(AxisName axis, AxisUnsigned axunsigned)
axis - the axis.axunsigned - the axis parameter to get.public long get(AxisName axis, AxisLong axlong)
axis - the axis.axlong - the axis parameter to get.public double get(AxisName axis, AxisSingle axsingle)
axis - the axis.axsingle - the axis parameter to get.public long get(ConnectionName conn, ConnectionUnsigned connunsigned)
conn - the connection.connunsigned - the parameter.public long get(EncoderName encoder, EncoderLong enclong)
encoder - the encoder.enclong - the encoder parameter to get.public long get(ProgramName program, ProgramUnsigned progunsigned)
program - the program.progunsigned - the parameter to get.public boolean get(ProgramName program, ProgramBit progbit)
program - the program.progbit - the flag bit to get.public double get(ProgramName program, LocalDouble locdouble)
program - the program.locdouble - the variable to get.public double[] get(ProgramName program, LocalDoubleArray ldarray)
program - the program.ldarray - the variable to get.public long get(ProgramName program, LocalLong loclong)
program - the program.loclong - the variable to get.public long[] get(ProgramName program, LocalLongArray llarray)
program - the program.llarray - the array to get.public double get(ProgramName program, LocalSingle locsingle)
program - the program.locsingle - the variable to get.public double[] get(ProgramName program, LocalSingleArray lsarray)
program - the program.lsarray - the array to get.public String get(ProgramName program, LocalString locstring)
program - the program.locstring - the variable to get.public String[] get(ProgramName program, LocalStringArray lstrarray)
program - the program.lstrarray - the array to get.public boolean get(MasterName master, MasterBit mbit)
master - the master.mbit - the bit to get.public long get(MasterName master, MasterUnsigned munsigned)
master - the master.munsigned - the parameter to get.public boolean get(SystemBit sysbit)
sysbit - the bit to get.public long get(SystemUnsigned sysul)
sysul - the parameter to get.public double get(UserParameter uparam)
uparam - the parameter to get.public void set(AxisName axis, AxisBit axbit, boolean value)
axis - the axis.axbit - the axis flag bit to set.value - true to set the bit, false to clear it.public void set(AxisName axis, AxisLong axlong, long value)
axis - the axis.axlong - the axis parameter to set.value - the new value.public void set(AxisName axis, AxisSingle axsingle, double value)
axis - the axis.axsingle - the axis parameter to set.value - the new value, which will be rounded to fit.public void set(EncoderName encoder, EncoderLong enclong, long value)
encoder - the encoder.enclong - the encoder parameter to set.value - the new value, which will be truncated on the left to fit.public void set(ProgramName program, LocalDouble locdouble, double value)
program - the program.locdouble - the scalar variable to set.value - the new value.public void set(ProgramName program, LocalDoubleArray ldarray, double[] value)
program - the program.ldarray - the local double array to set.value - the new values.public void set(ProgramName program, LocalLong loclong, long value)
program - the program.loclong - the local variable to set.value - the new value, which will be truncated on the left to fit.public void set(ProgramName program, LocalLongArray llarray, long[] value)
program - the program.llarray - the local array to set.value - the new values, which will be truncated on the left to fit.public void set(ProgramName program, LocalSingle locsingle, double value)
program - the program.locsingle - the variable to set.value - the new value, which will be rounded down to single precision.public void set(ProgramName program, LocalSingleArray lsarray, double[] value)
program - the program.lsarray - the array variable to set.value - the new values, which will be rounded down to single precision.public void set(ProgramName program, LocalString locstring, String value)
program - the program.locstring - the string variable to set.value - the new value, where each Java char will be truncated down to eight bits.public void set(ProgramName program, LocalStringArray lstrarray, String[] value)
program - the program.lstrarray - the string array to set.value - the new values, where each Java char will be truncated to eight bits.public void set(MasterName master, MasterBit mbit, boolean value)
master - the master.mbit - the flag bit to set/clear.value - true to set the bit, false to clear it.public void set(SystemBit sysbit, boolean value)
sysbit - the flag bit to set/clear.value - true to set the bit, false to clear it.public void set(SystemUnsigned sysul, long value)
sysul - the parameter to set.value - the new value, which will be truncated on the left to fit.public void set(UserParameter uparam, double... value)
uparam - the first parameter to set.value - the new values.public long globalAddress(UserParameter uparam)
uparam - the parameter.public long localAddress(int programNumber,
byte typeCode,
int arrayNumber,
int arrayIndex)
programNumber - the index of the program whose data we want the address of.typeCode - the type code to use in the address command.arrayNumber - for array types, the index of the particular array we want. For scalar
types this parameter is ignored and we use the implicit array of all scalar variables
of the given type.arrayIndex - the index number of the array element we want.public long getUnsignedParameter(int parameterIndex)
parameterIndex - the index number of the parameter.public void setUnsignedParameter(int parameterIndex,
long value)
parameterIndex - the index number of the parameter.value - the parameter value.public long getLongParameter(int parameterIndex)
parameterIndex - the index number of the parameter.public void setLongParameter(int parameterIndex,
long value)
parameterIndex - the index number of the parameter.value - the parameter value.public double getSingleParameter(int parameterIndex)
parameterIndex - the index number of the parameter.public void setSingleParameter(int parameterIndex,
double value)
parameterIndex - the index number of the parameter.value - the parameter value.public void setOrClearBit(int bitIndex,
boolean value)
bitIndex - the bit index number.value - true to set the bit, false to clear it.public byte[] encodeUnsigneds(long... value)
value - a series of values between 0 and 2**32 - 1 inclusive.public long[] decodeUnsigneds(byte... value)
value - the series of bytes.public byte[] encodeLongs(long... value)
value - a series of values between -2**31 and 2**31 - 1 inclusive.public long[] decodeLongs(byte... value)
value - the series of bytes.public byte[] encodeSingles(double... value)
Float.floatToIntBits(}.
Each integer is encoded using encodeUnsigneds(long...).value - a series of double values.public double[] decodeSingles(byte... value)
decodeUnsigneds(byte...). The integers are then
converted to floats using Float.intBitsToFloat(} and
the resulting floats are widened to doubles.value - a series of bytes.public byte[] encodeDoubles(double... value)
Double.doubleToLongBits(}.
Each long is broken into two 32-bit halves and encoded using
encodeUnsigneds(long...), the low -order half being encoded first.value - a series of double values.public double[] decodeDoubles(byte... value)
decodeUnsigneds(byte...).
Each pair of integers is combined into a single long, the first member
of each pair becoming the low order part. Then the longs are converted to
doubles using Double.longBitsToDouble(}.value - the series of bytes to decode.public byte[] encodeStrings(int elementWordCount,
String... value)
elementWordCount - the number of words to use for each string
(including the byte count word), padding with zero-valued bytes if needed.value - the series of strings.public String[] decodeStrings(int elementWordCount, byte... value)
encodeStrings(int, java.lang.String...),
turning AcroBasic strings represented a byte sequences into Java Strings.elementWordCount - the number of 4-byte words occupied by each
AcroBasic string, which includes the byte-count word.value - the byte array containing encoded string values.public byte[] peek(long address,
int wordCount,
byte conversion)
address - the memory address of the first, lowest-addressed word.wordCount - the number of words to get.conversion - the conversion code to use, for instance LONG_CONVERSION.public void poke(long address,
byte conversion,
byte... value)
address - the memory address of the first, lowest-addressed word.conversion - one of the conversion codes, for instance FP64_CONVERSION.public void sendFile(String fName, boolean echo)
fName - the pathname of the file.echo - true to have the controller echo what we send it, else false.public int sendStr(String cmnd)
cmnd - the command line, without the line termination which will be added.public int receiveAscii()
public void sendBinary(byte[] cmnd)
cmnd - the byte array containing the encoded command, which is assumed
to take up the entire array.public byte[] receiveBinary(int leng)
leng - the expected length of the reply.public void drain()
Copyright © 2017 LSST. All rights reserved.