Inhalte

Dependency Injection: Inter-Stopper-Communication

Table of Contents

Introduction

In order for the stoppers to interact with each other, they need a way to report to their neighbors that they are ready to receive and ready to send.

Receiver Interface

Interface ITransportInterfaceForReceiver
INTERFACE ITransportInterfaceForReceiver EXTENDS __SYSTEM.IQueryInterface
METHOD setIAmReadyToReceive
METHOD setPartIsArrived
METHOD resetIAmReadyToReceive
METHOD resetPartIsArrived

Sender Interface

Interface ITransportInterfaceForSender
INTERFACE ITransportInterfaceForSender EXTENDS __SYSTEM.IQueryInterface
PROPERTY nextIsReadyToRecive :BOOL
GET
PROPERTY partIsArrivedAtNext :BOOL
GET

Implementation

Class SimpleTransportInterface
FUNCTION_BLOCK SimpleTransportInterface IMPLEMENTS
	ITransportInterfaceForReceiver,
	ITransportInterfaceForSender

VAR
	receiverIsReadyToReceive 	:BOOL;
	partIsArrived 				:BOOL;
END_VAR
GET PROPERTY nextIsReadyToRecive :BOOL


nextIsReadyToRecive := THIS^.receiverIsReadyToReceive;
GET PROPERTY partIsArrivedAtNext :BOOL


partIsArrivedAtNext := THIS^.partIsArrived;
METHOD setIAmReadyToReceive
THIS^.receiverIsReadyToReceive := TRUE;
METHOD setPartIsArrived
THIS^.partIsArrived := TRUE;
METHOD resetIAmReadyToReceive
THIS^.receiverIsReadyToReceive := FALSE;
METHOD resetPartIsArrived
THIS^.partIsArrived := FALSE;