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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ParadigmaBase.h Source File

ParadigmaBase.h

00001 #ifndef __PARADIGMABASE_H__
00002 #define __PARADIGMABASE_H__
00003 
00004 namespace Paradigma
00005 {
00006 
00007 typedef unsigned char byte;
00008 typedef short word;
00009 typedef unsigned short uword;
00010 typedef unsigned long ulong;
00011 
00012 
00013 __packed class ParadigmaDword
00014 {
00015 protected:
00016     unsigned long   m_data;
00017 
00018 public:
00019     ParadigmaDword()    :   m_data(0)   {}
00020 
00021     /** On the MBED we need to swap the high and lowbytes after reading from stream.
00022       * this function will be called from reading routine.
00023       */
00024     void    adjustEndiness()        {
00025         m_data = ((m_data>>24)&0xFF) | ((m_data>>8)&0x0000FF00) | ((m_data<<8)&0x00FF0000) | ((m_data<<24)&0xFF000000);
00026     }
00027 
00028     ParadigmaDword&         operator=(ulong d)              {
00029         m_data = d;
00030         return *this;
00031     }
00032     ParadigmaDword&         operator=(ParadigmaDword d)     {
00033         m_data = d.m_data;
00034         return *this;
00035     }
00036 
00037     operator ulong() const                                  {
00038         return m_data;
00039     }
00040 };
00041 
00042 __packed class ParadigmaWord
00043 {
00044 protected:
00045     unsigned short  m_data;
00046 
00047 public:
00048     ParadigmaWord() :   m_data(0)   {}
00049 
00050     /** On the MBED we need to swap the high and lowbytes after reading from stream.
00051       * this function will be called from reading routine.
00052       */
00053     void    adjustEndiness()        {
00054         m_data = ((m_data&0xFF)<<8) | ((m_data>>8)&0xFF);
00055     }
00056 
00057     ParadigmaWord&          operator=(word d)               {
00058         m_data = d;
00059         return *this;
00060     }
00061     ParadigmaWord&          operator=(ParadigmaWord d)      {
00062         m_data = d.m_data;
00063         return *this;
00064     }
00065 
00066     operator word() const                                   {
00067         return m_data;
00068     }
00069 };
00070 }
00071 #endif // __PARADIGMABASE_H__