mirror of
https://github.com/JoelBender/bacpypes
synced 2025-09-28 22:15:23 +08:00
sync python versions
This commit is contained in:
parent
a358aae5bb
commit
1ec923c018
|
@ -224,7 +224,7 @@ class WriteBroadcastDistributionTable(BVLPDU):
|
|||
BVLCI.update(bvlpdu, self)
|
||||
for bdte in self.bvlciBDT:
|
||||
bvlpdu.put_data( bdte.addrAddr )
|
||||
bvlpdu.put_data( bdte.addrMask )
|
||||
bvlpdu.put_long( bdte.addrMask )
|
||||
|
||||
def decode(self, bvlpdu):
|
||||
BVLCI.update(self, bvlpdu)
|
||||
|
@ -401,6 +401,11 @@ class FDTEntry(DebugContents):
|
|||
self.fdTTL = None
|
||||
self.fdRemain = None
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Return true iff entries are identical."""
|
||||
return (self.fdAddress == other.fdAddress) and \
|
||||
(self.fdTTL == other.fdTTL) and (self.fdRemain == other.fdRemain)
|
||||
|
||||
def bvlpdu_contents(self, use_dict=None, as_class=dict):
|
||||
"""Return the contents of an object as a dict."""
|
||||
# make/extend the dictionary of content
|
||||
|
|
|
@ -26,9 +26,10 @@ _log = ModuleLogger(globals())
|
|||
|
||||
class Network:
|
||||
|
||||
def __init__(self, broadcast_address=None, drop_percent=0.0):
|
||||
if _debug: Network._debug("__init__ broadcast_address=%r drop_percent=%r", broadcast_address, drop_percent)
|
||||
def __init__(self, name='', broadcast_address=None, drop_percent=0.0):
|
||||
if _debug: Network._debug("__init__ name=%r broadcast_address=%r drop_percent=%r", name, broadcast_address, drop_percent)
|
||||
|
||||
self.name = name
|
||||
self.nodes = []
|
||||
self.broadcast_address = broadcast_address
|
||||
self.drop_percent = drop_percent
|
||||
|
@ -40,6 +41,10 @@ class Network:
|
|||
self.nodes.append(node)
|
||||
node.lan = self
|
||||
|
||||
# update the node name
|
||||
if not node.name:
|
||||
node.name = '%s:%s' % (self.name, node.address)
|
||||
|
||||
def remove_node(self, node):
|
||||
""" Remove a node from this network. """
|
||||
if _debug: Network._debug("remove_node %r", node)
|
||||
|
@ -51,7 +56,7 @@ class Network:
|
|||
""" Process a PDU by sending a copy to each node as dictated by the
|
||||
addressing and if a node is promiscuous.
|
||||
"""
|
||||
if _debug: Network._debug("process_pdu %r", pdu)
|
||||
if _debug: Network._debug("[%s]process_pdu %r", self.name, pdu)
|
||||
|
||||
# randomly drop a packet
|
||||
if self.drop_percent != 0.0:
|
||||
|
@ -83,15 +88,16 @@ bacpypes_debugging(Network)
|
|||
|
||||
class Node(Server):
|
||||
|
||||
def __init__(self, addr, lan=None, promiscuous=False, spoofing=False, sid=None):
|
||||
def __init__(self, addr, lan=None, name='', promiscuous=False, spoofing=False, sid=None):
|
||||
if _debug:
|
||||
Node._debug("__init__ %r lan=%r promiscuous=%r spoofing=%r sid=%r",
|
||||
addr, lan, promiscuous, spoofing, sid
|
||||
Node._debug("__init__ %r lan=%r name=%r, promiscuous=%r spoofing=%r sid=%r",
|
||||
addr, lan, name, promiscuous, spoofing, sid
|
||||
)
|
||||
Server.__init__(self, sid)
|
||||
|
||||
self.lan = None
|
||||
self.address = addr
|
||||
self.name = name
|
||||
|
||||
# bind to a lan if it was provided
|
||||
if lan is not None:
|
||||
|
@ -109,7 +115,7 @@ class Node(Server):
|
|||
|
||||
def indication(self, pdu):
|
||||
"""Send a message."""
|
||||
if _debug: Node._debug("indication %r", pdu)
|
||||
if _debug: Node._debug("[%s]indication %r", self.name, pdu)
|
||||
|
||||
# make sure we're connected
|
||||
if not self.lan:
|
||||
|
|
|
@ -221,7 +221,7 @@ class WriteBroadcastDistributionTable(BVLPDU):
|
|||
BVLCI.update(bvlpdu, self)
|
||||
for bdte in self.bvlciBDT:
|
||||
bvlpdu.put_data( bdte.addrAddr )
|
||||
bvlpdu.put_data( bdte.addrMask )
|
||||
bvlpdu.put_long( bdte.addrMask )
|
||||
|
||||
def decode(self, bvlpdu):
|
||||
BVLCI.update(self, bvlpdu)
|
||||
|
@ -398,6 +398,11 @@ class FDTEntry(DebugContents):
|
|||
self.fdTTL = None
|
||||
self.fdRemain = None
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Return true iff entries are identical."""
|
||||
return (self.fdAddress == other.fdAddress) and \
|
||||
(self.fdTTL == other.fdTTL) and (self.fdRemain == other.fdRemain)
|
||||
|
||||
def bvlpdu_contents(self, use_dict=None, as_class=dict):
|
||||
"""Return the contents of an object as a dict."""
|
||||
# make/extend the dictionary of content
|
||||
|
|
|
@ -27,9 +27,10 @@ _log = ModuleLogger(globals())
|
|||
@bacpypes_debugging
|
||||
class Network:
|
||||
|
||||
def __init__(self, broadcast_address=None, drop_percent=0.0):
|
||||
if _debug: Network._debug("__init__ broadcast_address=%r drop_percent=%r", broadcast_address, drop_percent)
|
||||
def __init__(self, name='', broadcast_address=None, drop_percent=0.0):
|
||||
if _debug: Network._debug("__init__ name=%r broadcast_address=%r drop_percent=%r", name, broadcast_address, drop_percent)
|
||||
|
||||
self.name = name
|
||||
self.nodes = []
|
||||
self.broadcast_address = broadcast_address
|
||||
self.drop_percent = drop_percent
|
||||
|
@ -41,6 +42,10 @@ class Network:
|
|||
self.nodes.append(node)
|
||||
node.lan = self
|
||||
|
||||
# update the node name
|
||||
if not node.name:
|
||||
node.name = '%s:%s' % (self.name, node.address)
|
||||
|
||||
def remove_node(self, node):
|
||||
""" Remove a node from this network. """
|
||||
if _debug: Network._debug("remove_node %r", node)
|
||||
|
@ -52,7 +57,7 @@ class Network:
|
|||
""" Process a PDU by sending a copy to each node as dictated by the
|
||||
addressing and if a node is promiscuous.
|
||||
"""
|
||||
if _debug: Network._debug("process_pdu %r", pdu)
|
||||
if _debug: Network._debug("[%s]process_pdu %r", self.name, pdu)
|
||||
|
||||
# randomly drop a packet
|
||||
if self.drop_percent != 0.0:
|
||||
|
@ -83,15 +88,16 @@ class Network:
|
|||
@bacpypes_debugging
|
||||
class Node(Server):
|
||||
|
||||
def __init__(self, addr, lan=None, promiscuous=False, spoofing=False, sid=None):
|
||||
def __init__(self, addr, lan=None, name='', promiscuous=False, spoofing=False, sid=None):
|
||||
if _debug:
|
||||
Node._debug("__init__ %r lan=%r promiscuous=%r spoofing=%r sid=%r",
|
||||
addr, lan, promiscuous, spoofing, sid
|
||||
Node._debug("__init__ %r lan=%r name=%r, promiscuous=%r spoofing=%r sid=%r",
|
||||
addr, lan, name, promiscuous, spoofing, sid
|
||||
)
|
||||
Server.__init__(self, sid)
|
||||
|
||||
self.lan = None
|
||||
self.address = addr
|
||||
self.name = name
|
||||
|
||||
# bind to a lan if it was provided
|
||||
if lan is not None:
|
||||
|
@ -109,7 +115,7 @@ class Node(Server):
|
|||
|
||||
def indication(self, pdu):
|
||||
"""Send a message."""
|
||||
if _debug: Node._debug("indication %r", pdu)
|
||||
if _debug: Node._debug("[%s]indication %r", self.name, pdu)
|
||||
|
||||
# make sure we're connected
|
||||
if not self.lan:
|
||||
|
|
|
@ -27,9 +27,10 @@ _log = ModuleLogger(globals())
|
|||
@bacpypes_debugging
|
||||
class Network:
|
||||
|
||||
def __init__(self, broadcast_address=None, drop_percent=0.0):
|
||||
if _debug: Network._debug("__init__ broadcast_address=%r drop_percent=%r", broadcast_address, drop_percent)
|
||||
def __init__(self, name='', broadcast_address=None, drop_percent=0.0):
|
||||
if _debug: Network._debug("__init__ name=%r broadcast_address=%r drop_percent=%r", name, broadcast_address, drop_percent)
|
||||
|
||||
self.name = name
|
||||
self.nodes = []
|
||||
self.broadcast_address = broadcast_address
|
||||
self.drop_percent = drop_percent
|
||||
|
@ -41,6 +42,10 @@ class Network:
|
|||
self.nodes.append(node)
|
||||
node.lan = self
|
||||
|
||||
# update the node name
|
||||
if not node.name:
|
||||
node.name = '%s:%s' % (self.name, node.address)
|
||||
|
||||
def remove_node(self, node):
|
||||
""" Remove a node from this network. """
|
||||
if _debug: Network._debug("remove_node %r", node)
|
||||
|
@ -52,7 +57,7 @@ class Network:
|
|||
""" Process a PDU by sending a copy to each node as dictated by the
|
||||
addressing and if a node is promiscuous.
|
||||
"""
|
||||
if _debug: Network._debug("process_pdu %r", pdu)
|
||||
if _debug: Network._debug("[%s]process_pdu %r", self.name, pdu)
|
||||
|
||||
# randomly drop a packet
|
||||
if self.drop_percent != 0.0:
|
||||
|
@ -83,15 +88,16 @@ class Network:
|
|||
@bacpypes_debugging
|
||||
class Node(Server):
|
||||
|
||||
def __init__(self, addr, lan=None, promiscuous=False, spoofing=False, sid=None):
|
||||
def __init__(self, addr, lan=None, name='', promiscuous=False, spoofing=False, sid=None):
|
||||
if _debug:
|
||||
Node._debug("__init__ %r lan=%r promiscuous=%r spoofing=%r sid=%r",
|
||||
addr, lan, promiscuous, spoofing, sid
|
||||
Node._debug("__init__ %r lan=%r name=%r, promiscuous=%r spoofing=%r sid=%r",
|
||||
addr, lan, name, promiscuous, spoofing, sid
|
||||
)
|
||||
Server.__init__(self, sid)
|
||||
|
||||
self.lan = None
|
||||
self.address = addr
|
||||
self.name = name
|
||||
|
||||
# bind to a lan if it was provided
|
||||
if lan is not None:
|
||||
|
@ -109,7 +115,7 @@ class Node(Server):
|
|||
|
||||
def indication(self, pdu):
|
||||
"""Send a message."""
|
||||
if _debug: Node._debug("indication %r", pdu)
|
||||
if _debug: Node._debug("[%s]indication %r", self.name, pdu)
|
||||
|
||||
# make sure we're connected
|
||||
if not self.lan:
|
||||
|
|
Loading…
Reference in New Issue
Block a user