Ports and other Variables

Ports must be explicitly defined while specifying a component interface. Ports are assigned component interface methods by simple assignment operations. PortType PortName = ReturnType MethodName[Parameters]

The port types specify how a component interface method may be composed with other component interface methods in classes that implement agent and component interfaces. Classes which implement agents or components that use composition styles may only use Port names to refer to methods (declared in agent and component definitions) in use.

Ports are primarily of five types

·	Source Source specifies a component interface method that produces output without being provided with any inputs. Syntax : Source SourceName = returnType methodName

Example: Source Bill = int ComputeReading ;

In order to invoke the method ComputeReading, we can use the name of the port i. e. Bill

·	Handler Handler specifies a component interface method that procures input and applies logic on inputs and produces output Syntax : Handler HandlerName = returnType methodName (parameter list)

Example: Handler ElectricityMeter = int ComputeReading (char CustomerID); In order to invoke the method ComputeReading, we can use the name of the port i. e. ElectricityMeter (char CustomerID)

·	Sink Sink specifies a component interface method that procures input and produces no output. Syntax : Sink SinkName = void methodName (parameter list)

Example: Sink ThrowTempAlarm = void Notify(int TempDifference) To invoke the method Notify : ThrowTempAlarm(int TempDifference)

·	Event Event specifies a component interface method that takes in input parameters, and calls back a handler or sink or the current component when a specified event occurs Syntax : Event SinkName = returnType methodName (parameter list) Example: An example of usage of Event. The method CheckTheRaisedTemp(Vector slaves) is called and if the critical temperature is reached in any of slaves specified in the vector – slaves, event is triggered. This method returns another vector holding the slave details which have reached their critical temperature.

Event TemperatureCheck = Vector CheckTheRaisedTemp(Vector slaves);

·	Rules A rule is a port that returns a Boolean and may or may not take in any input parameters. Syntax : Rule RuleName = Boolean methodName(parameterlist); Rule RuleName = Boolean methodName;

Example: If the critical temperature is reached returns true else false Rule CriticalTempReached = Boolean CheckIfCriticalTempReached(String slave);