rivella
rivella

Reputation: 1

How can Eclipse Sirius interact with other systems?

What I want:

I have a sensor with a variable isWorking(boolean) on a real system. Now I want a viewer that shows me if the sensor is working or not. For example sensor node is green or red.

What I have:

I have a softSPS program on CoDeSys with the variable isWorking. With JEasyOPC I can read/overwrite this variable and print it into Eclipse console. I also created a Sirius model for my system in an eclipse runtime as in all Sirius tutorials I found are shown. I saw that I can change the color of node with a Conditional Style.

So I have a node Sensor and a variable isWorking but I don't know how to connect them.

I found something about "external Java action" in Sirius documentation. There's also in Sirius Forum an example (https://www.eclipse.org/forums/index.php/t/764175/) but I don´t know if it´s work for my problem and how I can use JEasyOPC with them.

Another way I found is JFace Data Binding, but I only found a tutorial that works with an EMF Model and not with a Sirius Diagram (http://www.vogella.com/tutorials/EclipseDataBindingEMF/article.html). I don't want to change my meta model.

Upvotes: 0

Views: 1344

Answers (2)

Adrian Mos
Adrian Mos

Reputation: 11

The best way to do this is to use the Sirius Java Services mechanism. You need to first add the extension class on your Viewpoint in your Viewpoint Specification Project. You right click on the viewpoint and choose New Extension/Java Extension. There you put in the class name that contains a method that you will want to call in your Sirius element. To call your method however you should use either the service: element or the Acceleo expression like this [methodName()].

You need to make sure that your class on which you call the method is available for Sirius to use. This means you need to run the 3-Eclipse environment like this:

  • Eclipse environment no. 1 containing your model and class that contains your service method
  • Eclipse instance no. 2 launched from no. 1 which contains your Sirius Viewpoint Specification Project
  • Eclipse instance no. 3 launched form no. 2 which will contain your diagrams instantiated for your model instance.

You can have a look at this for more information (better than Java Actions): https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#service_methods

Also please keep in mind that if your service method needs to behave differently depending on the Sirius node you are displaying the result on, you will need to make sure you pass the right context. I can help with that as well, just let me know in a comment. However if your service method only checks for one thing and then returns a result (i.e. you only have one sensor that you are about in your diagram) then you don't need to worry about this.

Upvotes: 1

user4070663
user4070663

Reputation: 11

I know Eclipse and Sirius. If I understand you correctly you have a variable available with which you want display a node with different color according to variable value. To do that you must busy waiting [1] which is not the best practise, a best practise would be to be notified with a listener of variable value change.

Then following your chosen strategy, busy waiting (with a Thread which read in loop your variable) or listener, you need to update your EMF model to have Sirius reacts to you EMF model change and have it change the node's color.

Best Regards.

[1] http://en.wikipedia.org/wiki/Busy_waiting

Upvotes: 1

Related Questions