blob: 7db1f3837e22f7dfe0a1a7cc269e25b5cdfc5ec4 (
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
96
|
/*
* 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
int GetHeater() const { return heater; }
void SetHeater(int newHeater); // Set the heater to control
int GetSensorNumber() const { return sensorNumber; } // Get the supervisory sensor number
void SetSensorNumber(int sn); // Set the supervisory sensor number
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; // link to next HeaterProtection item for the same heater
float limit; // temperature limit
int heater; // number of the heater we are protecting
int sensorNumber; // the sensor that we use to monitor the heater
HeaterProtectionAction action; // what action we take of we detect a fault
HeaterProtectionTrigger trigger; // what is treated a fault
size_t badTemperatureCount; // how many consecutive sensor reading faults we have had
};
inline void HeaterProtection::SetSensorNumber(int sn)
{
sensorNumber = sn;
}
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
|