Beispiel #1
0
    def read_object_list(self, device_id, device_addr):
        if _debug:
            ReadAllObjectPropertiesApplication._debug("read_object_list %r %r",
                                                      device_id, device_addr)

        # create a context to hold the results
        context = ObjectPropertyContext(device_id, device_addr)

        # build a request for the object name
        request = ReadPropertyRequest(
            destination=context.device_addr,
            objectIdentifier=context.device_id,
            propertyIdentifier='objectList',
        )
        if _debug:
            ReadAllObjectPropertiesApplication._debug("    - request: %r",
                                                      request)

        # make an IOCB, reference the context
        iocb = IOCB(request)
        iocb.context = context
        if _debug:
            ReadAllObjectPropertiesApplication._debug("    - iocb: %r", iocb)

        # let us know when its complete
        iocb.add_callback(self.object_list_results)

        # give it to the application
        self.request_io(iocb)
Beispiel #2
0
    def read_next_object(self, context):
        if _debug:
            ReadObjectListApplication._debug("read_next_object %r", context)

        # if there's nothing more to do, we're done
        if not context._object_list_queue:
            if _debug: ReadObjectListApplication._debug("    - all done")
            context.completed()
            return

        # pop off the next object identifier
        object_id = context._object_list_queue.popleft()
        if _debug:
            ReadObjectListApplication._debug("    - object_id: %r", object_id)

        # build a request for the object name
        request = ReadPropertyRequest(
            destination=context.device_addr,
            objectIdentifier=object_id,
            propertyIdentifier='objectName',
        )
        if _debug:
            ReadObjectListApplication._debug("    - request: %r", request)

        # make an IOCB, reference the context
        iocb = IOCB(request)
        iocb.context = context
        if _debug: ReadObjectListApplication._debug("    - iocb: %r", iocb)

        # let us know when its complete
        iocb.add_callback(self.object_name_results)

        # give it to the application
        self.request_io(iocb)
Beispiel #3
0
    def read_next_object_properties(self, context):
        if _debug:
            ReadAllObjectPropertiesApplication._debug("read_next_object %r",
                                                      context)

        # if there's nothing more to do, we're done

        if all([
                len(context.properties_dict_queue[element]) == 0
                for element in context.properties_dict_queue
        ]):
            if _debug:
                ReadAllObjectPropertiesApplication._debug("    - all done")
            context.completed()
            return

        # pop off the next object identifier
        if context.current_object_id is None or len(
                context.properties_dict_queue[context.current_object_id]) == 0:
            context.current_object_id = context._object_list_queue.popleft()
            context.property_result_dict.update({
                context.current_object_id[0] + str(context.current_object_id[1]):
                dict()
            })

        context.current_property = context.properties_dict_queue[
            context.current_object_id].popleft()

        if _debug:
            ReadAllObjectPropertiesApplication._debug(
                "    - object_id: %r", context.current_object_id)

        # build a request for the object name
        request = ReadPropertyRequest(
            destination=context.device_addr,
            objectIdentifier=context.current_object_id,
            propertyIdentifier=context.current_property[0],
        )
        if _debug:
            ReadAllObjectPropertiesApplication._debug("    - request: %r",
                                                      request)

        # make an IOCB, reference the context
        iocb = IOCB(request)
        iocb.context = context
        if _debug:
            ReadAllObjectPropertiesApplication._debug("    - iocb: %r", iocb)

        # let us know when its complete
        iocb.add_callback(self.object_properties_results)

        # give it to the application
        self.request_io(iocb)
Beispiel #4
0
 def read(self,pduSource,obj_id,key,device,read=None):
     #function.log('request',pduSource,obj_id,key,device)
     if isinstance(obj_id,str):
         obj_id=obj_id.split(':')
         obj_id[1]=int(obj_id[1])
     request=ReadPropertyRequest(
         objectIdentifier=tuple(obj_id),
         propertyIdentifier=key,
         destination=RemoteStation(pduSource[0] or 0,bytearray(pduSource[1]))
     ) 
   
     iocb = IOCB(request)            
     iocb.context=device,key
     iocb.add_callback(read or self.readBack)
     self.request_io(iocb)