Is it possible to include device IP information into a BACnet function call from BACpypes?
-
I am currently working on my master's thesis, trying to connect a Dymola Simulation with a controller using BACnet do to a Software-In-The-Loop-Test. The controller needs to be adressed using the BACnet protocol including the IP of the controller. If the IP of the controller is not included, the controller discards the information. I tried to do this connection using BCVTB (Building Controls Virtual Test Bed) and the BCVTB-block, included in the Buildings 1.4 library by the Lawrence Berkely National Laboratory. However, BCVTB can not call for BACnet functions on devices with a specific IP. The BACnet commands are always sent to the Broadcast adress, this is why the controller discards the information. Is it possible to include IP information into the BACnet function call in BACpypes? I would call the BACpypes functions using the Python 27 block for Dymola, also shipped with the Buildings 1.4 library. If not, is there another possibility to connect Dymola to a BACnet device which needs to be adressed with its IP adress? Thanks a lot for your responses! Philipp Theilmann from RWTH Aachen University in Germany
-
Answer:
[I am the author of BACpypes and while this question has been answered in other forums, I thought I should answer it here as well.] There are a variety different aspects of BACnet as a peer-to-peer protocol and BACpypes as an implementation. First, BACnet devices on a network can be both clients (devices that initiate requests) and servers (devices that satisfy a request and provide a response), and be both a client and a server at the same time, and usually are. For example, if device A requests content from device B, B might ask A about its capabilities (how much data it can process in the response, for example) before actually providing the response. Second, BACnet uses UDP communications (stateless) rather than TCP (stateful) so developers that are accustomed to writing remote procedure call applications have an additional learning curve. Not steep, but different. It is not unusual for a client A to open a connection to server B, send the request (blocking as necessary to make sure the request was completely received), wait for the response (accumulating content that has been spread across multiple packets), then closing the connection. It is very unusual for client application developers to worry about what it means to be a server at the same time. BACpypes is a library that principally provides packet encoding and decoding functionality and then provides a skeleton framework with the minimal basic services for implementing applications that both clients and servers. It doesn't presume that the application is going to be mostly a client, mostly a server, or a balance between the two. BACpypes expects to "own" the thread where it is running, the socket select() loop sits at the very bottom of the stack, and all of the objects created by the thread are expected to be owned by the thread. Communications and object owership between the BACpypes thread and other threads must be carefully managed by the developer or there could be problems, so in that sense the library is not "thread safe". For applications like yours where you are going to be providing a function to be called in an unknown thread environment, you will need to build a queue or pipeline or semaphore mechanism so your requests and responses can be properly aligned, and when the request is completed, the function can return the response in the same context that the call was made. There is sample code in the project that shows how to build a REST-like web server that can translate GET requests into ReadPropertyRequest APDU's and "stringify" the response back. This sample has BACpypes running the main thread and HTTP request handler running in a separate thread, so your application needs to swap these roles. There will be more sample code to show one way of doing it, there are many!
Joel Bender at Quora Visit the source
Related Q & A:
- how to estimate the phase parameter of a complex function?Best solution by Mathematics
- How to speed up a wordpress function with multiple loops?Best solution by WordPress
- How to find the derivative without using a symbolic function in Matlab?Best solution by Stack Overflow
- How to access a nested function from another nested function in javascript?Best solution by devarticles.com
- How to graph a quadratic function on a graphing calculator?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.