Book a Demo

Author Topic: Activity Diagram Simulation - Interface to external programs?  (Read 8919 times)

Thorben

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Hello forum,

I am pretty new to EA. I am working on SysML models. In this context I developed some activity diagrams and started working with the simulation feature.
Now my question: is it possible to control an external program (e.g. Word) via a COM interface? E.g. I'd like to do the following things:

First action in diagram: open Word
Second action: write a line
Third action: store the current document
Fourth action: close word

I would like to start the simulation of these four concatenated actions (control flows) and see the mentioned effects (open Word, write line ect.) when
the appropriate action is entered and thus highlighted.

I could not find any hint in the help so far that COM is supported.

Thanks for your help.
Thorben

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1001
  • Karma: +59/-18
    • View Profile
Best regards,

Peter Heintz

Dermot

  • EA Administrator
  • EA User
  • *****
  • Posts: 591
  • Karma: +7/-0
    • View Profile

Thorben

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Activity Diagram Simulation - Interface to external programs?
« Reply #3 on: August 05, 2016, 06:24:50 pm »
Thanks for that hint! Indeed I could get my simulation running. In my example I can open the windows media player now with a certain video when entering a certain action, e.g. "action a".
I just entered this code in the "effect" field of the action:

var Player = new COMObject("WMPlayer.OCX");
Player.openPlayer("file:///D:/Videos/video.mp4);


So far, so good. However, as my code will increase with time i want to put it into a function "StartPlayer()" in a script called "InvokeWMPlayer" under a script group "MyScripts". I then
want to start the script when entering the action. So I replaced the code above by the string "MyScripts.InvokeWMPlayer". But it does not have any effect, the media player does
not start now. Why is that? Is invoking a script in the "effect" of a action not supported? Where else should I put my code?

Thanks all,
Tino

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Activity Diagram Simulation - Interface to external programs?
« Reply #4 on: August 05, 2016, 07:10:20 pm »
See the magic "!INC" keyword to include scripts into other scripts.

Geert

Thorben

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Activity Diagram Simulation - Interface to external programs?
« Reply #5 on: August 05, 2016, 07:31:14 pm »
Thanks, Geert.

I tried it out and put the following line in the "Effect" field:

!INC MyScripts.InvokeWMPlayer

The script "InvokeWMPlayer" looks like this:

function StartPlayer()
{
   var Player = new COMObject("WMPlayer.OCX");
   Player.openPlayer("file:///D:/Videos/video.mp4");
}

StartPlayer();


When I run this script from the script editor, everything is fine. Also, when I put the code from StartPlayer() into the "Effect" field of my action, it works, too
(Windows Media Player starts). But calling the script in "Effects" as described above does not have any effect  :(




Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Activity Diagram Simulation - Interface to external programs?
« Reply #6 on: August 05, 2016, 09:33:18 pm »
Ah, they might have forgotten to implement the "!INC" in the effects script engine.
You better check with support.

Geert

Dermot

  • EA Administrator
  • EA User
  • *****
  • Posts: 591
  • Karma: +7/-0
    • View Profile
Re: Activity Diagram Simulation - Interface to external programs?
« Reply #7 on: August 08, 2016, 03:26:04 pm »
With the simulation it was not intended to call external EA Scripts. A better solution for this is to call an Operation in the parent Class and place any code in Operations Behavior tab - F9 | Operations | Behavior.