classCCCUSBRemote
: publicCCCUSB
{CCCUSBRemote(std::string moduleName, std::string host, unsigned int port);
void writeActionRegister(uint16_t value);
int executeList(CCCUSBReadoutList& list, void* pReadBuffer, size_t readBufferSize, size_t* bytesRead);
int loadList(uint8_t listNumber, CCCUSBReadoutList& list);
int usbRead(void* data, size_t bufferSize, size_t* transferCount, int timeout = 2000);
std::string getHost();
unsigned int getPort();
void reconnect();
void connect();
void disconnect();
std::string marshallList(CCCUSBReadoutList& list);
size_t marshallOutputData(void* pOutputBuffer, const char* reply, size_t maxOutputSize);
};
This class provides remote access to the CC-USB through the CCUSBModule support in the tcl server. An external program can link to libCCUSB, instantiate this class and pretty much have its way with the CC-USB as if it owned it.
Restrictions:
lists cannot be downloaded (only immediate lists can be run).
the action register is not accessible.
The IRQ Mask cannot be written as that abomination requires action register operations
while internal registers can be manipulated be aware that This may cause an active readout to have undefined results. Registers you write may be overwritten by Readout's startup code.
CCCUSBRemote(std::string moduleName, std::string host, unsigned int port);
Constructs a CCCUSBRemote
object.
The resulting object can be used to communicate with
a CC-USB controlled by a CCUSBReadout program if it has
a ccusb module loaded into the slow-controls server named
moduleName
. A CException is thrown
if the connection with the slow-controls server at host
and
port
is unsuccessful.
void writeActionRegister(uint16_t value);
The writeAction register method is not fully implemented in the CCCUSBRemote. It maintains an implementation that does nothing more than print a message to the screen stating that it does nothing.
int executeList(CCCUSBReadoutList& list, void* pReadBuffer, size_t readBufferSize, size_t* bytesRead);
Performs a CAMAC list operation in immediate mode.
In order to do this, data taking mode must not
be on. The list
is built up
by constructing a CCCUSBReadoutList
(see CCCUSBReadoutList(3ccusb))
object and using its methods to add the appropriate
set of instructions to the list.
pReadBuffer
is a pointer to
a buffer you have prepared to receive the results
of the read operations in the list. This buffer
has readBufferSize
bytes
of data. On successful return,
bytesRead
will contain the
actual number of bytes transferred into your buffer.
On failure (return value other than 0),
the value of bytesRead
is not
well defined.
int loadList(uint8_t listNumber, CCCUSBReadoutList& list);
The loadList method is not fully supported in the CCCUSBRemote class. Instead, it is just a method that prints to the terminal that it is not supported.
int usbRead(void* data, size_t bufferSize, size_t* transferCount, int timeout = 2000);
Like the loadList and writeActionRegister methods, this is not fully implemented. It only prints a message to the terminal to indicate that it is not implemented.
void reconnect();
Forcibly disconnects from the slow controls server and connects using the host and port provided at construction. It is essentially just a call to disconnect followed by a call to connect.
void connect();
Connects to the server identified by the host and port parameters provided at construction. It also does create a new TCL interpreter instance for communicating. A CException can be thrown if the connection fails.
void disconnect();
Forcibly disconnects from the server. The current TCL interpreter owned by by the class instance is also deleted.
std::string marshallList(CCCUSBReadoutList& list);
This converts a CCCUSBReadoutList into a string format equivalent to a list. The format produced is actually a list of lists. The first list element contains the max size of the read buffer and the second element is the list of commands.
size_t marshallOutputData(void* pBuffer, const char* reply, size_t maxOutputSize);
This transfers the reply
from the server
into the user's buffer, i.e. pBuffer
. The
maximum size of the user's buffer is provided by maxOutputSize
.
The value returned from the method is the number of bytes that were actually
transferred into the user's buffer.