Subversion Repositories heating

Rev

Rev 40 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15 andreas 1
/*
2
 * Copyright (C) 2015 by Andreas Theofilu. All rights reserved!
3
 *
4
 * All rights reserved. No warranty, explicit or implicit, provided.
5
 *
6
 * NOTICE:  All information contained herein is, and remains
7
 * the property of Andreas Theofilu and his suppliers, if any.
8
 * The intellectual and technical concepts contained
9
 * herein are proprietary to Andreas Theofilu and its suppliers and
10
 * may be covered by European and Foreign Patents, patents in process,
11
 * and are protected by trade secret or copyright law.
12
 * Dissemination of this information or reproduction of this material
13
 * is strictly forbidden unless prior written permission is obtained
14
 * from Andreas Theofilu.
15
 * 
16
 * Author: Andreas Theofilu <andreas@theosys.at>
17
 */
18
#ifndef __HTML_H__
19
#define __HTML_H__
20
 
21
#include <microhttpd.h>
17 andreas 22
#include <iostream>
23
#include <string.h>
24
#include <vector>
25
#include "controller.h"
15 andreas 26
#include "helper.h"
27
 
28
class html : public helper
29
{
30
	public:
17 andreas 31
		typedef struct HTCONF
32
		{
33
			// By config file set variables
34
			char rname[32];
35
			int rnum;
36
			double soll;			// The temperature that should be
37
			double night;			// The reduced temperature for night
38
			double minimal;			// The minimal temperature
35 andreas 39
			time_t start1;			// The time the heating should have reached the "soll" temperature (if normal is set)
40
			time_t end1;			// The time the heating should end normal mode and start "night" mode.
41
			time_t start2;			// The time the heating stop and the value for night gets active (if normal is set)
42
			time_t end2;			// The time the heating should end night mode and start "normal" mode.
17 andreas 43
			HTCONF *next;
44
		}HTCONF;
45
 
46
	public:
15 andreas 47
		html();
48
		~html();
17 andreas 49
		void run();
50
		HTCONF *addConfig(HTCONF *ht);
40 andreas 51
		void setGlobals(double night, double absent, bool m) { glb_night = night; glb_absent = absent; mode = m; }
17 andreas 52
		void doStop() { stop = true; }
53
		void addController(Controller *controller);
46 andreas 54
		// Functions to return the actual settings
55
		double getGlbNight() { return glb_night; }
56
		double getGlbAbsent() { return glb_absent; }
57
		bool getRunMode() { return mode; }
58
		HTCONF *getHConfig() { return HeatConf; }
15 andreas 59
 
46 andreas 60
		inline bool hasChanged()
61
		{
62
			if (datar)
63
			{
64
				datar = false;
65
				return true;
66
			}
67
 
68
			return false;
69
		}
70
 
17 andreas 71
	protected:
40 andreas 72
		void setLocGlbNight(double d) { glb_night = d; }
73
 
17 andreas 74
		static int request_handler(void * cls, struct MHD_Connection * connection,
75
							   const char * url, const char * method, const char * version,
76
							   const char * upload_data, size_t * upload_data_size, void ** ptr);
19 andreas 77
		static void request_completed (void *cls, struct MHD_Connection *connection,
78
								void **con_cls, enum MHD_RequestTerminationCode toe);
17 andreas 79
 
15 andreas 80
	private:
17 andreas 81
		void initPages();
16 andreas 82
 
17 andreas 83
		HTCONF *HeatConf;
84
		double glb_night, glb_absent;
85
		bool mode;
86
		struct MHD_Daemon *daemon;
87
		std::string mainPage;
19 andreas 88
		static std::string intErrorPage;
17 andreas 89
		bool stop;
23 andreas 90
		int room;						// The currently selected room
46 andreas 91
		static bool datar;				// if true, something has changed
17 andreas 92
		/** List of controllers this server has. */
93
		std::vector<Controller*> controllers;
15 andreas 94
};
95
 
96
#endif