Exemplo n.º 1
0
def get_more_evidence():
    """
    Obtains a new piece of evidence and introduces it in the appropriate
    structures.
    """
    if BUF.get_status() is BUF.Status.STOPPED:
        return
    dtime = _TFACTOR * (T.time() - _T0) * 1000.0
    cursize = SIG.get_signal_length()
    if dtime - sp2ms(cursize) > sp2ms(_STEP):
        nchunks = int((min(ms2sp(dtime), _DURATION) - cursize) / _STEP)
        init = _OFFSET + cursize
        for i in xrange(len(_REC.leads)):
            fragment = _REC.signal[i, init:init + nchunks * _STEP]
            if len(fragment) < nchunks * _STEP:
                fragment = np.concatenate(
                    (fragment,
                     fragment[-1] * np.ones(_STEP - len(fragment) % _STEP)))
            SIG.add_signal_fragment(fragment, _REC.leads[i])
        for ann in (a for a in _ANNOTS
                    if ((is_qrs_annotation(a) or a.code is ECGCodes.FLWAV)
                        and init <= a.time < init + nchunks * _STEP)):
            rdef = o.RDeflection()
            atime = ann.time - _OFFSET
            rdef.time.value = Iv(atime, atime)
            #The level is established according to the annotation information.
            rdef.level = {
                SIG.VALID_LEAD_NAMES[lead]: 127
                for lead in _REC.leads
            }
            rdef.level[SIG.VALID_LEAD_NAMES[_REC.leads[ann.chan]]] = (127 -
                                                                      ann.num)
            rdef.freeze()
            BUF.publish_observation(rdef)
        newsize = SIG.get_signal_length()
        if newsize >= _DURATION or newsize >= len(_REC.signal[0]) - _OFFSET:
            BUF.set_status(BUF.Status.STOPPED)
Exemplo n.º 2
0
def stop():
    """Stops the acquisition of signal and evidence"""
    BUF.set_status(BUF.Status.STOPPED)
Exemplo n.º 3
0
def start():
    """Starts the acquisition of signal and evidence"""
    global _T0
    _T0 = T.time()
    BUF.set_status(BUF.Status.ACQUIRING)