Пример #1
0
def get_device_by_name_and_id(xml_name, slave_id, client):
    "xml name as in the folder ex: AE 3TL Inverter (w/ or w/out .xml)"
    xml_path = os.path.join(BASE,"templates/") + xml_name
    if not xml_path.endswith(".xml"):
        xml_path += ".xml"
    template = create_template_from_xml(xml_path)
    return Device(template, slave_id, client)
Пример #2
0
def print_sites(session):
    """Show site asset metadata"""

    devices = Device.list(session)

    # Get site info
    for device in devices:
        LOGGER.info("Device '%s'", device['deviceId'])

        site = map_device_to_site(device)
        print(site)
Пример #3
0
 def getDevices(self):
     devices = string.split(self.config.get(self.database, 'devices'), ',')
     database = []
     for d in devices:
         print "console.Database.getDevices>", d
         if d == '':
             continue
         address, instance = d.split('!')
         device = Device(address, self.port, int(instance))
         database.append(device)
     #print "console.Database.getDevices>", database
     return database
Пример #4
0
def print_sensors(session):
    """Show sensor asset metadata"""

    devices = Device.list(session)

    # Get sensor info
    for device in devices:
        LOGGER.info("Device '%s'", device['deviceId'])

        # Get latest data to get metric names
        row = Data.current_for_device(session, device['deviceId'])
        LOGGER.debug(row)

        sensor = map_device_to_sensor(device, row)
        print(sensor)
Пример #5
0
    def run(self):
        ioObjectTypes=[
                       bacnet.ObjectType.analogInput,  #@UndefinedVariable
                       bacnet.ObjectType.analogOutput, #@UndefinedVariable
                       bacnet.ObjectType.analogValue,  #@UndefinedVariable
                       bacnet.ObjectType.binaryInput,  #@UndefinedVariable
                       bacnet.ObjectType.binaryOutput, #@UndefinedVariable
                       bacnet.ObjectType.binaryValue,  #@UndefinedVariable
                       ]

        for target in self.devices:
            if info: print "FindObjects> ** device start:", target
            message=bacnet.ReadProperty('objectName',('device',target.device))
            response=yield Message(target.address,message)
            name=response.message.value._value
            response=yield database.Device(target.IP,target.port,target.device,name)
            deviceID,=response.pop()
            self.deviceid[deviceID]=Device(target.IP,target.port,target.device,deviceID)
            
            objects=[]
            index=0
            while True:
                index+=1
                readproperty=bacnet.ReadProperty('objectList',('device',target.device),index)
                request=yield Message(target.address,readproperty)
                if isinstance(request.message, bacnet.Error):
                    break
                
                o=request.message.value[0] ## Object
                if debug: print "FindObjects>", o
                if o.type in ioObjectTypes:
                    objects.append(o)

            if debug: print "FindObjects> ** device objects:",target.device
            for o in objects:
                response=yield Message(target.address,bacnet.ReadProperty('objectName',o))
                name=response.message.value._value
                response=yield Message(target.address,bacnet.ReadProperty('description',o))
                description=response.message.value._value
                if debug: print "FindObjects> name:", name, description
                response=yield database.Object(deviceID,target.device,o.type,o.instance,name,description)
                objectID,=response.pop()
                o=Object(deviceID,objectID,o.type,o.instance,name)
                target.objects.append(o)
                self.objectid[objectID]=o
                
            if debug: print "FindObjects> ** device end:",target.device
Пример #6
0
def get_data(session, start, end, average) -> iter:
    # Iterate over all available devices
    for device in Device.list(session):
        LOGGER.info("DEVICE %s", device)

        # Run query against this device
        row_count = 0
        for data in Data.analytics(session, device['deviceId'], start, end, average):
            row_count += 1
            # Build a data row
            row = data['payload']['d'].copy()

            row['sensor'] = device['deviceId']

            yield row

        LOGGER.info("Retrieved %s rows", row_count)
Пример #7
0
def print_status(session):
    """Show current device status"""
    for status in Device.status(session):
        print(status)