Skip to content

Commit

Permalink
release 0.17.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Bender committed Nov 17, 2019
1 parent 4111b86 commit 792041b
Show file tree
Hide file tree
Showing 97 changed files with 6,884 additions and 1,515 deletions.
17 changes: 17 additions & 0 deletions BACpypes~.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"bacpypes": {
"debug": ["__main__"],
"color": true
},
"local-device": {
"objectName": "Betelgeuse-47808",
"address": "128.253.109.40/24",
"objectIdentifier": 599,
"maxApduLengthAccepted": 1024,
"segmentationSupported": "segmentedBoth",
"maxSegmentsAccepted": 1024,
"vendorIdentifier": 15,
"foreignBBMD": "128.253.109.254",
"foreignTTL": 30
}
}
4 changes: 3 additions & 1 deletion py25/bacpypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
# Project Metadata
#

__version__ = '0.17.6'
__version__ = '0.17.7'
__author__ = 'Joel Bender'
__email__ = '[email protected]'

from . import settings

#
# Communications Core Modules
#
Expand Down
11 changes: 6 additions & 5 deletions py25/bacpypes/apdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1581,11 +1581,12 @@ class ReinitializeDeviceRequestReinitializedStateOfDevice(Enumerated):
enumerations = \
{ 'coldstart':0
, 'warmstart':1
, 'startbackup':2
, 'endbackup':3
, 'startrestore':4
, 'endrestore':5
, 'abortrestore':6
, 'startBackup':2
, 'endBackup':3
, 'startRestore':4
, 'endRestore':5
, 'abortRestore':6
, 'activateChanges':7
}

class ReinitializeDeviceRequest(ConfirmedRequestSequence):
Expand Down
1 change: 0 additions & 1 deletion py25/bacpypes/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ def segmented_request(self, apdu):
if _debug: ClientSSM._debug(" - error/reject/abort")

self.set_state(COMPLETED)
self.response = apdu
self.response(apdu)

else:
Expand Down
87 changes: 83 additions & 4 deletions py25/bacpypes/basetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
Base Types
"""

from .debugging import ModuleLogger
from .debugging import bacpypes_debugging, ModuleLogger
from .errors import MissingRequiredParameter

from .primitivedata import BitString, Boolean, CharacterString, Date, Double, \
from .primitivedata import Atomic, BitString, Boolean, CharacterString, Date, Double, \
Enumerated, Integer, Null, ObjectIdentifier, OctetString, Real, Time, \
Unsigned, Unsigned16
Unsigned, Unsigned16, Tag
from .constructeddata import Any, AnyAtomic, ArrayOf, Choice, Element, \
Sequence, SequenceOf

Expand Down Expand Up @@ -1719,9 +1720,87 @@ class RouterEntry(Sequence):
class NameValue(Sequence):
sequenceElements = \
[ Element('name', CharacterString)
, Element('value', AnyAtomic) # IS ATOMIC CORRECT HERE? value is limited to primitive datatypes and BACnetDateTime
, Element('value', AnyAtomic, None, True)
]

def __init__(self, name=None, value=None):
if _debug: NameValue._debug("__init__ name=%r value=%r", name, value)

# default to no value
self.name = name
self.value = None

if value is None:
pass
elif isinstance(value, (Atomic, DateTime)):
self.value = value
elif isinstance(value, Tag):
self.value = value.app_to_object()
else:
raise TypeError("invalid constructor datatype")

def encode(self, taglist):
if _debug: NameValue._debug("(%r)encode %r", self.__class__.__name__, taglist)

# build a tag and encode the name into it
tag = Tag()
CharacterString(self.name).encode(tag)
taglist.append(tag.app_to_context(0))

# the value is optional
if self.value is not None:
if isinstance(self.value, DateTime):
# has its own encoder
self.value.encode(taglist)
else:
# atomic values encode into a tag
tag = Tag()
self.value.encode(tag)
taglist.append(tag)

def decode(self, taglist):
if _debug: NameValue._debug("(%r)decode %r", self.__class__.__name__, taglist)

# no contents yet
self.name = None
self.value = None

# look for the context encoded character string
tag = taglist.Peek()
if _debug: NameValue._debug(" - name tag: %r", tag)
if (tag is None) or (tag.tagClass != Tag.contextTagClass) or (tag.tagNumber != 0):
raise MissingRequiredParameter("%s is a missing required element of %s" % ('name', self.__class__.__name__))

# pop it off and save the value
taglist.Pop()
tag = tag.context_to_app(Tag.characterStringAppTag)
self.name = CharacterString(tag).value

# look for the optional application encoded value
tag = taglist.Peek()
if _debug: NameValue._debug(" - value tag: %r", tag)
if tag and (tag.tagClass == Tag.applicationTagClass):

# if it is a date check the next one for a time
if (tag.tagNumber == Tag.dateAppTag) and (len(taglist.tagList) >= 2):
next_tag = taglist.tagList[1]
if _debug: NameValue._debug(" - next_tag: %r", next_tag)

if (next_tag.tagClass == Tag.applicationTagClass) and (next_tag.tagNumber == Tag.timeAppTag):
if _debug: NameValue._debug(" - remaining tag list 0: %r", taglist.tagList)

self.value = DateTime()
self.value.decode(taglist)
if _debug: NameValue._debug(" - date time value: %r", self.value)

# just a primitive value
if self.value is None:
taglist.Pop()
self.value = tag.app_to_object()

bacpypes_debugging(NameValue)

>>>>>>> stage
class DeviceAddress(Sequence):
sequenceElements = \
[ Element('networkNumber', Unsigned)
Expand Down
2 changes: 1 addition & 1 deletion py25/bacpypes/local/device.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

from ..debugging import bacpypes_debugging, ModuleLogger
from ..debugging import bacpypes_debugging, ModuleLogger, xtob

from ..primitivedata import Null, Boolean, Unsigned, Integer, Real, Double, \
OctetString, CharacterString, BitString, Enumerated, Date, Time, \
Expand Down
7 changes: 0 additions & 7 deletions py25/bacpypes/local/file.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
#!/usr/bin/env python

from ..debugging import bacpypes_debugging, ModuleLogger
from ..capability import Capability

from ..object import FileObject

from ..apdu import AtomicReadFileACK, AtomicReadFileACKAccessMethodChoice, \
AtomicReadFileACKAccessMethodRecordAccess, \
AtomicReadFileACKAccessMethodStreamAccess, \
AtomicWriteFileACK
from ..errors import ExecutionError, MissingRequiredParameter

# some debugging
_debug = 0
_log = ModuleLogger(globals())
Expand Down
Loading

0 comments on commit 792041b

Please sign in to comment.