コード例 #1
0
ファイル: SCPSection3.cs プロジェクト: zxy30/ECGToolkit
        protected override int _Read(byte[] buffer, int offset)
        {
            int end = offset - Size + Length;

            if ((offset + Marshal.SizeOf(_NrLeads) + Marshal.SizeOf(_Flags)) > end)
            {
                return(0x1);
            }
            _NrLeads = (byte)BytesTool.readBytes(buffer, offset, Marshal.SizeOf(_NrLeads), true);
            offset  += Marshal.SizeOf(_NrLeads);
            _Flags   = (byte)BytesTool.readBytes(buffer, offset, Marshal.SizeOf(_Flags), true);
            offset  += Marshal.SizeOf(_Flags);
            if (offset + (_NrLeads * SCPLead.Size) > end)
            {
                _Empty();
                return(0x2);
            }

            // BEGIN DIRTY SOLUTION!!!
            // this solution is for a bug in some CCW files.
            if (((end - offset) / SCPLead.Size) > _NrLeads)
            {
                _NrLeads = (byte)((end - offset) / SCPLead.Size);
            }
            // END DIRTY SOLUTION!!!

            _Leads = new SCPLead[_NrLeads];
            for (int loper = 0; loper < _NrLeads; loper++)
            {
                _Leads[loper] = new SCPLead();
                int err = _Leads[loper].Read(buffer, offset);
                if (err != 0)
                {
                    return(err << 2 + loper);
                }
                offset += SCPLead.Size;
            }
            return(0x0);
        }
コード例 #2
0
ファイル: SCPSection3.cs プロジェクト: zxy30/ECGToolkit
        public int setSignals(Signals signals)
        {
            if ((signals != null) &&
                (signals.NrLeads > 0) &&
                (signals.RhythmSamplesPerSecond != 0))
            {
                _NrLeads = (byte)signals.NrLeads;
                _Leads   = new SCPLead[_NrLeads];
                _Flags   = 0;
                for (int loper = 0; loper < _NrLeads; loper++)
                {
                    if (signals[loper] == null)
                    {
                        return(2);
                    }

                    _Leads[loper] = new SCPLead();
                    if (signals.MedianSamplesPerSecond != 0)
                    {
                        _Leads[loper].Start = (signals[loper].RhythmStart * signals.MedianSamplesPerSecond) / signals.RhythmSamplesPerSecond + 1;
                        _Leads[loper].End   = (signals[loper].RhythmEnd * signals.MedianSamplesPerSecond) / signals.RhythmSamplesPerSecond;
                    }
                    else
                    {
                        _Leads[loper].Start = signals[loper].RhythmStart + 1;
                        _Leads[loper].End   = signals[loper].RhythmEnd;
                    }
                    _Leads[loper].ID = (byte)signals[loper].Type;
                }

                if (_isSimultaneously())
                {
                    _Flags |= 0x4;
                }
                return(0);
            }
            return(1);
        }