Skip to main content

Air conditioning and interior lighting in a car

Now is the time to take the plunge and to practice with the concept of parallel states.

DURATION

You should be able to complete this exercise in 2 hours.

GOAL

The objective of this project is to model some features of the car (air conditioning and interior lighting). Keep in mind that the model is valid for all cars with different options.

CONTEXT

This service is dedicated to control interior light and air conditioning of a vehicle. The manipulation of the system is done directly by the driver :

  • The Driver switchs ON/OFF/Automatic the interior lighting.
  • The Driver selects the speed of air conditioning / the temperature.

ASSUMPTIONS

We assume that:

  • The interior lighting and air conditioning are two separate features.
  • The User can modify the state of the interior lighting at any time (switchs ON/OFF/Automatic).
  • The User can modify the state of the air conditioning (ON/OFF), increase or decrease the temperature.
  • The internal lighting switch implemented in this model is similar to this one (see the screenshot below).

Light Internal Switch

  • In its initial state, the light is off.
  • From the initial state, the user can switch directly to ON/Automatic Mode.
  • Once the ON mode is activated, it must be switched back to the initial state (OFF) before switching to automatic mode. For Air conditioning feature, the ventillation is available only when the engine is running.

START MODELING ON Designer

  • Create a new service.
  • Drag & Drop the life phase “Standard Use” to the Life Phase diagram.
  • Create a User actor named "User".
  • Create the following use cases of the life phase “Standard Use” and associations between them and User (AirConditioner, InternalLighting).

UCD Desginer

  • Create the following user stories for the use cases you have already created.

User Stories Designer

  • Create the following flows and interfaces.

Request Flows and interfaces Designer

tip

To accomplish this step successfully, you will need to create these enumerations.

Enumerations Designer

  • Create Feedback flows and interfaces.

Feedback Interfaces esigner

State Machine Creation

  • Drag & Drop a new state in MySpecStateMachine , name it "System_Available".
  • Define the state already created as initial State.
  • In order to create parallel states : you need to divide the area of ​​the already created state using the button "Region" in the Palette part.

Palette Part

  • After completing the previous steps, you should have a state machine similar to this one.

My Spec State Machine After Creating Regions

  • Drag & drop an initial state named "InternalLightingState" in the first region and an other one named "AirConditioningState" in the second region.

My Spec State Machine After Creating Regions2

  • Now you can continue the modeling by creating the states of each system in the dedicated region.
caution

Papyrus doesn't allow us to have transitions directly inside the regions created, that's why we have to create intermediate states "AirConditionningState" & "InternalLightingState" to avoid compilations problems related to this problem.

  • The region of "InternalLightingState" should contain three under states : Light_OFF, Light_ON, Light_Automatic_Mode.
  • The region of "AirConditioningState" should contain two under states : Ventillation_Unavailable, Ventillation_Available. When the ventillation is available there are four possible cases : Speed_OFF, Speed1, Speed2, Speed3.

User Stories Creation For Control_cabin_ventillation

  • Create a user story "Ventillation_is_available_when_Engine_is_running": This sequence diagram is used to transition the system from the Ventilation Unavailable state to the Ventilation Available state. N.B : The car's ventilation system is always linked to the engine state.

Ventillation is available when Engine is running

  • Create a user story "Ventillation_is_no_more_available_when_Engine_is_not_running": This sequence diagram is used to transition the system from the Ventilation Available state to the Ventilation Unavailable state when the engine is not running.

Ventillation is no more available when Engine is not running

  • Create a user story "User_Increases_Ventillation_Speed_When_It_Is_Off": This sequence diagram is used to pass the ventillation from speed off to speed 1.

User Increases Ventillation Speed When It Is Off

  • Create a user story "User_Increases_Ventillation_Speed_When_It_Is_In_Speed1": This sequence diagram is used to Increas the ventillation from speed 1 to speed 2.

User Increases Ventillation Speed When It Is In Speed1

  • Create a user story "User_Increases_Ventillation_Speed_When_It_Is_In_Speed2": This sequence diagram is used to Increas the ventillation from speed 2 to speed 3.

User Increases Ventillation Speed When It Is In Speed2

  • Create a user story "User_Decreases_Ventillation_Speed_When_It_Is_In_Speed3": This sequence diagram is used to Decreas the ventillation from speed 3 to speed 2.

User Decreases Ventillation Speed When It Is In Speed3

  • Create a user story "User_Decreases_Ventillation_Speed_When_It_Is_In_Speed2": This sequence diagram is used to Decreas the ventillation from speed 2 to speed 1.

User Decreases Ventillation Speed When It Is In Speed2

  • Create a user story "User_Decreases_Ventillation_Speed_When_It_Is_In_Speed1": This sequence diagram is used to pass the ventillation from speed 1 to speed OFF.

User Decreases Ventillation Speed When It Is In Speed1

User Stories Creation For Control_interior_lighting

  • Create a user story "User_Requests_Automatic_Mode": This sequence diagram is used to switch the interior lighting from OFF to Automatic Mode.

User Requests Automatic Mode

  • Create a user story "User_Requests_ON_Mode": This sequence diagram is used to switch ON the interior lighting when it is initially OFF.

User Requests ON Mode

  • Create a user story "User_Requests_OFF_Mode_When_It_Is_Switched_ON": This sequence diagram is used to switch OFF the interior lighting when it is already switched ON.

User Requests OFF Mode When It Is Switched_ON

  • Create a user story "User_Requests_OFF_Mode_When_It_Is_Automatic_Mode": This sequence diagram is used to switch OFF the interior lighting when it is already in automatic mode.

User Requests OFF Mode When It Is Automatic Mode

State Machine Generation

Once you have generated the state machine for all sequences diagrams, you should have the StateMachine diagram for the service as follows:

State Machine Designer

tip
  • You can generate the state chart of all sequence diagrams of a Use Case by selecting the Use Case in the Overview tab then cliquing on "Generate State Machines"

Generate state chart Designer

Code Compilation

  • To compile code you need to click on "[code] Generate and build";

    Code Compilation Designer

  • Select "MyProject" then click on OK.

    Code Generation Designer

  • Choose "Cygwin GCC" ten click on Finish.

    Create Project Designer

    When the code generation is finished successfully, you will have this pop up :

    Create Project Designer

    Export XML file

    Simply you need to click on the project in the Overview tab then click on "Export File XML"

    Export XML File Designer

    Simulation with Virtual Bench

    • Go on the Sim4Sys Virtual Bench: https://sim4sys.com/.
    • Identify with your login and password.
    • In the Projects tab choose your sandbox project.
    • Add Executable & Import Types and Flows : In the Project tab, open the Executables folder, in which you can add a new executable.

    Add Exe Designer

    • You can name it as you want, choose the path to the executable, otherwise, click the red cross to remove the path, then press Save:

      Edition Exe VB

    • A pop-up opens to ask if you want to import types and flows from the model to the virtual bench:

      Import Types and Flows VB

    • If you click on Ok, the below pop-up ask you to add the .xml file:

      Import XML File

    • Then, check that the types and flows are correct and click on Ok :

      Import Confirmation VB

    • Create Scenario contexts by clicking on the New Scenario sign.

      Sign VB

    • Create a new scenario.

      Add New Scenario

    • Name it as you wish, and press "Save". The new scenario should now be opened if you selected Open the new scenario option.

      Scenario Creation VB

    • Before creating new mappings, in your scenario tab, Add a new WebSockets, related to the Executable that you added earlier.

      Add Websocket VB

    • Configure the web socket creation and click on "Save".

      Websocket Config VB

    • Mapping : Establish mappings between the types and flows defined in the model and their representation in Virtual Bench.

      1. Switch to VB Edit Mode if you are in Run Mode, by clicking on the button:

        Run Mode VB

      2. In Edit mode, in the context menu below, select the timeline context (don't forget to add a timeline context before that).

      Timeline Context VB

      1. Create an element by double clicking on the timeline events axis.
      tip

      Double-click somewhere in the timeline events axis to add a timeline action element. Then select it, and go to the Parameter tab and change the Event type from "continuous" to "trigger" (in order to send the associatied mapping only one time), and click on Save on the TimelineAction popup to save the modifications

      Timeline action properties

      1. Right-click on the action and select Send flow.

      Send Flow VB

      1. Virtual Bench will ask you if you want to Create a new mapping, or Reuse an existing one, select "Create":

      Create flow mapping VB

      1. Configure your websoket and Select the flow that you want to send then click on save.

      Add Simu To Model Mapping

      1. Select the correct enumeration to send then click on Save.

      Edit Simu To Model Mapping

      You can add the other flows (simu to model) with the same method.

      1. In the context menu , select the HMI context to open it.
      2. In the HMI context menu, Drag & Drop the Text element.

      Text element VB

      1. Right-click on the Text element and select Receive flow:

      Reveice Flow VB

      1. Virtual Bench will ask you once again if you want to Create or Reuse a mapping, select "Create".

      Create Receive Flow VB

      1. Select the flow "Ventillation_Speed_Feedback" then click on save.

      Create Received Flow Mapping VB

      1. Edit model to simulation mapping then click on save.

      Model To Simulation Mapping

      You can add the other flows (model to simu) with the same method.

      Run scenario

      Now you can run the configured simulation scenario and analyze the results to evaluate the system’s behaviour.