Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Ocarina
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
TASTE
Ocarina
Commits
5c972459
Commit
5c972459
authored
Jul 20, 2015
by
yoogx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* getPropertyValueByName: new function, return a property
value from a string
parent
a2a02dc2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
6 deletions
+68
-6
resources/runtime/python/ocarina/ocarina.py
resources/runtime/python/ocarina/ocarina.py
+9
-2
resources/runtime/python/test/visitor.py
resources/runtime/python/test/visitor.py
+6
-4
src/backends/ocarina-backends-properties-utils.adb
src/backends/ocarina-backends-properties-utils.adb
+9
-0
src/backends/ocarina-backends-properties-utils.ads
src/backends/ocarina-backends-properties-utils.ads
+5
-0
src/python/ocarina-python_cmd.adb
src/python/ocarina-python_cmd.adb
+17
-0
src/python/ocarina-utils.adb
src/python/ocarina-utils.adb
+19
-0
src/python/ocarina-utils.ads
src/python/ocarina-utils.ads
+3
-0
No files found.
resources/runtime/python/ocarina/ocarina.py
View file @
5c972459
...
...
@@ -92,7 +92,14 @@ def generate (generator):
################################################################################
def
getPropertyValue
(
nodeId
,
name
Id
):
def
getPropertyValue
(
nodeId
,
property
Id
):
'''Get the value of the property
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertyValue
,
nodeId
,
nameId
)
return
runOcarinaFunction
(
libocarina_python
.
getPropertyValue
,
nodeId
,
propertyId
)
################################################################################
def
getPropertyValueByName
(
nodeId
,
propertyString
):
'''Get the value of the property
'''
return
runOcarinaFunction
(
libocarina_python
.
getPropertyValueByName
,
nodeId
,
propertyString
)
resources/runtime/python/test/visitor.py
View file @
5c972459
...
...
@@ -30,6 +30,7 @@ args = sys.argv[1:]
###################################
import
ocarina
import
lmp
def
visitor
(
component
,
level
):
"""
...
...
@@ -42,25 +43,26 @@ def visitor (component, level):
"""
print
' '
*
level
,
'Visiting '
,
ocarina
.
getInstanceName
(
component
)[
0
]
print
' '
*
level
,
'Visiting '
,
lmp
.
getInstanceName
(
component
)[
0
]
features
=
ocarina
.
AIN
.
Features
(
component
)[
0
];
if
features
is
not
None
:
print
' '
*
level
,
' -> features:'
,
features
for
feature
in
features
:
print
' '
*
level
,
' -> '
,
feature
,
","
,
ocarina
.
getInstanceName
(
feature
)[
0
]
print
' '
*
level
,
' -> '
,
feature
,
","
,
lmp
.
getInstanceName
(
feature
)[
0
]
properties
=
ocarina
.
AIN
.
Properties
(
component
)[
0
];
if
properties
is
not
None
:
print
' '
*
level
,
' -> properties:'
for
property
in
properties
:
print
' '
*
level
,
' '
,
ocarina
.
getPropertyValue
(
component
,
property
)[
0
]
print
'[looking for priority] '
*
level
,
' '
,
ocarina
.
getPropertyValueByName
(
component
,
u'priority'
)[
0
]
subcomponents
=
ocarina
.
AIN
.
Subcomponents
(
component
)[
0
];
if
subcomponents
is
not
None
:
print
' '
*
level
,
' -> subcomponents:'
,
subcomponents
for
subcomponent
in
subcomponents
:
print
' '
*
level
,
' -> '
,
subcomponent
,
","
,
ocarina
.
getInstanceName
(
subcomponent
)[
0
]
print
' '
*
level
,
' -> '
,
subcomponent
,
","
,
lmp
.
getInstanceName
(
subcomponent
)[
0
]
visitor
(
str
(
ocarina
.
AIN
.
Corresponding_Instance
(
subcomponent
)[
0
]),
level
+
3
)
print
' '
*
level
,
'end of visit of '
,
component
...
...
@@ -81,7 +83,7 @@ def main ():
print
'Visit AADL Instance tree'
print
'----------------------------------------------------'
root
=
ocarina
.
getRoot
()[
0
]
root
=
lmp
.
getRoot
()[
0
]
visitor
(
root
,
0
)
if
__name__
==
"__main__"
:
...
...
src/backends/ocarina-backends-properties-utils.adb
View file @
5c972459
...
...
@@ -157,6 +157,15 @@ package body Ocarina.Backends.Properties.Utils is
is
Prop_Name
:
constant
Name_Id
:=
Standard
.
Utils
.
To_Lower
(
Display_Name
(
Identifier
(
Property
)));
begin
return
Check_And_Get_Property
(
E
,
Prop_Name
);
end
Check_And_Get_Property
;
function
Check_And_Get_Property
(
E
:
Node_Id
;
Prop_Name
:
Name_Id
)
return
String_List
is
A
:
constant
String_Access
:=
new
String
'(
Get_Name_String
(
Prop_Name
));
AADL_Property_Value
:
Node_Id
;
...
...
src/backends/ocarina-backends-properties-utils.ads
View file @
5c972459
...
...
@@ -47,6 +47,11 @@ package Ocarina.Backends.Properties.Utils is
-- ("Period", "500 Ms")
-- ("Dispatch_Protocol", "Periodic")
function
Check_And_Get_Property
(
E
:
Node_Id
;
Prop_Name
:
Name_Id
)
return
String_List
;
function
Check_And_Get_Property
(
E
:
Node_Id
;
Property
:
Node_Id
)
...
...
src/python/ocarina-python_cmd.adb
View file @
5c972459
...
...
@@ -465,6 +465,18 @@ package body Ocarina.Python_Cmd is
Nth_Arg
(
Data
,
2
,
""
));
end
On_Get_Property_Value
;
procedure
On_Get_Property_Value_By_Name
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
);
procedure
On_Get_Property_Value_By_Name
(
Data
:
in
out
Callback_Data
'
Class
;
Command
:
String
)
is
pragma
Unreferenced
(
Command
);
begin
Get_Property_Value_By_Name
(
Data
,
Nth_Arg
(
Data
,
1
,
""
),
Nth_Arg
(
Data
,
2
,
""
));
end
On_Get_Property_Value_By_Name
;
----------------------
-- On_Get_Instances --
----------------------
...
...
@@ -673,6 +685,11 @@ package body Ocarina.Python_Cmd is
(
Repo
,
"getPropertyValue"
,
2
,
2
,
Handler
=>
On_Get_Property_Value
'
Unrestricted_Access
);
-- getPropertyValueByName() function
Register_Command
(
Repo
,
"getPropertyValueByName"
,
2
,
2
,
Handler
=>
On_Get_Property_Value_By_Name
'
Unrestricted_Access
);
-- getPropertyConstants() function
Register_Command
(
Repo
,
"getPropertyConstants"
,
1
,
1
,
...
...
src/python/ocarina-utils.adb
View file @
5c972459
...
...
@@ -280,6 +280,25 @@ package body Ocarina.Utils is
end
loop
;
end
Get_Property_Value
;
--------------------------------
-- Get_Property_Value_By_Name --
--------------------------------
procedure
Get_Property_Value_By_Name
(
Data
:
in
out
Callback_Data
'
Class
;
PropId
:
String
;
PropName
:
String
)
is
Result
:
constant
String_List
:=
Ocarina
.
Backends
.
Properties
.
Utils
.
Check_And_Get_Property
(
Get_Node_Id_From_String
(
PropId
),
Get_String_Name
(
PropName
));
begin
Set_Return_Value_As_List
(
Data
);
for
Elt
of
Result
loop
Set_Return_Value
(
Data
,
Elt
.
all
);
end
loop
;
end
Get_Property_Value_By_Name
;
-----------------
-- Get_Node_Id --
-----------------
...
...
src/python/ocarina-utils.ads
View file @
5c972459
...
...
@@ -60,8 +60,11 @@ package Ocarina.Utils is
function
Get_List_Id_From_String
(
Name
:
String
)
return
List_Id
;
function
Get_Int_From_String
(
Name
:
String
)
return
Int
;
function
Get_Value_Id_From_String
(
Name
:
String
)
return
Value_Id
;
procedure
Get_Node_Id
(
Data
:
in
out
Callback_Data
'
Class
;
N
:
String
);
procedure
Get_Property_Value
(
Data
:
in
out
Callback_Data
'
Class
;
PropId
:
String
;
PropName
:
String
);
procedure
Get_Property_Value_By_Name
(
Data
:
in
out
Callback_Data
'
Class
;
PropId
:
String
;
PropName
:
String
);
end
Ocarina
.
Utils
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment