API
 
Loading...
Searching...
No Matches
zaberUtils.hpp
Go to the documentation of this file.
1/** \file zaberUtils.hpp
2 * \brief utilties for working with zaber stages
3 *
4 * \ingroup zaberLowLevel_files
5 */
6
7#ifndef zaberUtils_hpp
8#define zaberUtils_hpp
9
10#include <iostream>
11
12
13#define ZUTILS_E_NOAT (-100)
14#define ZUTILS_E_NOSP (-101)
15#define ZUTILS_E_BADADD (-102)
16#define ZUTILS_E_SERIALSIZE (-103)
17
18namespace MagAOX
19{
20namespace app
21{
22
23/// Parse the system.serial query
24/**
25 * \returns 0 on success
26 * \returns <0 on error with error code primarily meant for unit testing
27 *
28 * \ingroup zaberLowLevel
29 */
30int parseSystemSerial( std::vector<int> & address,
31 std::vector<std::string> & serial,
32 const std::string & response
33 )
34{
35 size_t at = response.find('@', 0);
36
37 if(at == std::string::npos)
38 {
39 return ZUTILS_E_NOAT;
40 }
41
42 while(at != std::string::npos)
43 {
44 size_t sp = response.find(' ', at);
45
46 if(sp == std::string::npos)
47 {
48 return ZUTILS_E_NOSP;
49 }
50
51 if(sp-at != 3 ) //Address should be 2 characters
52 {
53 return ZUTILS_E_BADADD;
54 }
55
56 int add = std::stoi( response.substr(at+1, sp-at-1));
57
58 address.push_back(add);
59
60 at = response.find('@', at+1);
61
62 sp = response.rfind(' ', at);
63 size_t ed = response.find_first_of("\n@", sp);
64 if(ed == std::string::npos) ed = response.size();
65
66 if(ed-sp-1 > 6)
67 {
69 }
70
71 std::string ser = response.substr(sp+1, ed - sp-1);
72
73 serial.push_back(ser);
74 }
75
76 return 0;
77}
78
79} //namespace app
80} //namespace MagAOX
81
82#endif //zaberUtils_hpp
int parseSystemSerial(std::vector< int > &address, std::vector< std::string > &serial, const std::string &response)
Parse the system.serial query.
Definition dm.hpp:24
#define ZUTILS_E_NOSP
#define ZUTILS_E_NOAT
#define ZUTILS_E_SERIALSIZE
#define ZUTILS_E_BADADD