This library allows to parse and work with data sent by the Paradigma pelletti oven.

Files at this revision

API Documentation at this revision

Comitter:
leihen
Date:
Wed Jun 26 21:04:07 2013 +0000
Parent:
0:4873b21e0bca
Child:
2:27334bd6dc28
Commit message:
Small additions

Changed in this revision

ParadigmaBase.h Show annotated file Show diff for this revision Revisions of this file
ParadigmaData.cpp Show annotated file Show diff for this revision Revisions of this file
ParadigmaData.h Show annotated file Show diff for this revision Revisions of this file
ParadigmaDateTime.h Show annotated file Show diff for this revision Revisions of this file
ParadigmaTemperature.h Show annotated file Show diff for this revision Revisions of this file
--- a/ParadigmaBase.h	Sat Jun 22 10:59:05 2013 +0000
+++ b/ParadigmaBase.h	Wed Jun 26 21:04:07 2013 +0000
@@ -1,6 +1,8 @@
 #ifndef __PARADIGMABASE_H__
 #define __PARADIGMABASE_H__
 
+namespace Paradigma
+{
 
 typedef unsigned char byte;
 typedef short word;
@@ -10,39 +12,60 @@
 
 __packed class ParadigmaDword
 {
-    protected:
-        unsigned long   m_data;
-        
-    public:
-        ParadigmaDword()    :   m_data(0)   {}
-        
-        /** On the MBED we need to swap the high and lowbytes after reading from stream. 
-          * this function will be called from reading routine.
-          */
-        void    adjustEndiness()        { m_data = ((m_data>>24)&0xFF) | ((m_data>>8)&0x0000FF00) | ((m_data<<8)&0x00FF0000) | ((m_data<<24)&0xFF000000); }
-        
-        ParadigmaDword&         operator=(ulong d)              { m_data = d; return *this; }
-        ParadigmaDword&         operator=(ParadigmaDword d)     { m_data = d.m_data; return *this; }
-        
-        operator ulong() const                                  { return m_data; }
+protected:
+    unsigned long   m_data;
+
+public:
+    ParadigmaDword()    :   m_data(0)   {}
+
+    /** On the MBED we need to swap the high and lowbytes after reading from stream.
+      * this function will be called from reading routine.
+      */
+    void    adjustEndiness()        {
+        m_data = ((m_data>>24)&0xFF) | ((m_data>>8)&0x0000FF00) | ((m_data<<8)&0x00FF0000) | ((m_data<<24)&0xFF000000);
+    }
+
+    ParadigmaDword&         operator=(ulong d)              {
+        m_data = d;
+        return *this;
+    }
+    ParadigmaDword&         operator=(ParadigmaDword d)     {
+        m_data = d.m_data;
+        return *this;
+    }
+
+    operator ulong() const                                  {
+        return m_data;
+    }
 };
 
 __packed class ParadigmaWord
 {
-    protected:
-        unsigned short  m_data;
-        
-    public:
-        ParadigmaWord() :   m_data(0)   {}
-        
-        /** On the MBED we need to swap the high and lowbytes after reading from stream. 
-          * this function will be called from reading routine.
-          */
-        void    adjustEndiness()        { m_data = ((m_data&0xFF)<<8) | ((m_data>>8)&0xFF); }
-           
-        ParadigmaWord&          operator=(word d)               { m_data = d; return *this; }
-        ParadigmaWord&          operator=(ParadigmaWord d)      { m_data = d.m_data; return *this; }
-        
-        operator word() const                                   { return m_data; }
+protected:
+    unsigned short  m_data;
+
+public:
+    ParadigmaWord() :   m_data(0)   {}
+
+    /** On the MBED we need to swap the high and lowbytes after reading from stream.
+      * this function will be called from reading routine.
+      */
+    void    adjustEndiness()        {
+        m_data = ((m_data&0xFF)<<8) | ((m_data>>8)&0xFF);
+    }
+
+    ParadigmaWord&          operator=(word d)               {
+        m_data = d;
+        return *this;
+    }
+    ParadigmaWord&          operator=(ParadigmaWord d)      {
+        m_data = d.m_data;
+        return *this;
+    }
+
+    operator word() const                                   {
+        return m_data;
+    }
 };
+}
 #endif // __PARADIGMABASE_H__
\ No newline at end of file
--- a/ParadigmaData.cpp	Sat Jun 22 10:59:05 2013 +0000
+++ b/ParadigmaData.cpp	Wed Jun 26 21:04:07 2013 +0000
@@ -1,9 +1,12 @@
+#include "mbed.h"
 #include "ParadigmaData.h"
-
+#ifndef DEBUG
 #define DEBUG
+#endif
 #include "debug.h"
 
-
+using namespace Paradigma;
+static char m_Buffer[50];
 
 ParadigmaMonitorData& ParadigmaMonitorData::operator<<(char c)
 {
--- a/ParadigmaData.h	Sat Jun 22 10:59:05 2013 +0000
+++ b/ParadigmaData.h	Wed Jun 26 21:04:07 2013 +0000
@@ -1,7 +1,6 @@
 #ifndef __PARADIGMA_DATA_H__
 #define __PARADIGMA_DATA_H__
 
-#include "mbed.h"
 #include "ParadigmaBase.h"
 #include "ParadigmaTemperature.h"
 #include "ParadigmaDateTime.h"
@@ -9,7 +8,10 @@
 #include <string>
 using namespace std;
 
-/** ParadigmaBlockType_t enumerates valid values for the block type. The block type is always the first 
+namespace Paradigma
+{
+
+/** ParadigmaBlockType_t enumerates valid values for the block type. The block type is always the first
   * data byte in a response from paradigma. There are currently two known values.
   */
 typedef __packed enum {
@@ -23,7 +25,7 @@
     ParadigmaMessage = 0x0C,
 } ParadigmaMessageID_t;
 
-/** ParadigmaDatasetType_t specifies which type of information is contained in the datablock. Currently 
+/** ParadigmaDatasetType_t specifies which type of information is contained in the datablock. Currently
   * known values are : Dataset1 and Dataset2 for Variables, and Parameters for different settings which
   * can be changed and queried by the user.
   */
@@ -61,7 +63,7 @@
     ParadigmaBlockType_t        block_type;         // 0xFC for normal observable variables, 0xFD for parameter blocks
     unsigned char               block_length;
     ParadigmaMessageID_t        message_id;         // always 0x0C
-    ParadigmaDatasetType_t      dataset_type;  
+    ParadigmaDatasetType_t      dataset_type;
 } ParadigmaBlockHeader_t;
 
 typedef __packed struct {
@@ -70,7 +72,7 @@
     ParadigmaTemperature        Warmwassertemp;         //  (in 0,1 Grad Schritten)
     ParadigmaTemperature        Kesselvorlauf;          //  (in 0,1 Grad Schritten)
     ParadigmaTemperature        Kesselruecklauf;        //  (in 0,1 Grad Schritten)
-    
+
     ParadigmaTemperature        RaumtemperaturHK1;      //  (in 0,1 Grad Schritten)
     ParadigmaTemperature        RaumtemperaturHK2;      //  (in 0,1 Grad Schritten)
     ParadigmaTemperature        VorlauftemperaturHK1;   //  (in 0,1 Grad Schritten)
@@ -118,8 +120,8 @@
     byte                        LeistungPHK1;
     byte                        LeistungPHK2;
     byte                        LeistungPK;
-    
-    byte                        Checksumme;        
+
+    byte                        Checksumme;
 } MonDta2_t;
 
 
@@ -129,83 +131,147 @@
   */
 class ParadigmaMonitorData
 {
-        FunctionPointer         m_Callback;
-        
-        MonDta1_t               m_Data1;
-        MonDta2_t               m_Data2;
-        
-        char                    m_Buffer[50];
-        ParadigmaBlockHeader_t  m_Header;
-        ParadigmaDatasetType_t  m_activeDataBlock;
-        int                     m_actualPos;
-        char                    m_checksum;
-        
-        void                    invalidateHeader();
-        void                    callBack()  { m_Callback.call(); }
-        word                    swapWord(word d) { return ((d&0xFF)<<8) | ((d>>8)&0xFF); }
-        ulong                   swapDWord(ulong d) { return ((d>>24)&0xFF) | ((d>>8)&0x0000FF00) | ((d<<8)&0x00FF0000) | ((d<<24)&0xFF000000); }
-    public:
-        /** Public constructor. Will initialize all internal data and variables. */
-        ParadigmaMonitorData(): m_checksum(0)  {  memset(&m_Data1, 0, sizeof(m_Data1)); memset(&m_Data2, 0, sizeof(m_Data2)); invalidateHeader(); }
-        /** Access function to get the transmitted date time object.
-          * @returns : the date and time objects of the transmitted data.
-          */
-        ParadigmaDateTime getDateTime()                     { return m_Data1.DateTime; }
-        /** Access function to the Outside air temperature (AUSSENTEMP).
-          * @returns : the outside air temperature.
-          */
-        ParadigmaTemperature getAussentemp()                { return m_Data1.Aussentemp; }
-        /** Access function to the warm water temperature (WARMWASSERTEMP).
-          * @returns : the warm water temperature.
-          */
-        ParadigmaTemperature getWarmwassertemp()            { return m_Data1.Warmwassertemp; }
-        /** Access function to the 'kessel vorlauf' temperature.
-          * @returns : the temperature of the 'kessel vorlauf'.
-          */
-        ParadigmaTemperature getKesselvorlauf()             { return m_Data1.Kesselvorlauf; }
-        /** Access function to the 'kessel ruecklauf' temperature.
-          * @returns : the temperature of the 'kessel ruecklauf'.
-          */
-        ParadigmaTemperature getKesselruecklauf()           { return m_Data1.Kesselruecklauf; }
-        /** Access function to the room temperature of heating circuit 1.
-          * @returns : the room temperature of heating circuit 1.
-          */
-        ParadigmaTemperature getRaumtemperaturHK1()         { return m_Data1.RaumtemperaturHK1; }
-        /** Access function to the room temperature of heating circuit 2.
-          * @returns : the room temperature of heating circuit 2.
-          */
-        ParadigmaTemperature getRaumtemperaturHK2()         { return m_Data1.RaumtemperaturHK2; }
-        ParadigmaTemperature getVorlauftemperaturHK1()      { return m_Data1.VorlauftemperaturHK1; }
-        ParadigmaTemperature getVorlauftemperaturHK2()      { return m_Data1.VorlauftemperaturHK2; }
-        ParadigmaTemperature getRuecklauftemperaturHK1()    { return m_Data1.RuecklauftemperaturHK1; }
-        ParadigmaTemperature getRuecklauftemperaturHK2()    { return m_Data1.RuecklauftemperaturHK2; }
-        ParadigmaTemperature getPuffertemperaturOben()      { return m_Data1.PuffertemperaturOben; }
-        ParadigmaTemperature getPuffertemperaturUnten()     { return m_Data1.PuffertemperaturUnten; }
-        ParadigmaTemperature getZirkulationstemperatur()    { return m_Data1.Zirkulationstemperatur; }
-        
-        ParadigmaTemperature getRaumsollHK1()               { return m_Data2.RaumsollHK1;}
-        ParadigmaTemperature getRaumsollHK2()               { return m_Data2.RaumsollHK2;}
-        ParadigmaTemperature getVorlaufsollHK1()            { return m_Data2.VorlaufsollHK1;}
-        ParadigmaTemperature getVorlaufsollHK2()            { return m_Data2.VorlaufsollHK2;}
-        ParadigmaTemperature getWarmwassersolltemp()        { return m_Data2.Warmwassersolltemp;}
-        ParadigmaTemperature getPuffersolltemp()            { return m_Data2.Puffersolltemp;}
-        
-        /** Function will let the user select the temperature to be returned.
-          * @param sel : Will specify which temperature value to return.
-          * @returns : the temperature object as selected by param sel.
-          */
-        ParadigmaTemperature getTemperature(ParadigmaTemperatureSelector_t sel);
-        
-        ulong               getBetriebsstundenKessel()      { return (ulong)m_Data2.BetriebsstundenKessel; }
-        ulong               getAnzahlKesselstarts()         { return (ulong)m_Data2.AnzahlKesselstarts; }
-        word                getStoercodeKessel()            { return (word)m_Data2.StoercodeKessel; }
-        byte                getStoercodeFuehler()           { return (byte)m_Data2.StoercodeFuehler; }
-        
-        
-        ParadigmaMonitorData& operator<<( char c );
-        ParadigmaMonitorData& operator<<( char Buffer[] );
-        
-        void attach( void (*fct)(void) )    { m_Callback.attach(fct);}
+    FunctionPointer         m_Callback;
+
+    MonDta1_t               m_Data1;
+    MonDta2_t               m_Data2;
+
+    ParadigmaBlockHeader_t  m_Header;
+    ParadigmaDatasetType_t  m_activeDataBlock;
+    int                     m_actualPos;
+    char                    m_checksum;
+
+    void                    invalidateHeader();
+    void                    callBack()  {
+        m_Callback.call();
+    }
+    word                    swapWord(word d) {
+        return ((d&0xFF)<<8) | ((d>>8)&0xFF);
+    }
+    ulong                   swapDWord(ulong d) {
+        return ((d>>24)&0xFF) | ((d>>8)&0x0000FF00) | ((d<<8)&0x00FF0000) | ((d<<24)&0xFF000000);
+    }
+public:
+    /** Public constructor. Will initialize all internal data and variables. */
+    ParadigmaMonitorData(): m_checksum(0)  {
+        memset(&m_Data1, 0, sizeof(m_Data1));
+        memset(&m_Data2, 0, sizeof(m_Data2));
+        invalidateHeader();
+    }
+    /** Access function to get the transmitted date time object.
+      * @returns : the date and time objects of the transmitted data.
+      */
+    ParadigmaDateTime getDateTime()                     {
+        return m_Data1.DateTime;
+    }
+    /** Access function to the Outside air temperature (AUSSENTEMP).
+      * @returns : the outside air temperature.
+      */
+    ParadigmaTemperature getAussentemp()                {
+        return m_Data1.Aussentemp;
+    }
+    /** Access function to the warm water temperature (WARMWASSERTEMP).
+      * @returns : the warm water temperature.
+      */
+    ParadigmaTemperature getWarmwassertemp()            {
+        return m_Data1.Warmwassertemp;
+    }
+    /** Access function to the 'kessel vorlauf' temperature.
+      * @returns : the temperature of the 'kessel vorlauf'.
+      */
+    ParadigmaTemperature getKesselvorlauf()             {
+        return m_Data1.Kesselvorlauf;
+    }
+    /** Access function to the 'kessel ruecklauf' temperature.
+      * @returns : the temperature of the 'kessel ruecklauf'.
+      */
+    ParadigmaTemperature getKesselruecklauf()           {
+        return m_Data1.Kesselruecklauf;
+    }
+    /** Access function to the room temperature of heating circuit 1.
+      * @returns : the room temperature of heating circuit 1.
+      */
+    ParadigmaTemperature getRaumtemperaturHK1()         {
+        return m_Data1.RaumtemperaturHK1;
+    }
+    /** Access function to the room temperature of heating circuit 2.
+      * @returns : the room temperature of heating circuit 2.
+      */
+    ParadigmaTemperature getRaumtemperaturHK2()         {
+        return m_Data1.RaumtemperaturHK2;
+    }
+    ParadigmaTemperature getVorlauftemperaturHK1()      {
+        return m_Data1.VorlauftemperaturHK1;
+    }
+    ParadigmaTemperature getVorlauftemperaturHK2()      {
+        return m_Data1.VorlauftemperaturHK2;
+    }
+    ParadigmaTemperature getRuecklauftemperaturHK1()    {
+        return m_Data1.RuecklauftemperaturHK1;
+    }
+    ParadigmaTemperature getRuecklauftemperaturHK2()    {
+        return m_Data1.RuecklauftemperaturHK2;
+    }
+    ParadigmaTemperature getPuffertemperaturOben()      {
+        return m_Data1.PuffertemperaturOben;
+    }
+    ParadigmaTemperature getPuffertemperaturUnten()     {
+        return m_Data1.PuffertemperaturUnten;
+    }
+    ParadigmaTemperature getZirkulationstemperatur()    {
+        return m_Data1.Zirkulationstemperatur;
+    }
+
+    ParadigmaTemperature getRaumsollHK1()               {
+        return m_Data2.RaumsollHK1;
+    }
+    ParadigmaTemperature getRaumsollHK2()               {
+        return m_Data2.RaumsollHK2;
+    }
+    ParadigmaTemperature getVorlaufsollHK1()            {
+        return m_Data2.VorlaufsollHK1;
+    }
+    ParadigmaTemperature getVorlaufsollHK2()            {
+        return m_Data2.VorlaufsollHK2;
+    }
+    ParadigmaTemperature getWarmwassersolltemp()        {
+        return m_Data2.Warmwassersolltemp;
+    }
+    ParadigmaTemperature getPuffersolltemp()            {
+        return m_Data2.Puffersolltemp;
+    }
+
+    /** Function will let the user select the temperature to be returned.
+      * @param sel : Will specify which temperature value to return.
+      * @returns : the temperature object as selected by param sel.
+      */
+    ParadigmaTemperature getTemperature(ParadigmaTemperatureSelector_t sel);
+
+    ulong               getBetriebsstundenKessel()      {
+        return (ulong)m_Data2.BetriebsstundenKessel;
+    }
+    ulong               getAnzahlKesselstarts()         {
+        return (ulong)m_Data2.AnzahlKesselstarts;
+    }
+    word                getStoercodeKessel()            {
+        return (word)m_Data2.StoercodeKessel;
+    }
+    byte                getStoercodeFuehler()           {
+        return (byte)m_Data2.StoercodeFuehler;
+    }
+
+
+    ParadigmaMonitorData& operator<<( char c );
+    ParadigmaMonitorData& operator<<( char Buffer[] );
+
+    void attach( void (*fct)(void) )    {
+        m_Callback.attach(fct);
+    }
+    
+    template<typename T>
+    void attach(T* p, void (T::*mptr)(void)) {
+        m_Callback.attach(p, mptr);
+    }
 };
-
+}
 #endif
\ No newline at end of file
--- a/ParadigmaDateTime.h	Sat Jun 22 10:59:05 2013 +0000
+++ b/ParadigmaDateTime.h	Wed Jun 26 21:04:07 2013 +0000
@@ -3,6 +3,8 @@
 
 #include <string>
 
+namespace Paradigma {
+
 __packed class ParadigmaDateTime
 {
     protected:
@@ -28,5 +30,5 @@
         unsigned char       getMinute() const   { return bcdToDec(m_Minute); }
         unsigned char       getHour() const     { return bcdToDec(m_Hour); }
 };
-
+}
 #endif // __PARADIGMADATETIME_H__
\ No newline at end of file
--- a/ParadigmaTemperature.h	Sat Jun 22 10:59:05 2013 +0000
+++ b/ParadigmaTemperature.h	Wed Jun 26 21:04:07 2013 +0000
@@ -4,7 +4,7 @@
 #include <string>
 #include "ParadigmaBase.h"
 
-
+namespace Paradigma {
 
 typedef enum {
     //  Temperatures from Monitor Data 1
@@ -51,5 +51,5 @@
           */
         void    adjustEndiness()        { m_temp = ((m_temp&0xFF)<<8) | ((m_temp>>8)&0xFF); }
 };
-
+}
 #endif
\ No newline at end of file