Version FC

Dependencies:   DmTftLibrary eeprom SX1280Lib filesystem mbed

Fork of MSNV2-Terminal_V1-5 by Francis CHATAIN

Service.hpp

Committer:
patrick_duc
Date:
2018-08-30
Revision:
19:4b147d8f9164
Parent:
Channel.hpp@ 13:5414193da1de
Child:
20:b0281e8a375a

File content as of revision 19:4b147d8f9164:

#ifndef __CHANNEL_HPP__
#define __CHANNEL_HPP__

#include "mbed.h"
#include <iostream>
#include <string>
#include "ServiceExceptions.hpp"


class Service {

    public:
        typedef uint8_t MISNET_CODE ;

        enum DEVICE_TYPE {
            SENSOR    = 1, 
            ACTUATOR  = 2, 
            RECORDER   = 3
        } ;

        // A compléter au fur et a mesure et remonter l'info sur les centres applicatifs
        enum DEVICE_ID {
            NOT_IDENTIFIED  = 0 ,   //  Configuration nouvelle ou non référencée
            IKS01A2         = 1 ,   //  Liste des composants
            SMART_TERMINAL  = 2     //  BME280 + .... 
        } ;

        typedef uint8_t  GROUP ;

        typedef uint16_t VALUE_TYPE ;

        enum STATE {
            ENABLE_   = 1,  //   ACTIVE
            DISABLE_  = 0   //   ASLEEP
        } ;

        enum ACCESS_TYPE {
            GPIO_    = 1,
            I2C_     = 2,
            SPI_     = 3,
            UART_    = 4
        } ;
 
        typedef uint8_t ACCESS_PIN ;

        enum UP_MODE {
            BY_VALUE      = 1, // wakeup by irq
            BY_THRESHOLD  = 2  // wakeup by watchdog timer
        } ;

        enum REQUEST_MODE {
            IRQ_   = 1, // wakeup by irq
            TIME_  = 2  // wakeup by watchdog timer
        } ; 

        uint32_t TIMER_DIVIDER ;

        typedef float THRESHOLD_DELTA ;
        typedef float THRESHOLD_UP ;
        typedef float THRESHOLD_DOWN ;

        enum ACTION {
            MESSAGE         = 1, // Send Message
            MESSAGERELAY    = 2  // Send Message + ON/OFF internal relay
        } ;

        enum OUTPUT_MODE {
            IO        = 1, // ON/OFF 
            PWD       = 2  // PWD modulation 
        } ;

        // Constructor
        Service(            DEVICE_TYPE type,
                            MISNET_CODE misnet_code,
                            STATE state,
                            ACCESS_TYPE access_type,
                            REQUEST_MODE request_mode,
                            UP_MODE up_mode,
                            ACCESS_PIN access_pins[6],
                            ACTION action,
                            OUTPUT_MODE output_mode,
                            std::string comment);

        DEVICE_TYPE getDeviceType() {
            return this->device_type;
        }

        MISNET_CODE getMisnetCode() {
            return this->misnet_code;
        }

        STATE getState() {
            return this->state;
        }

        ACCESS_TYPE getAccessType() {
            return this->access_type;
        }

        REQUEST_MODE getRequestMode() {
            return this->request_mode;
        }

        UP_MODE getUpMode() {
            return this->up_mode;
        }

        ACCESS_PIN* getAccessPins() {
            return this->access_pins;
        }

        ACCESS_PIN getAccessPin(short index) {
            /*
            if (index < 1 || index > 6) {
                throw ServiceException();
            }
            */

            return this->access_pins[index - 1];
        }

        ACTION getAction() {
            return this->action;
        }

        OUTPUT_MODE getOutputMode() {
            return this->output_mode;
        }

        std::string getComment() {
            return this->comment;
        }

        friend std::ostream& operator<<(std::ostream&, const Service &);


    private:
        DEVICE_TYPE         device_type;
        MISNET_CODE         misnet_code;
        STATE               state;
        ACCESS_TYPE         access_type;
        ACCESS_PIN          access_pins[6];
        REQUEST_MODE        request_mode;
        UP_MODE             up_mode;
        /* The following fields are currently unused.
        uint32_t    timer_divider;
        uint32_t    threshold_delta;
        uint32_t    threshold_up;
        uint32_t    threshold_down;
        */
        ACTION              action;
        OUTPUT_MODE         output_mode;
        std::string         comment;
};

#endif // __CHANNEL_HPP__