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

📄 ecg_data.cpp

📁 一个开源的心电图测量仪驱动和应用软件,可记录
💻 CPP
字号:
// ECG_Data.cpp: implementation of the ECG_Data class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ECG_1.h"
#include "ECG_Data.h"
#include "Person.h"
#include "Ecg_Info.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CECG_Data::CECG_Data()
{

}

CECG_Data::~CECG_Data()
{

}

void CECG_Data::SetDataNew(double *source, int lenght,CString comment,int QRS_count,int QRS_ms,int PR_ms,int QT_QTc_ms,BYTE hh,BYTE mm)
{
	for(int i = 0;i<lenght;i++)
	{
		DATA.Add(short(*(source+i)));
	}
	COMMENT.Add(comment);
	QRS_COUNT.Add(QRS_count);
	QRS_MS.Add(QRS_ms);
	PR_MS.Add(PR_ms);
	QT_QTc_MS.Add(QT_QTc_ms);
	TIME.Add(SetTime(hh,mm));
}

void CECG_Data::SetDataAt(double *source,int start, int lenght)
{
	//Set data at specific position in start
	//Chect for overloading DATA array
	if(start+lenght<=GetAllDataLenght())
	{
		for(int i=0;i<lenght;i++)
		{
			DATA.SetAt(start+i,short(*(source+i)));
		}
	}
}

void CECG_Data::GetFrom(double *dest,int start, int lenght)
{
	//gets data from specific position start
	//Chect for overloading DATA array
	if(start+lenght<=GetAllDataLenght())
	{
		for(int i=0;i<lenght;i++)
		{
			*(dest+i) = double(short(DATA.GetAt(start+i)));
		}
	}
}

void CECG_Data::Message(double msg)
{
	short i = -32000;
	DATA.Add(i);
	CString str;
	str.Format("%d",short(DATA.GetAt(0)));
	str.Format("%d",GetAllDataLenght());
	MessageBox(NULL,str,"Message",MB_OK);
}

int CECG_Data::GetAllDataLenght()
{
	return DATA.GetSize();
}

void CECG_Data::SaveData(CString File_Name)
{
	CFile sFile(File_Name,CFile::modeCreate|CFile::modeWrite);
	CArchive dArchive(&sFile,CArchive::store);
	
	//Serialize the arrays
	SerializeAll(&dArchive);
}

void CECG_Data::OpenFile(CString File_Name)
{
	RemoveAll();
	CFile oFile(File_Name,CFile::modeRead);
	//Move file pointer to the file begining
	oFile.Seek(0,CFile::begin);
	DWORD f_lenght = oFile.GetLength();
	CArchive dArchive(&oFile,CArchive::load);
	
	//Serialize the arrays
	SerializeAll(&dArchive);
}

void CECG_Data::RemoveAll()
{
	//Free the memory
	DATA.RemoveAll();
	COMMENT.RemoveAll();
	QRS_COUNT.RemoveAll();
	QRS_MS.RemoveAll();
	PR_MS.RemoveAll();
	QT_QTc_MS.RemoveAll();
	TIME.RemoveAll();
}

void CECG_Data::SerializeAll(CArchive* ar)
{
	//Serialize the arrays
	DATA.Serialize(*ar);
	COMMENT.Serialize(*ar);
	QRS_COUNT.Serialize(*ar);
	QRS_MS.Serialize(*ar);
	PR_MS.Serialize(*ar);
	QT_QTc_MS.Serialize(*ar);
	TIME.Serialize(*ar);

	person.Serialize(*ar);
	ecg_info.Serialize(*ar);
}

void CECG_Data::SetInfoAt(int pos, CString comment, int qrs_count, int qrs_ms, int pr_ms, int qt_qtc_ms,BYTE hh,BYTE mm)
{
	if(pos<=QRS_COUNT.GetSize())
	{
		QRS_COUNT.SetAt(pos,qrs_count);
		COMMENT.SetAt(pos,comment);
		QRS_MS.SetAt(pos,qrs_ms);
		PR_MS.SetAt(pos,pr_ms);
		QT_QTc_MS.SetAt(pos,qt_qtc_ms);	
		TIME.SetAt(pos,SetTime(hh,mm));
	}
}

CString CECG_Data::GetInfoFrom(int pos, int *qrs_count, int *qrs_ms, int *pr_ms, int *qt_qtc_ms,BYTE* hh,BYTE* mm)
{
	if(pos<=QRS_COUNT.GetSize())
	{
		*qrs_count = QRS_COUNT.GetAt(pos);
		*qrs_ms = QRS_MS.GetAt(pos);
		*pr_ms = PR_MS.GetAt(pos);
		*qt_qtc_ms = QT_QTc_MS.GetAt(pos);
		GetTime(TIME.GetAt(pos),hh,mm);
	}
	return COMMENT.GetAt(pos);
}


WORD CECG_Data::SetTime(BYTE hh, BYTE mm)
{
	//converts hh & mm in to one word variable
	WORD w_time;
	w_time = hh;
	w_time = w_time << 8;
	w_time = w_time|mm;

	return w_time;

}

void CECG_Data::GetTime(WORD w_time, BYTE *hh, BYTE *mm)
{
	*mm = w_time & 0xFF;
	w_time = w_time >> 8;
	*hh = w_time & 0xFF;

}

int CECG_Data::GetQRSCount(int pos)
{
	//returns the QRS count for a specific record
	int count=0;
	if(pos<=QRS_COUNT.GetSize())
		count = QRS_COUNT.GetAt(pos);

	return count;
}

void CECG_Data::GetPosTime(int pos, BYTE *hh, BYTE *mm)
{
	if(pos<=TIME.GetSize())
	{
		if(pos<=TIME.GetSize())
		{
			GetTime(TIME.GetAt(pos),hh,mm);
		}
	}
}

int CECG_Data::GetQRSms(int pos)
{
	int count=0;
	if(pos<=QRS_MS.GetSize())
		count = QRS_MS.GetAt(pos);

	return count;

}

int CECG_Data::GetPRms(int pos)
{
	int count=0;
	if(pos<=PR_MS.GetSize())
		count = PR_MS.GetAt(pos);

	return count;
}

int CECG_Data::GetQTQTcms(int pos)
{
	int count=0;
	if(pos<=QT_QTc_MS.GetSize())
		count = QT_QTc_MS.GetAt(pos);

	return count;
}

⌨️ 快捷键说明

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