Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » eTrice » External Interface(making eTrice work well and play well with others)
External Interface [message #990115] Mon, 10 December 2012 23:03 Go to next message
Tim Born is currently offline Tim Born
Messages: 15
Registered: October 2012
Junior Member
http://www.eclipse.org/etrice/documentation/doc/etrice.html#Scope4

There are several possibilities to receive external events (e.g. TCP/UDP Socket, using OS messaging mechanism), but the easiest way is, to make a port usable from outside the model. To do that a few steps are necessary:
1. specify the messages (within a protocol) which should be sent into the model
2. model an actor with a port (which uses the specified protocol) and connect the port to the receiver
3. the external code should know the port (import of the port class)
4. the external code should provide a registration method, so that the actor is able to allow access to this port
5. the port can be used from the external code

------

I can follow all of that except #4, the "registration method". I am scanning through the generated code to see how an actor binds to a port, and I'm probably looking right at it and not seeing it. Is there an example of this idiom available somewhere?

thanks,
-tim
Re: External Interface [message #990183 is a reply to message #990115] Tue, 11 December 2012 10:18 Go to previous messageGo to next message
Thomas Jung is currently offline Thomas Jung
Messages: 12
Registered: February 2011
Junior Member
Hi Tim,

yes, you will find the registration method within the manual code of the tutorial "PedestrianLight":

/org.eclipse.etrice.tutorials.java/src/org/eclipse/etrice/tutorials/PedLightGUI/PedestrianLightWndNoTcp.java
at line 131:

// This is used for PedLightController tutorial and must be disabled for Blinky
public void setPort(PedControlProtocolConjPort p){
port=p;
}

In the tutorial model, this method will be called on the initial transition of the "GuiAdapter" actor. You can see, that the manual code must know the generated protocol class at this point. Other than in OT you can define your own protocoll class, with as many messages as you want. You must not relay on a predefined protocol class (External) as in OT.

The actor "GuiAdapter" from the tutorial, is able to receive messages from the model and may call methods from the manual code. In the other direction, the manual code is able to send messages via rgistered ports (e.g. if the "request" button is pressed, same file line 119):

if (s.equals("REQUEST")) {
System.out.println("Taste gedr├╝ckt");
// This is used for PedLightController tutorial and must be disabled for Blinky
if (port != null) port.start();
}
}

The "GuiAdapter" actor provides full protection, because sending messages (even from the manual code) takes place via the protected queue.


Could i answere your question?

Best Regards
Thomas

Re: External Interface [message #990329 is a reply to message #990115] Tue, 11 December 2012 21:22 Go to previous message
Tim Born is currently offline Tim Born
Messages: 15
Registered: October 2012
Junior Member
Doh! That's exactly what I was looking for, thanks very much.

Semi-related, but has anyone tried to using Spring Integration with eTrice? It seems Spring follows an inversion of control approach, as does eTrice, so I'm struggling to see how I can pass the port information to my Spring controller. A bit of a chicken-and-egg problem.

Cheers,
-tim
Previous Topic:etunit
Next Topic:Customized Code Generation
Goto Forum:
  


Current Time: Mon Oct 20 13:20:27 GMT 2014

Powered by FUDForum. Page generated in 0.02959 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software