How alexbeltran/gobacnet works
Main Components
• Command Line Interface (CLI): The baccli package which contains the main application (baccli/main.go and subcommands like discover.go, readprop.go, etc.). This module is the user-entry point.
• Core BACnet Client Library: The core package responsible for performing BACnet operations. It includes various utility files like const.go, device.go, iam.go, and listen.go which manage device communication.
• Encoding Module: The “encoding” directory holds code for forming, parsing, and validating BACnet messages using files such as apdu.go, npdu.go, and various helper modules (encoder.go, decoder.go). This represents the protocol marshalling layer.
• Property Module: The “property” folder, responsible for managing property-related functions (e.g., print.go and properties.go) that support reading/writing properties.
• Transaction Management: Two distinct subcomponents exist:
• TSM (in the “tsm” directory) handles transaction state management, likely overseeing message transactions and response tracking.
• UTSM (in the “utsm” directory) seems to manage subscriptions or message dispatching for asynchronous processes.
• Data Types: The “types” package abstracts BACnet-related data types such as APDU, NPDU, and other protocol constants. It provides structured representations used by the rest of the library.
Interactions and Data Flow
• The CLI (baccli) component acts as the user-facing controller. When a command (e.g., “whoIs”, “readprop”) is issued, it triggers calls into the BACnet client layer.
• The BACnet client layer calls into the Encoding module to build and decode messages. For instance, command handlers use functions from encoding/encoder.go and encoding/decoder.go.
• Parsed and constructed messages rely on data structures defined within the Types package.
• Transaction management handled in TSM and UTSM ensures that message exchanges (request/response) are tracked and managed, with a flow of state updates.
• The Property module is used when dealing with property-specific operations (such as enumerating and formatting device properties) which may be invoked by both the CLI and the core client.
Architectural Patterns & Design Principles
• Modular Design: The project is structured with separation of concerns—command parsing, protocol encoding/decoding, data type handling, and transaction management are isolated.
• Clear Layering: The CLI interacts with the core logic, which in turn handles protocols in the encoding layer. Data formats and constants are managed in the Types package.
• Testability: Notice the presence of several *_test.go files which suggest unit testing is considered across the modules.
Technologies and Relevant Frameworks
• BACnet protocol standards are implied in the encoding and types modules.
• Integration testing and continuous integration are suggested by the .travis.yml file.