def add_trigger(self, group, timestamp, pre_time=0, post_time=0, comment=""):
        """ add trigger to data group

        Parameters
        ----------
        group : int
            group index
        timestamp : float
            trigger time
        pre_time : float
            trigger pre time; default 0
        post_time : float
            trigger post time; default 0
        comment : str
            trigger comment

        """
        comment_template = """<EVcomment>
    <TX>{}</TX>
</EVcomment>"""
        try:
            group = self.groups[group]
        except IndexError:
            return

        trigger = group.trigger

        if comment:
            try:
                comment = ET.fromstring(comment)
                if comment.find(".//TX"):
                    comment = comment.find(".//TX").text
                else:
                    comment = ""
            except ET.ParseError:
                pass

        if trigger:
            count = trigger["trigger_events_nr"]
            trigger["trigger_events_nr"] += 1
            trigger.block_len += 24
            trigger[f"trigger_{count}_time"] = timestamp
            trigger[f"trigger_{count}_pretime"] = pre_time
            trigger[f"trigger_{count}_posttime"] = post_time
            if comment:
                if trigger.comment is None:
                    comment = f"{count + 1}. {comment}"
                    comment = comment_template.format(comment)
                    trigger.comment = comment
                else:
                    current_comment = trigger.comment
                    try:
                        current_comment = ET.fromstring(current_comment)
                        if current_comment.find(".//TX"):
                            current_comment = current_comment.find(".//TX").text
                        else:
                            current_comment = ""
                    except ET.ParseError:
                        pass

                    comment = f"{current_comment}\n{count + 1}. {comment}"
                    comment = comment_template.format(comment)
                    trigger.comment = comment
        else:
            trigger = TriggerBlock(
                trigger_event_nr=1,
                trigger_0_time=timestamp,
                trigger_0_pretime=pre_time,
                trigger_0_posttime=post_time,
            )
            if comment:
                comment = f"1. {comment}"
                comment = comment_template.format(comment)
                trigger.comment = comment

            group.trigger = trigger
def add_trigger ( self , group , timestamp , pre_time = 0 , post_time = 0 , comment = "" ) : comment_template = """<EVcomment>
    <TX>{}</TX>
</EVcomment>""" try : group = self . groups [ group ] except IndexError : return trigger = group . trigger if comment : try : comment = ET . fromstring ( comment ) if comment . find ( ".//TX" ) : comment = comment . find ( ".//TX" ) . text else : comment = "" except ET . ParseError : pass if trigger : count = trigger [ "trigger_events_nr" ] trigger [ "trigger_events_nr" ] += 1 trigger . block_len += 24 trigger [ f"trigger_{count}_time" ] = timestamp trigger [ f"trigger_{count}_pretime" ] = pre_time trigger [ f"trigger_{count}_posttime" ] = post_time if comment : if trigger . comment is None : comment = f"{count + 1}. {comment}" comment = comment_template . format ( comment ) trigger . comment = comment else : current_comment = trigger . comment try : current_comment = ET . fromstring ( current_comment ) if current_comment . find ( ".//TX" ) : current_comment = current_comment . find ( ".//TX" ) . text else : current_comment = "" except ET . ParseError : pass comment = f"{current_comment}\n{count + 1}. {comment}" comment = comment_template . format ( comment ) trigger . comment = comment else : trigger = TriggerBlock ( trigger_event_nr = 1 , trigger_0_time = timestamp , trigger_0_pretime = pre_time , trigger_0_posttime = post_time , ) if comment : comment = f"1. {comment}" comment = comment_template . format ( comment ) trigger . comment = comment group . trigger = trigger
add trigger to data group

        Parameters
        ----------
        group : int
            group index
        timestamp : float
            trigger time
        pre_time : float
            trigger pre time; default 0
        post_time : float
            trigger post time; default 0
        comment : str
            trigger comment