API
 
Loading...
Searching...
No Matches
ocamUtils.hpp
Go to the documentation of this file.
1/** \file ocamUtils.hpp
2 * \brief Utilities for the OCAM camera
3 *
4 * \ingroup ocam2KCtrl_files
5 */
6
7#ifndef ocamUtils_hpp
8#define ocamUtils_hpp
9
10#include <mx/ioutils/stringUtils.hpp>
11
12namespace MagAOX
13{
14namespace app
15{
16
17/// Structure to hold the OCAM camera temperature readings returned by the device.
18/**
19 * \ingroup ocam2KCtrl
20 */
22{
23 float CCD{ 0 }; ///< The detector temperature.
24 float CPU{ 0 }; ///< The CPU temperature
25 float POWER{ 0 }; ///< Power supply temperature
26 float BIAS{ 0 }; ///< Bias temperature
27 float WATER{ 0 }; ///< Cooling water temperature
28 float LEFT{ 0 }; ///< The left amplifier temperature
29 float RIGHT{ 0 }; ///< The right amplifier temperature
30 float SET{ 0 }; ///< The CCD set temeperature
31 float COOLING_POWER{ 0 }; ///< the cooling power in 100 mw.
32
33 /// Test for equality between two ocamTemps structures
34 /**
35 * \returns true if all members are equal
36 * \returns false otherwise
37 */
38 bool operator==( const ocamTemps &t /**< [in] the struct to compare to*/ )
39 {
40 return ( CCD == t.CCD && POWER == t.POWER && BIAS == t.BIAS && WATER == t.WATER && LEFT == t.LEFT &&
41 RIGHT == t.RIGHT && SET == t.SET && COOLING_POWER == t.COOLING_POWER );
42 }
43
44 /// Set all values to the invalid value, -999.
46 {
47 CCD = -999;
48 CPU = -999;
49 POWER = -999;
50 BIAS = -999;
51 WATER = -999;
52 LEFT = -999;
53 RIGHT = -999;
54 SET = -999;
55 COOLING_POWER = -999;
56
57 return 0;
58 }
59};
60
61/// Parse the OCAM temp query and fill the ocamTemps structure.
62/**
63 * \b Tests
64 * - Parsing the temp response \ref tests_MagAOX_app_ocamUtils_parse_temp_response "[test doc]"
65 *
66 * \returns 0 on success
67 * \returns -1 on error
68 *
69 * \ingroup ocam2KCtrl
70 */
71int parseTemps( ocamTemps &temps, ///< [out] the struture of temperature readings
72 const std::string &tstr ///< [in] the device response to parse.
73)
74{
75 std::vector<std::string> v;
76 mx::ioutils::parseStringVector( v, tstr, "[]" );
77
78 if( v.size() < 18 )
79 return -1;
80
81 temps.CCD = mx::ioutils::convertFromString<float>( v[1] );
82 temps.CPU = mx::ioutils::convertFromString<float>( v[3] );
83 temps.POWER = mx::ioutils::convertFromString<float>( v[5] );
84 temps.BIAS = mx::ioutils::convertFromString<float>( v[7] );
85 temps.WATER = mx::ioutils::convertFromString<float>( v[9] );
86 temps.LEFT = mx::ioutils::convertFromString<float>( v[11] );
87 temps.RIGHT = mx::ioutils::convertFromString<float>( v[13] );
88 temps.SET = mx::ioutils::convertFromString<float>( v[15] ) / 10.0;
89 temps.COOLING_POWER = mx::ioutils::convertFromString<float>( v[17] );
90
91 return 0;
92}
93
94/// Parse the FPS response
95/** Parses the OCAM 2K response to the "fps" query.
96 *
97 * \returns 0 on success
98 * \returns -1 on error
99 *
100 * \todo add test for FPS
101 *
102 * \ingroup ocam2KCtrl
103 */
104int parseFPS( float &fps, ///< [out] the fps returned by the camera
105 const std::string &fstr ///< [in] the response to parse
106)
107{
108 std::vector<std::string> v;
109 mx::ioutils::parseStringVector( v, fstr, "[]" );
110
111 if( v.size() < 3 )
112 return -1;
113
114 fps = mx::ioutils::convertFromString<float>( v[1] );
115
116 return 0;
117}
118
119/// Parse the EM gain response
120/** Example response: "Gain set to 2 \n\n", with the trailing space.
121 * Expects gain >=1 and <= 600, otherwise returns an error.
122 *
123 * \b Tests
124 * - Parsing the gain response \ref tests_MagAOX_app_ocamUtils_parse_gain_response "[test doc]"
125 *
126 * \returns 0 on success, and emGain set to a value >= 1
127 * \returns -1 on error, and emGain will be set to 0.
128 *
129 * \ingroup ocam2KCtrl
130 */
131int parseEMGain( unsigned &emGain, ///< [out] the value of gain returned by the camera
132 const std::string &fstr ///< [in] the query response from the camera.
133)
134{
135 std::vector<std::string> v;
136 mx::ioutils::parseStringVector( v, fstr, " " );
137
138 if( v.size() != 5 )
139 {
140 emGain = 0;
141 return -1;
142 }
143
144 emGain = mx::ioutils::convertFromString<unsigned>( v[3] );
145
146 if( emGain < 1 || emGain > 600 )
147 {
148 emGain = 0;
149 return -1;
150 }
151
152 return 0;
153}
154
155} // namespace app
156} // namespace MagAOX
157
158#endif // ocamUtils_hpp
int parseFPS(float &fps, const std::string &fstr)
Parse the FPS response.
int parseTemps(ocamTemps &temps, const std::string &tstr)
Parse the OCAM temp query and fill the ocamTemps structure.
Definition ocamUtils.hpp:71
int parseEMGain(unsigned &emGain, const std::string &fstr)
Parse the EM gain response.
Definition dm.hpp:26
Structure to hold the OCAM camera temperature readings returned by the device.
Definition ocamUtils.hpp:22
float WATER
Cooling water temperature.
Definition ocamUtils.hpp:27
int setInvalid()
Set all values to the invalid value, -999.
Definition ocamUtils.hpp:45
float COOLING_POWER
the cooling power in 100 mw.
Definition ocamUtils.hpp:31
float BIAS
Bias temperature.
Definition ocamUtils.hpp:26
bool operator==(const ocamTemps &t)
Test for equality between two ocamTemps structures.
Definition ocamUtils.hpp:38
float SET
The CCD set temeperature.
Definition ocamUtils.hpp:30
float CCD
The detector temperature.
Definition ocamUtils.hpp:23
float POWER
Power supply temperature.
Definition ocamUtils.hpp:25
float CPU
The CPU temperature.
Definition ocamUtils.hpp:24
float LEFT
The left amplifier temperature.
Definition ocamUtils.hpp:28
float RIGHT
The right amplifier temperature.
Definition ocamUtils.hpp:29