本文整理汇总了Python中device.Device方法的典型用法代码示例。如果您正苦于以下问题:Python device.Device方法的具体用法?Python device.Device怎么用?Python device.Device使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类device
的用法示例。
在下文中一共展示了device.Device方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _servicepacket
# 需要导入模块: import device [as 别名]
# 或者: from device import Device [as 别名]
def _servicepacket(self, host, port, packet):
service = packet.payload.service
port = packet.payload.port
deviceid = packet.frame_address.target
if deviceid not in self._devices and service == protocol.SERVICE_UDP:
# Create a new Device
new_device = Device(deviceid, host, self)
# Send its own packets to it
pktfilter = lambda p:(
p.frame_address.target == deviceid
and (
p.protocol_header.pkt_type == protocol.TYPE_ACKNOWLEDGEMENT
or p.protocol_header.pkt_type == protocol.TYPE_ECHORESPONSE
or p.protocol_header.pkt_type in protocol.CLASS_TYPE_STATE
))
self._transport.register_packet_handler(new_device._packethandler, pktfilter)
# Send the service packet directly to the device
new_device._packethandler(host, port, packet)
# Store it
self._devices[deviceid] = new_device
示例2: _grouppacket
# 需要导入模块: import device [as 别名]
# 或者: from device import Device [as 别名]
def _grouppacket(self, host, port, packet):
# Gather Data
group_id = packet.payload.group
group_id_tuple = tuple(group_id) # Hashable type
group_label = packet.payload.label
updated_at = packet.payload.updated_at
if group_id_tuple not in self._groups:
# Make a new Group
new_group = group.Group(group_id, self, self.by_group_id, device.Device._get_group_data)
# Store it
self._groups[group_id_tuple] = new_group
示例3: _locationpacket
# 需要导入模块: import device [as 别名]
# 或者: from device import Device [as 别名]
def _locationpacket(self, host, port, packet):
# Gather Data
location_id = packet.payload.location
location_id_tuple = tuple(location_id) # Hashable type
location_label = packet.payload.label
updated_at = packet.payload.updated_at
if location_id_tuple not in self._locations:
# Make a new Group for the location
new_location = group.Group(location_id, self, self.by_location_id, device.Device._get_location_data)
# Store it
self._locations[location_id_tuple] = new_location
示例4: by_id
# 需要导入模块: import device [as 别名]
# 或者: from device import Device [as 别名]
def by_id(self, id):
"""
Return the device with the id specified.
:param id: The device id
:returns: Device -- The device with the matching id.
"""
return filter(lambda d: d.id == id, self.get_devices())[0]
示例5: draw
# 需要导入模块: import device [as 别名]
# 或者: from device import Device [as 别名]
def draw(x, tolerance=0.05):
if isinstance(x, drawing.Drawing):
x = x.paths
device = Device()
time.sleep(2)
device.pen_up()
time.sleep(1)
device.home()
bar = progress.Bar()
for path in bar(x):
if tolerance:
path = simplify(path, tolerance)
device.draw(path)