www.pudn.com > PressMonitor_q.zip > MonitorDataset.cpp


// MonitorDataset.cpp: implementation of the CMonitorDataset class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#include "stdafx.h" 
#include "Monitor.h" 
#include "MonitorDataset.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char THIS_FILE[]=__FILE__; 
#define new DEBUG_NEW 
#endif 
 
////////////////////////////////////////////////////////////////////// 
// Construction/Destruction 
////////////////////////////////////////////////////////////////////// 
IMPLEMENT_SERIAL(CMonitorDataset, CObject, 2) 
 
CMonitorDataset::CMonitorDataset() 
{ 
} 
 
CMonitorDataset::~CMonitorDataset() 
{ 
} 
 
bool CMonitorDataset::AddData(double value, CTime time) 
{ 
    int index = m_valueArray.Add(value); 
	if(index <0) 
        return false; 
 
    index = m_timeArray.Add(time); 
	if(index <0) 
        return false; 
    return true; 
} 
 
void CMonitorDataset::ShiftData(double value,CTime time) 
{ 
	for(int f=0;f GetDataArraySize() ) 
		return ; 
	 
	m_valueArray.SetAt( index, value ); 
	m_timeArray.SetAt( index, time  ); 
} 
 
double CMonitorDataset::GetData(int index) 
{ 
	 
    return m_valueArray.GetAt(index); 
	 
} 
 
int CMonitorDataset::GetDataArraySize() 
{ 
	return m_valueArray.GetSize(); 
} 
 
CTime CMonitorDataset::GetTime(int index) 
{ 
	return m_timeArray.GetAt(index); 
} 
 
 
bool CMonitorDataset::GetMinMaxValue(double& nMin, double& nMax) 
{ 
	double min, max, temp; 
 
	if( GetDataArraySize() > 0 ) { 
		temp=GetData( 0 ); 
		// following lines help me to solve some problems with invalid values 
		if( temp == DATA_VALUE_INVALID ) { 
			min = DATA_VALUE_INVALID; 
			max = -DATA_VALUE_INVALID; 
		} 
		for( int f=1; f max ) 
					max = temp; 
			} 
		} 
		nMin = min; 
		nMax = max; 
		return true; 
	} else 
		return false; 
} 
 
void CMonitorDataset::Serialize(CArchive& ar) 
{ 
	if (ar.IsStoring()) 
	{ 
	} 
	else 
	{ 
	} 
	m_valueArray.Serialize(ar); 
	m_timeArray.Serialize(ar); 
}