Home

The Alarm System - ASD:Suite Community

image

Contents

1. In this exercise you learn to add the functionality of switching on and off the alarm system using a key to an ASD interface model Learning targets e How to create an interface model from scratch e How to define application interfaces and events e Non determinism in the interface e How to use Sequence Based Specification SBS e How to use the ASD ModelBuilder Conflict checker Filters Show State diagram Navigation References course material e Section 4 Sequence Based Specifications Key concepts and best practices e Section 6 ASD Interface Models Sequence Based Specifications Guidelines References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum Exercise 1A 2 Fill in SBS Add an action for each interface event double click an Actions cell SwitchOn should return OK or Failed SwitchOff should return VoidReply Add a target state double click a Target State cell Continue till all state transitions are complete Explore filters toolbar context sensitive filters right mouse click in SBS state diagram tab in SBS The Alarm System Exercise 2013 Verum In this exercise you learn to add the functionality of switching on and off the alarm system using a key to an ASD interface model Learning targets e How to create an interface model from scratch e How to define application interfaces and events e Non determinism
2. e Section 4 Sequence Based Specifications Key concepts and best practices e Section 6 ASD Interface Models Sequence Based Specifications Guidelines e Section 12 ASD Suite Model verification Definitions and best practices Model Verification References user manual s e ASD Suite User Manual e ASD Suite Visual Verification Guide The Alarm System Exercise 2013 Verum 10 Exercise 1B 2 3 Create new Modelling Interface AlarmSystem_INT providing Modelling event SwitchOffHandled Modelling event Triggered 4 Make SBS complete On SwitchOffHandled send notification SwitchOffOK On Triggered send notification Triggered 5 Verify interface model F5 6 Analyse and solve problems Note that the console will turn the LED green again when SwitchOffOK is received The console will turn the LED red on when the notification Triggered is received The Alarm System Exercise 2013 Verum In this exercise you learn to add a modelling interface The modelling interface allows you to define internal situations that change the external observable behaviour different state different actions When the AlarmSystem is requested to switch off you may want to wait till your entire system is really switched off On the interface level you don t need to know in detail what has been switched off but you only model the condition that the request to switch off has be
3. code according the modified use cases If the code is correct the system will be switched off giving the response SwitchOffOK If the system is not correct the system will be triggered which is indicated by SwitchOffHandled giving the response SwitchOffFailed After 10 seconds the siren will make sound unless a correct code is entered in the mean time If another incorrect code is entered the timer will not be restarted If the debug option is switched on in the generated code you will be able to read in the logging window which wrong code has been used to switch off the system Learning targets e How to define parameters in application and notification events in an interface model Note that ASD can be used in an iterative or a waterfall development process The exercise is described as a waterfall approach It is however possible to make iterations in exercise 7 For instance first extend the model to switch on the system with a correct secret code Check models analyse solve problems generate code and integrate and test If it works OK with the GUI then start modelling switch off functionality References course material e Section 8 Parameters Key concepts and best practices References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum 24 Exercise B Extend implemented behaviour with wrong correct code 1 Open design model AlarmSystem dm 2 Add used compon
4. in the interface e How to use Sequence Based Specification SBS e How to use the ASD ModelBuilder Rulecase wizards Filters Show State diagram Navigation References course material e Section 4 Sequence Based Specifications Key concepts and best practices e Section 6 ASD Interface Models Sequence Based Specifications Guidelines References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum Exercise 1B 1 Add notifications to an interface For educational purposes SwitchOff will be an asynchronous action and a notification is added for that Another notification is added for indicating that the sensor was triggered 1 Open interface model AlarmSystem im 2 Create new Notification Interface AlarmSystem_NI providing Notification event SwitchOffOK Notification event Triggered The Alarm System Exercise 2013 Verum In this exercise you learn to add notifications to an interface The notifications sent to the client will depend on modelling events The Console will turn the LED green when the SwitchOffOK notification is received The Console will turn the LED red when the Triggered notification is received Learning targets e How to define notification interfaces and notification events e How to use Sequence Based Specification SBS e How to use the ASD ModelBuilder e How to use the Visual Verification References course material
5. model Analyse and solve problems Generate code Build integrate and test The Alarm System Exercise 2013 Verum In this exercise you learn how you can condense a number of states that almost do the same to one state by using state variables By reducing the number of states the human perceived complexity in the SBS may decrease The model verification however will use the exact same state space as without state variables Learning targets e How to use state variables to condense SBS states References course material e Section 5 State Variables Key concepts and best practices References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum 26 Exercise 9 Explore interaction foreign ASD code 1 Investigate handwritten client component that uses the AlarmSystem interface C main cpp C Console cs Java Console java Generate used component stub from interface model SecretCode im Use component name SecretCode Select no proxy no synchronization primitives Compare generated used component stub with handwritten code The Alarm System Exercise 2013 Verum In this exercise you can have a look how e A foreign client component interacts with the ASD component i e AlarmSystem e How an ASD component interacts with a foreign used component This component can initially be generated from an ASD Model Interface and must be extended manually to fulfil its exten
6. user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum 30 Exercise 11 2B Refactor used component Sensor Open design model AlarmSystem dm Rename primary reference windowSensor into sensorProxy Rename construction WindowSensor into SensorProxy In tab Used Services for service Sensor Change relative path Sensor im into SensorProxy im Fix conflicts Verify Analyse and solve problems Generate code The Alarm System Exercise 2013 Verum In this exercise you learn how you can use another service component Learning targets e How to use used service references References course material References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum 31 Exercise 11 2C Make SensorProxy component Open interface model SensorProxy im Create new design model SensorProxy dm Add new primary reference windowSensor 2 instances construction WindowSensor Add new primary reference doorSensor 1 instances construction DoorSensor Make SBS complete Verify Analyse and solve problems Generate code Build integrate and test The Alarm System Exercise 2013 Verum In this exercise you learn how you can create a set of identical implementations of the same interface and how you can use Used Service References to address a set of components with the same interface Learning targets e Ho
7. using a KEYPAD to enter a secret code consisting of 3 numbers When SET is pressed the secret code will be sent to switch on off the system In case SwitchOn is called with a wrong code the reply event Failed will be returned OK otherwise In case SwitchOff is called with a wrong code the notification SwitchOffFailed is returned For debug purposes the wrong code will be sent back to the application A timer is started and the user can try to switch off again to prevent the siren making sound until the timer expires The siren is turned on regardless if a sensor has also triggered or not In case SwitchOff is called with the correct code the notification SwitchOffOK is returned The Alarm System Exercise 2013 Verum Our first specification of the AlarmSystem is extended to allow exercising on more advanced features We already had the sequence SwitchOff VoidReply SwitchOffHandled SwitchedOffOK from the previous exercises We now add the sequence SwitchOff VoidReply SwitchOffHandled SwitchedOffFailed These sequences are mutually exclusive In case of a wrong code the console will turn the LED red when notification SwitchOffFailed is received The state of the alarm system in that case is the same as if a sensor was triggered This means the siren will make sound after a delay unless the correct code is entered in the mean time In this phase the red LED will indicate the pre al
8. In the sub machine all details for deactivation are handled any other activity is Illegal Note that state variables in main and sub machines are not shared Learning targets e How to use sub machines References course material e Sequence Based Specifications Designs with Sub Machines References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum J3 Wrap up exercises With ASD Focus is on engineering instead of implementation Design errors are found before implementation Integration with other software is easy and quick Testing focuses on specification issues validation rather than design implementation issues verification The Alarm System Exercise 2013 Verum The hands on experience while doing these exercises should have given you insights on the world behind ASD and also on how ASD impacts your work The Alarm System Exercise 2013 Verum 34
9. Software Integration ASD Runtime and OSAL References user manual s e ASD Suite User Manual e ASD Runtime Guide The Alarm System Exercise 2013 Verum 19 Exercise 5B 2 6 For C and Java Solve compile error add the proper include import In AlarmSystem dm properties and regenerate code for AlarmSystem dm Rebuild and test The Alarm System Exercise 2013 Verum The Alarm System Exercise 2013 Verum 20 Exercise 6 Customise the generated code 1 Create in directory models Header txt add some comments Footer txt add some comments HeaderAndFooter txt have statements for including header for generating body and for including footer Open design model AlarmSystem dm open model properties Code Generation select your language and fill in HeaderAndFooter txt after Include file Generate code and inspect source code The Alarm System Exercise 2013 Verum In this exercise you learn how to customise the generated code Learning targets e How to customize generated code References course material e Section 13 ASD Suite Code generation References user manual s e ASD Suite User Manual keyword Code Customization User Provided Text e ASD Runtime Guide The Alarm System Exercise 2013 Verum 21 Modified use cases When leaving entering the building the alarm system can be switched on off by
10. System Exercise 2013 Verum These use cases describe the alarm system when it is complete The exercises will be done step by step incremental development so the intermediate result may differ from these use cases For example the first version of your alarm system will not have a time delay between the moment the sensor is triggered and the moment the siren is switched on At the Console switching off the siren must be done by switching off the entire system The Alarm System Exercise 2013 Verum Context Console Sensor The Alarm System Exercise 2013 Verum The Console is the Man Machine Interface MMI of the AlarmSystem It consists of a key switch to switch the system on or off and a LED to indicate the status green OFF yellow ON red TRIGGERED being pre alarm or alarm The graphical representation of Siren and Sensor as shown on the Console GUI are actually not part of the Console itself but are shown for validation testing The Console will be implemented by a GUI application which is ready to use to test the result of your exercises The Alarm System Exercise 2013 Verum ASD component diagram Console Application Interface 15 AlarmSystem dh Notification Interface ao Sensor The Alarm System Exercise 2013 Verum The service of the Sensor and Siren is described in their respective ASD Interface Model The implementation of Console Sensor and Siren can be found in the co
11. The Alarm System Exercise Verum The Alarm System Exercise 2013 Verum Purpose The purpose of the Alarm System exercise is To exercise ASD aspects in controllable small steps The Alarm System exercise provides practical ASD experience in the area of Modelling component specification interface model Modelling component implementation design model Verify interface design models Code generation Code integration The Alarm System Exercise 2013 Verum Purpose 2 We will do exercises step by step to learn How to create interface models How to create design models How to verify interface design models How to generate code and retrieve the ASD Runtime How to use ASD timers How to customise generated code header footer How to use parameters How to use state variables How to use Used Service References How to use sub machines System Exercise 2013 Verum The Alarm System Exercise 2013 Verum Use cases When you leave the building the alarm system can be switched on with a KEY The LED on the console turns yellow When entering the building the alarm system can be switched off by a KEY The LED on the console turns green When the alarm is triggered by one of the sensor s the LED on the console turns red after 5 seconds the siren turns on unless the system is switched off If the system is in alarm mode and switched off the siren turns off and the LED turns green The Alarm
12. arm The secret code is 917 hard coded in the implementation of the handwritten component SecretCode The Alarm System Exercise 2013 Verum 22 Context Console Sensor The Alarm System Exercise 2013 Verum The interface of the SecretCode Sensor and Siren are described in their respective Interface Models The implementation of Console Sensor and Siren can be found in the corresponding handwritten components You will make the Interface Model and Design Model of the AlarmSystem during the exercises Save your models in lt desktop gt AlarmSystemExercise models The Alarm System Exercise 2013 Verum 23 Exercise A Extend specified behaviour with wrong correct code 1 Open interface model AlarmSystem im 2 In Application Interface AlarmSystem Add an input parameter in SwitchOn and in SwitchOff called secretCode of type SecretCode 3 In Notification Interface AlarmSystem_NI a Add notification event SwitchOffFailed In SwitchOffFailed add input parameter called secretCode of type SecretCode 4 Make SBS complete On SwitchOffHandled send SwitchOffOK or SwitchOffF ailed lt wrong secret code gt 5 Verify interface model F5 6 Analyse and solve problems The Alarm System Exercise 2013 Verum In this exercise you learn how to define data exchange as input and output parameter The behaviour is modified to handle the wrong or correct
13. ded functionality Learning targets e How to write software that interacts with ASD components used component client component References course material e Section 15 Software Integration Foreign components References user manual s e ASD Runtime Guide The Alarm System Exercise 2013 Verum 27 Exercise 10 Using multiple identical implementations of a service Open design model AlarmSystem dm Change the number of instances of the used service reference windowSensor from 1 into 2 Verify design model Fix the SBS Use a Used Service Reference variable and the that operator Make the SBS such that no change is needed when the number of references is changed e g from 2 into 3 Verify design model Analyse and solve problems Generate code Build integrate and test The Alarm System Exercise 2013 Verum In this exercise you learn how you can create a set of identical implementations of the same interface and how you can use Used Service References to address a set of components with the same interface Learning targets e How to use used service references e How to use used service reference state variables and that operator References course material References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum Exercise 11 1 Using multiple different implementations of a service 1 Open design model AlarmSystem dm 2 Add anew sensor type DoorSe
14. en handled i e SwitchOffHandled The SwitchOffHandled condition may lead to a successful result or a failure For this exercise we assume switching off has succeeded The expected sequence is SwitchOff VoidReply SwitchOffHandled SwitchOffOK There can be a condition that will trip the alarm system eventually leading to the siren being turned on On the interface level you don t need to model in detail what is the exact cause of the Triggered alarm e g type of sensor but you only model the effect that such a condition will have on the external state behaviour In fact you make an abstraction i e Triggered of the internal behaviour Learning targets e How to define modelling events e The difference between Optional and Inevitable e How to use Sequence Based Specification SBS e How to use the ASD ModelBuilder and Visual Verification References course material e Section 4 Sequence Based Specifications Key concepts and best practices e Section 6 ASD Interface Models Sequence Based Specifications Guidelines e Section 12 ASD Suite Model verification Definitions and best practices Visual Verification References user manual s e ASD Suite User Manual e ASD Suite Visual Verification Guide The Alarm System Exercise 2013 Verum 11 Exercise 2 Create a design model from existing interface model Open ModelBuilder Create new design model AlarmSystem from AlarmSystem im Add used service
15. ent SecretCode 3 Make SBS complete Evaluate the result of the isCodeCorrect in a separate state 4 Verify design model F5 5 Build integrate and test The Alarm System Exercise 2013 Verum In this exercise you learn how to use input and output data in the design model Learning targets e How to use parameters in application and notification events in a design model e How to use storage specifiers in design models e How to implement data types defined used in ASD models e ASD does not guarantee data integrity experienced if storage specifiers are not used well e Conversion of data parameters into ASD control isCodeCorrect function e Note the alike behaviour in case of checking result of isCodeCorrect multiple states looking the same except a small difference References course material e Section 8 Parameters Key concepts and best practices e Section 15 Software Integration Foreign components e Section 16 Using Parameters Generated code References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum 25 Exercise 8 Reduce number of states in SBS 1 Open design model AlarmSystem dm 2 Choose one of the following options or combination e Make one state using state variable s instead of multiple states for checking isCodeCorrect result Use a boolean state variable s for recording whether sensor is triggered and whether siren is on Verify design
16. ion where the build environment expects the files i e lt code_dir gt see slide Note that through the model properties also debug info can be included in the generated code Learning targets e How to use the Code Generator References course material e Section 13 ASD Suite Code generation References user manual s e ASD Runtime Guide The Alarm System Exercise 2013 Verum 14 Exercise 4A 2 Generate code from ASD models continued 1 Generate interface code from each interface model 2 Generate source code from design model Or Generate all code from design model In this exercise you learn to generate code from ASD models Learning targets e How to use the Code Generator References course material e Section 13 ASD Suite Code generation References user manual s e ASD Runtime Guide The Alarm System Exercise 2013 Verum Exercise 4B 1 Integrate and test functionality 1 Retrieve ASD Runtime and save to lt code dir gt runtime 2 For C and C Visual Studio Express Go to lt code_dir gt and open solution AlarmSystem_2008 sIn or AlarmSystem_2010 sIn depending on which version is installed on your computer At Verum s side 2008 For Java Follow the instructions on next slide 3 Build solution 4 Execute solution and test functionality For Java select run as Java Application whenever asked The Alarm System Exercise 2013 Verum 16 In
17. nsor reference doorSensor service Sensor construction DoorSensor The DoorSensor will externally behave exactly the same as the WindowSensor but has a different implementation Note that adding a new type of sensor needs modification of the SBS in the AlarmSystem dm Undo adding doorSensor A better alternative is to make a new component SensorProxy that abstracts away the knowledge of a variety of sensor types for the AlarmSystem dm to improve the locality of change and separation of concerns The Alarm System Exercise 2013 Verum In this exercise you learn how you can use abstraction to improve the locality of change and separation of concerns in a design Learning targets e How to use used service references References course material References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum 29 Exercise 11 2A Copy an interface model 1 Open interface model Sensor im 2 In menu choose File gt Save As gt New Model name it SensorProxy 3 In SensorProxy im rename interfaces ISensor gt ISensorProxy ISensor_NI gt ISensorProxy_NI lSensor_INT gt ISensorProxy_INT The Alarm System Exercise 2013 Verum In this exercise you learn how you can make a copy of a interface model Learning targets e How to use used service references References course material References
18. pecifications Guidelines References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum 12 Exercise 3 Verify your design 1 Open ModelBuilder 2 Verify design model F5 3 Analyse and solve problems Explore the Model Navigator view The Alarm System Exercise 2013 Verum In this exercise you learn to correct the defined behaviour by using Visual Verification and to analyse solve the reported problems Learning targets e How to use Visual Verification e How to analyze design problems References course material e Section 11 ASD Execution Semantics e Section 12 ASD Suite Model verification Definitions and best practices References user manual s e ASD Suite Visual Verification Guide The Alarm System Exercise 2013 Verum 13 Exercise 4A 1 Generate code from ASD models lt code dir gt is code cpp for C a code cs for C code java for Java Open ModelBuilder In the models you created change the source file path to generate code in lt code_dir gt src generated and save For Java only in the interface model change namespace to com verum examples AlarmSystem The Alarm System Exercise 2013 Verum In this exercise you learn to generate code from ASD models Each model has properties related to code generation they can be filled in through the model properties The chosen source file path must point to the locat
19. rresponding handwritten components You will make the Interface Model and Design Model of the AlarmSystem during the exercises Save your models in lt desktop gt AlarmSystemExercise models The Alarm System Exercise 2013 Verum Tips Do the exercises step by step Let stakeholder verify your specifications review interface model before you continue When in doubt ask stakeholder do not make assumptions Use names exactly as specified between double quotes Have a look in the installed user manuals Stakeholder course leader Not only in this course but also in a real project you should involve the stakeholders to validate that you are making the correct product Making temporary assumptions is OK but add the fact you made an assumption as comment or tag and let the interface models be reviewed by the stakeholder s User guides are available online http community verum com documentation aspx Use them For more background information please consult the ASD community http community verum com The Alarm System Exercise 2013 Verum Exercise 1A 1 Add methods to an application interface 1 Open ModelBuilder 2 Create new interface model AlarmSystem 3 Create new Application Interface AlarmSystem Add event SwitchOn as valued function Add reply events OK or Failed Add event SwitchOff as void function The Alarm System Exercise 2013 Verum
20. s New Primary Reference Primary reference siren service Siren construction Siren Primary reference windowSensor service Sensor construction WindowSensor Implement component behaviour by filling in SBS making use of the used components used services The Alarm System Exercise 2013 Verum In this exercise you learn to create an ASD design model from an already existing interface model In case the interface model has modelling events the design model could initially have floating states These floating states can be resolved by adding used components and use their output events as input events in the SBS For example the Triggered modelling event is equivalent to the notification event SensorTriggered of the WindowSensor Note however that not all floating states have to be resolved it can happen that the interface model is prepared for failure situations while the used components do not have these failure situations In such cases a floating state can be removed Learning targets e How to create design model from existing interface model e How to add used services e How to fix floating states due to modelling events e Use Sequence Based Specification SBS e How to use the ASD ModelBuilder References course material e Section 4 Sequence Based Specifications Key concepts and best practices e Section 7 ASD Design Models Sequence Based S
21. s triggered Red LED indicates the receiving of notification Triggered before siren is turned on Verify design model Analyse and solve problems Generate code Build integrate and test The Triggered notification is the indication that there is an alarm condition LED is turned red The delay between sending the notification Triggered and the moment that the siren is actually switched on is to give you the opportunity to switch off the alarm system if you have the key The value of the timer can be set by editing the Create Timer t in the Select Actions editor Change argument t in 5 The Alarm System Exercise 2013 Verum 18 Exercise 5B 1 Prevent hard coded values in ASD models 1 Have a look at the following file C DelayTimes h C DelayTimes cs Java DelayTimes java Open design model AlarmSystem dm Change parameter of CreateTimer in C DelayTimes PreAlarmTime C Java DelayTimes PreAlarmTime Generate code Integrate and build Solve compile error see next slide The Alarm System Exercise 2013 Verum In this exercise you learn how to prevent hard coded values as parameter in ASD models and instead decide upon this in the code increases adaptability Learning targets e How use configurable literals as parameter References course material e Section 10 ASD Suite Timers e Section 13 ASD Suite Code generation e Section 14
22. this exercise you learn to retrieve the ASD Runtime and you experience the effort to integrate ASD runtime ASD generated code and other code into a testable product Learning targets e How to download the ASD Runtime e How to integrate ASD generated code with existing handwritten code e Integration easy job if interfaces are precise and complete References course material e Section 13 ASD Suite Code generation e Section 14 Software Integration ASD Runtime and OSAL References user manual s e ASD Runtime Guide The Alarm System Exercise 2013 Verum 16 Exercise 4B 1 Java From the Eclipse menu select File gt Import In the dialog that appears select under General Existing Projects into Workspace Select Next use the browse s button to find the root nas alee directory code java Do a not select Copy projects into workspace Press Finish to add the Alarm System project to your Eclipse workspace The Alarm System Exercise 2013 Verum When ever you have generated new code using the ASD ModelBuilder perform a refresh in the Project Explorer of Eclipse to view the changes The Alarm System Exercise 2013 Verum Exercise 5A Add a delay using the ASD timer Open design model AlarmSystem dm Add used timer component Use lTimer im from lt code_dir gt runtime Use timer value 5 to delay siren in case sensor ha
23. w to use used service references e How to use used service reference state variables and that operator References course material References user manual s e ASD Suite User Manual The Alarm System Exercise 2013 Verum 32 Exercise 12 Using sub machines Open design model SensorProxy dm Create new sub machine e g Deactivating On the transfer interface viaDeactivating Add event entry function Deactivate Add reply event exit function Deactivated Complete SBS of sub machine Deactivating Complete SBS of main machine Call Deactivate and wait for Deactivated Verify design model Analyse and solve problems Generate code Build integrate and test The Alarm System Exercise 2013 Verum In this exercise you learn how you can use sub machines You can use sub machines for a repeating piece of state behaviour or for product life cycle phase like Initialisation Termination Starting Stopping and so on The purpose of the sub machine in this exercise is to take care of all deactivation functionality in the SensorProxy Because the SensorProxy only has to deactivate a set of sensors a separate sub machine may seem a bit overdone but in general it is a good approach a Deactivation sub machine serves as an abstraction for the internal process of deactivation On main machine level you only start the deactivation and wait for the result in a so called super state

Download Pdf Manuals

image

Related Search

Related Contents

Copyright © All rights reserved.
Failed to retrieve file