Click here to Skip to main content
15,879,474 members
Articles / Programming Languages / C++

ECG recording, storing, filtering and recognition

Rate me:
Please Sign up or sign in to vote.
4.72/5 (110 votes)
14 Apr 200411 min read 727.2K   38.4K   156  
Full open code project for making driver and application software for ECG medical measurements.
// MultimediaTimer.cpp: implementation of the MultimediaTimer class.
//
//////////////////////////////////////////////////////////////////////
//Petrov Georgi Kostadinov Multimedia Function Timer call
#include "stdafx.h"
#include "MultimediaTimer.h"
#include "Mmsystem.h"
#include "conio.h"
//don't forget to include Winmm.lib!!!

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

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



MultimediaTimer::~MultimediaTimer()
{

}

void MultimediaTimer::StartTimer(void* obj,int period, int resolution,ThreadTimerProc lpTimerProc)
{
//������� �� �������� ��� ������� �� ���� void
//typedef void(*ThreadTimerProc)(void* obj,UINT idEvent);
	i_count = 0;
	//void* object;//�������� ��� void
	object = obj;//�������� ����� ��� ��������
	//����� �� ����� ������ � ��������� ������ ������ �� ����������
	proc = lpTimerProc;//proc � ��������� ��� ���
	//������������ �������� ��� ����� � ����������
	if(period<2)
		period = 2;//max speed 500Hz
	if(resolution<10)
		resolution = 10;//min resolution +-50 Hz

	i_MMperiod = period;
	timeBeginPeriod(period);
	m_idEvent = timeSetEvent(
		i_MMperiod,
		resolution,
		TimerFunction,//CALLBACK ������� ����� ���������� � ��������� 
		//����� �� �������� �������
		(DWORD)this,//�������� ��� ���� ����
		TIME_PERIODIC|TIME_CALLBACK_FUNCTION);
}

void CALLBACK MultimediaTimer::TimerFunction(UINT wTimerID, UINT msg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
	MultimediaTimer * ptimer = (MultimediaTimer*) dwUser;
	ptimer->MMTimerHandler();//�������� ������� � ����� ����

	//proc = lpTimerProc;//proc � ��������� ��� ���
	//������������ ������� �� �������� ��� ������� void( ����� � ����������)
	///void* object;//� �������� ��� �������� ����� �� �����
	//� ����� �� ������ ��������� ����� �� ����������
	////UINT m_idEvent;
//������� �� �������� ��� ������� �� ���� void
//typedef void(*ThreadTimerProc)(void* obj,UINT idEvent);
	//������ ���������� ���� ��� �� �� ��������� �� -> 
	//���� � ��� ��������!!! ��� �������� ����� ��������
	//proc(object,m_idEvent);
	ptimer->proc (ptimer->object, ptimer->m_idEvent);//��������� 
	//� ����� �� ������� ����� �� �������� �� �������-���������
}

void MultimediaTimer::MMTimerHandler()
{


}

void MultimediaTimer::StopTimer()
{
	timeKillEvent(m_idEvent);//destroy event ID

	timeEndPeriod(i_MMperiod);
}
/*
How to use?
void CTurboDlg::OnStop() 
{
	// TODO: Add your control notification handler code here
	MMTimer.StopTimer();
	UpdateData(false);
}
DECLARE AS STATIC!!!!!!!!!!!!!!!!
//This is our receiver function on our class that will use MM timer
static	void TimerFunction(void* obj,UINT idEvent);

void CTurboDlg::TimerFunction(void* obj,UINT idEvent)
{
	CTurboDlg * dlg = (CTurboDlg*) obj;
	dlg->handleTimer(idEvent);//��������� ��� ���������
	//� ��������� ����
}

void CTurboDlg::OnStart() 
{
	// TODO: Add your control notification handler code here
	m_count = 0;
	//TimerFunction ��� ��� ���������� �������� ��� ��������
	//����� �� ������� ���� � ���������� UINT idEvant
	//��� ����������� �� TimerFunction � ����� �� �������
	//���� � �������� ��� ����� ����� ������ � ����������
	MMTimer.StartTimer(this,2,10,TimerFunction);	
}

void CTurboDlg::handleTimer(UINT nIDEvent)
{
	if(m_count<5000)
		m_count++;
	else
		MMTimer.StopTimer();
}

void CTurboDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	
	CDialog::OnTimer(nIDEvent);
}
*/

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Systems Engineer
Bulgaria Bulgaria
PhD, Cum Laude in digital automation systems
M.S. in Telemommunication management
B.S. in Telecommunication systems engineering
Programming: CUDA, C/C++, VHDL
Software and Hardware development and consulting:
data acquisition, image processing, medical instrumentation

Comments and Discussions