#
# Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
-from bt2 import native_bt, object, utils
-from bt2 import value as bt2_value
import uuid as uuidp
+from bt2 import utils as bt2_utils
+from bt2 import value as bt2_value
+from bt2 import object as bt2_object
+from bt2 import native_bt
+
class ClockClassOffset:
def __init__(self, seconds=0, cycles=0):
- utils._check_int64(seconds)
- utils._check_int64(cycles)
+ bt2_utils._check_int64(seconds)
+ bt2_utils._check_int64(cycles)
self._seconds = seconds
self._cycles = cycles
return (self.seconds, self.cycles) == (other.seconds, other.cycles)
-class _ClockClassConst(object._SharedObject):
+class _ClockClassConst(bt2_object._SharedObject):
@staticmethod
def _get_ref(ptr):
native_bt.clock_class_get_ref(ptr)
return uuidp.UUID(bytes=uuid_bytes)
def cycles_to_ns_from_origin(self, cycles):
- utils._check_uint64(cycles)
+ bt2_utils._check_uint64(cycles)
status, ns = native_bt.clock_class_cycles_to_ns_from_origin(self._ptr, cycles)
error_msg = "cannot convert clock value to nanoseconds from origin for given clock class"
- utils._handle_func_status(status, error_msg)
+ bt2_utils._handle_func_status(status, error_msg)
return ns
def _user_attributes(self, user_attributes):
value = bt2_value.create_value(user_attributes)
- utils._check_type(value, bt2_value.MapValue)
+ bt2_utils._check_type(value, bt2_value.MapValue)
native_bt.clock_class_set_user_attributes(self._ptr, value._ptr)
_user_attributes = property(fset=_user_attributes)
def _name(self, name):
- utils._check_str(name)
+ bt2_utils._check_str(name)
status = native_bt.clock_class_set_name(self._ptr, name)
- utils._handle_func_status(status, "cannot set clock class object's name")
+ bt2_utils._handle_func_status(status, "cannot set clock class object's name")
_name = property(fset=_name)
def _description(self, description):
- utils._check_str(description)
+ bt2_utils._check_str(description)
status = native_bt.clock_class_set_description(self._ptr, description)
- utils._handle_func_status(status, "cannot set clock class object's description")
+ bt2_utils._handle_func_status(
+ status, "cannot set clock class object's description"
+ )
_description = property(fset=_description)
def _frequency(self, frequency):
- utils._check_uint64(frequency)
+ bt2_utils._check_uint64(frequency)
native_bt.clock_class_set_frequency(self._ptr, frequency)
_frequency = property(fset=_frequency)
def _precision(self, precision):
- utils._check_uint64(precision)
+ bt2_utils._check_uint64(precision)
native_bt.clock_class_set_precision(self._ptr, precision)
_precision = property(fset=_precision)
def _offset(self, offset):
- utils._check_type(offset, ClockClassOffset)
+ bt2_utils._check_type(offset, ClockClassOffset)
native_bt.clock_class_set_offset(self._ptr, offset.seconds, offset.cycles)
_offset = property(fset=_offset)
def _origin_is_unix_epoch(self, origin_is_unix_epoch):
- utils._check_bool(origin_is_unix_epoch)
+ bt2_utils._check_bool(origin_is_unix_epoch)
native_bt.clock_class_set_origin_is_unix_epoch(
self._ptr, int(origin_is_unix_epoch)
)
_origin_is_unix_epoch = property(fset=_origin_is_unix_epoch)
def _uuid(self, uuid):
- utils._check_type(uuid, uuidp.UUID)
+ bt2_utils._check_type(uuid, uuidp.UUID)
native_bt.clock_class_set_uuid(self._ptr, uuid.bytes)
_uuid = property(fset=_uuid)