Start to use Sim4Sys with a simple model (blackbox)
PRESENTATION
This tutorial is an introduction to the practice of the method. You will be guided through the process to realize your first model and the associated simulation.
Prerequisites
You should have already done the first tutorial Hello World.
News skills that you will acquire
On Designer:
- Define a Type,
- Add conditions in a User Story.
On Virtual Bench:
- Edit a Context,
- Use new Context elements: Gauge, Car, Road Pavement,
- Add a Curve Profil.
Duration
2h
CREATE A MODEL
- Click on File > New > Papyrus Project
- Select CIL4SysLanguage checkbox
- Click on Next
- Type the name of the Papyrus Project: Tutorial1, in the project name field
- Click on Next
- Select CIL4Sys Full Project Template in the field: “You can load a template”
- Click on Finish
CREATE A PROJECT
- Select Tutorial1 in CIL4Sys Overview. You can use the Refresh View button when selecting the Overview tab.
- Click on New Project
Sometimes, the button does not appear because of the size of the window. You can either resize the Overview tab horizontally or use a bigger screen.
- Type the name of the project: Car
- Click on OK
- Click on Ok in the confirmation dialog box
CREATE A SERVICE SPEED MANAGEMENT
- Double Click on the Car Structure diagram
You can resize the composite structure diagram by dragging the corners
- Drag&Drop a New Service in Product CSD
- Select Create
- Type the name of the service: Speed_Management
- Click on OK
ADD A LIFE PHASE TO A SERVICE
- Select Speed_Management Package in CIL4Sys Overview (refresh if it does not appear).
- Click on Complete Life Phases
- Drag&Drop a New Life Phase in the diagram for relevant phases of the service
- Select Standard Use
- Click on OK
CREATE A SIMPLE USE CASE
- Select Standard Use
- Click on Complete Use Cases
- Drag&Drop an actor on the diagram
- Select User
- Click on OK
- Drag&Drop a New UseCase on the diagram
- Type the name of the use case: Accelerate
- Click on OK
- Trace an association between the actor and the use case
CREATE A USER STORY IN A USE CASE
- Select Accelerate package in the CIL4Sys Overview
- Click on New User Story
- Type the name of the user story: The driver accelerates
- Click on OK
- Double Click on the user story: The driver accelerates
COMPLETE THE USER STORY
- Drag&Drop a New State on the Speed_Management Service lifeline
- Select FirstState
- Click on OK
- Rename the state after creation (in Active). You can do it just after the creation or by the Properties view of Papyrus
- Trace a New Message between the user and the service
- Click on Create a new flow
- Drag&Drop a New Interface on the diagram
- Type the name of the interface: I_the_driver_requests_to_accelerate
- Click on OK
- Before creating a new flow in the interface, we need to create a new data type AccelerationType
- Click on the View menu button in the CIL4Sys Overview
- Click on Create Type
- Create a New PrimitiveType
- Type the name: AccelerationType
- Choose the type: DECIMAL
- Click on OK
- Go back to the Request Interfaces diagram by clicking on the tab Request Interfaces
If you have closed the diagram previously, you can still get back to it via the CIL4Sys overview in the Interface package
- Drag&Drop a New Flow in the newly created interface
- Type the name
- Click on Add Data
- Type the name of the data: coef
- Select the type of the data: AccelerationType
- Click on OK
- Go back on the user story
- Trace a New message between the user and the service
- Select the newly created flow
- Click on OK
- Trace a message between the service lifeline on itself (internal activity)
- Click on Create a new activity
- Type the name of the activity: accelerate
- Click on OK
- Right-click on the service lifeline
- Select Edit > Create Variable
- Type the name of the variable: car_acceleration
- Choose the type: AccelerationType
- Set an init value: 0.0
- Click on OK
- Right-click on the accelerate activity
- Choose Edit > Complete Activity
- Select C++ Code
- Click on Next
- Type the code to accelerate: car acceleration = driver request acceleration (with both accelerations in m/s²)
car_acceleration = the_driver_requests_to_accelerate_coef;
- Click on Finish
- Trace a New Message between the service and the environment
- Click on Create a New Flow
- Drag&Drop a New Interface on the diagram
- Type the name of the interface: I_send_car_acceleration
- Drag&Drop a New Flow in the newly created interface
- Type the name: send_car_acceleration
- Click on Add Data
- Type the name of the data: value
- Select the type of the data: AccelerationType
- Click on OK
- Go back on the user story
- Trace a new message between the service and the environment
- Select the newly created flow
- Click on OK
- Select the data value: car_acceleration
- Click on OK
- Select the user story in the CIL4Sys Overview
- Click on Generate State Machine
- Click on Ok in the confirmation dialog box
Regenerate the state machine after each change in diagrams. You should find in the state machine everything that you have written in the diagrams. The state machine helps you to check the model consistency. It is also essential for the simulation to work.
TO GO FURTHER
For your future projects you should :
- Use the same project structure: project > products > services > life phases > use cases > user stories. One project can have several products, one product can have several services, and so on.
- Use types (as AccelerationType) to clarify the type of information you want to exchange in your model, it’s a tool to help you even if you find it useless at the beginning of the training, it is a good work habit.
In the following, we are going to apply the same steps to create other usecases.
USECASE "INFORM OF CAR SPEED"
- Click on the View menu button on the CIL4Sys overview
- Click on Create Type
- Click on Create a new primitive type
- Type the name: SpeedType
- Choose the type: Decimal
- Click on OK
- Select Standard Use Package in CIL4Sys Overview
- Click on Complete Use Cases
- Drag&Drop a New UseCase on the diagram
- Type the name of the new use case: Inform of car speed
- Click on OK
- Trace an association between the actor and the newly created use case
- Select the use case Inform of car speed in the CIL4Sys Overview
- Click on New User Story
- Type the name of the user story: The driver is informed of the car speed
- Click on OK
- Double Click on the newly created user story in the CIL4Sys Overview
- Drag&Drop a New State on the service lifeline
- Select Active
- Click on OK
- Trace a message between the environment and the service
- Click on Create a new flow
- Drag&Drop a New Interface on the FromEnv Interfaces diagram
- Type the name of the interface: I_the_car_speed_is_received
- Click on OK
- Drag&Drop a New flow in the newly created interface
- Type the name: the_car_speed_is_received
- Click on Add data
- Type the name: value
- Set the type of the data: SpeedType
- Go back on the sequence diagram
- Trace a message between the environment and the service
- Choose the_car_speed_is_received
- Trace a New Message between the service and the user
- Click on Create a New Flow
- Drag&Drop a New Interface on the Feedback Interfaces diagram
- Type the name of the interface: I_inform_the_driver_of_the_car_speed)
- Click on OK
- Drag&Drop a New flow in the newly created interface
- Type the name: inform_the_driver_of_the_car_speed
- Click on Add data
- Type the name: value
- Set the type of the data: SpeedType
- Go back on the sequence diagram
- Trace a message between the service and the user
- Choose inform_the_driver_of_the_car_speed
- Click on OK
- Select the value: the_car_speed_is_received_value
- Click on OK
- Select the user story in the CIL4Sys Overview
- Click on Generate State Machine
- Click on Ok in the confirmation dialog box