Example #1
0
    def retrieve_data(self):
        data_chunk = GeneralDataChunk(self.name,
                                      self.type,
                                      self.config.parameters,
                                      hidden=self.config.hidden)

        if self.config.is_valid():
            value = self.poll_node()
            data_type = 'diverse'
            if value is None:
                status = OPCUAReadStatus(99)
                data_chunk.add_status(status)
            else:
                status = OPCUAReadStatus(0)
                data_chunk.add_status(status)
                data_chunk.add_data(
                    DataChunkValue('opcua_value', value, data_type))
        else:
            status = OPCUAReadStatus(100)
            data_chunk.add_status(status)
            print('Step %s : No execution due to invalid configuration' %
                  self.name)

        for metadata_variable, metadata_value in self.config.metadata.items():
            data_chunk.add_metadata(
                MetadataChunkData(metadata_variable, metadata_value))
        return [data_chunk]
 def retrieve_data(self):
     data_chunk = GeneralDataChunk(self.name,
                                   self.type,
                                   self.config.parameters,
                                   hidden=self.config.hidden)
     data_type = 'diverse'
     data_chunk.add_data(
         DataChunkValue('static_value', self.config.parameters['value'],
                        data_type))
     for metadata_variable, metadata_value in self.config.metadata.items():
         data_chunk.add_metadata(
             MetadataChunkData(metadata_variable, metadata_value))
     return [data_chunk]
Example #3
0
    def retrieve_data(self):
        data_chunk = GeneralDataChunk(self.name,
                                      self.type,
                                      self.config.parameters,
                                      hidden=self.config.hidden)

        if not self.config.is_valid():
            status = CapturingStatus(100)
            data_chunk.add_status(status)
            print('Step %s : No execution due to invalid configuration' %
                  self.name)
            return [data_chunk]

        if not self.camera_status.initialised:
            self.connect()

        timestamp = MetadataChunkData('timestamp', get_timestamp())
        data_chunk.add_metadata(timestamp)

        if not self.camera_status.initialised:
            status = CapturingStatus(1)
            data_chunk.add_status(status)
            logging.warning(status.get_message())
            self.camera_status.initialised = False
            return [data_chunk]

        if self.camera_status.capturing:
            status = CapturingStatus(2)
            data_chunk.add_status(status)
            logging.warning(status.get_message())
            self.camera_status.initialised = False
            return [data_chunk]

        self.camera_status.capturing = True
        captured, frame_np = self.camera_object.read()
        self.camera_status.capturing = False

        if captured:
            data_chunk.add_data(DataChunkImage('frame', frame_np,
                                               'base64_png'))

            status = CapturingStatus(0)
            data_chunk.add_status(status)
            logging.warning(status.get_message())

            data_chunk.add_metadata(MetadataChunkData('colormap', 'BGR'))
            data_chunk.add_metadata(MetadataChunkData('shape', frame_np.shape))
            for metadata_variable, metadata_value in self.config.metadata.items(
            ):
                data_chunk.add_metadata(
                    MetadataChunkData(metadata_variable, metadata_value))
            return [data_chunk]
        else:
            status = CapturingStatus(99)
            data_chunk.add_status(status)
            logging.warning(status.get_message())
            self.camera_status.initialised = False
            return [data_chunk]
    def retrieve_data(self):
        data_chunk = GeneralDataChunk(self.name,
                                      self.type,
                                      self.config.parameters,
                                      hidden=self.config.hidden)

        if not self.config.is_valid():
            status = CapturingStatus(100)
            data_chunk.add_status(status)
            print('Step %s : No execution due to invalid configuration' %
                  self.name)
            return [data_chunk]

        if not self.camera_status.initialised:
            self.connect()

        timestamp = MetadataChunkData('timestamp', get_timestamp())
        data_chunk.add_metadata(timestamp)

        if not self.camera_status.initialised:
            status = CapturingStatus(1)
            data_chunk.add_status(status)
            logging.warning(status.get_message())
            self.camera_status.initialised = False
            return [data_chunk]

        if self.camera_status.capturing:
            status = CapturingStatus(2)
            data_chunk.add_status(status)
            logging.warning(status.get_message())
            self.camera_status.initialised = False
            return [data_chunk]

        self.camera_status.capturing = True
        if DEBUG:
            print('Connect')
            self.camera_status.initialised = True
            frame_raw = True
            frame_np = np.random.rand(640, 480, 3)
        else:
            frame_raw = self.camera_object.GetImage(GET_IMAGE_TIMEOUT)
            frame_shape = frame_raw.shape
            frame_colormap = 'BGR'
            frame_np = frame_raw.GetNPArray()

        self.camera_status.capturing = False

        if frame_raw is not None:
            data_chunk.add_data(DataChunkImage('frame', frame_np,
                                               'base64_png'))

            status = CapturingStatus(0)
            data_chunk.add_status(status)
            logging.warning(status.get_message())

            data_chunk.add_metadata(MetadataChunkData('colormap', 'BGR'))
            data_chunk.add_metadata(MetadataChunkData('shape', frame_np.shape))
            for metadata_variable, metadata_value in self.config.metadata.items(
            ):
                data_chunk.add_metadata(
                    MetadataChunkData(metadata_variable, metadata_value))
            return [data_chunk]
        else:
            status = CapturingStatus(99)
            data_chunk.add_status(status)
            logging.warning(status.get_message())
            self.camera_status.initialised = False
            return [data_chunk]