robotransform 0.0.4__tar.gz → 0.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: robotransform
3
- Version: 0.0.4
3
+ Version: 0.0.6
4
4
  Summary: Perform model transformations for the RoboSapiens project.
5
5
  Keywords: transformation
6
6
  Author: Arkadiusz Michał Ryś
@@ -706,5 +706,7 @@ Description-Content-Type: text/markdown
706
706
 
707
707
  # RoboTransform
708
708
 
709
- Library to perform model to model transformations in the context of RoboSapiens.
709
+ Library to perform model to model transformations in the context of RoboSAPIENS.
710
710
 
711
+ For installation steps follow [the documentation](https://robotransform-0f96de.pages.rys.one/).
712
+ We also provide [the reasoning behind certain decisions](-/jobs/artifacts/main/download?job=typst).
@@ -0,0 +1,6 @@
1
+ # RoboTransform
2
+
3
+ Library to perform model to model transformations in the context of RoboSAPIENS.
4
+
5
+ For installation steps follow [the documentation](https://robotransform-0f96de.pages.rys.one/).
6
+ We also provide [the reasoning behind certain decisions](-/jobs/artifacts/main/download?job=typst).
@@ -4,7 +4,7 @@ build-backend = "uv_build"
4
4
 
5
5
  [project]
6
6
  name = "robotransform"
7
- version = "0.0.4"
7
+ version = "0.0.6"
8
8
  description="Perform model transformations for the RoboSapiens project."
9
9
  authors = [
10
10
  {name = "Arkadiusz Michał Ryś", email = "Arkadiusz.Michal.Rys@gmail.com"},
@@ -566,7 +566,7 @@ class ProductType:
566
566
  def __repr__(self):
567
567
  if len(self.types) > 1:
568
568
  joined = "*".join(map(str, self.types))
569
- return f"{joined}]"
569
+ return f"{joined}"
570
570
  return f"{self.types[0]}"
571
571
 
572
572
 
@@ -576,7 +576,7 @@ class SeqType:
576
576
  parent: Any
577
577
 
578
578
  def __repr__(self):
579
- return f"Seq({self.domain})"
579
+ return f"[{self.domain}]"
580
580
 
581
581
 
582
582
  @dataclass
@@ -0,0 +1,32 @@
1
+ def type_to_port(_type) -> str:
2
+ # TODO this is wrong
3
+ if str(_type) in {"event", }:
4
+ return "event"
5
+ return "data"
6
+
7
+ def type_to_aadl_type(_type) -> str:
8
+ typename = str(_type)
9
+ # Boolean,
10
+ # Character,
11
+ # Float, Float_32, Float_64,
12
+ # Integer, Integer_8, Integer_16, Integer_32, Integer_64,
13
+ # Natural,
14
+ # String,
15
+ # Unsigned_8, Unsigned_16, Unsigned_32, Unsigned_64
16
+ mapping = {
17
+ "boolean": "Base_Types::Boolean",
18
+ "nat" : "Base_Types::Natural",
19
+ "real" : "Base_Types::Float",
20
+ }
21
+ # TODO Seq -> Array[...]
22
+ # TODO Matrix to Array[Array[...]]
23
+ # REASON: AADL does not support variable length arrays
24
+ # TODO Very hacky, not correct
25
+ if typename.startswith("[") and typename.endswith("]"):
26
+ typename = typename[1:-1]
27
+ elif "*" in typename:
28
+ typename = typename.split("*")[0]
29
+ return mapping.get(typename, f"messages::{typename}")
30
+
31
+ def aadl_case_fix(indetifier: str) -> str:
32
+ return identifier
@@ -0,0 +1,74 @@
1
+ {%- macro render_port(name, direction, type) -%}
2
+ {{ name }}: {{ direction }} {{ type | type_to_port }} port {{ type | type_to_aadl_type}};
3
+ {%- endmacro -%}
4
+
5
+ {%- macro render_node_threads(machine) -%}
6
+ {%- for node in machine.nodes %}
7
+ thread {{ node.name }}
8
+ --features {# TODO: Replace these with real resolved fields #}
9
+ --input: in data port Base_Types::Float;
10
+ --output: out data port Base_Types::Float;
11
+ end {{ node.name }};
12
+ thread implementation {{ node.name }}.impl
13
+ end {{ node.name }}.impl;
14
+ {%- endfor %}
15
+ {%- endmacro -%}
16
+
17
+ package LogicalArchitecture
18
+ public
19
+ with messages, Base_Types;
20
+ {%- for package in packages %}
21
+ process {{package.name}}
22
+ {%- set interface_vars = package.interfaces | map(attribute="variables") | sum(start=[]) -%}
23
+ {%- set machine_vars = package.machines | map(attribute="variables") | sum(start=[]) -%}
24
+ {%- if interface_vars or machine_vars %}
25
+ features
26
+ {%- for interface in package.interfaces -%}
27
+ {%- for variable in interface.variables %}
28
+ {{ render_port(variable.name, "in", variable.type) }}
29
+ {%- endfor %}
30
+ {%- endfor %}
31
+ {%- for machine in package.machines -%}
32
+ {%- for variable in machine.variables %}
33
+ {{ render_port(variable.name, "in", variable.type) }}
34
+ {%- endfor %}
35
+ {%- endfor -%}
36
+ {%- endif %}
37
+ end {{package.name}};
38
+ process implementation {{package.name}}.impl
39
+ {%- set machines_with_nodes = package.machines | selectattr('nodes') | selectattr('nodes', '!=', []) | list %}
40
+ {%- if machines_with_nodes %}
41
+ modes
42
+ {%- for machine in machines_with_nodes -%}
43
+ {% for node in machine.nodes %}
44
+ {{node.name}}: {% if loop.first %}initial {% endif %}mode;
45
+ {%- endfor %}
46
+ {%- endfor %}
47
+ {%- endif %}
48
+ {%- if machines_with_nodes %}
49
+ --subcomponents
50
+ {%- for machine in machines_with_nodes -%}
51
+ {% for node in machine.nodes %}
52
+ --{{node.name}}: thread {{node.name}}; {# TODO: Filter so not all nodes are transformed into threads #}
53
+ {%- endfor %}
54
+ {%- endfor %}
55
+ {%- endif %}
56
+ {%- set machines_with_transitions = package.machines | selectattr("transitions") | selectattr('transitions', '!=', []) | list %}
57
+ {%- if machines_with_transitions %}
58
+ annex behaviour_specification {**
59
+ mode transitions
60
+ {%- for machine in machines_with_transitions -%}
61
+ {% for transition in machine.transitions %}
62
+ {{ transition.source }} -> {{ transition.target }}; {# TODO: Check if these are correct #}
63
+ {%- endfor %}
64
+ {%- endfor %}
65
+ **};
66
+ {%- endif %}
67
+ end {{package.name}}.impl;
68
+ {%- if machines_with_nodes %}
69
+ {%- for machine in machines_with_nodes -%}
70
+ {{ render_node_threads(machine) }}
71
+ {%- endfor %}
72
+ {%- endif %}
73
+ {%- endfor %}
74
+ end LogicalArchitecture;
@@ -1,4 +0,0 @@
1
- # RoboTransform
2
-
3
- Library to perform model to model transformations in the context of RoboSapiens.
4
-
@@ -1,29 +0,0 @@
1
- def type_to_port(type) -> str:
2
- # TODO this is wrong
3
- typename = str(type)
4
- data_types = {"int", "integer", "real", "float", "double", "string"}
5
- mixed_types = {"event_data", "event data"}
6
-
7
- if typename in data_types:
8
- return "data"
9
- if typename in mixed_types:
10
- return "event data"
11
- return "data"
12
-
13
- def type_to_aadl_type(type) -> str:
14
- typename = str(type)
15
- # Boolean,
16
- # Character,
17
- # Float, Float_32, Float_64,
18
- # Integer, Integer_8, Integer_16, Integer_32, Integer_64,
19
- # Natural,
20
- # String,
21
- # Unsigned_8, Unsigned_16, Unsigned_32, Unsigned_64
22
- mapping = {
23
- "boolean": "Base_Types::Boolean",
24
- "nat": "Base_Types::Natural",
25
- "real": "Base_Types::Float",
26
- }
27
- # TODO Seq -> Array[...]
28
- # TODO Matrix to Array[Array[...]]
29
- return mapping.get(typename, f"messages::{typename}")
@@ -1,61 +0,0 @@
1
- {%- macro render_port(name, direction, type) -%}
2
- {{ name }}: {{ direction }} {{ type | type_to_port }} port {{ type | type_to_aadl_type}};
3
- {%- endmacro -%}
4
-
5
- {%- macro render_state_threads(machine) -%}
6
- {%- for state in machine.states %}
7
- thread {{ state.name }}
8
- features
9
- {# TODO: Replace these with real resolved fields #}
10
- input: in event data port messages::input_type;
11
- output: out event data port messages::output_type;
12
- end {{ state.name }};
13
-
14
- thread implementation {{ state.name }}.impl
15
- end {{ state.name }}.impl;
16
- {%- endfor %}
17
- {%- endmacro -%}
18
-
19
-
20
- package LogicalArchitecture
21
- public
22
- with messages, Base_Types;
23
- {%- for package in packages %}
24
- process {{package.name}}
25
- {%- set interface_vars = package.interfaces | map(attribute="variables") | sum(start=[]) -%}
26
- {%- set machine_vars = package.machines | map(attribute="variables") | sum(start=[]) -%}
27
- {%- if interface_vars or machine_vars %}
28
- features
29
- {%- for interface in package.interfaces -%}
30
- {%- for variable in interface.variables %}
31
- {{ render_port(variable.name, "in", variable.type) }}
32
- {%- endfor %}
33
- {%- endfor %}
34
- {%- for machine in package.machines -%}
35
- {%- for variable in machine.variables %}
36
- {{ render_port(variable.name, "in", variable.type) }}
37
- {%- endfor %}
38
- {%- endfor -%}
39
- {%- endif %}
40
- end {{package.name}};
41
- process implementation {{package.name}}.impl
42
- {%- set machines_with_states = package.machines | selectattr("states") | select("truthy") | list %}
43
- {%- if machines_with_states %}
44
- subcomponents
45
- {%- for machine in machines_with_states -%}
46
- {% for state in machine.states %}
47
- {{state.name}}: thread {{state.name}}; -- TODO: FILTER SO THAT NOT ALL STATES ARE TRANSFORMED INTO THREADS
48
- {%- endfor %}
49
- {%- endfor %}
50
- {%- endif %}
51
- connections
52
- I1: port input_name -> thread_name.input_name; -- TODO: CANNOT RESOLVE CONNECTIONS!!
53
- O1: port thread_name.output_name -> output_name; -- TODO: CANNOT RESOLVE CONNECTIONS!!
54
- end {{package.name}}.impl;
55
- {%- if machines_with_states %}
56
- {%- for machine in machines_with_states %}
57
- {{ render_state_threads(machine) }}
58
- {%- endfor %}
59
- {%- endif %}
60
- {%- endfor %}
61
- end LogicalArchitecture;
File without changes