erpc_interface/erpc_PLCObject/client.py
author Edouard Tisserant <edouard@beremiz.fr>
Mon, 28 Oct 2024 16:02:47 +0100
changeset 4032 1ffff67678ad
parent 3946 8815b44be31e
child 4035 c317fc64035e
permissions -rw-r--r--
Add ExtendedCall to PLCObject as a replacement of RemoteExec and reflect it in eRPC interface.

ExtendedCall is a generic remote procedure call that runtime code can register to and that IDE extensions can call.
For example a fieldbus extension can use ExtendedCall to browse the fieldbus devices connected to the runtime.
#
# Generated by erpcgen 1.12.0 on Mon Oct 28 11:30:03 2024.
#
# AUTOGENERATED - DO NOT EDIT
#

import erpc
from . import common, interface

# Client for BeremizPLCObjectService
class BeremizPLCObjectServiceClient(interface.IBeremizPLCObjectService):
    def __init__(self, manager):
        super(BeremizPLCObjectServiceClient, self).__init__()
        self._clientManager = manager

    def AppendChunkToBlob(self, data, blobID, newBlobID):
        assert type(newBlobID) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.APPENDCHUNKTOBLOB_ID,
                sequence=request.sequence))
        if data is None:
            raise ValueError("data is None")
        codec.write_binary(data)
        if blobID is None:
            raise ValueError("blobID is None")
        codec.write_binary(blobID)

        # Send request and process reply.
        self._clientManager.perform_request(request)
        newBlobID.value = codec.read_binary()
        _result = codec.read_uint32()
        return _result

    def GetLogMessage(self, level, msgID, message):
        assert type(message) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.GETLOGMESSAGE_ID,
                sequence=request.sequence))
        if level is None:
            raise ValueError("level is None")
        codec.write_uint8(level)
        if msgID is None:
            raise ValueError("msgID is None")
        codec.write_uint32(msgID)

        # Send request and process reply.
        self._clientManager.perform_request(request)
        message.value = common.log_message()._read(codec)
        _result = codec.read_uint32()
        return _result

    def GetPLCID(self, plcID):
        assert type(plcID) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.GETPLCID_ID,
                sequence=request.sequence))

        # Send request and process reply.
        self._clientManager.perform_request(request)
        plcID.value = common.PSKID()._read(codec)
        _result = codec.read_uint32()
        return _result

    def GetPLCstatus(self, status):
        assert type(status) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.GETPLCSTATUS_ID,
                sequence=request.sequence))

        # Send request and process reply.
        self._clientManager.perform_request(request)
        status.value = common.PLCstatus()._read(codec)
        _result = codec.read_uint32()
        return _result

    def GetTraceVariables(self, debugToken, traces):
        assert type(traces) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.GETTRACEVARIABLES_ID,
                sequence=request.sequence))
        if debugToken is None:
            raise ValueError("debugToken is None")
        codec.write_uint32(debugToken)

        # Send request and process reply.
        self._clientManager.perform_request(request)
        traces.value = common.TraceVariables()._read(codec)
        _result = codec.read_uint32()
        return _result

    def MatchMD5(self, MD5, match):
        assert type(match) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.MATCHMD5_ID,
                sequence=request.sequence))
        if MD5 is None:
            raise ValueError("MD5 is None")
        codec.write_string(MD5)

        # Send request and process reply.
        self._clientManager.perform_request(request)
        match.value = codec.read_bool()
        _result = codec.read_uint32()
        return _result

    def NewPLC(self, md5sum, plcObjectBlobID, extrafiles, success):
        assert type(success) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.NEWPLC_ID,
                sequence=request.sequence))
        if md5sum is None:
            raise ValueError("md5sum is None")
        codec.write_string(md5sum)
        if plcObjectBlobID is None:
            raise ValueError("plcObjectBlobID is None")
        codec.write_binary(plcObjectBlobID)
        if extrafiles is None:
            raise ValueError("extrafiles is None")
        codec.start_write_list(len(extrafiles))
        for _i0 in extrafiles:
            _i0._write(codec)


        # Send request and process reply.
        self._clientManager.perform_request(request)
        success.value = codec.read_bool()
        _result = codec.read_uint32()
        return _result

    def PurgeBlobs(self):
        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.PURGEBLOBS_ID,
                sequence=request.sequence))

        # Send request and process reply.
        self._clientManager.perform_request(request)
        _result = codec.read_uint32()
        return _result

    def RepairPLC(self):
        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.REPAIRPLC_ID,
                sequence=request.sequence))

        # Send request and process reply.
        self._clientManager.perform_request(request)
        _result = codec.read_uint32()
        return _result

    def ResetLogCount(self):
        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.RESETLOGCOUNT_ID,
                sequence=request.sequence))

        # Send request and process reply.
        self._clientManager.perform_request(request)
        _result = codec.read_uint32()
        return _result

    def SeedBlob(self, seed, blobID):
        assert type(blobID) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.SEEDBLOB_ID,
                sequence=request.sequence))
        if seed is None:
            raise ValueError("seed is None")
        codec.write_binary(seed)

        # Send request and process reply.
        self._clientManager.perform_request(request)
        blobID.value = codec.read_binary()
        _result = codec.read_uint32()
        return _result

    def SetTraceVariablesList(self, orders, debugtoken):
        assert type(debugtoken) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.SETTRACEVARIABLESLIST_ID,
                sequence=request.sequence))
        if orders is None:
            raise ValueError("orders is None")
        codec.start_write_list(len(orders))
        for _i0 in orders:
            _i0._write(codec)


        # Send request and process reply.
        self._clientManager.perform_request(request)
        debugtoken.value = codec.read_int32()
        _result = codec.read_uint32()
        return _result

    def StartPLC(self):
        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.STARTPLC_ID,
                sequence=request.sequence))

        # Send request and process reply.
        self._clientManager.perform_request(request)
        _result = codec.read_uint32()
        return _result

    def StopPLC(self, success):
        assert type(success) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.STOPPLC_ID,
                sequence=request.sequence))

        # Send request and process reply.
        self._clientManager.perform_request(request)
        success.value = codec.read_bool()
        _result = codec.read_uint32()
        return _result

    def ExtendedCall(self, method, argument, answer):
        assert type(answer) is erpc.Reference, "out parameter must be a Reference object"

        # Build remote function invocation message.
        request = self._clientManager.create_request()
        codec = request.codec
        codec.start_write_message(erpc.codec.MessageInfo(
                type=erpc.codec.MessageType.kInvocationMessage,
                service=self.SERVICE_ID,
                request=self.EXTENDEDCALL_ID,
                sequence=request.sequence))
        if method is None:
            raise ValueError("method is None")
        codec.write_string(method)
        if argument is None:
            raise ValueError("argument is None")
        codec.write_binary(argument)

        # Send request and process reply.
        self._clientManager.perform_request(request)
        answer.value = codec.read_binary()
        _result = codec.read_uint32()
        return _result