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

📄 rec_datasource.cpp

📁 电能质量交换格式转换库
💻 CPP
📖 第 1 页 / 共 2 页
字号:
            )
{
    long        idxNew = -1;

    CPQDIF_E_Collection *   pcollDefns;
    CPQDIF_E_Collection *   pcollOne;
    CPQDIF_E_Collection *   pcollSeriesDefns;
    
    pcollDefns = GetChannelDefns();
    if( pcollDefns )
    {
        //  Get the new index
        idxNew = GetCountChannelDefns();

        //  Create the new channel def'n
        pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION );
        if( pcollOne )
        {
            pcollOne->SetTag( tagOneChannelDefn );

            //  Stuff in the information...
            pcollOne->SetVectorString( tagChannelName, name );
            pcollOne->SetScalarUINT4( tagPhaseID, idPhase );
            pcollOne->SetScalarUINT4( tagQuantityMeasuredID, idQM );
            pcollOne->SetScalarGUID( tagQuantityTypeID, idQuantityType );

            //  Also add an empty collection for the series definitions
            pcollSeriesDefns = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION );
            if( pcollSeriesDefns )
            {
                pcollSeriesDefns->SetTag( tagSeriesDefns );
                pcollOne->Add( pcollSeriesDefns );
            }
        }

        //  Add it!
        pcollDefns->Add( pcollOne );
    }

    return idxNew;
}

long CPQDIF_R_DataSource::AddSeriesDefn
            (
                    long     idxChannelDefn,
                    UINT4    idQuantityUnits,
            const   GUID     idValueType,
                    UINT4    idStorageMethod
            )
{
    long        idxNew = -1;

    CPQDIF_E_Collection *   pcolOneChannelDefn;
    CPQDIF_E_Collection *   pcollSeriesDefns;
    CPQDIF_E_Collection *   pcollOne;
    
    //  Find the one channel defn we're looking for
    pcolOneChannelDefn = GetOneChannelDefn( idxChannelDefn );
    if( pcolOneChannelDefn )
    {
#ifdef _DEBUG
        //  Is this the right tag?
        const   char *  pname;
        pname = theInfo.GetNameOfTag( pcolOneChannelDefn->GetTag() );
#endif

        //  Find the series defns for this channel defn
        pcollSeriesDefns = GetSeriesDefns( pcolOneChannelDefn );
        if( pcollSeriesDefns )
        {
            //  Get the new index
            idxNew = GetCountSeriesDefns( idxChannelDefn );

            //  Create the new series def'n
            pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION );
            pcollOne->SetTag( tagOneSeriesDefn );

            //  Stuff in the information...
            pcollOne->SetScalarUINT4( tagQuantityUnitsID, idQuantityUnits );
            pcollOne->SetScalarGUID( tagValueTypeID, idValueType );
            pcollOne->SetScalarUINT4( tagStorageMethodID, idStorageMethod );

            //  Add it!
            pcollSeriesDefns->Add( pcollOne );
        }
    }

    return idxNew;
}


long CPQDIF_R_DataSource::AddSeriesDefn2
            (
                    long     idxChannelDefn,
                    UINT4    idQuantityUnits,
            const   GUID     idValueType,
            const   GUID     idCharacteristicType,
                    UINT4    idStorageMethod
            )
{
    long        idxNew = -1;

    CPQDIF_E_Collection *   pcolOneChannelDefn;
    CPQDIF_E_Collection *   pcollSeriesDefns;
    CPQDIF_E_Collection *   pcollOne;
    
    //  Find the one channel defn we're looking for
    pcolOneChannelDefn = GetOneChannelDefn( idxChannelDefn );
    if( pcolOneChannelDefn )
    {
#ifdef _DEBUG
        //  Is this the right tag?
        const   char *  pname;
        pname = theInfo.GetNameOfTag( pcolOneChannelDefn->GetTag() );
#endif

        //  Find the series defns for this channel defn
        pcollSeriesDefns = GetSeriesDefns( pcolOneChannelDefn );
        if( pcollSeriesDefns )
        {
            //  Get the new index
            idxNew = GetCountSeriesDefns( idxChannelDefn );

            //  Create the new series def'n
            pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION );
            pcollOne->SetTag( tagOneSeriesDefn );

            //  Stuff in the information...
            pcollOne->SetScalarUINT4( tagQuantityUnitsID, idQuantityUnits );
            pcollOne->SetScalarGUID( tagQuantityCharacteristicID, idCharacteristicType );
            pcollOne->SetScalarGUID( tagValueTypeID, idValueType );
            pcollOne->SetScalarUINT4( tagStorageMethodID, idStorageMethod );

            //  Add it!
            pcollSeriesDefns->Add( pcollOne );
        }
    }

    return idxNew;
}

bool CPQDIF_R_DataSource::GetSeriesDefnNominal
            (
            long     idxChannelDefn,
            long     idxSeriesDefn,
            double & dNominal
            )
    {
    bool    status = false;

    CPQDIF_E_Collection *   pcolOneSeriesDefn;
    CPQDIF_E_Scalar *       pscalar;

    //  Initialize
    dNominal = -1.0;
    
    //  Find the one channel defn we're looking for
    pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn );
    if( pcolOneSeriesDefn )
        {
        //  Is this the right tag?
        //
        //  Rob does this call over the place but does not
        //  do anything with the result.  Why is it here? - EWG
        //
//        const   char *  pname;
//        pname = theInfo.GetNameOfTag( pcolOneSeriesDefn->GetTag() );

        //  check the return values
        status = true;
        pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagSeriesNominalQuantity );
        if( status && pscalar )
            {
            status = pscalar->GetValueREAL8( dNominal );
            }
        }

    return status;
    }


bool CPQDIF_R_DataSource::GetSeriesDefnPrecisionAndResolution 
			(
            long        idxChannel,
            long        idxSeries,
            UINT4	  & uPrecision,
            double    & dResolution
            )

{
    CPQDIF_E_Collection *   pcolOneSeriesDefn;
    CPQDIF_E_Scalar *       pscalar;
    bool    status = false;

    //  Initialize
    uPrecision = -1;
	dResolution = 0.0;
    
    //  Find the one channel defn we're looking for
    pcolOneSeriesDefn = GetOneSeriesDefn( idxChannel, idxSeries );
    if( pcolOneSeriesDefn )
        {

        //  check the return values
        status = true;
        pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagQuantitySignificantDigitsID );
        if( status && pscalar )
            {
            status = pscalar->GetValueUINT4( uPrecision );
            }

        pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagQuantityResolutionID );
        if( pscalar )
            {
            pscalar->GetValueREAL8( dResolution );
            }
        }

	return status;
    }



bool CPQDIF_R_DataSource::SetSeriesDefnNominal
            (
            long     idxChannelDefn,
            long     idxSeriesDefn,
            double   dNominal
            )
    {
    bool    status = false;

    CPQDIF_E_Collection *   pcolOneSeriesDefn;
    CPQDIF_E_Scalar *       pscalar;

    //  Find the one channel defn we're looking for
    pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn );
    if( pcolOneSeriesDefn )
        {
        //  Is this the right tag?
        //
        //  Rob does this call over the place but does not
        //  do anything with the result.  Why is it here? - EWG
        //
//        const   char *  pname;
//        pname = theInfo.GetNameOfTag( pcolOneSeriesDefn->GetTag() );

        status = true;
        //
        //
        //  See if scalar already present
        //
        pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagSeriesNominalQuantity );
        if( pscalar )
            {
            //
            //
            //  Is there so set new value
            //
            status = pscalar->SetValueREAL8( dNominal );
            }
        else
            {
            //
            //
            //  Is not there so add scalar
            //
            pscalar = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR );
            if( pscalar )
                {
                pscalar->SetTag( tagSeriesNominalQuantity );
                status = pscalar->SetValueREAL8( dNominal );
                pcolOneSeriesDefn->Add( pscalar );
                }
            }
#ifdef zap
        //
        //
        //  The following line does the same thing as the several
        //  lines above but without error checking.
        //
        //  The third parameter allows replacement of tag
        //  value if tag already present.  If tag not present,
        //  it is added and the value set.
        //  The 
        //
        pcolOneSeriesDefn->SetScalarREAL8( tagSeriesNominalQuantity, dNominal, true);
#endif
        }

    return status;
    }

bool CPQDIF_R_DataSource::SetSeriesDefnPrefix
            (
            long    idxChannelDefn,
            long    idxSeriesDefn,
            long    idPrefix
            )
    {
    bool    status = false;

    //  Find the one channel defn we're looking for
    CPQDIF_E_Collection *   pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn );
    if( pcolOneSeriesDefn )
        {
        status = true;
        //
        //
        //  The third parameter allows replacement of tag
        //  value if tag already present.  If tag not present,
        //  it is added and the value set.
        //  The 
        //
        pcolOneSeriesDefn->SetScalarUINT4( tagHintGreekPrefixID, idPrefix, true);
        }

    return status;
    }

bool CPQDIF_R_DataSource::SetSeriesDefnUnits
            (
            long    idxChannelDefn,
            long    idxSeriesDefn,
            long    idUnits
            )
    {
    bool    status = false;

    //  Find the one channel defn we're looking for
    CPQDIF_E_Collection *   pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn );
    if( pcolOneSeriesDefn )
        {
        status = true;
        //
        //
        //  The third parameter allows replacement of tag
        //  value if tag already present.  If tag not present,
        //  it is added and the value set.
        //  The 
        //
        pcolOneSeriesDefn->SetScalarUINT4( tagHintPreferredUnitsID, idUnits, true);
        }

    return status;
    }

bool CPQDIF_R_DataSource::SetSeriesDefnDisplay
            (
            long    idxChannelDefn,
            long    idxSeriesDefn,
            long    idDisplay
            )
    {
    bool    status = false;

    //  Find the one channel defn we're looking for
    CPQDIF_E_Collection *   pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn );
    if( pcolOneSeriesDefn )
        {
        status = true;
        //
        //
        //  The third parameter allows replacement of tag
        //  value if tag already present.  If tag not present,
        //  it is added and the value set.
        //  The 
        //
        pcolOneSeriesDefn->SetScalarUINT4( tagHintDefaultDisplayID, idDisplay, true);
        }

    return status;
    }

bool CPQDIF_R_DataSource::SetSeriesDefnDigits
            (
            long    idxChannelDefn,
            long    idxSeriesDefn,
            long    idDigits
            )
    {
    bool    status = false;

    //  Find the one channel defn we're looking for
    CPQDIF_E_Collection *   pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn );
    if( pcolOneSeriesDefn )
        {
        status = true;
        //
        //
        //  The third parameter allows replacement of tag
        //  value if tag already present.  If tag not present,
        //  it is added and the value set.
        //  The 
        //
        pcolOneSeriesDefn->SetScalarUINT4( tagQuantitySignificantDigitsID, idDigits, true);
        }

    return status;
    }


bool CPQDIF_R_DataSource::SetSeriesDefnResolution
            (
            long    idxChannelDefn,
            long    idxSeriesDefn,
            double  dRes
            )
    {
    bool    status = false;

    //  Find the one channel defn we're looking for
    CPQDIF_E_Collection *   pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn );
    if( pcolOneSeriesDefn )
        {
        status = true;
        //
        //
        //  The third parameter allows replacement of tag
        //  value if tag already present.  If tag not present,
        //  it is added and the value set.
        //  The 
        //
        pcolOneSeriesDefn->SetScalarREAL8( tagQuantityResolutionID, dRes, true);
        }

    return status;
    }


⌨️ 快捷键说明

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