Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[etrice-dev] major changes in Java runtime and generator

Hi developers,

the runtime ports (more general the interface items) have now the capability to connect automatically.
For this purpose they rely on a map from the port instance path to a list of port instance paths which are interpreted as peers.
The code that fills this map is generated in the sub system class. No addresses need to be generated anymore and no addresses need to be passed to actors and ports.
Rather, the ports fetch their own address dynamically. Then they look up their peer port(s) and locate them in the RTObject tree. If the peer isn't present yet the peer later will create the connection when it is created.

The replicated ports now are not only an array of ports but have somewhat more "intelligence" in that they create sub ports as needed when peers connect. So peers don't connect to certain sub ports but rather they are connected to newly created sub ports in the order of their creation.

With this step the generation of the actor structure is much simpler than it used to be. It also opens the possibility to create the actors hierarchically in the constructors which will be done in the following step.

Below find an example of a simple ping pong application
(A possible improvement could be to replace the long path strings with their respective hash values (and move the strings to comments for better readability).)

-Henrik

	@Override
	public void instantiateActors() {
		
		MessageServiceController msgSvcCtrl = RTServices.getInstance().getMsgSvcCtrl();

		// thread mappings
		msgSvcCtrl.addPathToThread("/System_PingPong/subsystem", THREAD__DEFAULT);
		msgSvcCtrl.addPathToThread("/System_PingPong/subsystem/application", THREAD__DEFAULT);
		msgSvcCtrl.addPathToThread("/System_PingPong/subsystem/application/MrPing", THREAD_MRPINGTHREAD);
		msgSvcCtrl.addPathToThread("/System_PingPong/subsystem/application/MrPong1", THREAD_MRPONG1THREAD);
		msgSvcCtrl.addPathToThread("/System_PingPong/subsystem/services", THREAD__DEFAULT);
		
		// port to peer port mappings
		msgSvcCtrl.addPathToPeer("/System_PingPong/subsystem/application/MrPing/PingPongPort", "/System_PingPong/subsystem/application/MrPong1/PingPongPort");
		msgSvcCtrl.addPathToPeer("/System_PingPong/subsystem/application/MrPing/timer", "/System_PingPong/subsystem/services/timer");
		msgSvcCtrl.addPathToPeer("/System_PingPong/subsystem/application/MrPong1/PingPongPort", "/System_PingPong/subsystem/application/MrPing/PingPongPort");
		msgSvcCtrl.addPathToPeer("/System_PingPong/subsystem/services/timer", "/System_PingPong/subsystem/application/MrPing/timer");

		// instantiate all actor instances
		instances = new ActorClassBase[4];
		instances[0] = new PingPongTop(
			this,
			"application"
		); 
		instances[1] = new MrPingActor(
			instances[0],
			"MrPing"
		); 
		instances[2] = new MrPongActor1(
			instances[0],
			"MrPong1"
		); 
		instances[3] = new ATimingService(
			this,
			"services"
		); 
		
		// apply instance attribute configurations
	}


Back to the top