Subversion Repositories heating

Rev

Rev 16 | Rev 23 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * Copyright (C) 2015 by Andreas Theofilu. All rights reserved!
 *
 * All rights reserved. No warranty, explicit or implicit, provided.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Andreas Theofilu and his suppliers, if any.
 * The intellectual and technical concepts contained
 * herein are proprietary to Andreas Theofilu and its suppliers and
 * may be covered by European and Foreign Patents, patents in process,
 * and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Andreas Theofilu.
 * 
 * Author: Andreas Theofilu <andreas@theosys.at>
 */
#ifndef __HTML_H__
#define __HTML_H__

#include <microhttpd.h>
#include <iostream>
#include <string.h>
#include <vector>
#include "controller.h"
#include "helper.h"

class html : public helper
{
        public:
                typedef struct HTCONF
                {
                        // By config file set variables
                        char rname[32];
                        int rnum;
                        double soll;                    // The temperature that should be
                        double night;                   // The reduced temperature for night
                        double minimal;                 // The minimal temperature
                        time_t start;                   // The time the heating should have reached the "soll" temperature (if normal is set)
                        time_t end;                             // The time the heating should end normal mode and start "night" mode.
                        HTCONF *next;
                }HTCONF;

        public:
                html();
                ~html();
                void run();
                HTCONF *addConfig(HTCONF *ht);
                void setGlobals(double night, double absent, bool m) { glb_night = night; glb_absent = absent; }
                void doStop() { stop = true; }
                void addController(Controller *controller);

        protected:
                static int request_handler(void * cls, struct MHD_Connection * connection,
                                                           const char * url, const char * method, const char * version,
                                                           const char * upload_data, size_t * upload_data_size, void ** ptr);
                int send_page (struct MHD_Connection *connection, const char *page);

/*              int iterate_post (void *coninfo_cls, enum MHD_ValueKind kind, const char *key,
                                                                 const char *filename, const char *content_type,
                                                                 const char *transfer_encoding, const char *data, uint64_t off,
                                                                 size_t size);
                void request_completed (void *cls, struct MHD_Connection *connection,
                                                                           void **con_cls, enum MHD_RequestTerminationCode toe);
                int answer_to_connection (void *cls, struct MHD_Connection *connection,
                                                                                 const char *url, const char *method,
                                                                                 const char *version, const char *upload_data,
                                                                                 size_t *upload_data_size, void **con_cls);
*/
        private:
                void initPages();

                HTCONF *HeatConf;
                double glb_night, glb_absent;
                bool mode;
                struct MHD_Daemon *daemon;
                std::string mainPage;
                bool stop;
                /** List of controllers this server has. */
                std::vector<Controller*> controllers;
};

#endif