本文整理匯總了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)