reflow-oven-control-sw/stm-firmware/include/reflow-controller/temp-profile/temp-profile-parser.h

106 lines
3.7 KiB
C
Raw Permalink Normal View History

2021-03-18 22:44:05 +01:00
/* Reflow Oven Controller
*
* Copyright (C) 2021 Mario Hüttel <mario.huettel@gmx.net>
*
* This file is part of the Reflow Oven Controller Project.
*
* The reflow oven controller is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the reflow oven controller project.
* If not, see <http://www.gnu.org/licenses/>.
*/
2021-05-22 16:46:26 +02:00
/**
2021-10-23 21:00:21 +02:00
* @defgroup temp-profile Temperature Profile Parser and Executer
2021-05-22 16:46:26 +02:00
* @{
*/
2021-03-18 22:44:05 +01:00
#ifndef __CONFIG_PARSER_TEMP_PROFILE_PARSER_H__
#define __CONFIG_PARSER_TEMP_PROFILE_PARSER_H__
#include <stdint.h>
#include <linklist-lib/singly-linked-list.h>
2021-03-18 22:44:05 +01:00
2021-05-22 16:46:26 +02:00
/**
* @brief Command types the temperature profile language supports
*/
2021-03-18 22:44:05 +01:00
enum pl_command_type {
2021-05-22 16:46:26 +02:00
PL_PID_CONF = 0, /**< @brief Configure the PID parameters and start PID controller */
PL_SET_TEMP, /**< @brief Set the target temperature of the PID controller */
PL_SET_RAMP, /**< @brief Perform a temperature ramp */
PL_WAIT_FOR_TEMP, /**< @brief Wait until a temperature is reached */
PL_WAIT_FOR_TIME, /**< @brief Wait for a specific amount of time */
PL_LOUDSPEAKER_SET, /**< @brief Set the loudspeaker/beeper */
PL_OFF, /**< @brief Disable the temperature output and shutdown the PID controller */
PL_CLEAR_FLAGS, /**< @brief Try clear all flags */
2021-12-26 20:59:08 +01:00
PL_DIGIO_CONF, /**< @brief Configure a DIGIO pin */
PL_DIGIO_SET, /**< @brief Set a DIGIO pin */
PL_DIGIO_WAIT, /**< @brief Wait until a DIGIO pin is set to the specified level */
2021-05-22 16:46:26 +02:00
_PL_NUM_CMDS, /**< @brief Sentinel to determine the total amount of commands */
2021-03-18 22:44:05 +01:00
};
2021-05-22 16:46:26 +02:00
/**
* @brief Profile language parser return value
*/
2021-03-18 22:44:05 +01:00
enum pl_ret_val {
2021-05-22 16:46:26 +02:00
PL_RET_SUCCESS = 0, /**< @brief Profile parsed successfully */
PL_RET_DISK_ERR, /**< @brief Disk I/O error */
PL_RET_PARAM_ERR, /**< @brief Function parameter error */
PL_RET_LIST_FULL, /**< @brief Command list is full. Temperature profile is longer than the specified maximum */
PL_RET_SCRIPT_ERR, /**< @brief Syntax error in temperature profile */
2021-03-18 22:44:05 +01:00
};
2021-05-22 16:46:26 +02:00
/**
2021-10-23 21:14:24 +02:00
* @brief Maximum parameter count of a command.
2021-05-22 16:46:26 +02:00
*/
#define PROFILE_LANG_MAX_NUM_ARGS (8)
2021-03-18 22:44:05 +01:00
2021-05-22 16:46:26 +02:00
/**
* @brief Structure representing a command in a temperature profile.
*/
2021-03-18 22:44:05 +01:00
struct pl_command {
2021-05-22 16:46:26 +02:00
enum pl_command_type cmd; /**< @brief Command */
float params[PROFILE_LANG_MAX_NUM_ARGS]; /**< @brief Parameters */
2021-03-18 22:44:05 +01:00
};
/**
* @brief Parse a temperature profile from file and generate the command list
*
* Commands are parsed into the list given by \p command_list. If \p max_len is reached,
* the function returns with @ref PL_RET_LIST_FULL
*
* In any case, the command list not cleared afterwards. The user has to clear the command list manually
* using @ref temp_profile_free_command_list.
*
* @param filename File to parse
* @param[in, out] command_list Command list to output @ref pl_command elements in.
* @param max_len maximum number of commands.
* @param cmds_parsed Number of parsed commands
* @return
*/
2021-03-18 22:44:05 +01:00
enum pl_ret_val temp_profile_parse_from_file(const char *filename,
SlList **command_list,
uint32_t max_len,
2021-03-18 22:44:05 +01:00
uint32_t *cmds_parsed);
/**
2021-10-23 21:14:24 +02:00
* @brief Fully free a comamnd list including hte stored command structures.
*
* \p list's destination is set to NULL to indicate the empty list.
*
* @param[in, out] list Pointer to list.
*/
void temp_profile_free_command_list(SlList **list);
2021-03-18 22:44:05 +01:00
#endif /* __CONFIG_PARSER_TEMP_PROFILE_PARSER_H__ */
2021-05-22 16:46:26 +02:00
/** @} */