Create a response frame based on this frame.

        :param data: Data section of response as bytearray. If None, request data section is kept.
        :return: ModbusTCPFrame instance that represents a response
11441
def create_response(self, data=None):
        
        frame = deepcopy(self)
        if data is not None:
            frame.data = data
        frame.length = 2 + len(frame.data)
        return frame
797778
def build_frame(command, payload):
        """"""
        packet_length = 2 + len(payload) + 1
        ret = struct.pack("BB", 0, packet_length)
        ret += struct.pack(">H", command.value)
        ret += payload
        ret += struct.pack("B", calc_crc(ret))
        return ret
1268268
def make_data(self, message):

        

        if not isinstance(message, Message):
            return message
        return message.export(self.transport_content_type)
647241
def make_response(self,
                      data: Any = None,
                      **kwargs: Any) -> Any:
        
        """
        if not self._valid_request:
            logger.error('Request not validated, cannot make response')
            raise self.make_error('Request not validated before, cannot make '
                                  'response')

        if data is None and self.response_factory is None:
            logger.error('Response data omit, but no response factory is used')
            raise self.make_error('Response data could be omitted only when '
                                  'response factory is used')

        response_schema = getattr(self.module, 'response', None)
        if response_schema is not None:
            self._validate(data, response_schema)

        if self.response_factory is not None:
            return self.response_factory(
                *([data] if data is not None else []),
                **kwargs)
        return data
1202143
def create_data_and_metadata_from_data(self, data: numpy.ndarray, intensity_calibration: CalibrationModule.Calibration=None, dimensional_calibrations: typing.List[CalibrationModule.Calibration]=None, metadata: dict=None, timestamp: str=None) -> DataAndMetadata.DataAndMetadata:
        
        return self.create_data_and_metadata(numpy.copy(data), intensity_calibration, dimensional_calibrations, metadata, timestamp)
1022456
def send_response(self, body, set_content_type=True):
        
        settings = get_settings(self.application, force_instance=True)
        handler = settings[self.get_response_content_type()]
        content_type, data_bytes = handler.to_bytes(body)
        if set_content_type:
            self.set_header('Content-Type', content_type)
            self.add_header('Vary', 'Accept')
        self.write(data_bytes)
775204
def create_response_adu(self, meta_data, response_pdu):
        
        first_part_adu = struct.pack('>B', meta_data['unit_id']) + response_pdu
        return first_part_adu + get_crc(first_part_adu)
273189
def data_response(self):
        
        d = self.ImageNumerics.image2array(self.Data.data * self.ImageNumerics.mask)
        return d
642483
def create(**data):
        
        http_client = HttpClient()
        response, _ = http_client.post(routes.url(routes.PAYMENT_RESOURCE), data)
        return resources.Payment(**response)
1165544
def make_response(status, headers, payload, environ):
    
    return Response(body=payload, status=int(status.split()[0]),
                    headers=headers)
691804
private ModbusResponse getAndCheckResponse() throws ModbusException {
        ModbusResponse res = transaction.getResponse();
        if (res == null) {
            throw new ModbusException("No response");
        }
        return res;
    }
1142502
def add_content(self, data):
        # type: (Optional[Union[Dict[str, Any], ET.Element]]) -> None
        
        if data is None:
            return

        if isinstance(data, ET.Element):
            bytes_data = ET.tostring(data, encoding="utf8")
            self.headers['Content-Length'] = str(len(bytes_data))
            self.data = bytes_data
            return

        # By default, assume JSON
        try:
            self.data = json.dumps(data)
            self.headers['Content-Length'] = str(len(self.data))
        except TypeError:
            self.data = data
878315
def as_iframe(self, html_data):
        """"""

        srcdoc = html_data.replace('"', "'")
        return ('<iframe id="{div_id}", srcdoc="{srcdoc}" style="width: {width}; '
                'height: {height};"></iframe>'.format(
                    div_id=self.div_id,
                    srcdoc=srcdoc,
                    width=self.width,
                    height=self.height))
943493
def _build_response(data, renderer=None):
    
    if isinstance(data, Response) or isinstance(data, BaseResponse):
        return data
    if not renderer:
        raise AttributeError(" Renderer is required")
    if isinstance(data, dict) or data is None:
        data = {} if data is None else data
        for _ in __view_parsers:
            data = _(data)
        return renderer(data), 200
    elif isinstance(data, tuple):
        data, status, headers = _normalize_response_tuple(data)
        for _ in __view_parsers:
            data = _(data)
        return renderer(data or {}), status, headers
    return data
390259
def _pipe(content):
    
    response = _data_frame(content).to_csv(index=False,sep='|')
    return response
442457
def nulldata_script(data: bytes) -> NulldataScript:
    ''''''

    stack = StackData.from_bytes(data)
    return NulldataScript(stack)
980876
def make_response(status, headers, payload, environ):
    
    headers_dict = {}
    content_type = None
    for h in headers:
        if h[0].lower() == 'content-type':
            content_type = h[1]
        else:
            headers_dict[h[0]] = h[1]
    return HTTPResponse(body_bytes=payload, content_type=content_type,
                        status=int(status.split()[0]), headers=headers_dict)