libraries / Mitov / Mitov_DateTime.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_DATE_DIME_h
  11#define _MITOV_DATE_DIME_h
  12
  13#include <Mitov.h>
  14
  15namespace Mitov
  16{
  17//---------------------------------------------------------------------------
  18    class EncodeDateTime : public Mitov::BasicCommonMultiInput<long, TDateTime, 7>
  19        {
  20                typedef Mitov::BasicCommonMultiInput<long, TDateTime, 7> inherited;
  21
  22    public:
  23        TDateTime       InitialValue;
  24                bool    OnlyModified = false;
  25
  26        protected:
  27                virtual TDateTime CalculateOutput() override
  28                {
  29                        TDateTime ADate;
  30                        ADate.TryEncodeDateTime( InputPins[ 0 ].Value, InputPins[ 1 ].Value, InputPins[ 2 ].Value, InputPins[ 3 ].Value, InputPins[ 4 ].Value, InputPins[ 5 ].Value, InputPins[ 6 ].Value );
  31                        return ADate;
  32                }
  33
  34        };
  35//---------------------------------------------------------------------------
  36        class DecodeDateTime : public CommonSink
  37        {
  38                typedef Mitov::CommonSink inherited;
  39
  40        public:
  41                OpenWire::SourcePin     OutputPins[ 7 ];
  42
  43        protected:
  44                virtual void DoReceive( void *_Data ) override
  45                {
  46                        TDateTime &ADate = *(TDateTime *)_Data;
  47                        uint16_t AItem16[ 7 ];
  48                        ADate.DecodeDateTime( AItem16[ 0 ], AItem16[ 1 ], AItem16[ 2 ], AItem16[ 3 ], AItem16[ 4 ], AItem16[ 5 ], AItem16[ 6 ] );
  49                        for( int i = 0; i < 7; ++ i )
  50                        {
  51                                long int AValue = AItem16[ i ];
  52                                OutputPins[ i ].Notify( &AValue );
  53                        }
  54                }
  55        };      
  56//---------------------------------------------------------------------------
  57}
  58
  59#endif