Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
git+https://github.com/Open-MBEE/sysmlv2-python-client.git@main
requests
pytest
pytest_check
pytest-timeout
11 changes: 7 additions & 4 deletions src/flexo_syside_lib/retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from typing import Tuple, Optional
import os
import pathlib

print('Retriever is loading...')
import syside_license
from sysmlv2_client import SysMLV2Client
from flexo_syside_lib.core import convert_json_to_sysml_textual
Expand Down Expand Up @@ -81,6 +81,8 @@ def _default_base_and_token() -> Tuple[str, str]:
# === Main Model Retrieval ===
def retrieve_latest_sysml_full_model(
project_name: str = DEFAULT_PROJECT_NAME,
base_url:str = None,
bearer_token:str = None,
verbose: bool = True,
) -> str:
"""
Expand All @@ -102,7 +104,8 @@ def retrieve_latest_sysml_full_model(
EnvironmentError: if required environment variables are missing.
RuntimeError: if the project cannot be found.
"""
base_url, bearer_token = _default_base_and_token()
if base_url is None or bearer_token is None:
base_url, bearer_token = _default_base_and_token()

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

# --- Model retrieval ---
elements = client.list_elements(project_id, latest_commit_id)
sysml_text, _ = convert_json_to_sysml_textual(elements)
(sysml_text, model), warnings = convert_json_to_sysml_textual(elements)

return sysml_text
return (sysml_text, model), warnings


# === Entrypoint ===
Expand Down
15 changes: 15 additions & 0 deletions tests/Drone2.sysml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package MechanicalObjectExample {
private import ScalarValues::*;
part def DroneSystem {
part def Drone {
part battery {
/*attribute mass:ISQ::MassValue = 2.5 [SI::kg];*/
attribute m:Real=2.5;
}
part propulsionUnit {
attribute mass:ISQ::MassValue = 0.5 [SI::kg];
}
}
}

}
23 changes: 23 additions & 0 deletions tests/Test1.sysml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package MechanicalObjectExample {
abstract item def MechanicalObject {
attribute mass :> ISQ::mass;
}

abstract item mechanicalObjects[*] : MechanicalObject;

metadata def <mec> MechanicalObjectMetadata :> Metaobjects::SemanticMetadata {
:>> baseType = mechanicalObjects meta SysML::Usage;
}

part def DroneSystem {
part def Drone {
#mec part battery {
attribute :>> mass = 2.5 [SI::kg];
}
#mec part propulsionUnit {
attribute :>> mass = 0.5 [SI::kg];
}
}
}

}
9 changes: 9 additions & 0 deletions tests/Test3.sysml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package FlashlightStarterModel {
part flashlight {
exhibit state flashlightStates {
state off;
transition start then off;
}
}
}

15 changes: 15 additions & 0 deletions tests/Test4.sysml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package FlashlightStarterModel {
package FlashlightSpecificationAndDesign {
package Parts {
}
}
package Views1{
//private import Views::*;
view flashlightPartsTree{
expose FlashlightSpecificationAndDesign::Parts::**;
filter @SysML::PartUsage;
render Views::asTreeDiagram;
}
}
}

1,416 changes: 1,416 additions & 0 deletions tests/Test5.sysml

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions tests/Test6.sysml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package MechanicalObjectExample {
abstract item def MechanicalObject {
attribute mass :> ISQ::mass;
}

abstract item mechanicalObjects[*] : MechanicalObject;

metadata def <mec> MechanicalObjectMetadata :> Metaobjects::SemanticMetadata {
:>> baseType = mechanicalObjects meta SysML::Usage;
}

part def DroneSystem {
part def Drone {
#mec part battery {
attribute :>> mass = 2.5 [SI::kg];
item shape[1] : ShapeItems::Box :>> shape {
attribute :>> length = 10 [SI::cm];
attribute :>> width = 4 [SI::cm];
attribute :>> height = 3 [SI::cm];
}
}
#mec part propulsionUnit {
attribute :>> mass = 0.5 [SI::kg];
item shape[1] : ShapeItems::Cylinder :>> shape;
}
}
}

}
Loading
Loading