Book a Demo

Author Topic: How to use the COM interface in simulations  (Read 4372 times)

michielper

  • EA User
  • **
  • Posts: 176
  • Karma: +2/-1
    • View Profile
How to use the COM interface in simulations
« on: April 30, 2020, 08:44:08 pm »
I have read that it is possible to create COM objects with Javascript in a simulation (e.g. of a State Machine). And it should even be possible to communicate between an EA simulation and another application or system, using these COM objects. However, the documentation on this is not sufficient to understand how to do this.

So, my question is: How do I create and use a COM object to communicate via a serial port (USB) from a simulation?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: How to use the COM interface in simulations
« Reply #1 on: May 01, 2020, 09:13:22 am »
Follow this (C#) guide for how to make a class visible.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/interop/example-com-class

This page describes how to call it from within a simulation.

https://www.sparxsystems.com/enterprise_architect_user_guide/15.1/model_simulation/dynamic_simulation_with_javasc.html

I can't help with communicating via a serial port, it's a little too far outside my expertise.

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: How to use the COM interface in simulations
« Reply #2 on: May 01, 2020, 10:35:54 am »
You could perhaps look at the SerialPort in System.IO.Ports
Some sample guidance and code in this url
https://docs.microsoft.com/en-us/dotnet/api/system.io.ports.serialport?redirectedfrom=MSDN&view=dotnet-plat-ext-3.1

Note that if I recall correctly you can't access I/O direct in C# like you can in C++ so if you want direct access you need to use C++.

« Last Edit: May 01, 2020, 10:43:05 am by Sunshine »
Happy to help
:)