Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def character_string_decode(tag):
"""Decode an character_string application tag into an character_string."""
if _debug: character_string_decode._debug("character_string_decode %r", tag)
obj = CharacterString(tag)
if _debug: character_string_decode._debug(" - obj: %r", obj)
return obj
, (OptionalProperty,'weeklySchedule', ArrayOf(DailySchedule))
, (OptionalProperty,'exceptionSchedule', ArrayOf(SpecialEvent))
, (ReadableProperty,'scheduleDefault', AnyAtomic)
, (ReadableProperty,'listOfObjectPropertyReferences', SequenceOf(DeviceObjectPropertyReference))
, (ReadableProperty,'priorityForWriting', Unsigned)
, (ReadableProperty,'statusFlags', StatusFlags)
, (ReadableProperty,'reliability', Reliability)
, (ReadableProperty,'outOfService', Boolean)
, (OptionalProperty,'eventDetectionEnable', Boolean)
, (OptionalProperty,'notificationClass', Unsigned)
, (OptionalProperty,'eventEnable', EventTransitionBits)
, (ReadableProperty,'eventState', EventState)
, (OptionalProperty,'ackedTransitions', EventTransitionBits)
, (OptionalProperty,'notifyType', NotifyType)
, (OptionalProperty,'eventTimeStamps', ArrayOf(TimeStamp))
, (OptionalProperty,'eventMessageTexts', ArrayOf(CharacterString))
, (OptionalProperty,'eventMessageTextsConfig', ArrayOf(CharacterString))
, (OptionalProperty,'reliabilityEvaluationInhibit', Boolean)
]
, (OptionalProperty,'derivativeConstant', Real)
, (OptionalProperty,'derivativeConstantUnits', EngineeringUnits)
, (OptionalProperty,'bias', Real)
, (OptionalProperty,'maximumOutput', Real)
, (OptionalProperty,'minimumOutput', Real)
, (ReadableProperty,'priorityForWriting', Unsigned)
, (OptionalProperty,'covIncrement', Real)
, (OptionalProperty,'timeDelay', Unsigned)
, (OptionalProperty,'notificationClass', Unsigned)
, (OptionalProperty,'errorLimit', Real)
, (OptionalProperty,'deadband', Real)
, (OptionalProperty,'eventEnable', EventTransitionBits)
, (OptionalProperty,'ackedTransitions', EventTransitionBits)
, (OptionalProperty,'notifyType', NotifyType)
, (OptionalProperty,'eventTimeStamps', ArrayOf(TimeStamp))
, (OptionalProperty,'eventMessageTexts', ArrayOf(CharacterString))
, (OptionalProperty,'eventMessageTextsConfig', ArrayOf(CharacterString))
, (OptionalProperty,'eventDetectionEnable', Boolean)
, (OptionalProperty,'eventAlgorithmInhibitRef', ObjectPropertyReference)
, (OptionalProperty,'eventAlgorithmInhibit', Boolean)
, (OptionalProperty,'timeDelayNormal', Unsigned)
, (OptionalProperty,'reliabilityEvaluationInhibit', Boolean)
]
def test_character_string_str(self):
if _debug: TestCharacterString._debug("test_character_string_str")
obj = CharacterString("hello")
assert obj.value == "hello"
assert str(obj) == "CharacterString(0,X'68656c6c6f')"
, (OptionalProperty,'stopTime', DateTime)
, (ReadableProperty,'stopWhenFull', Boolean)
, (ReadableProperty,'bufferSize', Unsigned)
, (ReadableProperty,'logBuffer', SequenceOf(EventLogRecord))
, (WritableProperty,'recordCount', Unsigned)
, (ReadableProperty,'totalRecordCount', Unsigned)
, (OptionalProperty,'notificationThreshold', Unsigned)
, (OptionalProperty,'recordsSinceNotification', Unsigned)
, (OptionalProperty,'lastNotifyRecord', Unsigned)
, (OptionalProperty,'notificationClass', Unsigned)
, (OptionalProperty,'eventEnable', EventTransitionBits)
, (OptionalProperty,'ackedTransitions', EventTransitionBits)
, (OptionalProperty,'notifyType', NotifyType)
, (OptionalProperty,'eventTimeStamps', ArrayOf(TimeStamp))
, (OptionalProperty,'eventMessageTexts', ArrayOf(CharacterString))
, (OptionalProperty,'eventMessageTextsConfig', ArrayOf(CharacterString))
, (OptionalProperty,'eventDetectionEnable', Boolean)
, (OptionalProperty,'eventAlgorithmInhibitRef', ObjectPropertyReference)
, (OptionalProperty,'eventAlgorithmInhibit', Boolean)
]
, (OptionalProperty,'startTime', DateTime)
, (OptionalProperty,'stopTime', DateTime)
, (ReadableProperty,'stopWhenFull', Boolean)
, (ReadableProperty,'bufferSize', Unsigned)
, (ReadableProperty,'logBuffer', SequenceOf(EventLogRecord))
, (WritableProperty,'recordCount', Unsigned)
, (ReadableProperty,'totalRecordCount', Unsigned)
, (OptionalProperty,'notificationThreshold', Unsigned)
, (OptionalProperty,'recordsSinceNotification', Unsigned)
, (OptionalProperty,'lastNotifyRecord', Unsigned)
, (OptionalProperty,'notificationClass', Unsigned)
, (OptionalProperty,'eventEnable', EventTransitionBits)
, (OptionalProperty,'ackedTransitions', EventTransitionBits)
, (OptionalProperty,'notifyType', NotifyType)
, (OptionalProperty,'eventTimeStamps', ArrayOf(TimeStamp))
, (OptionalProperty,'eventMessageTexts', ArrayOf(CharacterString))
, (OptionalProperty,'eventMessageTextsConfig', ArrayOf(CharacterString))
, (OptionalProperty,'eventDetectionEnable', Boolean)
, (OptionalProperty,'eventAlgorithmInhibitRef', ObjectPropertyReference)
, (OptionalProperty,'eventAlgorithmInhibit', Boolean)
]
def setUp(self):
if _debug: Test_StructuredViewObject._debug("Test_StructuredViewObject")
self.obj = StructuredViewObject()
self.objType = 'structuredView'
self.identifiers = self.build_list_of_identifiers(self.obj.properties)
self.numberOfPropertiesRequired = 4
self.writeValue = 0
self.listOfProperties = \
[ (ReadableProperty,'nodeType', NodeType)
, (OptionalProperty,'nodeSubtype', CharacterString)
, (ReadableProperty,'subordinateList', ArrayOf(DeviceObjectReference))
, (OptionalProperty,'subordinateAnnotations', ArrayOf(CharacterString))
]
# not an array, write access denied
with self.assertRaises(ExecutionError):
obj.ReadProperty('location', 0)
# write access successful
obj.WriteProperty('location', "work")
assert obj.location == "work"
# wrong data type
with self.assertRaises(InvalidParameterDatatype):
obj.WriteProperty('location', 12)
# array of character strings
ArrayOfCharacterString = ArrayOf(CharacterString)
@bacpypes_debugging
@register_object_type(vendor_id=999)
class SampleWritableArray(Object):
objectType = 'sampleWritableLocation'
properties = [
WritableProperty('location', ArrayOfCharacterString),
]
def __init__(self, **kwargs):
if _debug: SampleWritableArray._debug("__init__ %r", kwargs)
Object.__init__(self, **kwargs)
@bacpypes_debugging
objectIdentifier=('schedule', 3),
objectName='Schedule 3',
presentValue=CharacterString(""),
effectivePeriod=DateRange(
startDate=(0, 1, 1, 1),
endDate=(254, 12, 31, 2),
),
exceptionSchedule=ArrayOf(SpecialEvent)([
SpecialEvent(
period=SpecialEventPeriod(
calendarEntry=CalendarEntry(
weekNDay=xtob("FF.FF.05"),
),
),
listOfTimeValues=[
TimeValue(time=(0,0,0,0), value=CharacterString("It's Friday!")),
],
eventPriority=1,
),
]),
scheduleDefault=CharacterString("Keep working."),
)
_log.debug(" - so: %r", so)
this_application.add_object(so)
schedule_objects.append(so)
#
# A schedule object that refers to an AnalogValueObject in the test
# device.
#
so = LocalScheduleObject(
objectIdentifier=('schedule', 4),
Property,
register_object_type,
)
#
# Proprietary Objects and their attributes
#
JCIDeviceObject = {
"name": "JCIDeviceObject",
"vendor_id": 5,
"objectType": "device",
"bacpypes_type": DeviceObject,
"properties": {
"SupervisorOnline": {"obj_id": 3653, "primitive": Boolean, "mutable": True},
"Model": {"obj_id": 1320, "primitive": CharacterString, "mutable": False},
"MemoryUsage": {"obj_id": 2581, "primitive": Real, "mutable": False},
"ObjectMemoryUsage": {"obj_id": 2582, "primitive": Real, "mutable": False},
"CPU": {"obj_id": 2583, "primitive": Real, "mutable": False},
"FlashUsage": {"obj_id": 2584, "primitive": Real, "mutable": False},
"JCISystemStatus": {"obj_id": 847, "primitive": Enumerated, "mutable": False},
"SABusPerformance": {
"obj_id": 12157,
"primitive": Enumerated,
"mutable": False,
},
"SABusTokenLoopTime": {
"obj_id": 12158,
"primitive": Unsigned,
"mutable": False,
},
"SABusCOVRcvPerMinute": {