External Interface [message #990115] |
Mon, 10 December 2012 18:03  |
Eclipse User |
|
|
|
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 05:18   |
Eclipse User |
|
|
|
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 16:22  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 1.02515 seconds