--- a/bacnet/bacnet.py Thu May 28 11:01:42 2020 +0100
+++ b/bacnet/bacnet.py Thu May 28 11:15:22 2020 +0100
@@ -35,11 +35,11 @@
from bacnet.BacnetSlaveEditor import *
from bacnet.BacnetSlaveEditor import ObjectProperties
from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_MEMORY
-
-base_folder = os.path.split(
- os.path.dirname(os.path.realpath(__file__)))[0]
+from ConfigTreeNode import ConfigTreeNode
+
+base_folder = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
base_folder = os.path.join(base_folder, "..")
-BacnetPath = os.path.join(base_folder, "BACnet")
+BacnetPath = os.path.join(base_folder, "BACnet")
BacnetLibraryPath = os.path.join(BacnetPath, "lib")
BacnetIncludePath = os.path.join(BacnetPath, "include")
BacnetIncludePortPath = os.path.join(BacnetPath, "ports")
@@ -50,6 +50,10 @@
BACNET_VENDOR_NAME = "Beremiz.org"
BACNET_DEVICE_MODEL_NAME = "Beremiz PLC"
+
+# Max String Size of BACnet Paramaters
+BACNET_PARAM_STRING_SIZE = 64
+
#
#
#
@@ -97,6 +101,14 @@
</xsd:element>
</xsd:schema>
"""
+ # NOTE; Add the following code/declaration to the aboce XSD in order to activate the
+ # Override_Parameters_Saved_on_PLC flag (currenty not in use as it requires further
+ # analysis how the user would interpret this user interface option.
+ # <--- snip --->
+ # <xsd:attribute name="Override_Parameters_Saved_on_PLC"
+ # type="xsd:boolean" use="optional" default="true"/>
+ # <--- snip --->
+ #
# NOTE: BACnet device (object) IDs are 22 bits long (not counting the 10 bits for the type ID)
# so the Device instance ID is limited from 0 to 22^2-1 = 4194303
# However, 4194303 is reserved for special use (similar to NULL pointer), so last
@@ -552,8 +564,10 @@
generate_file_handle .write(generate_file_content)
generate_file_handle .close()
- #
- # Generate the source files #
+
+
+ #
+ # Generate the C source code files
#
def CTNGenerate_C(self, buildpath, locations):
# Determine the current location in Beremiz's project configuration
@@ -596,6 +610,11 @@
# The BACnetServerNode attribute is added dynamically by ConfigTreeNode._AddParamsMembers()
# It will be an XML parser object created by
# GenerateParserFromXSDstring(self.XSD).CreateRoot()
+ #
+ # Note: Override_Parameters_Saved_on_PLC is converted to an integer by int()
+ # The above flag is not currently in use. It requires further thinking on how the
+ # user will interpret and interact with this user interface...
+ #loc_dict["Override_Parameters_Saved_on_PLC"] = int(self.BACnetServerNode.getOverride_Parameters_Saved_on_PLC())
loc_dict["network_interface"] = self.BACnetServerNode.getNetwork_Interface()
loc_dict["port_number"] = self.BACnetServerNode.getUDP_Port_Number()
loc_dict["BACnet_Device_ID"] = self.BACnetServerNode.getBACnet_Device_ID()
@@ -607,6 +626,8 @@
loc_dict["BACnet_Vendor_ID"] = BACNET_VENDOR_ID
loc_dict["BACnet_Vendor_Name"] = BACNET_VENDOR_NAME
loc_dict["BACnet_Model_Name"] = BACNET_DEVICE_MODEL_NAME
+ loc_dict["BACnet_Param_String_Size"] = BACNET_PARAM_STRING_SIZE
+
# 2) Add the data specific to each BACnet object type
# For each BACnet object type, start off by creating some intermediate helpful lists
@@ -726,4 +747,33 @@
CFLAGS = ' -I"' + BacnetIncludePath + '"'
CFLAGS += ' -I"' + BacnetIncludePortPath + '"'
+ # ----------------------------------------------------------------------
+ # Create a file containing the default configuration paramters.
+ # Beremiz will then transfer this file to the PLC, where the web server
+ # will read it to obtain the default configuration parameters.
+ # ----------------------------------------------------------------------
+ # NOTE: This is no loner needed! The web interface will read these
+ # parameters directly from the compiled C code (.so file)
+ #
+ ### extra_file_name = os.path.join(buildpath, "%s_%s.%s" % ('bacnet_extrafile', postfix, 'txt'))
+ ### extra_file_handle = open(extra_file_name, 'w')
+ ###
+ ### proplist = ["network_interface", "port_number", "BACnet_Device_ID", "BACnet_Device_Name",
+ ### "BACnet_Comm_Control_Password", "BACnet_Device_Location",
+ ### "BACnet_Device_Description", "BACnet_Device_AppSoft_Version"]
+ ### for propname in proplist:
+ ### extra_file_handle.write("%s:%s\n" % (propname, loc_dict[propname]))
+ ###
+ ### extra_file_handle.close()
+ ### extra_file_handle = open(extra_file_name, 'r')
+
+ # Format of data to return:
+ # [(Cfiles, CFLAGS), ...], LDFLAGS, DoCalls, extra_files
+ # LDFLAGS = ['flag1', 'flag2', ...]
+ # DoCalls = true or false
+ # extra_files = (fname,fobject), ...
+ # fobject = file object, already open'ed for read() !!
+ #
+ # extra_files -> files that will be downloaded to the PLC!
return [(Generated_BACnet_c_mainfile_name, CFLAGS)], LDFLAGS, True
+ #return [(Generated_BACnet_c_mainfile_name, CFLAGS)], LDFLAGS, True, ('extrafile1.txt', extra_file_handle)