Welcome to mirror list, hosted at ThFree Co, Russian Federation.

HeaterProtection.h « Heating « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4373fb51376886eebbcd802579794f5ecabe6532 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * HeaterProtection.h
 *
 *  Created on: 16 Nov 2017
 *      Author: Christian
 */

#ifndef HEATERPROTECTION_H
#define HEATERPROTECTION_H

#include "RepRapFirmware.h"


// Condition of a heater protection event
enum class HeaterProtectionTrigger : uint8_t
{
	TemperatureExceeded,
	TemperatureTooLow
};

const HeaterProtectionTrigger MaxHeaterProtectionTrigger = HeaterProtectionTrigger::TemperatureTooLow;

// The action to trigger when the target condition is met
enum class HeaterProtectionAction : uint8_t
{
	GenerateFault = 0,
	PermanentSwitchOff,
	TemporarySwitchOff
};

const HeaterProtectionAction MaxHeaterProtectionAction = HeaterProtectionAction::TemporarySwitchOff;


class Heat;

class HeaterProtection
{
public:
	friend class Heat;

	HeaterProtection(size_t index);
	void Init(float tempLimit);

	HeaterProtection *Next() const { return next; }
	void SetNext(HeaterProtection *n) { next = n; }

	bool Check();													// Check if any action needs to be taken

	int8_t GetHeater() const { return heater; }
	void SetHeater(int8_t newHeater);								// Set the heater to control

	int8_t GetSupervisedHeater() const { return supervisedHeater; }	// Get the heater to supervise
	void SetSupervisedHeater(int8_t heater);						// Set the heater to supervise

	float GetTemperatureLimit() const { return limit; }				// Get the temperature limit
	void SetTemperatureLimit(float newLimit);						// Set the temperature limit

	HeaterProtectionAction GetAction() const { return action; }		// Get the action to trigger when a temperature event occurs
	void SetAction(HeaterProtectionAction newAction);				// Set the action to trigger when a temperature event occurs

	HeaterProtectionTrigger GetTrigger() const { return trigger; }	// Get the condition for a temperature event
	void SetTrigger(HeaterProtectionTrigger newTrigger);			// Set the condition for a temperature event

private:
	HeaterProtection *next;

	float limit;
	int8_t heater, supervisedHeater;
	HeaterProtectionAction action;
	HeaterProtectionTrigger trigger;

	size_t badTemperatureCount;
};

inline void HeaterProtection::SetSupervisedHeater(int8_t heater)
{
	supervisedHeater = heater;
}

inline void HeaterProtection::SetTemperatureLimit(float newLimit)
{
	limit = newLimit;
}

inline void HeaterProtection::SetAction(HeaterProtectionAction newAction)
{
	action = newAction;
}

inline void HeaterProtection::SetTrigger(HeaterProtectionTrigger newTrigger)
{
	trigger = newTrigger;
}

#endif