⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ser_cont_el.cpp

📁 PQDIF软件包(SDK,Software Development Kit),它能转换、生成并且显示PQDIF文件.对于开发电力系统的数据输出非常有用。
💻 CPP
字号:
/*
**  PQController class. This class is used to control the reconstitution
**  of PQDIF element objects from a buffer where they have been archived.
**  --------------------------------------------------------------------------
**
**  File name:          $Workfile: ser_cont_el.cpp $
**  Last modified:      $Modtime: 2/11/98 11:37a $
**  Last modified by:   $Author: Rob $
**
**  VCS archive path:   $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/ser_cont_el.cpp $
**  VCS revision:       $Revision: 5 $ 
*/
#include "PQDIF_classes.h"


//  Local definitions
#define MAX_LEVELS  256



//  Construction
//  ============

PQController::PQController( void )
    {
    m_arrayTags = new GUID[ MAX_LEVELS ];
    m_arrayCollections = new CPQDIF_E_Collection* [ MAX_LEVELS ];

    m_levelCurrent = 0;
    memset( m_arrayTags, 0, sizeof( GUID ) * MAX_LEVELS );
    }

PQController::~PQController( void )
    {
    if( m_arrayTags )
        delete [] m_arrayTags;
    if( m_arrayCollections )
        delete [] m_arrayCollections;
    }


void PQController::ParseRecord
            ( 
            BYTE *                  buffer, 
            SIZE4                   size, 
            CPQDIF_E_Collection *   pcollMain
            )
    {
    PQDIFIterator * piter;

    m_arrayCollections[ m_levelCurrent ] = pcollMain;
    
    piter = new PQDIFIterator( this, buffer, size, 0, m_levelCurrent );
    if( piter )
        {
        piter->ParseCollection();
        delete piter;
        }

    return;
    }


bool PQController::acceptCollection
            ( 
            int             index,
            const GUID&     tag,
            int             level
            )
    {
    CPQDIF_E_Collection *   pcollNew;
    CPQDIF_E_Collection *   pcollPrevious;

    //  Create the new collection object
    pcollNew = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION );
    if( pcollNew )
    {
        pcollNew->SetTag( tag );

        //  Keep track of where we are
        m_levelCurrent = level;
        m_arrayTags[ m_levelCurrent ] = tag;

        //  Add it to the previous collection
        pcollPrevious = m_arrayCollections[ m_levelCurrent - 1 ];
//        ASSERT( pcollPrevious );
        pcollPrevious->Add( pcollNew );

        //  Get a pointer to it
        m_arrayCollections[ m_levelCurrent ] = (CPQDIF_E_Collection *) pcollPrevious->GetElement( pcollPrevious->GetCount() - 1 );
    }

	//	Unused parameter
	index = index;

    return true;
    }


void PQController::endOfCollection( int level )
    {
    //  Clear the pointer
    m_arrayCollections[ level ] = NULL;

    //  Back up the previous level
    m_levelCurrent = level - 1;
    }

            
bool PQController::acceptScalar
            ( 
            int             index,
            const GUID&     tag, 
            long            typePhysical,
            //c_scalar *      pscalar,
            void *          pdata
            )
    {
    bool        status = false;
    PQDIFValue  value;
    CPQDIF_E_Scalar *   pel;

//    ASSERT( pdata );

    //  Decode the value
    status = decodeValue( typePhysical, pdata, value );
    if( status )
        {
        //  Create new element
        pel = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR );
//        ASSERT( pel );
        if( pel )
            {
            //  Initialize it
            pel->SetTag( tag );
            pel->SetValue( typePhysical, value );

            //  Add it to the current collection
//            ASSERT( m_arrayCollections[ m_levelCurrent ] );
            m_arrayCollections[ m_levelCurrent ]->Add( pel );
            }
        }

	//	Unused parameter
	index = index;

    return status;
    }


bool PQController::acceptVector
            ( 
            int             index,
            const GUID&     tag, 
            long            typePhysical,
            c_vector *      pvector,
            void *          pdata
            )
    {
    bool                status = FALSE;
    long                idxValue;
    SIZE4               sizeValue;
    BYTE *              pdataVector;
    PQDIFValue          value;
    CPQDIF_E_Vector *   pel;

    //  Validate parameters
//    ASSERT( pvector );
//    ASSERT( pdata );

    //  Init
    pdataVector = (BYTE *) pdata;
    sizeValue = theInfo.GetNumBytesOfType( typePhysical );

    //  Create new element
    pel = (CPQDIF_E_Vector *) theFactory.NewElement( ID_ELEMENT_TYPE_VECTOR );
//    ASSERT( pel );
    if( pel )
        {
        //  Initialize it
        pel->SetTag( tag );
        pel->SetPhysicalType( typePhysical );
        pel->SetCount( pvector->count );

        for( idxValue = 0; idxValue < pvector->count; idxValue++ )
            {
            //  Decode the value
            status = decodeValue( typePhysical, pdataVector, value );
            if( status )
                {
                pel->SetValue( idxValue, value );
                }
            else
                {
                //  A problem occurred while decoding...
                break;
                }

            //  Increment pointer to the next value
            pdataVector += sizeValue;
            }

        //  Add the element to the current collection
//        ASSERT( m_arrayCollections[ m_levelCurrent ] );
        m_arrayCollections[ m_levelCurrent ]->Add( pel );
        }

	//	Unused parameter
	index = index;

    return status;
    }


bool PQController::decodeValue
            ( 
            long        typePhysical,
            void *      pdata,
            PQDIFValue& value
            )
    {
    bool    status = TRUE;

    switch( typePhysical )
        {
        case ID_PHYS_TYPE_BOOLEAN1:
            value.bool1 =  *( (BOOL1 *) pdata );
            break;

        case ID_PHYS_TYPE_CHAR1:
            value.char1 =  *( (CHAR1 *) pdata );
            break;

        case ID_PHYS_TYPE_INTEGER1:
            value.int1 =  *( (INT1 *) pdata );
            break;

        case ID_PHYS_TYPE_UNS_INTEGER1:
            value.uint1 =  *( (UINT1 *) pdata );
            break;

        case ID_PHYS_TYPE_BOOLEAN2:
            value.bool2 =  *( (BOOL2 *) pdata );
            break;

        case ID_PHYS_TYPE_CHAR2:
            value.char2 =  *( (CHAR2 *) pdata );
            break;

        case ID_PHYS_TYPE_INTEGER2:
            value.int2 =  *( (INT2 *) pdata );
            break;

        case ID_PHYS_TYPE_UNS_INTEGER2:
            value.uint2 =  *( (UINT2 *) pdata );
            break;

        case ID_PHYS_TYPE_BOOLEAN4:
            value.bool4 =  *( (BOOL4 *) pdata );
            break;

        case ID_PHYS_TYPE_INTEGER4:
            value.int4 =  *( (INT4 *) pdata );
            break;

        case ID_PHYS_TYPE_UNS_INTEGER4:
            value.uint4 =  *( (UINT4 *) pdata );
            break;

        case ID_PHYS_TYPE_REAL4:
            value.real4 =  *( (REAL4 *) pdata );
            break;

        case ID_PHYS_TYPE_REAL8:
            value.real8 =  *( (REAL8 *) pdata );
            break;

        case ID_PHYS_TYPE_COMPLEX8:
            value.complex8 =  *( (COMPLEX8 *) pdata );
            break;

        case ID_PHYS_TYPE_COMPLEX16:
            value.complex16 =  *( (COMPLEX16 *) pdata );
            break;

        case ID_PHYS_TYPE_TIMESTAMPPQDIF:
            value.ts =  *( (ts *) pdata );
            break;

        case ID_PHYS_TYPE_GUID:
            value.guid =  *( (GUID *) pdata );
            break;

        default:
            status = FALSE;
            break;
        }

    return status;
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -