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

TemperatureSensor.h « Sensors « Heating « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 26aec74ef2e08e386cdaed33e9c3e73839da088a (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
#ifndef TEMPERATURESENSOR_H
#define TEMPERATURESENSOR_H

#include "RepRapFirmware.h"
#include "Heating/TemperatureError.h"		// for result codes

class GCodeBuffer;

class TemperatureSensor
{
public:
	TemperatureSensor(unsigned int chan, const char *type);

	// Configure the sensor from M305 parameters.
	// If we find any parameters, process them and return true. If an error occurs while processing them, set 'error' to true and write an error message to 'reply.
	// if we find no relevant parameters, report the current parameters to 'reply' and return 'false'.
	virtual bool Configure(unsigned int mCode, unsigned int heater, GCodeBuffer& gb, StringRef& reply, bool& error);

	// Initialise or re-initialise the temperature sensor
	virtual void Init() = 0;

	// Try to get a temperature reading
	virtual TemperatureError GetTemperature(float& t) = 0;

	// Return the channel number
	unsigned int GetSensorChannel() const { return sensorChannel; }

	// Return the sensor type
	const char *GetSensorType() const { return sensorType; }

	// Configure then heater name, if it is provided
	void TryConfigureHeaterName(GCodeBuffer& gb, bool& seen);

	// Virtual destructor
	virtual ~TemperatureSensor();

	// Set the name - normally called only once
	void SetHeaterName(const char *newName);

	// Get the name. Returns nullptr if no name has been assigned.
	const char *GetHeaterName() const { return heaterName; }

	// Factory method
	static TemperatureSensor *Create(unsigned int channel);

protected:
	void CopyBasicHeaterDetails(unsigned int heater, StringRef& reply) const;

private:
	const unsigned int sensorChannel;
	const char * const sensorType;
	const char *heaterName;
};

#endif // TEMPERATURESENSOR_H