Ejemplo n.º 1
0
        public int setSignals(Signals signals)
        {
            if ((signals != null) &&
                (signals.NrLeads != 0))
            {
                _MedianDataLength = signals.MedianLength;
                _FirstFiducial    = signals.MedianFiducialPoint;

                if (signals.QRSZone == null)
                {
                    _NrQRS       = 0;
                    _Subtraction = null;
                    _Protected   = null;
                }
                else
                {
                    _NrQRS       = (ushort)signals.QRSZone.Length;
                    _Subtraction = new SCPQRSSubtraction[_NrQRS];
                    _Protected   = new SCPQRSProtected[_NrQRS];

                    for (int loper = 0; loper < _NrQRS; loper++)
                    {
                        _Subtraction[loper] = new SCPQRSSubtraction();
                        _Protected[loper]   = new SCPQRSProtected();

                        if (signals.QRSZone[loper] != null)
                        {
                            _Subtraction[loper].Type     = signals.QRSZone[loper].Type;
                            _Subtraction[loper].Fiducial = signals.QRSZone[loper].Fiducial;

                            if (_Subtraction[loper].Type == 0)
                            {
                                _Subtraction[loper].Start = signals.QRSZone[loper].Start + 1;
                                _Subtraction[loper].End   = signals.QRSZone[loper].End;

                                if (((_Subtraction[loper].End - _Subtraction[loper].Fiducial) + _FirstFiducial)
                                    >= ((signals.MedianLength * signals.MedianSamplesPerSecond) / 1000))
                                {
                                    _Subtraction[loper].End = (int)(((((signals.MedianLength * signals.MedianSamplesPerSecond) / 1000) - _FirstFiducial) + _Subtraction[loper].Fiducial - 2) & 0xfffffffe);
                                }

                                _Protected[loper].Start = _Subtraction[loper].Start;
                                _Protected[loper].End   = _Subtraction[loper].End;
                            }
                            else
                            {
                            }
                        }
                    }
                }

                return(0);
            }
            return(1);
        }
Ejemplo n.º 2
0
        protected override int _Read(byte[] buffer, int offset)
        {
            int end = offset - Size + Length;

            if ((offset + Marshal.SizeOf(_MedianDataLength) + Marshal.SizeOf(_FirstFiducial) + Marshal.SizeOf(_NrQRS)) > end)
            {
                return(0x1);
            }
            _MedianDataLength = (ushort)BytesTool.readBytes(buffer, offset, Marshal.SizeOf(_MedianDataLength), true);
            offset           += Marshal.SizeOf(_MedianDataLength);
            _FirstFiducial    = (ushort)BytesTool.readBytes(buffer, offset, Marshal.SizeOf(_FirstFiducial), true);
            offset           += Marshal.SizeOf(_FirstFiducial);
            _NrQRS            = (ushort)BytesTool.readBytes(buffer, offset, Marshal.SizeOf(_NrQRS), true);
            offset           += Marshal.SizeOf(_NrQRS);
            if ((offset + (_NrQRS * SCPQRSSubtraction.Size)) > end)
            {
                return(0x2);
            }
            _Subtraction = new SCPQRSSubtraction[_NrQRS];
            for (int loper = 0; loper < _NrQRS; loper++)
            {
                _Subtraction[loper] = new SCPQRSSubtraction();
                int err = _Subtraction[loper].Read(buffer, offset);
                if (err != 0)
                {
                    return(err << (2 + loper));
                }
                offset += SCPQRSSubtraction.Size;
            }

            if ((offset + (_NrQRS * SCPQRSProtected.Size)) > end)
            {
                return(0x0);
            }

            _Protected = new SCPQRSProtected[_NrQRS];
            for (int loper = 0; loper < _NrQRS; loper++)
            {
                _Protected[loper] = new SCPQRSProtected();
                int err = _Protected[loper].Read(buffer, offset);
                if (err != 0)
                {
                    return(err << (2 + loper));
                }
                offset += SCPQRSProtected.Size;
            }
            return(0x0);
        }