Comments (2)
You are expecting [None]
to be "cast" as [PriorityValue(None)]
but that isn't provided, PriorityValue
is a Choice
with no element selected and there needs to be at least one. If you specified [PriorityValue()] * 16
you would eventually be tripped up because it would be the same item repeated 16 times, and the same for [PriorityValue(null=())] * 16
.
The definition of PriorityArray
includes a "prototype" value that sets the null
option and this is copied for each item of the array when an instance is created so to create a new empty array, just call PriorityArray()
.
from bacpypes.
thanks - that got that sorted
`def create_analog_output(row):
try:
ArrayOfPropertyIdentifier = ArrayOf(PropertyIdentifier)
property_list = ArrayOfPropertyIdentifier([
'presentValue', 'statusFlags', 'eventState', 'outOfService', 'units',
'minPresValue', 'maxPresValue', 'resolution', 'covIncrement', 'description',
'highLimit', 'lowLimit', 'limitEnable'
])
analog_output = AnalogOutputObject(
objectName=row['Object_Name'],
objectIdentifier=(AnalogOutputObject.objectType, row['Object_Identifier']),
presentValue=row['Present_Value'],
statusFlags=calculate_status_flags(row),
eventState=row.get('Event_State', 0), # Assuming default value is 0
outOfService=bool(row['Out_Of_Service']), # Convert to bool
units=row['BACnet_Engineering_Units'],
minPresValue=row['Min_Pres_Value'],
maxPresValue=row['Max_Pres_Value'],
resolution=row.get('Resolution', None),
covIncrement=row.get('COV_Increment', 1),
description=row['Description'],
highLimit=row.get('High_Limit', None),
lowLimit=row.get('Low_Limit', None),
limitEnable=row.get('Limit_Enable', [False, False]),
propertyList=property_list,
)
# Initialize the priority array with default values
priority_array = PriorityArray()
# Set the Present_Value at the specified priority position if within range
if 'Priority' in row and 1 <= row['Priority'] <= 16:
priority_index = row['Priority'] # Don't need to Adjust for 0-based index
priority_array[priority_index] = PriorityValue(real=Real(row['Present_Value']))
# Assign the priority array to the object
analog_output.priorityArray = priority_array
# Print out the priority array
logging.info(f"Priority Array Contents: Current Priority is {row['Priority']} with a value of {row['Present_Value']}")
# for i, priority_value in enumerate(priority_array):
# # Log the actual value contained in the PriorityValue object
# if priority_value:
# logging.info(f"Priority {i+1}: {priority_value.real}")
# else:
# logging.info(f"Priority {i+1}: None")
logging.debug(f"Created AnalogOutputObject: {analog_output}")
return analog_output
except Exception as e:
logging.error(f"{color.RED}An error occurred in create_analog_output: {e}{color.END}")
return None`
from bacpypes.
Related Issues (20)
- BACnet Services request notification
- asyncore removed from python 3.12 HOT 4
- Issue in dockerising an MSTP application using Misty and BACpypes HOT 1
- Problem with ConfirmedEventNotification in BACpypes Sample HOT 2
- BACnet device is not discoverable in Yabe HOT 4
- MAC Address from I-Am HOT 2
- Do we need to modify our code if we are prefering BACnet port as TCP over UDP? HOT 1
- Clearing / Releasing a priority HOT 2
- Dependency asyncore has been removed in python 3.12. HOT 2
- How do I alter the object properties' values while the simulator is running? HOT 1
- Remote network responds to WhoIsIAm but not ReadProperty HOT 5
- COV - how is Priority handled HOT 1
- COV subscription setting lifetime to 0 causes Error HOT 2
- Erroneous Day-of-week code in packet when building readRange log-buffer request with time-range HOT 6
- Upload GitHub release and PyPI archive HOT 2
- Python 3.12 Unsupported version of Python HOT 2
- External Device writing to one of My Objects HOT 7
- Is there a way to detect where a change came from in the BACnet Stack? HOT 2
- Issue with first use of set_timeout of IOCB when updating from v0.16 to v0.18 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bacpypes.