本文整理汇总了Python中Packet.Packet.set方法的典型用法代码示例。如果您正苦于以下问题:Python Packet.set方法的具体用法?Python Packet.set怎么用?Python Packet.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet.Packet
的用法示例。
在下文中一共展示了Packet.set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _send_ack
# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import set [as 别名]
def _send_ack(self):
packet = Packet()
packet.set("specification", "setting_ack")
packet.set("next_index", self._next_index)
packet.set("sensor_id", self._rf_sensor.id)
self._rf_sensor.enqueue(packet, to=0)
示例2: start
# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import set [as 别名]
def start(self):
"""
Start the NTP algorithm by sending the current time to the
server (ground station) for synchronization.
"""
# Construct the NTP packet.
packet = Packet()
packet.set("specification", "ntp")
packet.set("sensor_id", self._sensor.id)
packet.set("timestamp_1", time.time())
packet.set("timestamp_2", 0)
packet.set("timestamp_3", 0)
packet.set("timestamp_4", 0)
# Send the NTP packet to the ground station.
self._sensor._send_tx_frame(packet, 0)
示例3: _create_rssi_ground_station_packet
# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import set [as 别名]
def _create_rssi_ground_station_packet(self, rssi_broadcast_packet):
"""
Create a `Packet` object according to the "rssi_ground_station"
specification using data from an `rssi_broadcast_packet`. The
`rssi_broadcast_packet` must be created according to the
"rssi_broadcast" specification.
The resulting packet is only missing RSSI information.
The packet can be sent to the ground station as an indication of the
signal strength between the RF sensor that sent the `rssi_broadcast_packet`
and the current RF sensor.
"""
from_valid = rssi_broadcast_packet.get("valid")
from_id = rssi_broadcast_packet.get("sensor_id")
from_waypoint_index = rssi_broadcast_packet.get("waypoint_index")
location = self._location_callback()[0]
location_valid = self._valid_callback(other_valid=from_valid,
other_id=from_id,
other_index=from_waypoint_index)
packet = Packet()
packet.set("specification", "rssi_ground_station")
packet.set("sensor_id", self._id)
packet.set("from_latitude", rssi_broadcast_packet.get("latitude"))
packet.set("from_longitude", rssi_broadcast_packet.get("longitude"))
packet.set("from_valid", from_valid)
packet.set("to_latitude", location[0])
packet.set("to_longitude", location[1])
packet.set("to_valid", location_valid)
return packet
示例4: _create_rssi_broadcast_packet
# 需要导入模块: from Packet import Packet [as 别名]
# 或者: from Packet.Packet import set [as 别名]
def _create_rssi_broadcast_packet(self):
"""
Create a `Packet` object according to the "rssi_broadcast" specification.
The resulting packet is complete.
"""
location, waypoint_index = self._location_callback()
packet = Packet()
packet.set("specification", "rssi_broadcast")
packet.set("latitude", location[0])
packet.set("longitude", location[1])
packet.set("valid", self._valid_callback())
packet.set("waypoint_index", waypoint_index)
packet.set("sensor_id", self._id)
packet.set("timestamp", time.time())
return packet