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. This delegates to the receiver adapter for the specified channel and asks it to generate the get code.
        Specified by:
        generateGetCode in interface PortCodeGenerator
        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
        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 code for replacing the getAndFree() macro. This delegates to the receiver adapter for the specified channel and asks it to generate the get code.
        Specified by:
        generateGetAndFree in interface PortCodeGenerator
        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.
      • 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. This delegates to the receiver adapter for the specified channel and asks it to generate the hasToken code.
        Specified by:
        generateHasTokenCode in interface PortCodeGenerator
        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. This delegates to the receiver adapter for the specified channel and asks it to generate the send code.
        Specified by:
        generatePutCode in interface PortCodeGenerator
        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.
      • generateInitializeCode

        public java.lang.String generateInitializeCode()
                                                throws IllegalActionException
        Generate the initialize code for this IOPort. The initialize code is generated by appending the initialize code for each receiver contained by this IOPort.
        Overrides:
        generateInitializeCode in class NamedProgramCodeGeneratorAdapter
        Returns:
        The generated initialize code.
        Throws:
        IllegalActionException - If an error occurs when getting the receiver adapters or generating their initialize 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
        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.