Skip to content

Commit

Permalink
stage merged and conflicts resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Bender committed Apr 22, 2020
1 parent d832f84 commit cc9a5c4
Show file tree
Hide file tree
Showing 38 changed files with 2,233 additions and 271 deletions.
23 changes: 23 additions & 0 deletions check_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

for version in 2.7 3.4 3.5 3.6 3.7 3.8;
do
if [ -a "`which python$version`" ]; then
python$version << EOF
import sys
python_version = "%d.%d.%d" % sys.version_info[:3]
try:
import bacpypes
print("%s: %s @ %s" %(
python_version,
bacpypes.__version__, bacpypes.__file__,
))
except ImportError:
print("%s: not installed" % (
python_version,
))
EOF
fi
done
2 changes: 1 addition & 1 deletion py25/bacpypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Project Metadata
#

__version__ = '0.18.0'
__version__ = '0.18.1'
__author__ = 'Joel Bender'
__email__ = '[email protected]'

Expand Down
5 changes: 3 additions & 2 deletions py25/bacpypes/apdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from .primitivedata import Boolean, CharacterString, Enumerated, Integer, \
ObjectIdentifier, ObjectType, OctetString, Real, TagList, Unsigned, \
expand_enumerations
from .constructeddata import Any, Choice, Element, Sequence, SequenceOf
from .constructeddata import Any, Choice, Element, \
Sequence, SequenceOf, SequenceOfAny
from .basetypes import ChannelValue, DateTime, DeviceAddress, ErrorType, \
EventState, EventTransitionBits, EventType, LifeSafetyOperation, \
NotificationParameters, NotifyType, ObjectPropertyReference, \
Expand Down Expand Up @@ -963,7 +964,7 @@ class ReadRangeACK(ComplexAckSequence):
, Element('propertyArrayIndex', Unsigned, 2, True)
, Element('resultFlags', ResultFlags, 3)
, Element('itemCount', Unsigned, 4)
, Element('itemData', SequenceOf(Any), 5)
, Element('itemData', SequenceOfAny, 5)
, Element('firstSequenceNumber', Unsigned, 6, True)
]

Expand Down
2 changes: 1 addition & 1 deletion py25/bacpypes/bvll.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def bvlpdu_contents(self, use_dict=None, as_class=dict):
"""Return the contents of an object as a dict."""
foreign_device_table = []
for fdte in self.bvlciFDT:
foreign_device_table.append(fdte.dict_contents(as_class=as_class))
foreign_device_table.append(fdte.bvlpdu_contents(as_class=as_class))

return key_value_contents(use_dict=use_dict, as_class=as_class,
key_values=(
Expand Down
2 changes: 1 addition & 1 deletion py25/bacpypes/local/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ def WriteProperty(self, property, value, arrayIndex=None, priority=None, direct=
if _debug: Commandable._debug(" - priority_value: %r", priority_value)

# the null or the choice has to be set, the other clear
if value is ():
if value == ():
if _debug: Commandable._debug(" - write a null")
priority_value.null = value
setattr(priority_value, _Commando._pv_choice, None)
Expand Down
20 changes: 20 additions & 0 deletions py25/bacpypes/local/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ def __init__(self, sched_obj):

# add a monitor for the present value
sched_obj._property_monitors['presentValue'].append(self.present_value_changed)
sched_obj._property_monitors['weeklySchedule'].append(self.schedule_changed)
sched_obj._property_monitors['exceptionSchedule'].append(self.schedule_changed)

# call to interpret the schedule
deferred(self.process_task)
Expand Down Expand Up @@ -406,6 +408,24 @@ def present_value_changed(self, old_value, new_value):
except Exception as err:
if _debug: LocalScheduleInterpreter._debug(" - error: %r", err)

def schedule_changed(self, old_value, new_value):
"""This function is called when the weeklySchedule or the exceptionSchedule
property of the local schedule object has changed, both internally by
this interpreter, or externally by some client using WriteProperty."""
if _debug:
LocalScheduleInterpreter._debug(
"schedule_changed(%s) %s %s", self.sched_obj.objectName,
old_value, new_value,
)

# if this hasn't been added to an application, there's nothing to do
if not self.sched_obj._app:
if _debug: LocalScheduleInterpreter._debug(" - no application")
return

# real work done by process_task
self.process_task()

def process_task(self):
if _debug: LocalScheduleInterpreter._debug("process_task(%s)", self.sched_obj.objectName)

Expand Down
2 changes: 1 addition & 1 deletion py25/bacpypes/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ class ScheduleObject(Object):
properties = \
[ ReadableProperty('presentValue', AnyAtomic)
, ReadableProperty('effectivePeriod', DateRange)
, OptionalProperty('weeklySchedule', ArrayOf(DailySchedule))
, OptionalProperty('weeklySchedule', ArrayOf(DailySchedule, 7))
, OptionalProperty('exceptionSchedule', ArrayOf(SpecialEvent))
, ReadableProperty('scheduleDefault', AnyAtomic)
, ReadableProperty('listOfObjectPropertyReferences', ListOf(DeviceObjectPropertyReference))
Expand Down
4 changes: 2 additions & 2 deletions py25/bacpypes/service/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def do_ReadPropertyRequest(self, apdu):
raise PropertyError(apdu.propertyIdentifier)

# change atomic values into something encodeable
if issubclass(datatype, Atomic):
if issubclass(datatype, Atomic) or (issubclass(datatype, (Array, List)) and isinstance(value, list)):
value = datatype(value)
elif issubclass(datatype, Array) and (apdu.propertyArrayIndex is not None):
if apdu.propertyArrayIndex == 0:
Expand Down Expand Up @@ -164,7 +164,7 @@ def read_property_to_any(obj, propertyIdentifier, propertyArrayIndex=None):
raise ExecutionError(errorClass='property', errorCode='unknownProperty')

# change atomic values into something encodeable
if issubclass(datatype, Atomic):
if issubclass(datatype, Atomic) or (issubclass(datatype, (Array, List)) and isinstance(value, list)):
value = datatype(value)
elif issubclass(datatype, Array) and (propertyArrayIndex is not None):
if propertyArrayIndex == 0:
Expand Down
2 changes: 1 addition & 1 deletion py27/bacpypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Project Metadata
#

__version__ = '0.18.0'
__version__ = '0.18.1'
__author__ = 'Joel Bender'
__email__ = '[email protected]'

Expand Down
4 changes: 2 additions & 2 deletions py27/bacpypes/apdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from .primitivedata import Boolean, CharacterString, Enumerated, Integer, \
ObjectIdentifier, ObjectType, OctetString, Real, TagList, Unsigned, \
expand_enumerations
from .constructeddata import Any, Choice, Element, Sequence, SequenceOf, \
SequenceOfAny
from .constructeddata import Any, Choice, Element, \
Sequence, SequenceOf, SequenceOfAny
from .basetypes import ChannelValue, DateTime, DeviceAddress, ErrorType, \
EventState, EventTransitionBits, EventType, LifeSafetyOperation, \
NotificationParameters, NotifyType, ObjectPropertyReference, \
Expand Down
2 changes: 1 addition & 1 deletion py27/bacpypes/bvll.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def bvlpdu_contents(self, use_dict=None, as_class=dict):
"""Return the contents of an object as a dict."""
foreign_device_table = []
for fdte in self.bvlciFDT:
foreign_device_table.append(fdte.dict_contents(as_class=as_class))
foreign_device_table.append(fdte.bvlpdu_contents(as_class=as_class))

return key_value_contents(use_dict=use_dict, as_class=as_class,
key_values=(
Expand Down
2 changes: 1 addition & 1 deletion py27/bacpypes/local/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def WriteProperty(self, property, value, arrayIndex=None, priority=None, direct=
if _debug: Commandable._debug(" - priority_value: %r", priority_value)

# the null or the choice has to be set, the other clear
if value is ():
if value == ():
if _debug: Commandable._debug(" - write a null")
priority_value.null = value
setattr(priority_value, _Commando._pv_choice, None)
Expand Down
20 changes: 20 additions & 0 deletions py27/bacpypes/local/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ def __init__(self, sched_obj):

# add a monitor for the present value
sched_obj._property_monitors['presentValue'].append(self.present_value_changed)
sched_obj._property_monitors['weeklySchedule'].append(self.schedule_changed)
sched_obj._property_monitors['exceptionSchedule'].append(self.schedule_changed)

# call to interpret the schedule
deferred(self.process_task)
Expand Down Expand Up @@ -405,6 +407,24 @@ def present_value_changed(self, old_value, new_value):
except Exception as err:
if _debug: LocalScheduleInterpreter._debug(" - error: %r", err)

def schedule_changed(self, old_value, new_value):
"""This function is called when the weeklySchedule or the exceptionSchedule
property of the local schedule object has changed, both internally by
this interpreter, or externally by some client using WriteProperty."""
if _debug:
LocalScheduleInterpreter._debug(
"schedule_changed(%s) %s %s", self.sched_obj.objectName,
old_value, new_value,
)

# if this hasn't been added to an application, there's nothing to do
if not self.sched_obj._app:
if _debug: LocalScheduleInterpreter._debug(" - no application")
return

# real work done by process_task
self.process_task()

def process_task(self):
if _debug: LocalScheduleInterpreter._debug("process_task(%s)", self.sched_obj.objectName)

Expand Down
2 changes: 1 addition & 1 deletion py27/bacpypes/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ class ScheduleObject(Object):
properties = \
[ ReadableProperty('presentValue', AnyAtomic)
, ReadableProperty('effectivePeriod', DateRange)
, OptionalProperty('weeklySchedule', ArrayOf(DailySchedule))
, OptionalProperty('weeklySchedule', ArrayOf(DailySchedule, 7))
, OptionalProperty('exceptionSchedule', ArrayOf(SpecialEvent))
, ReadableProperty('scheduleDefault', AnyAtomic)
, ReadableProperty('listOfObjectPropertyReferences', ListOf(DeviceObjectPropertyReference))
Expand Down
4 changes: 2 additions & 2 deletions py27/bacpypes/service/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def do_ReadPropertyRequest(self, apdu):
raise PropertyError(apdu.propertyIdentifier)

# change atomic values into something encodeable
if issubclass(datatype, Atomic):
if issubclass(datatype, Atomic) or (issubclass(datatype, (Array, List)) and isinstance(value, list)):
value = datatype(value)
elif issubclass(datatype, Array) and (apdu.propertyArrayIndex is not None):
if apdu.propertyArrayIndex == 0:
Expand Down Expand Up @@ -164,7 +164,7 @@ def read_property_to_any(obj, propertyIdentifier, propertyArrayIndex=None):
raise ExecutionError(errorClass='property', errorCode='unknownProperty')

# change atomic values into something encodeable
if issubclass(datatype, Atomic):
if issubclass(datatype, Atomic) or (issubclass(datatype, (Array, List)) and isinstance(value, list)):
value = datatype(value)
elif issubclass(datatype, Array) and (propertyArrayIndex is not None):
if propertyArrayIndex == 0:
Expand Down
2 changes: 1 addition & 1 deletion py34/bacpypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Project Metadata
#

__version__ = '0.18.0'
__version__ = '0.18.1'
__author__ = 'Joel Bender'
__email__ = '[email protected]'

Expand Down
5 changes: 3 additions & 2 deletions py34/bacpypes/apdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from .primitivedata import Boolean, CharacterString, Enumerated, Integer, \
ObjectIdentifier, ObjectType, OctetString, Real, TagList, Unsigned, \
expand_enumerations
from .constructeddata import Any, Choice, Element, Sequence, SequenceOf
from .constructeddata import Any, Choice, Element, \
Sequence, SequenceOf, SequenceOfAny
from .basetypes import ChannelValue, DateTime, DeviceAddress, ErrorType, \
EventState, EventTransitionBits, EventType, LifeSafetyOperation, \
NotificationParameters, NotifyType, ObjectPropertyReference, \
Expand Down Expand Up @@ -956,7 +957,7 @@ class ReadRangeACK(ComplexAckSequence):
, Element('propertyArrayIndex', Unsigned, 2, True)
, Element('resultFlags', ResultFlags, 3)
, Element('itemCount', Unsigned, 4)
, Element('itemData', SequenceOf(Any), 5)
, Element('itemData', SequenceOfAny, 5)
, Element('firstSequenceNumber', Unsigned, 6, True)
]

Expand Down
2 changes: 1 addition & 1 deletion py34/bacpypes/bvll.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ def bvlpdu_contents(self, use_dict=None, as_class=dict):
"""Return the contents of an object as a dict."""
foreign_device_table = []
for fdte in self.bvlciFDT:
foreign_device_table.append(fdte.dict_contents(as_class=as_class))
foreign_device_table.append(fdte.bvlpdu_contents(as_class=as_class))

return key_value_contents(use_dict=use_dict, as_class=as_class,
key_values=(
Expand Down
2 changes: 1 addition & 1 deletion py34/bacpypes/local/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ def WriteProperty(self, property, value, arrayIndex=None, priority=None, direct=
if _debug: Commandable._debug(" - priority_value: %r", priority_value)

# the null or the choice has to be set, the other clear
if value is ():
if value == ():
if _debug: Commandable._debug(" - write a null")
priority_value.null = value
setattr(priority_value, _Commando._pv_choice, None)
Expand Down
20 changes: 20 additions & 0 deletions py34/bacpypes/local/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ def __init__(self, sched_obj):

# add a monitor for the present value
sched_obj._property_monitors['presentValue'].append(self.present_value_changed)
sched_obj._property_monitors['weeklySchedule'].append(self.schedule_changed)
sched_obj._property_monitors['exceptionSchedule'].append(self.schedule_changed)

# call to interpret the schedule
deferred(self.process_task)
Expand Down Expand Up @@ -405,6 +407,24 @@ def present_value_changed(self, old_value, new_value):
except Exception as err:
if _debug: LocalScheduleInterpreter._debug(" - error: %r", err)

def schedule_changed(self, old_value, new_value):
"""This function is called when the weeklySchedule or the exceptionSchedule
property of the local schedule object has changed, both internally by
this interpreter, or externally by some client using WriteProperty."""
if _debug:
LocalScheduleInterpreter._debug(
"schedule_changed(%s) %s %s", self.sched_obj.objectName,
old_value, new_value,
)

# if this hasn't been added to an application, there's nothing to do
if not self.sched_obj._app:
if _debug: LocalScheduleInterpreter._debug(" - no application")
return

# real work done by process_task
self.process_task()

def process_task(self):
if _debug: LocalScheduleInterpreter._debug("process_task(%s)", self.sched_obj.objectName)

Expand Down
2 changes: 1 addition & 1 deletion py34/bacpypes/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,7 @@ class ScheduleObject(Object):
properties = \
[ ReadableProperty('presentValue', AnyAtomic)
, ReadableProperty('effectivePeriod', DateRange)
, OptionalProperty('weeklySchedule', ArrayOf(DailySchedule))
, OptionalProperty('weeklySchedule', ArrayOf(DailySchedule, 7))
, OptionalProperty('exceptionSchedule', ArrayOf(SpecialEvent))
, ReadableProperty('scheduleDefault', AnyAtomic)
, ReadableProperty('listOfObjectPropertyReferences', ListOf(DeviceObjectPropertyReference))
Expand Down
3 changes: 1 addition & 2 deletions py34/bacpypes/primitivedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,7 @@ def get_long(self):

def keylist(self):
"""Return a list of names in order by value."""
items = self.enumerations.items()
items.sort(lambda a, b: self.cmp(a[1], b[1]))
items = sorted(self.enumerations.items(), key=lambda a: a[1])

# last item has highest value
rslt = [None] * (items[-1][1] + 1)
Expand Down
9 changes: 4 additions & 5 deletions py34/bacpypes/service/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
from ..primitivedata import Atomic, Null, Unsigned
from ..constructeddata import Any, Array, ArrayOf, List

from ..apdu import Error, \
SimpleAckPDU, ReadPropertyACK, ReadPropertyMultipleACK, \
from ..apdu import SimpleAckPDU, ReadPropertyACK, ReadPropertyMultipleACK, \
ReadAccessResult, ReadAccessResultElement, ReadAccessResultElementChoice
from ..errors import ExecutionError
from ..object import Property, Object, PropertyError
from ..object import PropertyError

# some debugging
_debug = 0
Expand Down Expand Up @@ -62,7 +61,7 @@ def do_ReadPropertyRequest(self, apdu):
raise PropertyError(apdu.propertyIdentifier)

# change atomic values into something encodeable
if issubclass(datatype, Atomic):
if issubclass(datatype, Atomic) or (issubclass(datatype, (Array, List)) and isinstance(value, list)):
value = datatype(value)
elif issubclass(datatype, Array) and (apdu.propertyArrayIndex is not None):
if apdu.propertyArrayIndex == 0:
Expand Down Expand Up @@ -164,7 +163,7 @@ def read_property_to_any(obj, propertyIdentifier, propertyArrayIndex=None):
raise ExecutionError(errorClass='property', errorCode='unknownProperty')

# change atomic values into something encodeable
if issubclass(datatype, Atomic):
if issubclass(datatype, Atomic) or (issubclass(datatype, (Array, List)) and isinstance(value, list)):
value = datatype(value)
elif issubclass(datatype, Array) and (propertyArrayIndex is not None):
if propertyArrayIndex == 0:
Expand Down
Loading

0 comments on commit cc9a5c4

Please sign in to comment.