Skip to content

Commit 40ac613

Browse files
Merge pull request #28 from Open-MBEE/develop
Develop
2 parents 78fc88b + d1b5546 commit 40ac613

15 files changed

Lines changed: 3335 additions & 6 deletions

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
git+https://github.com/Open-MBEE/sysmlv2-python-client.git@main
22
requests
3+
pytest
4+
pytest_check
5+
pytest-timeout

src/flexo_syside_lib/retriever.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from typing import Tuple, Optional
1313
import os
1414
import pathlib
15-
15+
print('Retriever is loading...')
1616
import syside_license
1717
from sysmlv2_client import SysMLV2Client
1818
from flexo_syside_lib.core import convert_json_to_sysml_textual
@@ -81,6 +81,8 @@ def _default_base_and_token() -> Tuple[str, str]:
8181
# === Main Model Retrieval ===
8282
def retrieve_latest_sysml_full_model(
8383
project_name: str = DEFAULT_PROJECT_NAME,
84+
base_url:str = None,
85+
bearer_token:str = None,
8486
verbose: bool = True,
8587
) -> str:
8688
"""
@@ -102,7 +104,8 @@ def retrieve_latest_sysml_full_model(
102104
EnvironmentError: if required environment variables are missing.
103105
RuntimeError: if the project cannot be found.
104106
"""
105-
base_url, bearer_token = _default_base_and_token()
107+
if base_url is None or bearer_token is None:
108+
base_url, bearer_token = _default_base_and_token()
106109

107110
if verbose:
108111
print(f"[Flexo] Base URL: {base_url}")
@@ -125,9 +128,9 @@ def retrieve_latest_sysml_full_model(
125128

126129
# --- Model retrieval ---
127130
elements = client.list_elements(project_id, latest_commit_id)
128-
sysml_text, _ = convert_json_to_sysml_textual(elements)
131+
(sysml_text, model), warnings = convert_json_to_sysml_textual(elements)
129132

130-
return sysml_text
133+
return (sysml_text, model), warnings
131134

132135

133136
# === Entrypoint ===

tests/Drone2.sysml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package MechanicalObjectExample {
2+
private import ScalarValues::*;
3+
part def DroneSystem {
4+
part def Drone {
5+
part battery {
6+
/*attribute mass:ISQ::MassValue = 2.5 [SI::kg];*/
7+
attribute m:Real=2.5;
8+
}
9+
part propulsionUnit {
10+
attribute mass:ISQ::MassValue = 0.5 [SI::kg];
11+
}
12+
}
13+
}
14+
15+
}

tests/Test1.sysml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package MechanicalObjectExample {
2+
abstract item def MechanicalObject {
3+
attribute mass :> ISQ::mass;
4+
}
5+
6+
abstract item mechanicalObjects[*] : MechanicalObject;
7+
8+
metadata def <mec> MechanicalObjectMetadata :> Metaobjects::SemanticMetadata {
9+
:>> baseType = mechanicalObjects meta SysML::Usage;
10+
}
11+
12+
part def DroneSystem {
13+
part def Drone {
14+
#mec part battery {
15+
attribute :>> mass = 2.5 [SI::kg];
16+
}
17+
#mec part propulsionUnit {
18+
attribute :>> mass = 0.5 [SI::kg];
19+
}
20+
}
21+
}
22+
23+
}

tests/Test3.sysml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package FlashlightStarterModel {
2+
part flashlight {
3+
exhibit state flashlightStates {
4+
state off;
5+
transition start then off;
6+
}
7+
}
8+
}
9+

tests/Test4.sysml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package FlashlightStarterModel {
2+
package FlashlightSpecificationAndDesign {
3+
package Parts {
4+
}
5+
}
6+
package Views1{
7+
//private import Views::*;
8+
view flashlightPartsTree{
9+
expose FlashlightSpecificationAndDesign::Parts::**;
10+
filter @SysML::PartUsage;
11+
render Views::asTreeDiagram;
12+
}
13+
}
14+
}
15+

tests/Test5.sysml

Lines changed: 1416 additions & 0 deletions
Large diffs are not rendered by default.

tests/Test6.sysml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package MechanicalObjectExample {
2+
abstract item def MechanicalObject {
3+
attribute mass :> ISQ::mass;
4+
}
5+
6+
abstract item mechanicalObjects[*] : MechanicalObject;
7+
8+
metadata def <mec> MechanicalObjectMetadata :> Metaobjects::SemanticMetadata {
9+
:>> baseType = mechanicalObjects meta SysML::Usage;
10+
}
11+
12+
part def DroneSystem {
13+
part def Drone {
14+
#mec part battery {
15+
attribute :>> mass = 2.5 [SI::kg];
16+
item shape[1] : ShapeItems::Box :>> shape {
17+
attribute :>> length = 10 [SI::cm];
18+
attribute :>> width = 4 [SI::cm];
19+
attribute :>> height = 3 [SI::cm];
20+
}
21+
}
22+
#mec part propulsionUnit {
23+
attribute :>> mass = 0.5 [SI::kg];
24+
item shape[1] : ShapeItems::Cylinder :>> shape;
25+
}
26+
}
27+
}
28+
29+
}

0 commit comments

Comments
 (0)