15 #ifndef VISIONTRANSFER_PARAMETERTRANSFER_H 16 #define VISIONTRANSFER_PARAMETERTRANSFER_H 18 #include "visiontransfer/networking.h" 19 #include "visiontransfer/parameterinfo.h" 20 #include "visiontransfer/tokenizer.h" 21 #include "visiontransfer/parameterset.h" 26 #include <condition_variable> 154 static constexpr
int SOCKET_TIMEOUT_MS = 500;
157 static constexpr
unsigned char MESSAGE_READ_INT = 0x01;
158 static constexpr
unsigned char MESSAGE_READ_DOUBLE = 0x02;
159 static constexpr
unsigned char MESSAGE_READ_BOOL = 0x03;
160 static constexpr
unsigned char MESSAGE_WRITE_INT = 0x04;
161 static constexpr
unsigned char MESSAGE_WRITE_DOUBLE = 0x05;
162 static constexpr
unsigned char MESSAGE_WRITE_BOOL = 0x06;
163 static constexpr
unsigned char MESSAGE_ENUMERATE_PARAMS = 0x07;
167 static constexpr
unsigned int RECV_BUF_SIZE = 1024*1024;
168 char recvBuf[RECV_BUF_SIZE];
169 unsigned int recvBufBytes;
170 unsigned int pollDelay;
172 std::string networkErrorString;
176 std::shared_ptr<std::thread> receiverThread;
183 std::mutex readyMutex;
185 std::condition_variable readyCond;
189 std::map<int, std::condition_variable> waitConds;
191 std::map<int, std::mutex> waitCondMutexes;
193 std::map<int, std::pair<bool, std::string> > lastSetRequestResult;
196 void waitNetworkReady();
202 void blockingCallThisThread(std::function<
void()>,
int waitMaxMilliseconds=1000);
204 void receiverRoutine();
207 void readParameter(
unsigned char messageType,
const char*
id,
unsigned char* dest,
int length);
208 void recvData(
unsigned char* dest,
int length);
210 std::map<std::string, ParameterInfo> recvEnumeration();
void writeIntParameter(const char *id, int value)
Writes an integer value to a parameter of the parameter server.
Allows a configuration of device parameters over the network.
void writeParameter(const char *id, const T &value)
Writes a scalar value to a parameter of the parameter server.
ParameterTransfer(const char *address, const char *service="7683")
Creates an object and connects to the given server.
bool readBoolParameter(const char *id)
Reads a boolean value from the parameter server.
std::map< std::string, ParameterInfo > getAllParameters()
Enumerates all parameters as reported by the device.
param::ParameterSet & getParameterSet()
Returns a reference to the internal parameter set (once the network handshake is complete) ...
double readDoubleParameter(const char *id)
Reads a double precision floating point value from the parameter server.
void writeBoolParameter(const char *id, bool value)
Writes a boolean value to a parameter of the parameter server.
int readIntParameter(const char *id)
Reads an integer value from the parameter server.
void writeDoubleParameter(const char *id, double value)
Writes a double precision floating point value to a parameter of the parameter server.