Private Sub unarrollo_NewData (buflocal() As Byte)
Dim count As Int
Dim iii,jjj,punto,elcanal As Int
Dim canal(8) As Short
Dim Balto,Bbajo AsShort
Dim encontrado As Boolean
Dim pini,posi_inicio As Int
Dim dato As Double
Dim abit,bbit,cbit As Short
count=buflocal.Length
recibidos=recibidos+count
npaquetes=npaquetes+1
If count>3 Then
encontrado=False
pini=0
posi_inicio=-1
Do While encontrado=False
abit=Bit.AND(buflocal(pini),0xFF)
bbit=Bit.AND(buflocal(pini+1),0xFF)
cbit=Bit.AND(buflocal(pini+2),0xFF)
If (abit=0xFF) AND (bbit=0xFF) AND (cbit=0x0F) Then
posi_inicio=pini
encontrado=True
End If
pini=pini+1
If pini>count-6 Then encontrado=True
Loop
End If
Dim npbufer As Int
npbufer=(count-posi_inicio)
npbufer=(npbufer/21)-1
If (posi_inicio>=0) AND (npbufer>0) Then
' Hay un nuevo grupo de derivaciones
'If npbufer<=0 Then Return
posi_inicio=posi_inicio+5
For iii=0 To npbufer
punto=iii*21
' DoEvents
For jjj=0To7
elcanal=jjj*2
Balto=Bit.AND(buflocal(posi_inicio+punto+elcanal),0xFF)
Bbajo=Bit.AND(buflocal(posi_inicio+1+punto+elcanal),0xFF)
Balto=Bit.ShiftLeft(Balto,8)
canal(jjj)= Bit.OR(Balto,Bbajo)
Next
npecg=npecg+1
npuntostotales=npuntostotales+1
Ifnpecg>=npuntosecgThennpecg=0
ecg(0,npecg)=canal(1)
ecg(1,npecg)=canal(2)
ecg(2,npecg)=ecg(1,npecg)-ecg(0,npecg)
ecg(3,npecg)=-(ecg(0,npecg)+ecg(1,npecg))/2
ecg(4,npecg)=(ecg(0,npecg)-ecg(2,npecg))/2
ecg(5,npecg)=(ecg(1,npecg)+ecg(0,npecg))/2
ecg(6,npecg)=canal(7)
ecg(7,npecg)=canal(3)
ecg(8,npecg)=canal(4)
ecg(9,npecg)=canal(5)
ecg(10,npecg)=canal(6)
‘’ This is the code that, if removed, makes that app work fast
ganancia = 1.001701595e+00
For jjj=0 To ncanales-1
xv(jjj,0)= xv(jjj,1)
xv(jjj,1)= xv(jjj,2)
xv(jjj,2)= xv(jjj,3)
xv(jjj,3)= xv(jjj,4)
xv(jjj,4)=ecg(jjj,npecg)/ganancia
yv(jjj,0)= yv(jjj,1)
yv(jjj,1)= yv(jjj,2)
yv(jjj,2)= yv(jjj,3)
yv(jjj,3)= yv(jjj,4)
yv(jjj,4)=(xv(jjj,0)+xv(jjj,4))-4*(xv(jjj,1)+xv(jjj,3))+6*xv(jjj,2)+ _
(-0.9966061611*yv(jjj,0))+(3.9898113460*yv(jjj,1))+ _
(-5.9898042025*yv(jjj,2))+(3.9965990176*yv(jjj,3))
ecg(jjj,npecg)=(yv(jjj,4)) ' /divisory)
Next' jjj del filtro digital
If filtrado Then
ganancia=6.880159536e+01
For jjj=0 To ncanales-1
xxv(jjj,0)= xxv(jjj,1)
xxv(jjj,1)= xxv(jjj,2)
xxv(jjj,2)= xxv(jjj,3)
xxv(jjj,3)= xxv(jjj,4)
xxv(jjj,4)=ecg(jjj,npecg)/ganancia
yyv(jjj,0)= yyv(jjj,1)
yyv(jjj,1)= yyv(jjj,2)
yyv(jjj,2)= yyv(jjj,3)
yyv(jjj,3)= yyv(jjj,4)
yyv(jjj,4)=(xxv(jjj,0) + xxv(jjj,4)) + 4 * (xxv(jjj,1) + xxv(jjj,3)) + 6 * xxv(jjj,2)+ _
( -0.3042874459 * yyv(jjj,0)) + ( 1.2113918802 * yyv(jjj,1))+ _
( -2.1702818344 * yyv(jjj,2)) + ( 2.0306246530 * yyv(jjj,3))
ecg(jjj,npecg)=(yyv(jjj,4))
Next' { del For del filtrado digital }
EndIf' de filtrado pasa bajas
IfTrueThen' modulo(npecg,pasox)=0 Then
' xx = xx + dx
xant=xx
ii=ii+1
xx = (Div*ii)/50 ' 50 muestras de ECG corresponden a un cuadro de 5 mm (250 muest=25 mm)
If xx>GridW Then
EraseCurves
xx = 0
ii=0
xant=0
GetValues
DrawCurves
Return
End If
GetValues
DrawCurves
End If
Next ' iii Siguiente punto del ECG
If modulo(npecg,100)=0 Then let_paciente.Text="NE:"&NumberFormat(npecg,0,0)
EndIf ' Posi_inicio
End Sub' Llegaron bytes del ZiECG
[\code]