1.1.0版本

This commit is contained in:
xinzhu.yin
2026-04-16 16:51:05 +08:00
commit c157e774e5
333 changed files with 70759 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
from UniTAP.common.timestamp import Timestamp
class ResultObject:
"""
The base class of all capture results.
Contains information about `start_capture_time`, `end_capture_time`, `timestamp` and `buffer` with captured data.
"""
def __init__(self):
self.__start_capture_time = 0
self.__end_capture_time = 0
self.__timestamp = Timestamp(0)
self.__buffer = []
@property
def start_capture_time(self) -> int:
"""
Return start capture time.
Returns:
object of `int` type
"""
return self.__start_capture_time
@property
def end_capture_time(self) -> int:
"""
Return end capture time.
Returns:
object of `int` type
"""
return self.__end_capture_time
@property
def timestamp(self) -> Timestamp:
"""
Return timestamp.
Returns:
object of `Timestamp` type
"""
return self.__timestamp
@property
def buffer(self) -> list:
"""
Return buffer with captured data.
Returns:
object of list type
"""
return self.__buffer
@buffer.setter
def buffer(self, value):
"""
Set data to buffer
Args:
value - any type of object
"""
self.__buffer.append(value)
@start_capture_time.setter
def start_capture_time(self, start_capture_time: int):
"""
Set start capture time.
Args:
start_capture_time (int) - must be more than 0.
"""
if start_capture_time <= 0:
raise ValueError(f"Start capture time cannot be less than 0.")
self.__start_capture_time = start_capture_time
@end_capture_time.setter
def end_capture_time(self, end_capture_time: int):
"""
Set end capture time.
Args:
end_capture_time (int) - must be more than 0.
"""
if end_capture_time <= 0:
raise ValueError(f"End capture time cannot be less than 0.")
self.__end_capture_time = end_capture_time
@timestamp.setter
def timestamp(self, timestamp: int):
"""
Set timestamp.
Args:
timestamp (int) - must be more than 0.
"""
if timestamp <= 0:
raise ValueError(f"Timestamp cannot be less than 0.")
self.__timestamp.value = timestamp
def clear(self):
"""
Clear all data.
"""
self.__start_capture_time = 0
self.__end_capture_time = 0
self.__timestamp = Timestamp(0)
self.__buffer = []