Class Cola2Session

Class Documentation

class Cola2Session

A class representing a COLA2 session to handle send, receive and process telegrams synchronously in the format as specified by the SICK Cola2 protocol. This class is not thread-safe and works strictly sequential (one command after another).

Public Functions

explicit Cola2Session(communication::TCPClientPtr tcp_client)

Constructor of the Cola 2 Session object.

Parameters

tcp_client – Pointer on a TCPClient object.

Cola2Session() = delete
Cola2Session(const Cola2Session&) = delete
Cola2Session &operator=(const Cola2Session&) = delete
void sendCommand(Command &cmd, sick::types::time_duration_t timeout = boost::posix_time::seconds(5))

A blocking operation sends a COLA2 command as telegram to the connected sensor. Throws an exception if the timeout is exceeded.

Parameters
  • cmd – The command to send via COLA2 to the sensor.

  • timeout – The timeout on a single send/receive socket operation. This is not the overall timeout limit but guarantees the synchronous send/receive operations not to wait forever.

boost::optional<uint32_t> getSessionID() const

Get the current session ID, if available.

Returns

boost::optional<uint32_t> Returns the sessionID wrapped as optional value.

uint16_t getNextRequestID()

Get the next possible requestID. This increments the internal counter by one.

Returns

uint16_t Returns an incremented request ID.

void setSessionID(uint32_t session_id)

Set the Session I D object.

Parameters

session_id

void open()

Opens a COLA2 session.

void close()

Closes the current COLA2 session. If no session is opened, the function will return silently without raising an exception.