@@ -76,7 +76,16 @@ def parse(cls, devstr: str) -> ndi_daq_daqsystemstring:
7676 channeltype = match .group (1 )
7777 numspec = match .group (2 )
7878
79+ # Check for threshold suffix (e.g., '_t2.5' in 'aep1-3_t2.5')
80+ threshold_str = ""
81+ t_idx = numspec .find ("_t" )
82+ if t_idx != - 1 :
83+ threshold_str = numspec [t_idx :]
84+ numspec = numspec [:t_idx ]
85+
7986 channellist = _parse_channel_numbers (numspec )
87+ if threshold_str :
88+ channeltype = channeltype + threshold_str
8089 channels .append ((channeltype , channellist ))
8190
8291 return cls (devicename = devicename , channels = channels )
@@ -96,8 +105,7 @@ def devicestring(self) -> str:
96105 if not channellist :
97106 parts .append (channeltype )
98107 else :
99- numstr = _format_channel_numbers (channellist )
100- parts .append (f"{ channeltype } { numstr } " )
108+ parts .append (ndi_daq_daqsystemstring .channeltype2str (channeltype , channellist ))
101109
102110 return f"{ self .devicename } :{ ';' .join (parts )} "
103111
@@ -132,6 +140,51 @@ def __str__(self) -> str:
132140 def __repr__ (self ) -> str :
133141 return f"ndi_daq_daqsystemstring('{ self .devicestring ()} ')"
134142
143+ @staticmethod
144+ def channeltype2str (ct : str , channellist : list [int ]) -> str :
145+ """
146+ Build a device string segment from a channeltype and channel list.
147+
148+ Handles threshold suffixes (e.g., ``_t2.5``) by placing the channel
149+ numbers between the base type and the suffix.
150+
151+ Args:
152+ ct: Channel type string, optionally with threshold suffix
153+ (e.g., ``'aep'`` or ``'aep_t2.5'``)
154+ channellist: List of channel numbers
155+
156+ Returns:
157+ Device string segment (e.g., ``'aep1-3_t2.5'``)
158+ """
159+ t_idx = ct .find ("_t" )
160+ if t_idx != - 1 :
161+ base = ct [:t_idx ]
162+ threshold_str = ct [t_idx :]
163+ return f"{ base } { _format_channel_numbers (channellist )} { threshold_str } "
164+ return f"{ ct } { _format_channel_numbers (channellist )} "
165+
166+ @staticmethod
167+ def parse_analog_event_channeltype (ct : str ) -> tuple [str , float ]:
168+ """
169+ Extract base type and threshold from a channel type string.
170+
171+ Given a channel type string like ``'aep_t2.5'``, returns the base
172+ type (``'aep'``) and threshold (``2.5``). If no threshold suffix
173+ is present, threshold is ``0.0``.
174+
175+ Args:
176+ ct: Channel type string (e.g., ``'aep_t2.5'``, ``'aimp'``)
177+
178+ Returns:
179+ Tuple of (base_type, threshold)
180+ """
181+ t_idx = ct .find ("_t" )
182+ if t_idx != - 1 :
183+ base_type = ct [:t_idx ]
184+ threshold = float (ct [t_idx + 2 :])
185+ return base_type , threshold
186+ return ct , 0.0
187+
135188 def __eq__ (self , other ) -> bool :
136189 if not isinstance (other , ndi_daq_daqsystemstring ):
137190 return False
0 commit comments