Restructuring and comments
This commit is contained in:
		@@ -1,52 +0,0 @@
 | 
			
		||||
/* 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/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef __TEMP_PROFILE_EXECUTER_H__
 | 
			
		||||
#define __TEMP_PROFILE_EXECUTER_H__
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <reflow-controller/config-parser/temp-profile-parser.h>
 | 
			
		||||
 | 
			
		||||
#define MAX_PROFILE_LENGTH 64
 | 
			
		||||
 | 
			
		||||
enum tpe_status {
 | 
			
		||||
	TPE_OFF,
 | 
			
		||||
	TPE_RUNNING,
 | 
			
		||||
	TPE_ABORT,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct tpe_current_state {
 | 
			
		||||
	enum tpe_status status;
 | 
			
		||||
	float setpoint;
 | 
			
		||||
	uint64_t start_timestamp;
 | 
			
		||||
	uint32_t step;
 | 
			
		||||
	uint32_t profile_steps;
 | 
			
		||||
	enum pl_command_type current_command;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum pl_ret_val temp_profile_executer_start(const char *filename);
 | 
			
		||||
 | 
			
		||||
int temp_profile_executer_handle(void);
 | 
			
		||||
 | 
			
		||||
const struct tpe_current_state *temp_profile_executer_status(void);
 | 
			
		||||
 | 
			
		||||
int temp_profile_executer_stop(void);
 | 
			
		||||
 | 
			
		||||
#endif /* __TEMP_PROFILE_EXECUTER_H__ */
 | 
			
		||||
@@ -0,0 +1,94 @@
 | 
			
		||||
/* 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/>.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @addtogroup temp-profile
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef __TEMP_PROFILE_EXECUTER_H__
 | 
			
		||||
#define __TEMP_PROFILE_EXECUTER_H__
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <reflow-controller/temp-profile/temp-profile-parser.h>
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Maximum command count of a temperature profile the parser will handle
 | 
			
		||||
 */
 | 
			
		||||
#define MAX_PROFILE_LENGTH 64
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Status of the temperature profile execution
 | 
			
		||||
 */
 | 
			
		||||
enum tpe_status {
 | 
			
		||||
	TPE_OFF, /**< @brief No profile execution */
 | 
			
		||||
	TPE_RUNNING, /**< @brief Profile currently running */
 | 
			
		||||
	TPE_ABORT, /**< @brief Profile execution aborted due to event / error */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief The current execution state of the temperature profile
 | 
			
		||||
 */
 | 
			
		||||
struct tpe_current_state {
 | 
			
		||||
	enum tpe_status status; /**< @brief Execution status */
 | 
			
		||||
	float setpoint; /**< @brief Temperature setpoint in degrees Celsius */
 | 
			
		||||
	uint64_t start_timestamp; /**< @brief The millisicend tick timestamp, the profile execution was started */
 | 
			
		||||
	uint32_t step; /**< @brief Current execution step. Starts at 0 */
 | 
			
		||||
	uint32_t profile_steps; /**< @brief Number of steps (commands) in profile */
 | 
			
		||||
	enum pl_command_type current_command; /**< @brief The currently executed command */
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Start a temperature profile execution from a file on SD card.
 | 
			
		||||
 * @param filename Filename of the temperature profile
 | 
			
		||||
 * @return Status. PL_RET_SUCCESS id profile was parsed and started successfully
 | 
			
		||||
 */
 | 
			
		||||
enum pl_ret_val temp_profile_executer_start(const char *filename);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Handle the profile execution
 | 
			
		||||
 *
 | 
			
		||||
 * The function checks if since the last time it ran, 100 ms have passed. If yes,
 | 
			
		||||
 * it proceeds with the command execution.
 | 
			
		||||
 *
 | 
			
		||||
 * @note This must be periodically called.
 | 
			
		||||
 * @return  0 if successul, negative if profile not running or aborted or temperature set and PID not configured.
 | 
			
		||||
 */
 | 
			
		||||
int temp_profile_executer_handle(void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Get the curretn execution state of the temperature profile executer
 | 
			
		||||
 * @warning The returned state structure is static and used internally. You must not modify it.
 | 
			
		||||
 * @return Execution state
 | 
			
		||||
 */
 | 
			
		||||
const struct tpe_current_state *temp_profile_executer_status(void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Stop the temperature profile execution.
 | 
			
		||||
 *
 | 
			
		||||
 * The profile execution is stopped and the beeper is deactivated.
 | 
			
		||||
 *
 | 
			
		||||
 * @return always 0. This function cannot fail.
 | 
			
		||||
 */
 | 
			
		||||
int temp_profile_executer_stop(void);
 | 
			
		||||
 | 
			
		||||
#endif /* __TEMP_PROFILE_EXECUTER_H__ */
 | 
			
		||||
 | 
			
		||||
/** @} */
 | 
			
		||||
		Reference in New Issue
	
	Block a user