* @param start_time only mandatory for the first point in the trajectory, a double representing the UNIX epoch of the starting instant of the trajectory
* The following 3 lines of code allow the overloaded functions to ignore the optional parameter and use the default one defined in the original SRTMinorServoCommandLibrary header file
* Python module definition. Since the original SRTMinorServoCommandLibrary only contains static functions, we write the Python module with static functions only, omitting the class
* This class privately extends the type std::map<std::string, std::variant<long, double, std::string>>.
* It is therefore an std::map which can hold different types of values, such as long, double and str::string, in the same container.
* It is used to store the answers received from the SRTMinorServo Leonardo system.
* This design was critical since all the received values have heterogeneous keys and values.
* With this object, the SRTMinorServoSocket can correctly retrieve and store all the received values without having to know the keys or types a priori.
*/
/*
* Declare this class as friend since it will have to iterate through the inner map
* get method. It must be used with a template parameter, in order for the SRTMinorServoAnswerMap to be able to retrieve the correct type of object for the given key.
* The method will automatically convert the retrieved long, double or std::string to the given template type.
* @param T the type (i.e.: int, long, double, char*) of the object to be retrieved. It can be anything derived from integral, floating point or string values.
* @param key the key assigned to the value you want to retrieve
* @return the value associated to given key 'key', returned as template type 'T', if possible. Be aware that some casts (i.e.: long to int, double to float) will lose precision and/or overflow
* @throw std::bad_variant_access when retrieving the stored value by asking the wrong type (i.e.: stored type is a double but T is char*)
* @throw std::runtime_error when attempting to retrieve a value with a type which cannot be stored in the container (anything not integral, not floating point and not similar to std::string)
* put method. The template parameter is automatically deducted from the 'value' argument. Stores the given 'value' associated with key 'key'
* @param key the key associated to the stored value 'value'
* @param value the value we are storing with the given key 'key'
* @throw std::runtime_error when attempting to store a value with a type which cannot be stored in the container (anything not integral, not floating point and not similar to std::string)
* Shared mutex to control read and write accesses. Multiple reading access are permitted and will only block writing access. Writing access will block all accesses
@@ -26,14 +29,14 @@ class SRTMinorServoCommandLibrary
public:
/**
* Builds the command used to ask the status of the MSCU or, eventually, a single servo
* @param servo_id the ID string of the eventual single servo to retrieve the status
* @param servo_id the ID string of the eventual single servo to retrieve the status. Send no servo_id argument to retrieve the general status of the system
* @return the composed message
*/
staticstd::stringstatus(std::stringservo_id="");
/**
* Builds the command used to configure the telescope for an observation
* @param configuration the desired observing configuration
* Builds the command used to configure the telescope for a specific focal path
* @param configuration the desired focal path to command to the minor servo systems
* @return the composed message
*/
staticstd::stringsetup(std::stringconfiguration);
@@ -54,7 +57,7 @@ public:
staticstd::stringstop(std::stringservo_id);
/*
* Builds the command used to move a single servo to a given set of coordinates
* Builds the command used to move a single servo to a given set of virtual coordinates
* @param servo_id the ID string of the single servo to be moved
* @param coordinates a vector containing the N coordinates to be sent to the servo
* Builds the command used to provide a single tracking set of coordinates to a single servo
* Builds the command used to provide a single tracking point of virtual coordinates to a single servo
* @param servo_id the ID string of the single servo to send the command to
* @param trajectory_id the ID number of the trajectory the given set of coordinates belongs to
* @param point_id the ID number of the given set of coordinates inside the trajectory
* @param coordinates a vector containing the N coordinates the servo have to move to at the given time
* @param start_time only mandatory for the first point in the trajectory, a double representing the UNIX epoch of the starting instant of the trajectory
* @param start_time only mandatory for the first point in the trajectory, a double representing the UNIX Epoch of the starting instant of the trajectory
* Parses the received answer by splitting it and synamically populating a std::map
* Parses the received answer by splitting it and dynamically populating a SRTMinorServoAnswerMap object
* @param answer the string containing the answer received from the VBrain proxy
* @return a std::map (dictionary) containing the answer splitted into keys and values. The keys are always std::string, the values can either be int, double or std::string.
* @return a SRTMinorServoAnswerMap dictionary containing the answer splitted into keys and values. The keys are always std::string, the values can either be long, double or std::string.