Author Topic: How to get the Trigger-Data of a Timer event ? (C# script)  (Read 9421 times)

bd

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
How to get the Trigger-Data of a Timer event ? (C# script)
« on: November 06, 2018, 09:14:41 pm »
Hello everyone,

I am trying to read out (with a C#-script), all the data of my Softwarearchitecture and export the data into an AUTOSAR XML-File.
One of the SW-Components has an internal behavior, which contains runnables. Furthermore there is a timer-element, which is acting as a trigger.

The timer element has properties like "General" and "Trigger". The "Trigger"-property contains "Name", "Type" and "Specification". My problem is now to get the values of these attributes.
I tried for example "timerelement.Properties.item(1).Name;" etc. but I didn't get a useful result.  :(   

Are you so Kind and show me an example how to get the values of the Trigger ?

Thank you,
bd
 

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #1 on: November 06, 2018, 10:30:42 pm »
How (in the UI) do you create the timer element?

q.

bd

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #2 on: November 06, 2018, 10:45:21 pm »
Hi,

Toolbox -> More Tools -> LieberLieber AUTOSAR Engineer -> AUTOSAR Behavior -> AUTOSAR Event (Accept Timer)


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #3 on: November 06, 2018, 11:08:16 pm »
Funny these questions come in lots now (see this thread). You t_xref looks like this:
Code: [Select]
@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=AcceptEventTimer@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;
q

bd

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #4 on: November 07, 2018, 02:03:24 am »
Hi,

thank you for the answer.
I used your description in the SQL-Query like this.

string name = repo.SQLQuery("SELECT Name FROM t_xref WHERE Description=\"@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=AcceptEventTimer@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;\"");
...

I saved the result into an XML-File.
I got this result
...
-<Data>

-<Row>

<Name>CustomProperties</Name>

</Row>

</Data>
...

But the Name of the Timer-element is "trg_50ms".

I am a bit confused. What is my mistake ?

Best regards,
bd

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #5 on: November 07, 2018, 03:35:35 am »
Don't search for the description string. You need to match t_xref.Client to match the action's element GUID.

q.

bd

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #6 on: November 08, 2018, 01:18:36 am »
Ok I matched the element's GUID. I used the GUID in "repo.GetElementByGuid(GUID)" but I get the same results.
I only Need the Trigger's Type,Name and Specification from the action's element.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #7 on: November 08, 2018, 01:34:49 am »
What shall I say? My crystal ball is unfortunately broken.

q.

bd

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #8 on: November 08, 2018, 02:03:15 am »
thank you for your help btw. :) I am trying my best to get these data :/

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #9 on: November 08, 2018, 02:59:19 am »
If you don't come up with details it's impossible to give any help. So if you are interested in solving your issue please show some details. What does not work? What did you do? Just "it does not work" will not provide any answer since that's no question but a statement.

q.

bd

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #10 on: November 12, 2018, 10:30:32 pm »
Ok, I will try to explain it again.

My target is: Developing an own Add-in, with C# as language, for Enterprise Architect. The Add-in should be an AUTOSAR XML-Exporter.

What I did so far: I use the Example AUTOSAR Model from LieberLieber, so I can test my own ARXML-Exporter. Until now, my ARXML-Exporter exports the data of existing SW-Components and the associated Ports.

Where am I stuck: One of the SW-Component contains an Internal-Behavior-Element. In this element, there are Runnables (Btw. I am able to get the data of the Runnables). In addition there is a Timer-Event-Element. When I double-click on the element, I can see the properties. In the properties, there is an item named "Triggers". When I click on Triggers, I can see the Features like "Name", "Type", "Specification". Now I want to read out this Features with my script and export them also to the ARXML-File.
I thought I could read out this features with, for example, "eventElement.properties.item(1).Name","eventElement.properties.item(1).Type" or "eventElement.properties.item(1).Specification".
I know it is not elegant, but I didn't find another solution.

I am asking for a way to get the values of These features. I hope you understand now my Problem

Best regards,
bd
             

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13387
  • Karma: +564/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #11 on: November 12, 2018, 10:50:07 pm »
bd,

You are probably the only (active) user here that uses AUTOSAR

So unless you show us a part of the model and the code I don't think we will be able to help.
If we can see what you mean by "trigger" we could maybe point you in the right direction.

You could also try to contact LieberLieber directly. They will probably be glad to help, and since thy wrote the AUTOSAR add-in they will definitely understand what you are talking about.

Geert

bd

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #12 on: November 12, 2018, 11:36:30 pm »
Hi Geert,
I mean these ones.
Thank you.

bd

« Last Edit: November 12, 2018, 11:39:34 pm by bd »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #13 on: November 12, 2018, 11:56:45 pm »
I told you what to do to get these out. But you did not show the code you used. Nor the error you encountered.

q.

bd

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: How to get the Trigger-Data of a Timer event ? (C# script)
« Reply #14 on: November 13, 2018, 12:07:34 am »
Ok I tried this way.
Code: [Select]
EA.Element sourceElement = repo.GetElementByID(id);
                   
                    if (sourceElement.MetaType == "AcceptEventTimerAction")
                    {
                       
                        XmlDocument xml = new XmlDocument();
                        string query = repo.SQLQuery("SELECT * FROM t_xref WHERE Description=\"@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=AcceptEventTimer@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;\"");
                        //System.IO.File.WriteAllText(@"C:\text.xml", query);
                        XmlReader xmlreader = XmlReader.Create(new StringReader(query));
                        using (xmlreader)
                        {
                            while (xmlreader.Read())
                            {
                                if (xmlreader.Name == "Client")                                {

                                    // I am a bit confused here
                                 
                                    EA.Element swComponent = repo.GetElementByGuid(xmlreader.ReadInnerXml());
                                 
                                }
                            }
                        }
                       


                    }