def add_point(self, point: BACnetPointModel, _update_point_store=True): [priority_array, present_value] = default_values(point.priority_array_write, point.relinquish_default) if point.use_next_available_address: point.address = BACnetPointModel.get_next_available_address( point.address) object_identifier = create_object_identifier(point.object_type.name, point.address) if point.object_type.name == "analogOutput": register_object_type(AnalogOutputCmdObject) p = AnalogOutputFeedbackObject( profileName=point.uuid, objectIdentifier=(point.object_type.name, point.address), objectName=point.object_name, relinquishDefault=point.relinquish_default, presentValue=present_value, priorityArray=priority_array, eventState=point.event_state.name, statusFlags=StatusFlags(), units=EngineeringUnits(point.units.name), description=point.description, outOfService=False, ) self.__bacnet.add_object(p) self.__registry[object_identifier] = p elif point.object_type.name == "analogValue": register_object_type(AnalogValueCmdObject) p = AnalogValueFeedbackObject( profileName=point.uuid, objectIdentifier=(point.object_type.name, point.address), objectName=point.object_name, relinquishDefault=point.relinquish_default, presentValue=present_value, priorityArray=priority_array, eventState=point.event_state.name, statusFlags=StatusFlags(), units=EngineeringUnits(point.units.name), description=point.description, outOfService=False, ) self.__bacnet.add_object(p) self.__registry[object_identifier] = p if _update_point_store: # make it so on start of app not to update the point store update_point_store(point.uuid, present_value) setting: AppSetting = current_app.config[AppSetting.FLASK_KEY] if setting.mqtt.enabled: priority = get_highest_priority_field(point.priority_array_write) mqtt_client = MqttClient() mqtt_client.publish_value( ('ao', object_identifier, point.object_name), present_value, priority)
def _process_unknown(self, object_type, obj): obj_units = "UNKNOWN UNIT ENUM VALUE" try: obj_units = EngineeringUnits(obj.get('units')).value if isinstance(obj_units, int): obj_units = 'UNKNOWN UNIT ENUM VALUE: ' + str(obj.get('units')) except ValueError: if obj.get('units'): obj_units += ": " + str(obj.get('units')) units_details = '' notes = obj.get('description', '').strip() if object_type.startswith('analog') or object_type in ( 'largeAnalogValue', 'integerValue', 'positiveIntegerValue'): if not object_type.endswith('Value'): res_value = obj.get('resolution') if res_value: notes = 'Resolution: {resolution:.6g}'.format( resolution=res_value) if object_type not in ( 'largeAnalogValue', 'integerValue', 'positiveIntegerValue'): min_value = obj.get('minPresValue', -MAX_RANGE_REPORT) max_value = obj.get('maxPresValue', MAX_RANGE_REPORT) has_min = min_value > -MAX_RANGE_REPORT has_max = max_value < MAX_RANGE_REPORT if has_min and has_max: units_details = '{min:.2f} to {max:.2f}'.format( min=min_value, max=max_value) elif has_min: units_details = 'Min: {min:.2f}'.format( min=min_value) elif has_max: units_details = 'Max: {max:.2f}'.format( max=max_value) else: units_details = 'No limits.' if object_type != 'analogInput': if 'relinquishDefault' in obj: units_details += ' (default {default})'.format( default=obj.get('relinquishDefault')) units_details = units_details.strip() return obj_units, units_details, notes
def start_device(): print("Starting BACnet device") new_device = BAC0.lite() new_device._log.info('Device ID : {}'.format(new_device.Boid)) time.sleep(10) default_pv = CharacterString("empty") current_humidity = create_AV(oid=0, name="Current_Humidity", pv=0, pv_writable=False) current_humidity.units = EngineeringUnits("percent") current_humidity.description = CharacterString( "Current Humidity in percent relative humidity") current_temp = create_AV(oid=1, name="Current_Temp", pv=0, pv_writable=False) current_temp.units = EngineeringUnits("degreesFahrenheit") current_temp.description = CharacterString("Current Temperature in degF") current_windspd = create_AV(oid=2, name="Current_Wind_Speed", pv=0, pv_writable=False) current_windspd.units = EngineeringUnits("milesPerHour") current_windspd.description = CharacterString("Current Wind Speed") current_winddir = create_CharStrValue(oid=3, name="Current_Wind_Dir", pv=default_pv, pv_writable=False) current_winddir.description = CharacterString("Wind Direction String") current_pressure = create_AV(oid=4, name="Current_Pressure", pv=0, pv_writable=False) current_pressure.units = EngineeringUnits("hectopascals") current_pressure.description = CharacterString( "Current Barometric Pressure") current_cloudcov = create_AV(oid=5, name="Current_Cloud_Cover", pv=0, pv_writable=False) current_cloudcov.units = EngineeringUnits("percent") current_cloudcov.description = CharacterString( "Current Cloud Cover in Percent") last_update = create_DateTimeValue(oid=1, name="Last_Update") last_update.description = CharacterString("Last update timestamp") current_location = create_CharStrValue(oid=8, name="Weather_Station_City", pv=default_pv) current_location.description = CharacterString( "Location of Weather Station") current_description = create_CharStrValue( oid=9, name="Current_Weather_Description", pv=default_pv) current_description.description = CharacterString( "Weather Station Description String") current_dewpoint = create_AV(oid=10, name="Current_Dewpoint", pv=0, pv_writable=False) current_dewpoint.units = EngineeringUnits("degreesFahrenheit") current_dewpoint.description = CharacterString("Current Outdoor Dewpoint") new_device.this_application.add_object(current_humidity) new_device.this_application.add_object(current_temp) new_device.this_application.add_object(current_windspd) new_device.this_application.add_object(current_winddir) new_device.this_application.add_object(current_pressure) new_device.this_application.add_object(current_cloudcov) new_device.this_application.add_object(last_update) new_device.this_application.add_object(current_location) new_device.this_application.add_object(current_description) new_device.this_application.add_object(current_dewpoint) return new_device
def main(): device_info = { 'ip': '10.169.204.200', 'netmask': 23, 'port': 47809, 'objectName': 'FHL-DAF-DUSTMETER', 'objectIdentifier': 522020, 'vendorIdentifier': 15, 'location': 'FHL-DAF-CLEAN-ROOM', 'vendorName': 'DESY-ATLAS', 'modelName': 'DUST-METERS', 'softwareVersion': 'bacpypes_v0.16.2_py27', 'description': 'FHL-DAF clean room dustmeter server' } print device_info this_device = LocalDeviceObject( objectName=device_info['objectName'], objectIdentifier=device_info['objectIdentifier'], vendorIdentifier=device_info['vendorIdentifier']) this_device._values['location'] = CharacterString(device_info['location']) this_device._values['vendorName'] = CharacterString( device_info['vendorName']) this_device._values['modelName'] = CharacterString( device_info['modelName']) this_device._values['applicationSoftwareVersion'] = CharacterString( device_info['softwareVersion']) this_device._values['description'] = CharacterString( device_info['description']) this_addr = str(device_info['ip'] + '/' + str(device_info['netmask']) + ':' + str(device_info['port'])) print 'bacnet server will listen at', this_addr this_application = BIPSimpleApplication(this_device, this_addr) this_application.add_capability(ReadWritePropertyMultipleServices) this_device.protocolServicesSupported = this_application.get_services_supported( ).value meter_info = [ { 'name': 'dustmeter_a19', 'index': 1, 'host': 'fhlrs232_a19.desy.de', 'description': 'dustmeter on RS232-Ethernet bridge at somewhere', }, { 'name': 'dustmeter_a27', 'index': 2, 'host': 'fhlrs232_a27.desy.de', 'description': 'dustmeter on RS232-Ethernet bridge at somewhere', }, { 'name': 'dustmeter_a40', 'index': 3, 'host': 'fhlrs232_a40.desy.de', 'description': 'dustmeter on RS232-Ethernet bridge at somewhere', }, { 'name': 'dustmeter_a43', 'index': 4, 'host': 'fhlrs232_a43.desy.de', 'description': 'dustmeter on RS232-Ethernet bridge at somewhere', }, { 'name': 'dustmeter_a49', 'index': 5, 'host': 'fhlrs232_a49.desy.de', 'description': 'dustmeter on RS232-Ethernet bridge at somewhere', }, { 'name': 'dustmeter_a56', 'index': 6, 'host': 'fhlrs232_a56.desy.de', 'description': 'dustmeter on RS232-Ethernet bridge at somewhere', }, ] meters = [] for info in meter_info: m = dustmeter.DustMeter(name=info['name'], host=info['host']) m.start() meters.append(m) objs = [] for info in meter_info: ai_obj = AnalogInputObject(objectIdentifier=('analogInput', info['index']), \ objectName=info['name']) ai_obj._values['description'] = CharacterString(info['description']) ai_obj._values['deviceType'] = CharacterString( 'Particles(>0.5um) PerCubicFoot') ai_obj._values['units'] = EngineeringUnits('noUnits') ai_obj._values['updateInterval'] = Unsigned(60) ai_obj._values['resolution'] = Real(100) this_application.add_object(ai_obj) objs.append(ai_obj) mythread = dataThread(meters, objs) mythread.start() run() mythread.stop() mythread.join() for m in meters: m.stop() m.join() print "end of join"
def start_device(): print("Starting BACnet device") new_device = BAC0.lite() new_device._log.info('Device ID : {}'.format(new_device.Boid)) time.sleep(10) default_pv = CharacterString("empty") ####humidity####### Current_humidity = create_AV(oid=0, name="Midnight_Humidity", pv=0, pv_writable=False) Current_humidity.units = EngineeringUnits("percent") Current_humidity.description = CharacterString( "Midnight Humidity in Percent Relative Humidity") ####temp####### Current_temp = create_AV(oid=1, name="Midnight_Temp", pv=0, pv_writable=False) Current_tempunits = EngineeringUnits("degreesFahrenheit") Current_description = CharacterString("5AM Temperature in degF") ####dewpoint####### Current_dewpoint = create_AV(oid=2, name="Midnight_Dewpoint", pv=0, pv_writable=False) Current_dewpoint.units = EngineeringUnits("degreesFahrenheit") Current_dewpoint.description = CharacterString("Midnight Outdoor Dewpoint") ####clouds####### Current_clouds = create_AV(oid=3, name="Midnight_Cloud_Cover", pv=0, pv_writable=False) Current_clouds.units = EngineeringUnits("percent") Current_clouds.description = CharacterString( "Midnight Cloud Cover In Percent") ####description####### Current_description = create_CharStrValue( oid=4, name="Midnight_Weather_Description", pv=default_pv) Current_description.description = CharacterString( "Midnight Weather Description") ####humidity####### Five_AM_humidity = create_AV(oid=5, name="5:00AM_Humidity", pv=0, pv_writable=False) Five_AM_humidity.units = EngineeringUnits("percent") Five_AM_humidity.description = CharacterString( "5AM Humidity in Percent Relative Humidity") ####temp####### Five_AM_temp = create_AV(oid=6, name="5:00AM_Temp", pv=0, pv_writable=False) Five_AM_temp.units = EngineeringUnits("degreesFahrenheit") Five_AM_temp.description = CharacterString("5AM Temperature in degF") ####dewpoint####### Five_AM_dewpoint = create_AV(oid=7, name="5:00AM_Dewpoint", pv=0, pv_writable=False) Five_AM_dewpoint.units = EngineeringUnits("degreesFahrenheit") Five_AM_dewpoint.description = CharacterString("5AM Outdoor Dewpoint") ####clouds####### Five_AM_clouds = create_AV(oid=8, name="5:00AM_Cloud_Cover", pv=0, pv_writable=False) Five_AM_clouds.units = EngineeringUnits("percent") Five_AM_clouds.description = CharacterString("5AM Cloud Cover In Percent") ####description####### Five_AM_description = create_CharStrValue( oid=9, name="5:00AM_Weather_Description", pv=default_pv) Five_AM_description.description = CharacterString( "5AM Weather Description 5AM") ####humidity#######3HR Eight_AM_humidity = create_AV(oid=10, name="8:00AM_Humidity", pv=0, pv_writable=False) Eight_AM_humidity.units = EngineeringUnits("percent") Eight_AM_humidity.description = CharacterString( "8:00AM Humidity in Percent Relative Humidity") ####temp#######3HR Eight_AM_temp = create_AV(oid=11, name="8:00AM_Temp", pv=0, pv_writable=False) Eight_AM_temp.units = EngineeringUnits("degreesFahrenheit") Eight_AM_temp.description = CharacterString("8:00AM Temp in degF") ####dewpoint#######3HR Eight_AM_dewpoint = create_AV(oid=12, name="8:00AM_Dewpoint", pv=0, pv_writable=False) Eight_AM_dewpoint.units = EngineeringUnits("degreesFahrenheit") Eight_AM_dewpoint.description = CharacterString("8:00AM Outdoor Dewpoint") ####clouds#######3HR Eight_AM_clouds = create_AV(oid=13, name="8:00AM_Cloud_Cover", pv=0, pv_writable=False) Eight_AM_clouds.units = EngineeringUnits("percent") Eight_AM_clouds.description = CharacterString( "8:00AM Cloud Cover In Percent") ####description#######3HR Eight_AM_description = create_CharStrValue( oid=14, name="8:00AM_Weather_Description", pv=default_pv) Eight_AM_description.description = CharacterString( "8:00AM Weather Description") ####humidity#######6HR Eleven_AM_humidity = create_AV(oid=15, name="11:00AM_Humidity", pv=0, pv_writable=False) Eleven_AM_humidity.units = EngineeringUnits("percent") Eleven_AM_humidity.description = CharacterString( "11:00AM Humidity in Percent Relative Humidity") ####temp#######6HR Eleven_AM_temp = create_AV(oid=16, name="11:00AM_Temp", pv=0, pv_writable=False) Eleven_AM_temp.units = EngineeringUnits("degreesFahrenheit") Eleven_AM_temp.description = CharacterString("11:00AM Temp in degF") ####dewpoint#######6HR Eleven_AM_dewpoint = create_AV(oid=17, name="11:00AM_Dewpoint", pv=0, pv_writable=False) Eleven_AM_dewpoint.units = EngineeringUnits("degreesFahrenheit") Eleven_AM_dewpoint.description = CharacterString( "11:00AM Outdoor Dewpoint") ####clouds#######6HR Eleven_AM_clouds = create_AV(oid=18, name="11:00AM_Cloud_Cover", pv=0, pv_writable=False) Eleven_AM_clouds.units = EngineeringUnits("percent") Eleven_AM_clouds.description = CharacterString( "11:00AM Cloud Cover In Percent") ####description#######6HR Eleven_AM_description = create_CharStrValue( oid=19, name="11:00AM_Weather_Description", pv=default_pv) Eleven_AM_description.description = CharacterString( "11:00AM Weather Description") ####humidity#######9HR Two_PM_humidity = create_AV(oid=20, name="2:00PM_Humidity", pv=0, pv_writable=False) Two_PM_humidity.units = EngineeringUnits("percent") Two_PM_humidity.description = CharacterString( "2:00PM Humidity in Percent Relative Humidity") ####temp#######9HR Two_PM_temp = create_AV(oid=21, name="2:00PM_Temp", pv=0, pv_writable=False) Two_PM_temp.units = EngineeringUnits("degreesFahrenheit") Two_PM_temp.description = CharacterString("2:00PM Temp in degF") ####dewpoint#######9HR Two_PM_dewpoint = create_AV(oid=22, name="2:00PM_Dewpoint", pv=0, pv_writable=False) Two_PM_dewpoint.units = EngineeringUnits("degreesFahrenheit") Two_PM_dewpoint.description = CharacterString("2:00PM Outdoor Dewpoint") ####clouds#######9HR Two_PM_clouds = create_AV(oid=23, name="2:00PM_Cloud_Cover", pv=0, pv_writable=False) Two_PM_clouds.units = EngineeringUnits("percent") Two_PM_clouds.description = CharacterString( "2:00PM Cloud Cover In Percent") ####description#######9HR Two_PM_description = create_CharStrValue(oid=24, name="2:00PM_Weather_Description", pv=default_pv) Two_PM_description.description = CharacterString( "2:00PM Weather Description") ####humidity#######12HR Five_PM_humidity = create_AV(oid=25, name="5:00PM_Humidity", pv=0, pv_writable=False) Five_PM_humidity.units = EngineeringUnits("percent") Five_PM_humidity.description = CharacterString( "5:00PM Humidity in Percent Relative Humidity") ####temp#######12HR Five_PM_temp = create_AV(oid=26, name="5:00PM_Temp", pv=0, pv_writable=False) Five_PM_temp.units = EngineeringUnits("degreesFahrenheit") Five_PM_temp.description = CharacterString("5:00PM Temp in degF") ####dewpoint#######12HR Five_PM_dewpoint = create_AV(oid=27, name="5:00PM_Dewpoint", pv=0, pv_writable=False) Five_PM_dewpoint.units = EngineeringUnits("degreesFahrenheit") Five_PM_dewpoint.description = CharacterString("5:00PM Outdoor Dewpoint") ####clouds#######12HR Five_PM_clouds = create_AV(oid=28, name="5:00PM_Cloud_Cover", pv=0, pv_writable=False) Five_PM_clouds.units = EngineeringUnits("percent") Five_PM_clouds.description = CharacterString( "5:00PM Cloud Cover In Percent") ####description#######12HR Five_PM_description = create_CharStrValue( oid=29, name="5:00PM_Weather_Description", pv=default_pv) Five_PM_description.description = CharacterString( "5:00PM Weather Description") ####humidity#######15HR Eight_PM_humidity = create_AV(oid=30, name="8:00PM_Humidity", pv=0, pv_writable=False) Eight_PM_humidity.units = EngineeringUnits("percent") Eight_PM_humidity.description = CharacterString( "8:00PM Humidity in Percent Relative Humidity") ####temp#######15HR Eight_PM_temp = create_AV(oid=31, name="8:00PM_Temp", pv=0, pv_writable=False) Eight_PM_temp.units = EngineeringUnits("degreesFahrenheit") Eight_PM_temp.description = CharacterString("8:00PM Temp in degF") ####dewpoint#######15HR Eight_PM_dewpoint = create_AV(oid=32, name="8:00PM_Dewpoint", pv=0, pv_writable=False) Eight_PM_dewpoint.units = EngineeringUnits("degreesFahrenheit") Eight_PM_dewpoint.description = CharacterString("8:00PM Outdoor Dewpoint") ####clouds#######15HR Eight_PM_clouds = create_AV(oid=33, name="8:00PM_Cloud_Cover", pv=0, pv_writable=False) Eight_PM_clouds.units = EngineeringUnits("percent") Eight_PM_clouds.description = CharacterString( "8:00PM Cloud Cover In Percent") ####description#######15HR Eight_PM_description = create_CharStrValue( oid=34, name="8:00PM_Weather_Description", pv=default_pv) Eight_PM_description.description = CharacterString( "8:00PM Weather Description") ####GPS####### latitude = create_AV(oid=35, name="Latitude_GPS_Setting", pv=0, pv_writable=False) latitude.description = CharacterString( "GPS Latitude for Weather Data Request") ####GPS####### longitude = create_AV(oid=36, name="Longitude_GPS_Setting", pv=0, pv_writable=False) longitude.description = CharacterString( "GPS Longitude for Weather Data Request") new_device.this_application.add_object(Current_humidity) new_device.this_application.add_object(Current_temp) new_device.this_application.add_object(Current_dewpoint) new_device.this_application.add_object(Current_clouds) new_device.this_application.add_object(Current_description) new_device.this_application.add_object(Five_AM_humidity) new_device.this_application.add_object(Five_AM_temp) new_device.this_application.add_object(Five_AM_dewpoint) new_device.this_application.add_object(Five_AM_clouds) new_device.this_application.add_object(Five_AM_description) new_device.this_application.add_object(Eight_AM_humidity) new_device.this_application.add_object(Eight_AM_temp) new_device.this_application.add_object(Eight_AM_dewpoint) new_device.this_application.add_object(Eight_AM_clouds) new_device.this_application.add_object(Eight_AM_description) new_device.this_application.add_object(Eleven_AM_humidity) new_device.this_application.add_object(Eleven_AM_temp) new_device.this_application.add_object(Eleven_AM_dewpoint) new_device.this_application.add_object(Eleven_AM_clouds) new_device.this_application.add_object(Eleven_AM_description) new_device.this_application.add_object(Two_PM_humidity) new_device.this_application.add_object(Two_PM_temp) new_device.this_application.add_object(Two_PM_dewpoint) new_device.this_application.add_object(Two_PM_clouds) new_device.this_application.add_object(Two_PM_description) new_device.this_application.add_object(Five_PM_humidity) new_device.this_application.add_object(Five_PM_temp) new_device.this_application.add_object(Five_PM_dewpoint) new_device.this_application.add_object(Five_PM_clouds) new_device.this_application.add_object(Five_PM_description) new_device.this_application.add_object(Eight_PM_humidity) new_device.this_application.add_object(Eight_PM_temp) new_device.this_application.add_object(Eight_PM_dewpoint) new_device.this_application.add_object(Eight_PM_clouds) new_device.this_application.add_object(Eight_PM_description) new_device.this_application.add_object(latitude) new_device.this_application.add_object(longitude) return new_device
ms = metermodule.getMeters(info) print("Got {} meter(s) from {}".format(len(ms), metersection)) meters_active.extend(ms) for m in ms: m.name = "{}_{}".format(metersection, m.name) ai_obj = AnalogInputObject(objectIdentifier=("analogInput", idx), objectName=m.name) if "description" in info: ai_obj._values["description"] = CharacterString( info["description"]) if "deviceType" in info: ai_obj._values["deviceType"] = CharacterString( info["deviceType"]) ai_obj._values["units"] = EngineeringUnits("noUnits") if "updateInterval" in info: try: updateInterval = int(info["updateInterval"]) if updateInterval < 0: raise ValueError("Invalid negative value :" + info["updateInterval"]) except ValueError as e: print( "Value of updateInterval in section {}: {}".format( metersection, e)) exit(1) ai_obj._values["updateInterval"] = Unsigned(updateInterval) if "resolution" in info: try: resolution = float(info["resolution"])
def main(): if not path.exists("server.cfg"): logger.error("Error: File server.cfg not found.") exit(1) cparser = configparser.ConfigParser() cparser.read("server.cfg") if not "server" in cparser: logger.error("Invalid config: No server section") exit(1) required_keys = { "ip", "port", "objectname", "vendoridentifier", "location", "vendorname", "modelname", "description" } missing_keys = required_keys - set(cparser["server"].keys()) if len(missing_keys) != 0: logger.error("Missing config keys in server section: " + (" ".join(missing_keys))) exit(1) device_info = { 'ip': cparser["server"]["ip"], 'netmask': 23, 'port': cparser["server"]["port"], 'objectName': cparser["server"]["objectName"], 'objectIdentifier': 522020, 'vendorIdentifier': int(cparser["server"]["vendorIdentifier"]), 'location': cparser["server"]["location"], 'vendorName': cparser["server"]["vendorName"], 'modelName': cparser["server"]["modelName"], 'softwareVersion': "bacpypes_{}_python{}.{}.{}".format(bacpypes_version, version_info[0], version_info[1], version_info[2]), 'description': cparser["server"]["description"] } logger.info("=== INIT ===") logger.info(device_info) this_device = LocalDeviceObject( objectName=device_info["objectName"], objectIdentifier=device_info["objectIdentifier"], vendorIdentifier=device_info["vendorIdentifier"]) this_device._values['location'] = CharacterString(device_info['location']) this_device._values['vendorName'] = CharacterString( device_info['vendorName']) this_device._values['modelName'] = CharacterString( device_info['modelName']) this_device._values['applicationSoftwareVersion'] = CharacterString( device_info['softwareVersion']) this_device._values['description'] = CharacterString( device_info['description']) this_addr = str(device_info['ip'] + '/' + str(device_info['netmask']) + ':' + str(device_info['port'])) logger.info("bacnet server will listen at {}".format(this_addr)) this_application = BIPSimpleApplication(this_device, this_addr) this_application.add_capability(ReadWritePropertyMultipleServices) this_device.protocolServicesSupported = this_application.get_services_supported( ).value meters_active = [] ai_objs = [] idx = 1 logger.info("Initializing meters...") for key, metermodule in METERS.items(): if not key in cparser["server"]: logger.warning( "No key '{}' in config server section. Skipping".format(key)) continue metersections = cparser["server"][key].split() missing_metersections = set(metersections) - set(cparser.keys()) if len(missing_metersections) != 0: logger.error("Missing config sections for meters: " + "".join(missing_metersections)) exit(1) for metersection in metersections: info = cparser[metersection] ms = metermodule.getMeters(info) logger.info("Got {} meter(s) from {}".format( len(ms), metersection)) meters_active.extend(ms) for m in ms: m.name = "{}_{}".format(metersection, m.name) ai_obj = AnalogInputObject(objectIdentifier=("analogInput", idx), objectName=m.name) if "description" in info: ai_obj._values["description"] = CharacterString( info["description"]) if "deviceType" in info: ai_obj._values["deviceType"] = CharacterString( info["deviceType"]) ai_obj._values["units"] = EngineeringUnits("noUnits") if "updateInterval" in info: try: updateInterval = int(info["updateInterval"]) if updateInterval < 0: raise ValueError("Invalid negative value :" + info["updateInterval"]) except ValueError as e: logger.error( "Value of updateInterval in section {}: {}".format( metersection, e)) exit(1) ai_obj._values["updateInterval"] = Unsigned(updateInterval) if "resolution" in info: try: resolution = float(info["resolution"]) except ValueError as e: logger.error( "Value of updateInterval in section {}: {}".format( metersection, e)) exit(1) ai_obj._values["resolution"] = Real(resolution) this_application.add_object(ai_obj) ai_objs.append(ai_obj) idx += 1 fname = m.name output_csv = os.path.join(str('/var/www/html'), fname + u".csv") mode = 'a' if sys.version_info.major < 3: mode += 'b' with open(output_csv, mode) as f: header = OrderedDict([('# time', None), (m.name, None)]) writer = csv.DictWriter(f, fieldnames=header, extrasaction=u"ignore") writer.writeheader() f.close() for m in meters_active: m.start() datathread = DataThread(meters_active, ai_objs) datathread.start() bacpypesrun() datathread.stop() datathread.join() for m in meters_active: m.stop() m.join()