Class IOPort

    • Constructor Detail

      • IOPort

        public IOPort​(IOPort component)
        Construct the code generator adapter for the given IOPort.
        Parameters:
        component - The IOPort.
    • Method Detail

      • generateGetCode

        public java.lang.String generateGetCode​(java.lang.String channel,
                                                java.lang.String offset)
                                         throws IllegalActionException
        Generate code for replacing the get() macro.
        Specified by:
        generateGetCode in interface PortCodeGenerator
        Overrides:
        generateGetCode in class IOPort
        Parameters:
        channel - The channel for which to generate the get code.
        offset - The offset in the array representation of the port.
        Returns:
        The code that gets data from the specified channel.
        Throws:
        IllegalActionException - If the receiver adapter is not found or it encounters an error while generating the get code.
      • generateGetCodeWithoutType

        public java.lang.String generateGetCodeWithoutType​(java.lang.String channel,
                                                           java.lang.String offset)
                                                    throws IllegalActionException
        Generate the code to get a token from a port, but don't include the type, for example payload.Int.
        Specified by:
        generateGetCodeWithoutType in interface PortCodeGenerator
        Overrides:
        generateGetCodeWithoutType in class IOPort
        Parameters:
        channel - The channel for which the get code is generated.
        offset - The offset in the array representation of the port.
        Returns:
        The code that gets data from the channel.
        Throws:
        IllegalActionException - If the director adapter class cannot be found.
      • generateGetAndFree

        public java.lang.String generateGetAndFree​(java.lang.String channel,
                                                   java.lang.String offset)
                                            throws IllegalActionException
        Generate the code to get a token from a port and then free it.
        Specified by:
        generateGetAndFree in interface PortCodeGenerator
        Overrides:
        generateGetAndFree in class IOPort
        Parameters:
        channel - The channel for which the get code is generated.
        offset - The offset in the array representation of the port.
        Returns:
        The code that gets data from the channel.
        Throws:
        IllegalActionException - If the director adapter class cannot be found.
      • generatePortDeclaration

        public java.lang.String generatePortDeclaration()
                                                 throws IllegalActionException
        Generate the code of the declaration of an IOPort (or a subclass) Initialize all its dependencies (container, widths ...) In this base class we deal with all the known kinds of ports, however ideally we should create an adapter for each type of port. There are essentially four types of ports : - input/output - from a composite/atomic actor The creation of the receivers relies on this distinction.
        Returns:
        the port declaration to include in the actor constructor
        Throws:
        IllegalActionException - if the getWidth or getWidthInside throws an exception
      • generateHasTokenCode

        public java.lang.String generateHasTokenCode​(java.lang.String channel,
                                                     java.lang.String offset)
                                              throws IllegalActionException
        Generate code to check if the receiver has a token.
        Specified by:
        generateHasTokenCode in interface PortCodeGenerator
        Overrides:
        generateHasTokenCode in class IOPort
        Parameters:
        channel - The channel for which to generate the hasToken code.
        offset - The offset in the array representation of the port.
        Returns:
        The code that checks whether there is data in the specified channel.
        Throws:
        IllegalActionException - If the receiver adapter is not found or it encounters an error while generating the hasToken code.
      • generatePutCode

        public java.lang.String generatePutCode​(java.lang.String channel,
                                                java.lang.String offset,
                                                java.lang.String dataToken)
                                         throws IllegalActionException
        Generate code for replacing the send() macro.
        Specified by:
        generatePutCode in interface PortCodeGenerator
        Overrides:
        generatePutCode in class IOPort
        Parameters:
        channel - The channel for which to generate the send code.
        offset - The offset in the array representation of the port.
        dataToken - The token to be sent.
        Returns:
        The code that sends data to the specified channel.
        Throws:
        IllegalActionException - If the receiver adapter is not found or it encounters an error while generating the send code.
      • generatePutLocalInsideCode

        public java.lang.String generatePutLocalInsideCode​(java.lang.String channel,
                                                           java.lang.String offset,
                                                           java.lang.String dataToken)
                                                    throws IllegalActionException
        Generate code for replacing the sendLocalInside() macro.
        Specified by:
        generatePutLocalInsideCode in interface PortCodeGenerator
        Overrides:
        generatePutLocalInsideCode in class IOPort
        Parameters:
        channel - The channel for which to generate the send code.
        offset - The offset in the array representation of the port.
        dataToken - The token to be sent.
        Returns:
        The code that sends data to the specified channel.
        Throws:
        IllegalActionException - If the receiver adapter is not found or it encounters an error while generating the send code.