Sim Toolkit - UI Diagram - Show Current State?

General discussions about MagicDraw

Moderator: Moderators

Sim Toolkit - UI Diagram - Show Current State?

Postby matthew.j.wynhoff@boeing.com » Wed Mar 29, 2017 5:55 pm

I have a few questions on the UI Diagram and Simulation Toolkit:

1. Observe multiple blocks on UI Diagram?
Can the UI Diagram report information on multiple blocks that have their state charts running? I am simulating my Traffic Light System Block which has its own state chart, and it has 3 parts that have their own state charts and exchange signals between each other and trigger state changes and further actions. It'd be nice for me to observe my simulation and seeing what the current values of states and properties across all 4 blocks.

2. Can I use the UI Diagram to report the current state that my blocks are in?
In Rhapsody, on the UI diagram I can add a LED icon, and tie a state to that LED such that when my simulation is in that specific state, the LED illuminates and blinks red. I'd like to be able to do something similar in magic draw. Is this possible? Or am I going to have to create a property on my block and update it for every state change to report the current state. I'd love for my simulation to report the current signal color (which it does) but also report the current states my vehicles are in (Driving, slowing down, stopped at intersection).

Attached is my model, see the "Index" Diagram at the top level. There are comments on the model and pink comments are asking questions of help needed. I have attempt at a UI and a configuration tied to it that reports the traffic light system properties, but I'd like to also show my current vehicles states as well, it seems like it'd be a lot of extra work to populate a property that reports vehicle states rather than just reporting the states directly

Thanks for the answers to this previous post, it enabled me to get this far, so thank you so much!
sim-toolkit-ads-send-event-actions-and-update-structural-t5089.html
You do not have the required permissions to view the files attached to this post.
matthew.j.wynhoff@boeing.com
Forum Beginner
Forum Beginner
 
Posts: 28
Posts Rating:2
Joined: Mon Jan 16, 2017 5:12 pm
Full name: Matt

Re: Sim Toolkit - UI Diagram - Show Current State?

Postby chanon_s » Mon Apr 03, 2017 4:03 am

Dear Matthew

We have modified your sample project and attach here:

TrafficLightSystem_DONE_UI_Modified.mdzip


We have also added some comments in the opened diagrams which explained what we have done. Please try to run the Sim for UI2 configuration to see the result.

1. Observe multiple blocks on UI Diagram?

Please refer to https://docs.nomagic.com/display/CSTD184/Nested+UI+Configuration+stereotype for how to create nested panels/group boxes, representing each part property.

2. Can I use the UI Diagram to report the current state that my blocks are in?

Please refer to https://docs.nomagic.com/display/CSTD184/ImageSwitcher+and+ActiveImage for how to create an image switcher.

Sincerely

Chanon S.
No Magic Customer Support
You do not have the required permissions to view the files attached to this post.
chanon_s
Customer Support
Customer Support
 
Posts: 95
Posts Rating:11
Joined: Thu Dec 04, 2014 2:21 am

Re: Sim Toolkit - UI Diagram - Show Current State?

Postby matthew.j.wynhoff@boeing.com » Thu Apr 06, 2017 9:47 pm

OK Great! Thank you for updating the model. I am going to have to study and digest this and look over the linked documentation. Thank you so much! This will help me get much further in understanding the UI and Simulating my models.

Question:
On the Label for value where you use the code to display the current state, how did you know to use the following code to display the current value of my state? What language is this in? in the future if I want to do something similar I just should reuse this code in value field?

var currentState = ALH.getState($context$);
currentState != null ? currentState.getName() : "";
matthew.j.wynhoff@boeing.com
Forum Beginner
Forum Beginner
 
Posts: 28
Posts Rating:2
Joined: Mon Jan 16, 2017 5:12 pm
Full name: Matt

Re: Sim Toolkit - UI Diagram - Show Current State?

Postby chanon_s » Thu Apr 06, 2017 10:57 pm

Dear Matthew

You can specify a script expression in the value tag value of the <<RuntimeValue>> stereotype which is applied to a UI label. The syntax of the given script in the project is in javascript format. However, you cannot use different languages for each label because It will use the default language which is set in the Default Language option to evaluate script expressions (Please refer to this option by going to Magic Draw main menu > Options > Environment > Simulation > Simulation Framework group > Default Language).

In addition, please refer to https://docs.nomagic.com/display/CSTD184/AH+API for the list of available open APIs and https://docs.nomagic.com/display/CSTD184/Getting+the+current+state+of+a+run-time+object for the detail of API used in the project.

Sincerely

Chanon S.
No Magic Customer Support
chanon_s
Customer Support
Customer Support
 
Posts: 95
Posts Rating:11
Joined: Thu Dec 04, 2014 2:21 am

Re: Sim Toolkit - UI Diagram - Show Current State?

Postby btalbert-goldstein@draper.com » Thu Apr 08, 2021 1:28 pm

Is there a way to display the value/name of a nested state in the UI label?
The ALH code provided only reports the highest-level current state.
Thanks,
Ben
btalbert-goldstein@draper.com
Forum Newbie
Forum Newbie
 
Posts: 5
Posts Rating:0
Joined: Thu Apr 08, 2021 1:20 pm

Re: Sim Toolkit - UI Diagram - Show Current State?

Postby chanon_s » Fri Apr 09, 2021 5:29 am

Dear Ben

Have you checked our sample project (TrafficLightSystem_DONE_UI_Modified.mdzip) in a previous comment of ours? Please see the Simulation UI User Interface Modeling Diagram and try running the Sim for UI2 simulation configuration. Each group box of the main GUI shows the state of the represented nested part.

nested_states.png


Please see this link for more information on how group boxes or panels can be used to represent a nested part.

Best Regards

Chanon S.
No Magic Customer Support
You do not have the required permissions to view the files attached to this post.
chanon_s
Customer Support
Customer Support
 
Posts: 95
Posts Rating:11
Joined: Thu Dec 04, 2014 2:21 am

Re: Sim Toolkit - UI Diagram - Show Current State?

Postby btalbert-goldstein@draper.com » Fri Apr 09, 2021 7:16 am

Thanks,
I didn't phrase my question correctly. What I meant to ask about is composite-states. How can I determine the current, lowest-level state if it is nested in a composite state?

For instance in the example here https://docs.nomagic.com/display/MD185/Extracting+in+State+Machine+diagram, how would you display the "Verification" state in a UI label? I only am able to report the "Login" state with my best efforts.

I did not find any composite states in the example model provided.

Thanks again,
Ben
btalbert-goldstein@draper.com
Forum Newbie
Forum Newbie
 
Posts: 5
Posts Rating:0
Joined: Thu Apr 08, 2021 1:20 pm

Re: Sim Toolkit - UI Diagram - Show Current State?

Postby chanon_s » Mon Apr 12, 2021 2:27 am

Dear Ben

Unfortunately, there is no Open API to get all active states from a runtime object in current versions of CST. However, you can access the list of all active states of a runtime object by calling the getActiveStates() method. But, please keep in mind that this is not an Open API and is subject to change at any time.

Please see the attached project for the example.

TrafficLightSystem_DONE_UI_ActiveStates.mdzip


Best Regards

Chanon S.
No Magic Customer Support
You do not have the required permissions to view the files attached to this post.
chanon_s
Customer Support
Customer Support
 
Posts: 95
Posts Rating:11
Joined: Thu Dec 04, 2014 2:21 am

Re: Sim Toolkit - UI Diagram - Show Current State?

Postby btalbert-goldstein@draper.com » Mon Apr 12, 2021 8:51 am

This is perfect. And I actually like that it displays all the states at the same time, because I think it's useful to see them in this way.

Thank you!
btalbert-goldstein@draper.com
Forum Newbie
Forum Newbie
 
Posts: 5
Posts Rating:0
Joined: Thu Apr 08, 2021 1:20 pm


Return to MagicDraw

Who is online

Users browsing this forum: No registered users and 0 guests