libvisiontransfer  6.4.0
parametertransfer.h
1 /*******************************************************************************
2  * Copyright (c) 2019 Nerian Vision GmbH
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *******************************************************************************/
14 
15 #ifndef VISIONTRANSFER_PARAMETERTRANSFER_H
16 #define VISIONTRANSFER_PARAMETERTRANSFER_H
17 
18 #include "visiontransfer/networking.h"
19 
20 namespace visiontransfer {
21 namespace internal {
22 
37 public:
45  ParameterTransfer(const char* address, const char* service = "7683");
47 
58  int readIntParameter(int32_t id);
59 
71  double readDoubleParameter(int32_t id);
72 
83  bool readBoolParameter(int32_t id);
84 
95  void writeIntParameter(int32_t id, int32_t value);
96 
107  void writeDoubleParameter(int32_t id, double value);
108 
119  void writeBoolParameter(int32_t id, int32_t value);
120 
121 public:
122  static constexpr int SOCKET_TIMEOUT_MS = 500;
123 
124  // Message types
125  static constexpr unsigned char MESSAGE_READ_INT = 0x01;
126  static constexpr unsigned char MESSAGE_READ_DOUBLE = 0x02;
127  static constexpr unsigned char MESSAGE_READ_BOOL = 0x03;
128  static constexpr unsigned char MESSAGE_WRITE_INT = 0x04;
129  static constexpr unsigned char MESSAGE_WRITE_DOUBLE = 0x05;
130  static constexpr unsigned char MESSAGE_WRITE_BOOL = 0x06;
131 
132  SOCKET socket;
133 
134  void checkProtocolVersion();
135  void readParameter(unsigned char messageType, int32_t id, unsigned char* dest, int length);
136  void recvData(unsigned char* dest, int length);
137 
138  template<typename T>
139  void writeParameter(unsigned char messageType, int32_t id, T value);
140 };
141 
142 }} // namespace
143 
144 #endif
void writeDoubleParameter(int32_t id, double value)
Writes a double precision floating point value to a parameter of the parameter server.
Allows a configuration of device parameters over the network.
bool readBoolParameter(int32_t id)
Reads a boolean value from the parameter server.
void writeBoolParameter(int32_t id, int32_t value)
Writes a boolean value to a parameter of the parameter server.
double readDoubleParameter(int32_t id)
Reads a double precision floating point value from the parameter server.
ParameterTransfer(const char *address, const char *service="7683")
Creates an object and connects to the given server.
int readIntParameter(int32_t id)
Reads an integer value from the parameter server.
void writeIntParameter(int32_t id, int32_t value)
Writes an integer value to a parameter of the parameter server.
Nerian Vision Technologies