ethcamerasettings.h
1 /**************************************************************************
2  *
3  * File: ethcamerasettings.h
4  *
5  *
6  * Description: Contains the wrapper class definition for the ETH camera API.
7  * The ETH Camera API allows you to send and receive commands to a Ethernet Camera that supports
8  * the ISO17215 standard. This simplifies handling and communication with ETH cameras.
9  *
10  * Copyright (C) 2018 CrossControl AB
11  * All rights reserved.
12  * Contact: CrossControl AB (info@crosscontrol.com)
13  *
14 **************************************************************************/
15 
16 #ifndef ETHCAMERASETTINGS_H
17 #define ETHCAMERASETTINGS_H
18 
19 /*************************************************************************
20  * Include Files
21  *************************************************************************/
22 #include <string>
23 #include <vector>
24 #include "camtypes.h"
25 
26 /*************************************************************************
27  * Manifest constants, macros
28  *************************************************************************/
29 #ifndef MAX_WAIT_TIME_MS
30 #define MAX_WAIT_TIME_MS 1500
31 #endif
32 
33 class CameraSettings;
34 
35 namespace CrossControl {
36 
37 /*************************************************************************
38  * Class definition
39  *************************************************************************/
45 {
46 public:
47 
52 
58  ETHCameraSettings(std::string ipAddress, int portNum, int clientID = 1);
59 
63  ETHCameraSettings(ETHCameraSettings &other) = delete;
64 
69 
76 
84  ETHCamStatus open(std::string ipAddress, int portNum);
85 
93  ETHCamStatus openServiceDiscovery(std::vector<std::string> multicastGroups, int portNumber);
94 
100  ETHCamStatus openServiceDiscovery(int portNumber);
101 
107 
113 
120  ETHCamStatus getDatasheet(Datasheet &datasheet, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
121 
128  ETHCamStatus getCamStatus(CamStatus &camStatus, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
129 
136  ETHCamStatus setCamExclusive(const int expireTimeSeconds = 5, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
137 
144  ETHCamStatus eraseCamExclusive(const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
145 
153  ETHCamStatus setRegionOfInterest(const RegionOfInterest regionOfInterest, const uint32_t roiIndex, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
154 
163  ETHCamStatus getRegionOfInterest(RegionOfInterest &regionOfInterest, const uint32_t roiIndex, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
164 
171  ETHCamStatus getRegionsOfInterest(std::vector<uint32_t> &roiIndices, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
172 
179  ETHCamStatus eraseRegionOfInterest(const uint32_t roiIndex, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
180 
187  ETHCamStatus subscribeROIVideo(const uint32_t roiIndex = 0, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
188 
196  ETHCamStatus subscribeROIVideo(VideoContent &videoContent, const uint32_t roiIndex = 0, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
197 
204  ETHCamStatus unsubscribeROIVideo(const uint32_t roiIndex, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
205 
213  ETHCamStatus setBrightnessControl(const SignedControl sControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
214 
221  ETHCamStatus getBrightnessControl(SignedControl &sControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
222 
230  ETHCamStatus setSaturationControl(const UnsignedControl uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
231 
238  ETHCamStatus getSaturationControl(UnsignedControl &uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
239 
247  ETHCamStatus setGammaControl(const UnsignedControl uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
248 
256  ETHCamStatus getGammaControl(UnsignedControl &uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
257 
265  ETHCamStatus setHeaterControl(const UnsignedControl uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
266 
273  ETHCamStatus getHeaterControl(UnsignedControl &uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
274 
281  ETHCamStatus setCamRegister(const ImagerRegister imagerRegister, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
282 
291  ETHCamStatus setCamRegister(const uint16_t regAddress, const uint16_t regValue, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
292 
300  ETHCamStatus setCamRegisters(const std::vector<ImagerRegister> &imagerRegisters, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
301 
309  ETHCamStatus getCamRegister(const uint16_t regAddress, uint16_t &regValue, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
310 
318  ETHCamStatus getCamRegisters(const std::vector<uint16_t> &addressList, std::vector<ImagerRegister> &imagerRegisters, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
319 
326  ETHCamStatus sendMessageNoResponse(const unsigned char *data, const size_t messageLength) const;
327 
337  ETHCamStatus sendMessageWithResponse(const unsigned char * data, const size_t messageLength, unsigned char * responseData, size_t &responseLength, const int maxWaitTimeMs = MAX_WAIT_TIME_MS) const;
338 
345 
351  uint16_t getSessionID() const;
352 
358  void setSessionID(uint16_t arg);
359 
364  uint16_t getClientID() const;
365 
371  void setClientID(uint16_t arg);
372 
378  static std::string stringifyETHCamStatus(const ETHCamStatus camStatus);
379 
380 private:
381  CameraSettings* m_cameraSettings;
382 };
383 }
384 
385 #endif // ETHCAMERASETTINGS_H
ETHCamStatus openServiceDiscovery(std::vector< std::string > multicastGroups, int portNumber)
Opens a socket to look for Service Discovery messages.
The sIPv4Option struct Describes the IPv4EndpointOption.
Definition: camtypes.h:501
ETHCamStatus getHeaterControl(UnsignedControl &uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to populate the Heater Control data struct with data from the camera.
ETHCamStatus getCamRegisters(const std::vector< uint16_t > &addressList, std::vector< ImagerRegister > &imagerRegisters, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
getCamRegisters Attempts to read a list of imager registers
The ETHCameraSettings class This class is the inteface between the ETH Camera and the user...
Definition: ethcamerasettings.h:44
void setClientID(uint16_t arg)
Sets the client ID.
ETHCamStatus getCamRegister(const uint16_t regAddress, uint16_t &regValue, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Reads the content of a register block of the camera imager.
ETHCamStatus setRegionOfInterest(const RegionOfInterest regionOfInterest, const uint32_t roiIndex, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attehmps to set the parameters for the region of interest addressed by index.
void setSessionID(uint16_t arg)
Sets a new session ID.
Defines the region of interest. The ROIs (regions of interest) are used to acquire data from the came...
Definition: camtypes.h:451
ETHCameraSettings()
Creates the API class.
ETHCamStatus closeServiceDiscoverySocket()
Closes the Service Discovery socket.
ETHCamStatus setGammaControl(const UnsignedControl uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to set the control for the gamma correction of the camera.
ETHCamStatus close()
Closes the socket.
ETHCamStatus getDatasheet(Datasheet &datasheet, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to fill a struct with the datasheet of the camera.
ETHCamStatus
Returncodes and error messages. Can be sent from either the camera or the API.
Definition: camtypes.h:66
ETHCamStatus getSaturationControl(UnsignedControl &uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to populate the Saturation Control data struct with data from the camera.
ETHCamStatus open()
Opens a UDP-socket with the address and port number previously supplied.
Definition: camtypes.h:25
ETHCamStatus getRegionsOfInterest(std::vector< uint32_t > &roiIndices, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Gets the indices for all the regions of interest.
ETHCamStatus getCamStatus(CamStatus &camStatus, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to fill a struct with the status of the ETH Camera.
Defines the camera status information.
Definition: camtypes.h:252
ETHCamStatus setCamRegisters(const std::vector< ImagerRegister > &imagerRegisters, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to write (atomic access) the content of a register block of the camera imager.
ETHCamStatus unsubscribeROIVideo(const uint32_t roiIndex, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Ends the transmission of a video stream for the requested ROI index.
~ETHCameraSettings()
Deletes the API class and frees all allocated memory.
ETHCamStatus setBrightnessControl(const SignedControl sControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to set the control for the brightness circuits of the camera.
ETHCamStatus sendMessageWithResponse(const unsigned char *data, const size_t messageLength, unsigned char *responseData, size_t &responseLength, const int maxWaitTimeMs=MAX_WAIT_TIME_MS) const
Sends a custom message to the camera and reads the response.
ETHCamStatus getGammaControl(UnsignedControl &uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to populate the Gamma Control data struct with data from the camera.
ETHCamStatus setHeaterControl(const UnsignedControl uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to set the controls for the heater of the camera.
ETHCamStatus getBrightnessControl(SignedControl &sControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to populate the Brigthness Control data struct with data from the camera.
Definition of an address/value pair of imager register.
Definition: camtypes.h:217
ETHCamStatus setCamRegister(const ImagerRegister imagerRegister, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to writes the content of a register of the cameras imager addressed by physical register add...
ETHCamStatus setSaturationControl(const UnsignedControl uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to set the control for the saturation circuits of the camera.
uint16_t getClientID() const
Returns the client ID number.
ETHCamStatus eraseRegionOfInterest(const uint32_t roiIndex, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempt to erases all parameters for the requested region of interest.
ETHCamStatus getRegionOfInterest(RegionOfInterest &regionOfInterest, const uint32_t roiIndex, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Gets the parameters for the region of interest addressed by index.
ETHCamStatus serviceDiscoveryGetIPv4(IPv4Option &option)
Reads the socket for a Service Discovery - Offer Service message with the IPv4 endpoint option...
ETHCamStatus subscribeROIVideo(const uint32_t roiIndex=0, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Starts the transmission of a video stream for the requested ROI index.
uint16_t getSessionID() const
Returns the session ID number.
ETHCamStatus setCamExclusive(const int expireTimeSeconds=5, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to assign the control of the camera exclusively to the requesting client.
ETHCamStatus sendMessageNoResponse(const unsigned char *data, const size_t messageLength) const
Sends a custom message, without expecting a response from the camera.
Definition of a signed camera control.
Definition: camtypes.h:273
Definition of a unsigned camera control.
Definition: camtypes.h:283
ETHCamStatus eraseCamExclusive(const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to remove the exclusive control look for the requesting client.
Defines the format of a video content notification package.
Definition: camtypes.h:238
static std::string stringifyETHCamStatus(const ETHCamStatus camStatus)
Returns the ETHCamStatus enum as a std::string, useful for debugging.
Defines the characteristics of the camera.
Definition: camtypes.h:397