libraries / Mitov / Mitov_BinaryDecoder.hon commit Added link to project report (97a3ba0)
   1////////////////////////////////////////////////////////////////////////////////
   2//                                                                            //
   3//     This software is supplied under the terms of a license agreement or    //
   4//     nondisclosure agreement with Mitov Software and may not be copied      //
   5//     or disclosed except in accordance with the terms of that agreement.    //
   6//         Copyright(c) 2002-2016 Mitov Software. All Rights Reserved.        //
   7//                                                                            //
   8////////////////////////////////////////////////////////////////////////////////
   9
  10#ifndef _MITOV_BINARY_DECODER_h
  11#define _MITOV_BINARY_DECODER_h
  12
  13#include <Mitov.h>
  14
  15namespace Mitov
  16{
  17        class BinaryDecoder : public Mitov::CommonSink
  18        {
  19                typedef Mitov::CommonSink inherited;
  20
  21        public:
  22                Mitov::SimpleList<OpenWire::SourcePin> OutputPins;
  23
  24        public:
  25                unsigned long   InitialValue = 0;
  26
  27        protected:
  28                unsigned long   FOldValue = 0;
  29
  30        protected:
  31                void SetValue( unsigned long AValue )
  32                {
  33                        FOldValue = AValue;
  34                        OutputPins[ FOldValue ].Notify( (void *)&GBooleanConst[ 1 ] );
  35                }
  36
  37        protected:
  38                virtual void DoReceive( void *_Data ) override
  39                {
  40                        unsigned long AValue = *(unsigned long *)_Data;
  41                        if( FOldValue == AValue )
  42                                return;
  43
  44                        OutputPins[ FOldValue ].Notify( (void *)&GBooleanConst[ 0 ] );
  45
  46                        SetValue( AValue );
  47                }
  48
  49                virtual void SystemInit()
  50                {
  51                        inherited::SystemInit();
  52                        SetValue( InitialValue );
  53                }
  54
  55        };
  56//---------------------------------------------------------------------------
  57}
  58
  59#endif