13 #include "sick_scan/tcp/interfaces/tcp.hpp" 18 #include "sick_scan/tcp/tools/Mutex.hpp" 128 std::string ipAddress,
131 bool weWantFieldData,
446 return m_messageType;
451 return m_frameLength;
455 UINT32 getPayLoadLength()
const;
457 std::string getCommandString()
const;
463 INT32 getVariableIndex();
466 std::string getVariableName();
468 bool isValid()
const {
return (m_buffer != NULL); }
471 void detectEncoding();
473 void detectMessageType();
497 bool isValid() {
return (m_answerBuffer != NULL); }
506 #endif // SOPASBASE_H SopasBase::SopasMessageType getMessageType() const
DecoderFunctionMapByIndex m_decoderFunctionMapByIndex
void processFrame_CoLa_A(SopasEventMessage &frame)
void closeTcpConnection()
static const std::string COMMAND_Read_Variable_ByName
SopasBase::SopasMessageType m_messageType
State m_state
Device info.
bool registerEvent(const std::string &eventName)
Registers an event by name.
bool receiveAnswer_CoLa_A(SopasCommand cmd, std::string name, UINT32 timeout, SopasAnswer *&answer)
SopasMessageType
types of answers of the sensor
static const std::string VARIABLENAME_DEVICEIDENT
bool m_weWantScanData
Flag to enable/disable scan data reception.
static const std::string VARIABLENAME_SCANCONFIG
void colaB_decodeScannerTypeAndVersion(UINT8 *buffer, UINT16 pos)
Class that encapsulates a buffer that was sent as return to a sync call. (variable / method) ...
static std::string convertSopasErrorCodeToText(UINT16 errorCode)
static const std::string COMMAND_Register_Event_Answer
Class that encapsulates a buffer that was sent as return to a sync call. (variable / method) ...
static const std::string EVENTNAME_SUBSCRIBE_EVALCASES
static const std::string VARIABLENAME_SCANDATACONFIG
static const std::string COMMAND_Register_Event_ByName
Mutex m_receiveDataMutex
Access mutex for buffer.
const std::string & getScannerVersion() const
static const std::string COMMAND_Method_Result_Answer
Class that represents a message that was sent by a sensor. (Event message)
virtual ~SopasBase()
Destructor.
SopasCommand colaA_decodeCommand(std::string *rxData)
SopasBase::SopasEncoding getEncodingType() const
void(* DisconnectFunction)(void *obj)
static const std::string METHODNAME_LOGOUT
static const std::string COMMAND_Invoke_Method_ByIndex
SopasEncoding m_encoding
ByName or ByIndex.
read/write variable, invoke methods by index (indexes will be generated !!!)
static const std::string METHODNAME_LOGIN
Object has been constructed. Use init() to go into CONNECTED state.
SopasBase::SopasProtocol m_protocol
bool isConnected()
Returns true if the tcp connection is established.
static const std::string METHODNAME_STOP_MEASURE
SopasBase()
Default constructor.
DecoderFunctionMapByName m_decoderFunctionMapByName
UINT32 m_numberOfBytesInResponseBuffer
Number of bytes in buffer.
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
void readCallbackFunction(UINT8 *buffer, UINT32 &numOfBytes)
static const std::string COMMAND_Write_Variable_ByName
Event Acknowledge -Answer to register event.
void processFrame_CoLa_B(SopasEventMessage &frame)
UINT32 m_numberOfBytesInReceiveBuffer
Number of bytes in buffer.
static const std::string COMMAND_Invoke_Method_Answer
void copyFrameToResposeBuffer(UINT32 frameLength)
static const std::string COMMAND_Send_Event_ByIndex
bool receiveAnswer(SopasCommand cmd, std::string name, UINT32 timeout, SopasAnswer *&answer)
Take answer from read thread and decode it. Waits for a certain answer by name. Event data (scans) ar...
static const std::string COMMAND_Register_Event_ByIndex
read/write variable, invoke methods by name
static const std::string COMMAND_Read_Variable_Answer
static const std::string COMMAND_Write_Variable_ByIndex
std::string sopasCommandToString(SopasCommand cmd)
static const std::string COMMAND_Write_Variable_Answer
std::map< UINT16, DecoderFunction > DecoderFunctionMapByIndex
void removeFrameFromReceiveBuffer(UINT32 frameLength)
bool writeVariable(const std::string &variableName, BYTE *parameters, UINT16 parametersLength)
Write a variable to the sensor by name.
void setEventCallbackFunction(DecoderFunction decoderFunction, UINT16 eventIndex)
SopasEventMessage findFrameInReceiveBuffer()
Depending on the protocol the start and end of a frame will be found.
void setReadOnlyMode(bool mode)
IndexToNameMap m_indexToNameMap
void processFrame(SopasEventMessage &frame)
Reads one frame from receive buffer and decodes it.
SopasCommand stringToSopasCommand(const std::string &cmdString)
Converts strings in sopas answer buffer to SopasCommand enum.
bool m_fieldEventIsRegistered
static const std::string EVENTNAME_SUBSCRIBE_SCANS
bool m_weWantFieldData
Flag to enable/disable protection field data reception.
static const UINT16 INDEX_DEVICE_IDENT
Class that represents a message that was sent by a sensor. (Event message)
static const std::string COMMAND_Event_Acknowledge
UINT8 m_receiveBuffer[25000]
Low-Level receive buffer for all data (25000 should be enough for NAV300 Events)
std::string m_scannerName
Read from scanner.
void(* DecoderFunction)(SopasEventMessage &frame)
virtual void evalCaseResultDecoder(SopasEventMessage &msg)=0
SopasProtocol m_protocol
Used protocol (ColaA oder ColaB)
virtual void scanDataDecoder(SopasEventMessage &msg)=0
void colaA_decodeScannerTypeAndVersion(std::string *rxData)
const std::string & getScannerName() const
std::map< UINT16, std::string > IndexToNameMap
void setEventCallbackFunction(DecoderFunction decoderFunction, const std::string &eventName)
bool action_getScannerTypeAndVersion()
Reads the scanner type and version variable from the sensor and stores it in the member variables...
bool disconnect()
Closes the connection to the LMS. This is the opposite of init().
static const std::string METHODNAME_START_MEASURE
static const std::string COMMAND_Method_Result_ByIndex
SopasBase::SopasEncoding m_encoding
bool receiveAnswer_CoLa_B(SopasCommand cmd, std::string name, UINT32 timeout, SopasAnswer *&answer)
static const std::string VARIABLENAME_DATAOUTPUTRANGE
bool readVariable(const std::string &variableName, SopasAnswer *&answer)
Reads a variable from the sensor by name.
void sendCommandBuffer(UINT8 *buffer, UINT16 len)
Sends the content of the buffer via TCP to the sensor.
static const std::string COMMAND_Invoke_Method_ByName
static const std::string COMMAND_Read_Variable_ByIndex
std::string m_scannerVersion
Read from scanner.
UINT8 m_responseBuffer[1024]
Receive buffer for everything except scan data and eval case data.
double makeAngleValid(double angle)
SopasBase::SopasProtocol getProtocolType() const
Send Event (by name, receive)
~SopasEventMessage()
Destructor.
bool connect()
Connects to a sensor via tcp and reads the device name.
std::map< std::string, DecoderFunction > DecoderFunctionMapByName
bool unregisterEvent(const std::string &eventName)
Unregisters an event by name.
static const std::string COMMAND_Send_Event_ByName
bool invokeMethod(const std::string &methodeName, BYTE *parameters, UINT16 parametersLength, SopasAnswer *&answer)
Invoke a method on the sensor.
bool m_scanEventIsRegistered
static void readCallbackFunctionS(void *obj, UINT8 *buffer, UINT32 &numOfBytes)
Function that will be called on incomming data via tcp.
static const std::string COMMAND_Method_Result_ByName
virtual bool init(SopasProtocol protocol, std::string ipAddress, UINT16 portNumber, bool weWantScanData, bool weWantFieldData, bool readOnlyMode, Tcp::DisconnectFunction disconnectFunction, void *obj)
Initialization.
static const std::string METHODNAME_SET_SCANCONFIG