Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started 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
-
How (in the UI) do you create the timer element?
q.
-
Hi,
Toolbox -> More Tools -> LieberLieber AUTOSAR Engineer -> AUTOSAR Behavior -> AUTOSAR Event (Accept Timer)
-
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:
@PROP=@NAME=kind@ENDNAME;@TYPE=ActionKind@ENDTYPE;@VALU=AcceptEventTimer@ENDVALU;@PRMT=@ENDPRMT;@ENDPROP;
q
-
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
-
Don't search for the description string. You need to match t_xref.Client to match the action's element GUID.
q.
-
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.
-
What shall I say? My crystal ball is unfortunately broken.
q.
-
thank you for your help btw. :) I am trying my best to get these data :/
-
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.
-
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
-
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
-
Hi Geert,
I mean these ones.
Thank you.
bd
(https://imgur.com/tsqFm64.png)
-
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.
-
Ok I tried this way.
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());
}
}
}
}
-
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:
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
-
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.
-
Ok thank you. I will try it out :)
-
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:
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
_________________
-
How can I get the values "0.5" & "Time" from the description. With parsing ?
-
Uhm, what?
q.
-
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
-
Ok, thank you.
bd