📄 rec_observ.cpp
字号:
// Add it!
pcolInstances->Add( pcollOne );
}
return idxNew;
}
long CPQDIF_R_Observation::AddSeriesDouble
(
long idxChannel,
long countValues,
double * arValues
)
{
long idxNew = -1;
CPQDIF_E_Vector * pvectData;
long idx;
double * pValue;
// Create vector for the series data
pvectData = (CPQDIF_E_Vector *) theFactory.NewElement( ID_ELEMENT_TYPE_VECTOR );
if( pvectData )
{
pvectData->SetTag( tagSeriesValues );
pvectData->SetPhysicalType( ID_PHYS_TYPE_REAL8 );
// Copy over series data
pValue = arValues;
pvectData->SetCount( countValues );
for( idx = 0; idx < countValues; idx++, pValue++ )
{
pvectData->SetValue( idx, *pValue );
}
// Add it ...
idxNew = AddSeriesVector( idxChannel, pvectData );
// If it was not successful, delete the vector
if( idxNew < 0 )
{
delete pvectData;
}
}
return idxNew;
}
long CPQDIF_R_Observation::AddSeriesVector
(
long idxChannel,
CPQDIF_E_Vector * pvectData
)
{
long idxNew = -1;
CPQDIF_E_Collection * pcolOneChannel;
CPQDIF_E_Collection * pcolSI;
CPQDIF_E_Collection * pcollOne;
pcolOneChannel = GetOneChannel( idxChannel );
if( pcolOneChannel && pvectData )
{
pcolSI = GetSeriesInstances( pcolOneChannel );
if( pcolSI )
{
// New channel index
idxNew = pcolSI->GetCount();
// Create the new channel def'n
pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION );
if( pcollOne )
{
// Set the tag for this collection ...
pcollOne->SetTag( tagOneSeriesInstance );
// Make sure the vector has the right tag ...
pvectData->SetTag( tagSeriesValues );
// The vector is currently the only member of this collection.
pcollOne->Add( pvectData );
}
// Add it!
pcolSI->Add( pcollOne );
}
}
return idxNew;
}
long CPQDIF_R_Observation::AddSeriesShared
(
long idxChannel,
long idxChannelShared,
long idxSeriesShared
)
{
long idxNew = -1;
CPQDIF_E_Collection * pcolOneChannel;
CPQDIF_E_Collection * pcolSI;
CPQDIF_E_Collection * pcollOne;
CPQDIF_E_Scalar * pscSharedChannel;
CPQDIF_E_Scalar * pscSharedSeries;
pcolOneChannel = GetOneChannel( idxChannel );
if( pcolOneChannel )
{
pcolSI = GetSeriesInstances( pcolOneChannel );
if( pcolSI )
{
// New channel index
idxNew = pcolSI->GetCount();
// Create the new channel def'n
pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION );
if( pcollOne )
{
// Set the tag for this collection ...
pcollOne->SetTag( tagOneSeriesInstance );
// Create scalars which indicate which channel/series is to be shared
pscSharedChannel = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR );
pscSharedSeries = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR );
if( pscSharedChannel && pscSharedSeries )
{
// Tags & values
pscSharedChannel->SetTag( tagSeriesShareChannelIdx );
pscSharedChannel->SetPhysicalType( ID_PHYS_TYPE_UNS_INTEGER4 );
pscSharedChannel->SetValueUINT4( idxChannelShared );
pscSharedSeries->SetTag( tagSeriesShareSeriesIdx );
pscSharedSeries->SetPhysicalType( ID_PHYS_TYPE_UNS_INTEGER4 );
pscSharedSeries->SetValueUINT4( idxSeriesShared );
// Stuff 'em
pcollOne->Add( pscSharedChannel );
pcollOne->Add( pscSharedSeries );
}
}
// Add it!
pcolSI->Add( pcollOne );
}
}
return idxNew;
}
bool CPQDIF_R_Observation::SetSeriesBaseQuantity
(
long idxChannel,
long idxSeries,
double value
)
{
bool status = false;
CPQDIF_E_Collection * pcol;
CPQDIF_E_Scalar * psc;
// Find the series
pcol = GetOneSeries( idxChannel, idxSeries );
if( pcol )
{
psc = FindScalarInCollection( pcol, tagSeriesBaseQuantity );
if( !psc )
{
// Create it !
psc = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR );
if( psc )
{
pcol->Add( psc );
}
}
// Init the scalar
if( psc )
{
psc->SetTag( tagSeriesBaseQuantity );
psc->SetValueREAL8( value );
status = TRUE;
}
}
return status;
}
bool CPQDIF_R_Observation::SetSeriesScale
(
long idxChannel,
long idxSeries,
double scale,
double offset
)
{
bool status = false;
CPQDIF_E_Collection * pcol;
CPQDIF_E_Scalar * psc;
#ifdef zap
// Find the series
pcol = GetOneSeries( idxChannel, idxSeries );
if( pcol )
{
psc = FindOrCreateScalarInCollection( pcol, tagSeriesScale, ID_PHYS_TYPE_REAL8 );
if( psc )
{
status = psc->SetValueREAL8( scale );
}
psc = FindOrCreateScalarInCollection( pcol, tagSeriesOffset, ID_PHYS_TYPE_REAL8 );
if( psc )
{
status = psc->SetValueREAL8( offset );
}
}
#endif
// Find the series
pcol = GetOneSeries( idxChannel, idxSeries );
if( pcol )
{
psc = FindScalarInCollection( pcol, tagSeriesScale );
if( !psc )
{
// Create it !
psc = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR );
if( psc )
{
pcol->Add( psc );
}
}
// Init the scalar
if( psc )
{
psc->SetTag( tagSeriesScale );
psc->SetValueREAL8( scale );
status = TRUE;
}
psc = FindScalarInCollection( pcol, tagSeriesOffset );
if( !psc )
{
// Create it !
psc = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR );
if( psc )
{
pcol->Add( psc );
}
}
// Init the scalar
if( psc )
{
psc->SetTag( tagSeriesOffset );
psc->SetValueREAL8( offset );
status = TRUE;
}
}
return status;
}
bool CPQDIF_R_Observation::GetSeriesBaseQuantity
(
long idxChannel,
long idxSeries,
double& value
)
{
bool status = false;
CPQDIF_E_Collection * pcol;
CPQDIF_E_Scalar * psc;
// Find the series
pcol = GetOneSeries( idxChannel, idxSeries );
if( pcol )
{
psc = FindScalarInCollection( pcol, tagSeriesBaseQuantity );
if( psc )
{
status = psc->GetValueREAL8( value );
}
}
return status;
}
#ifdef PQDIF_USE_COM
bool CPQDIF_R_Observation::GetObservationExtendedData
(
GUID& gidTag,
VARIANT& value
)
{
bool status = false;
CPQDIF_E_Scalar * psc;
psc = FindScalarInCollection( m_record->m_pcollMain, gidTag );
if( psc )
{
status = psc->GetValue( value );
}
return status;
}
bool CPQDIF_R_Observation::GetSeriesExtendedData
(
long idxChannel,
long idxSeries,
GUID& gidTag,
VARIANT& value
)
{
bool status = false;
CPQDIF_E_Collection * pcollOneChannel;
CPQDIF_E_Scalar * psc;
pcollOneChannel = GetOneSeries( idxChannel, idxSeries );
if (pcollOneChannel)
{
psc = FindScalarInCollection( pcollOneChannel, gidTag );
if( psc )
{
status = psc->GetValue( value );
}
}
return status;
}
bool CPQDIF_R_Observation::GetChannelExtendedData
(
long idxChannel,
GUID& gidTag,
VARIANT& value
)
{
bool status = false;
CPQDIF_E_Collection * pcollOneChannel;
CPQDIF_E_Scalar * psc;
pcollOneChannel = GetOneChannel( idxChannel );
if (pcollOneChannel)
{
psc = FindScalarInCollection( pcollOneChannel, gidTag );
if( psc )
{
status = psc->GetValue( value );
}
}
return status;
}
#endif
bool CPQDIF_R_Observation::GetSeriesDefnNominal
(
long idxChannel,
long idxSeries,
double & dNominal
)
{
bool status = false;
long idxChannelDefn;
status = GetChannelDefnIdx( idxChannel, idxChannelDefn );
if (m_pds)
{
status = m_pds->GetSeriesDefnNominal(idxChannelDefn, idxSeries, dNominal);
}
return status;
}
bool CPQDIF_R_Observation::GetSeriesDefnPrecisionAndResolution
(
long idxChannel,
long idxSeries,
UINT4 & uPrecision,
double & dResolution
)
{
bool status = false;
long idxChannelDefn;
status = GetChannelDefnIdx( idxChannel, idxChannelDefn );
if (m_pds)
{
status = m_pds->GetSeriesDefnPrecisionAndResolution(idxChannelDefn, idxSeries, uPrecision, dResolution);
}
return status;
}
bool CPQDIF_R_Observation::GetSeriesScale
(
long idxChannel,
long idxSeries,
double& scale,
double& offset
)
{
bool status = false;
CPQDIF_E_Collection * pcol;
CPQDIF_E_Scalar * psc;
// Find the series
pcol = GetOneSeries( idxChannel, idxSeries );
if( pcol )
{
psc = FindScalarInCollection( pcol, tagSeriesScale );
if( psc )
{
status = psc->GetValueREAL8( scale );
}
psc = FindScalarInCollection( pcol, tagSeriesOffset );
if( psc )
{
status = psc->GetValueREAL8( offset );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -