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

📄 rec_settings.cpp

📁 电能质量交换格式转换库
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*
**  CPQDIF_R_Settings class. Implements a PQDIF record "wrapper" for the
**  settings record. You can cast a standard record object to this class.
**  --------------------------------------------------------------------------
**
**  File name:          $Workfile: rec_settings.cpp $
**  Last modified:      $Modtime: 2/22/00 5:28p $
**  Last modified by:   $Author: Jack $
**
**  VCS archive path:   $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/rec_settings.cpp $
**  VCS revision:       $Revision: 15 $ 
*/
#include "PQDIF_classes.h"

CPQDIF_R_Settings::~CPQDIF_R_Settings()
{

	return;

}

long CPQDIF_R_Settings::GetCountChannels( void )
{
    long                    count = 0;
    CPQDIF_E_Collection *   pcolCI;

    pcolCI = GetChannelSettings();
    if( pcolCI )
    {
        count = pcolCI->GetCount(); 
    }

    return count;
}


bool CPQDIF_R_Settings::GetConnectionInfo
        (
        UINT4&  connectionType
        )
{
    bool    status = false;

    CPQDIF_E_Scalar *       psc;

    //  Init
	connectionType = 0;

    psc = FindScalarInCollection( m_pcollMain, tagSettingPhysicalConnection );
    if( psc )
		status = psc->GetValueUINT4( connectionType );

	return status;
}


bool CPQDIF_R_Settings::GetInfo
        (
        TIMESTAMPPQDIF&     timeEffective,
        TIMESTAMPPQDIF&     timeInstalled,
        TIMESTAMPPQDIF&     timeRemoved,  
        bool&               useCal,       
        bool&               useTrans      
        )
{
    bool    status = false;
    bool    foundItem = false;

    CPQDIF_E_Scalar *       psc;

    //  Init
    memset( &timeEffective, 0, sizeof( timeEffective ) );
    memset( &timeInstalled, 0, sizeof( timeEffective ) );
    memset( &timeRemoved, 0, sizeof( timeEffective ) );
    useCal = false;
    useTrans = false;

    //  Find effective time (required)
    status = true;
    if( status )
    {
        status = false;
        psc = FindScalarInCollection( m_pcollMain, tagEffective );
        if( psc )
        {
            foundItem = psc->GetValueTimeStamp( timeEffective );
            if( foundItem )
            {
                status = true;
            }
        }
    }

    //  Find installed time (optional)
    if( status )
    {
        psc = FindScalarInCollection( m_pcollMain, tagTimeInstalled );
        if( psc )
        {
            foundItem = psc->GetValueTimeStamp( timeInstalled );
        }
    }

    //  Find removed time (optional)
    if( status )
    {
        psc = FindScalarInCollection( m_pcollMain, tagTimeRemoved );
        if( psc )
        {
            foundItem = psc->GetValueTimeStamp( timeRemoved );
        }
    }

    //  Find useCal (required)
    if( status )
    {
        status = false;
        psc = FindScalarInCollection( m_pcollMain, tagUseCalibration );
        if( psc )
        {
            foundItem = psc->GetValueBOOL4( useCal );
            if( foundItem )
            {
                status = true;
            }
        }
    }

    //  Find useTrans (required)
    if( status )
    {
        status = false;
        psc = FindScalarInCollection( m_pcollMain, tagUseTransducer );
        if( psc )
        {
            foundItem = psc->GetValueBOOL4( useTrans );
            if( foundItem )
            {
                status = true;
            }
        }
    }

    return status;
}

bool CPQDIF_R_Settings::GetChannelInfo (long idxChannel, UINT4 & idxChannelDefn) 
    {
    //
    //
    //  Initialize
    //
    bool    foundItem = false;

    idxChannelDefn = 999999999;

    //  Find the appropriate channel collection
    CPQDIF_E_Collection * pcollMain = GetOneChannelSetting( idxChannel );
    if( pcollMain )
        {
        PQDIFValue              value;
        //  Find channel defn (required)
        foundItem = GetScalarValueInCollection( pcollMain, tagChannelDefnIdx, ID_PHYS_TYPE_UNS_INTEGER4, value );
        if( foundItem )
            {
            idxChannelDefn = value.uint4;
            }
        }

    return foundItem;
    }

#ifdef zap
//
//
//  Most of the returned items are optional.  This function
//  returns 0 for those that it can't find.  It returns all of
//  the values it can find.  It should probably return false
//  if it can't find the channel definition index.  I didn't
//  change that for fear of side effects.
// 
//  This function should probably not be used.  Instead,
//  individual queries on each element would be more appropriate
//  so that proper action can be taken when one is not available.
//  Using a value of 0 to indicate non-use has many potential
//  problems - EWG.
//
bool CPQDIF_R_Settings::GetChannelInfo
        (
        long            idxChannel,
        UINT4&          idxChannelDefn,
        UINT4&          triggerTypeID,
        REAL8&          fullScale,  
        REAL8&          noiseFloor, 
        REAL8&          triggerLow, 
        REAL8&          triggerHigh,
        REAL8&          triggerRate,
        CPQDIF_E_Vector&    triggerShapeParam   //  Array of [3] ... or NULL
        //REAL8 *         triggerShapeParam   //  Array of [3] ... or NULL
        ) 
{
    bool    status = false;
    bool    foundItem;

    CPQDIF_E_Collection *   pcollMain;
    CPQDIF_E_Collection *   pcollChannel = NULL;
    CPQDIF_E_Vector *       pvect;
    PQDIFValue              value;

            long        count;
            long        idx;
            double      valueREAL8;
    const   long        countParams = 3;

    //  Find the appropriate channel collection
    pcollMain = GetOneChannelSetting( idxChannel );
    if( pcollMain )
    {
        status = true;
    }

    //  Find channel defn (required)
    if( status )
    {
        foundItem = GetScalarValueInCollection( pcollMain, tagChannelDefnIdx, ID_PHYS_TYPE_UNS_INTEGER4, value );
        if( foundItem )
        {
            idxChannelDefn = value.uint4;
            status = true;
        }
    }

    //  Find trigger type (optional)
    if( status )
    {
        foundItem = GetScalarValueInCollection( pcollMain, tagTriggerTypeID, ID_PHYS_TYPE_UNS_INTEGER4, value );
        if( foundItem )
        {
            triggerTypeID = value.uint4;
            status = true;
        }
    }

    //  Find full scale (optional)
    if( status )
    {
//        status = false;
        foundItem = GetScalarValueInCollection( pcollMain, tagFullScale, ID_PHYS_TYPE_REAL8, value );
        if( foundItem )
        {
            fullScale = value.real8;
            status = true;
        }
    }

    //  Find noise floor (optional)
    if( status )
    {
//        status = false;
        foundItem = GetScalarValueInCollection( pcollMain, tagNoiseFloor, ID_PHYS_TYPE_REAL8, value );
        if( foundItem )
        {
            noiseFloor = value.real8;
            status = true;
        }
    }

    //  Find trigger low (optional)
    if( status )
    {
//        status = false;
        foundItem = GetScalarValueInCollection( pcollMain, tagTriggerLow, ID_PHYS_TYPE_REAL8, value );
        if( foundItem )
        {
            triggerLow = value.real8;
            status = true;
        }
    }

    //  Find trigger high (optional)
    if( status )
    {
//        status = false;
        foundItem = GetScalarValueInCollection( pcollMain, tagTriggerHigh, ID_PHYS_TYPE_REAL8, value );
        if( foundItem )
        {
            triggerHigh = value.real8;
            status = true;
        }
    }


    //  Find trigger rate (optional)
    if( status )
    {
//        status = false;
        foundItem = GetScalarValueInCollection( pcollMain, tagTriggerRate, ID_PHYS_TYPE_REAL8, value );
        if( foundItem )
        {
            triggerRate = value.real8;
            status = true;
        }
    }

    //  Find trigger shape (optional)
    if( status )
    {
        //status = false;

        pvect = FindVectorInCollection( pcollMain, tagTriggerShapeParam );
        if( pvect )
        {
            //  Check size of vector
            pvect->GetCount( count );
            if( pvect->GetPhysicalType() == ID_PHYS_TYPE_REAL8
                && count == countParams )
            {
                //  Copy them over (pvect --> triggerShapeParam)
                triggerShapeParam.SetCount( count );
                for( idx = 0; idx < count; idx++ )
                {
                    pvect->GetValueREAL8( idx, valueREAL8 );
                    triggerShapeParam.SetValueREAL8( idx, valueREAL8 );
                }
                status = true;

            }   //  Got the right physical type and array size
        }   //  Found vector
    }

    return status;
}
#endif


bool CPQDIF_R_Settings::GetChanTrans
        (
        long                idxChannel,
        UINT4&              xdTransformerTypeID,
        REAL8&              xdSystemSideRatio,  
        REAL8&              xdMonitorSideRatio,
        CPQDIF_E_Vector&    xdFrequencyResponse //  Array [n]... or NULL
        )
{
    bool    status = false;
    bool    foundItem;

    CPQDIF_E_Collection *   pcollMain;
    CPQDIF_E_Collection *   pcollChannel = NULL;
    CPQDIF_E_Vector *       pvect;
    PQDIFValue              value;

    long        count;
    long        idx;
    double      valueREAL8;

    //  Find the appropriate channel collection
    pcollMain = GetOneChannelSetting( idxChannel );
    if( pcollMain )
    {
        status = true;
    }

    //  Find xdTransformerTypeID (required)
    if( status )
    {
        foundItem = GetScalarValueInCollection( pcollMain, tagXDTransformerTypeID, ID_PHYS_TYPE_UNS_INTEGER4, value );
        if( foundItem )
        {
            xdTransformerTypeID = value.uint4;
            status = true;
        }
    }

    //  Find xdSystemSideRatio (required)
    if( status )
    {
        status = false;
        foundItem = GetScalarValueInCollection( pcollMain, tagXDSystemSideRatio, ID_PHYS_TYPE_REAL8, value );
        if( foundItem )
        {
            xdSystemSideRatio = value.real8;

⌨️ 快捷键说明

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