Documentation updated
This commit is contained in:
@@ -56,7 +56,7 @@ public:
|
||||
*/
|
||||
virtual void exitState(Equipment<T>* equipment) {}
|
||||
/**
|
||||
* @brief Logic to apply all strategies created.
|
||||
* @brief Applies all registered strategies for the current state.
|
||||
* @param equipment Pointer to the Equipment instance.
|
||||
*/
|
||||
virtual void _applyStrategies(Equipment<T>* equipment);
|
||||
@@ -64,14 +64,30 @@ public:
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Adds a behavior strategy for a specific Modbus point.
|
||||
* @param pointDescription The description of the Modbus point to apply the strategy to.
|
||||
* @param strategy A pointer to the Strategy_Behavior object. The State will take ownership.
|
||||
* @brief Gets the value of a Modbus point, handling float types correctly.
|
||||
* This is a helper function to safely read a value from a point, whether it's
|
||||
* a standard integer register or a `ModbusFloatDecorator`.
|
||||
* @param equipment Pointer to the Equipment instance.
|
||||
* @param pointName The description key of the Modbus point to read.
|
||||
* @return The value of the point as a float. Returns 0.0f if not found.
|
||||
*/
|
||||
float getPointValue(Equipment<T>* equipment, const std::string& pointName);
|
||||
/**
|
||||
* @brief Sets the value of a Modbus point, handling float types correctly.
|
||||
* This is a helper function to safely write a value to a point, whether it's
|
||||
* a standard integer register or a `ModbusFloatDecorator`.
|
||||
* @param equipment Pointer to the Equipment instance.
|
||||
* @param pointName The description key of the Modbus point to write to.
|
||||
* @param value The float value to set. It will be rounded for integer points.
|
||||
*/
|
||||
void setPointValue(Equipment<T>* equipment, const std::string& pointName, float value);
|
||||
/**
|
||||
* @brief Adds a behavior strategy for a specific Modbus point in this state.
|
||||
* @param pointDescription The description of the Modbus point to apply the strategy to.
|
||||
* @param strategy A pointer to the Strategy_Behavior object. The State takes ownership.
|
||||
*/
|
||||
void addStrategy(const std::string& pointDescription, Strategy_Behavior* strategy);
|
||||
std::map<std::string, Strategy_Behavior*> _strategies;
|
||||
std::map<std::string, Strategy_Behavior*> _strategies; /**< @brief Map of strategies active in this state, keyed by point description. */
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -95,6 +111,15 @@ void State<T>::addStrategy(const std::string& pointDescription, Strategy_Behavio
|
||||
this->_strategies[pointDescription] = strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the value of a Modbus point, correctly handling float types.
|
||||
* This helper function checks if the point is a `ModbusFloatDecorator` and calls
|
||||
* `getFloatValue()` if it is. Otherwise, it gets the standard integer value and
|
||||
* casts it to a float.
|
||||
* @param equipment Pointer to the Equipment instance.
|
||||
* @param pointName The description key of the Modbus point.
|
||||
* @return The point's value as a float. Returns 0.0f if the point is not found.
|
||||
*/
|
||||
template<typename T>
|
||||
float State<T>::getPointValue(Equipment<T>* equipment, const std::string& pointName) {
|
||||
ModbusPoint<T>* point = equipment->getModbusPoint(pointName);
|
||||
@@ -109,6 +134,15 @@ float State<T>::getPointValue(Equipment<T>* equipment, const std::string& pointN
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the value of a Modbus point, correctly handling float types.
|
||||
* This helper function checks if the point is a `ModbusFloatDecorator` and calls
|
||||
* `setFloatValue()` if it is. Otherwise, it rounds the float to the nearest
|
||||
* integer and calls the standard `setValue()`.
|
||||
* @param equipment Pointer to the Equipment instance.
|
||||
* @param pointName The description key of the Modbus point.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
template<typename T>
|
||||
void State<T>::setPointValue(Equipment<T>* equipment, const std::string& pointName, float value) {
|
||||
ModbusPoint<T>* point = equipment->getModbusPoint(pointName);
|
||||
|
||||
Reference in New Issue
Block a user