Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: bd on November 06, 2018, 09:14:41 pm

Title: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd 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
 
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: qwerty on November 06, 2018, 10:30:42 pm
How (in the UI) do you create the timer element?

q.
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd on November 06, 2018, 10:45:21 pm
Hi,

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

Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: qwerty on November 06, 2018, 11:08:16 pm
Funny these questions come in lots now (see this thread (https://www.sparxsystems.com/forums/smf/index.php/topic,41155.0.html)). You t_xref looks like this:
Code: [Select]
@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=AcceptEventTimer@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;
q
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd 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
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: qwerty 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.
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd 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.
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: qwerty on November 08, 2018, 01:34:49 am
What shall I say? My crystal ball is unfortunately broken.

q.
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd on November 08, 2018, 02:03:15 am
thank you for your help btw. :) I am trying my best to get these data :/
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: qwerty 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.
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd 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
             
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: Geert Bellekens 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
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd on November 12, 2018, 11:36:30 pm
Hi Geert,
I mean these ones.
Thank you.

bd

(https://imgur.com/tsqFm64.png)
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: qwerty 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.
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd 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());
                                 
                                }
                            }
                        }
                       


                    }
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: Geert Bellekens on November 13, 2018, 12:20:56 am
You have to look into the correct t_xref records.

They are related to your Action based on the t_xref.Client = t_object.ea_guid

In your case there will be two t_xref records. One that indicates the type of Action, and the other that specifies the GUID of the trigger element.

So based upon that trigger element you will again need to query t_xref. One record specifies the kind of trigger (Time) and the other specifies the specification (0.5s)
On my test model they look like this:

Code: [Select]
XrefID Name Type Visibility Namespace Requirement Constraint Behavior Partition Description Client Supplier Link
{6FD0BC82-87EA-43dd-83B1-02EF301AB86B} MOFProps element property Public NULL NULL NULL event 0 RefGUID={89807AC7-D452-48eb-85EC-844975D3497B};RefName=0.5s; {F0E65A7D-D49C-47e1-B198-50B0F2D6C091} <none> NULL
{829EF67E-BDB8-444b-95C4-581AD0CEA054} CustomProperties element property Public NULL NULL NULL NULL 0 @PROP=@NAME=kind@ENDNAME;@TYPE=TriggerKind@ENDTYPE;@VALU=Time@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP; {F0E65A7D-D49C-47e1-B198-50B0F2D6C091} <none> NULL

I'm not sure how much of this info can be read using the API objects purely.

Geert
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: qwerty on November 13, 2018, 12:39:04 am
The API doesn't offer that (at least until 13.5; did not catch up with V14 but would not expect it anyway) so that way my advice to go to t_xref.

q.
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd on November 13, 2018, 09:25:01 pm
Ok thank you. I will try it out :)
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: wahidovic123 on November 14, 2018, 08:06:16 am
You have to look into the correct t_xref records.

They are related to your Action based on the t_xref.Client = t_object.ea_guid

In your case there will be two t_xref records. One that indicates the type of Action, and the other that specifies the GUID of the trigger element.

So based upon that trigger element you will again need to query t_xref. One record specifies the kind of trigger (Time) and the other specifies the specification (0.5s)
On my test model they look like this:

Code: [Select]
XrefID Name Type Visibility Namespace Requirement Constraint Behavior Partition Description Client Supplier Link
{6FD0BC82-87EA-43dd-83B1-02EF301AB86B} MOFProps element property Public NULL NULL NULL event 0 RefGUID={89807AC7-D452-48eb-85EC-844975D3497B};RefName=0.5s; {F0E65A7D-D49C-47e1-B198-50B0F2D6C091} <none> NULL
{829EF67E-BDB8-444b-95C4-581AD0CEA054} CustomProperties element property Public NULL NULL NULL NULL 0 @PROP=@NAME=kind@ENDNAME;@TYPE=TriggerKind@ENDTYPE;@VALU=Time@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP; {F0E65A7D-D49C-47e1-B198-50B0F2D6C091} <none> NULL

I'm not sure how much of this info can be read using the API objects purely

Geert
Subway Surfers (https://subwaysurfers.vip/) Psiphon (https://psiphon.vip/) Hill Climb Racing (https://hillclimbracing.vip/)
ok thank you for your reply
_________________
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd on December 04, 2018, 02:11:09 am
How can I get the values "0.5" & "Time" from the description. With parsing ?
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: qwerty on December 04, 2018, 03:01:03 am
Uhm, what?

q.
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: Geert Bellekens on December 04, 2018, 03:30:56 am
How can I get the values "0.5" & "Time" from the description. With parsing ?
Yes, you'll have to parse the contents of the xref records to get these values out.
(if indeed there is no way to get to it from the API objects. Since I haven't tested it myself I'm not 100% sure these values aren't available somewhere from the API)

Geert
Title: Re: How to get the Trigger-Data of a Timer event ? (C# script)
Post by: bd on December 04, 2018, 09:20:39 pm
Ok, thank you.

bd