-
Notifications
You must be signed in to change notification settings - Fork 1
HomeAutomationSystem
Open house.ecorediag in the model folder. The diagram that appears when opening this file is the design of our system.
A House consists of Rooms. Rooms can be connected to other rooms. Each room can have several External Doors and several Windows that can be opened or closed. A presence sensor will tell us if there is some person in the house. A temperature sensor will tell us the external temperature in Celsius as an integer value. A room could have one or more heaters. A house could have several automatic cleaning robots.
closeWindows: Each room has a physical button that calls the closeWindows method that will close all the windows of the room.
presenceGoOutsideEvent: The method must switch off the lights of all the rooms.
globalOpen: The house must have a globalOpen method that will open all the doors and windows of the house. It will return true once it was executed successfully. This method is normally called in case of emergency so for safety reasons the timeout to finish the operation is 2 seconds.
globalClose: The house must have a globalClose method that will close all the doors and windows. If the house has a presence sensor the doors and windows will be closed only in the case that there is no presence in the house. It will return true once it was executed successfully or false in case that there were presence in the house.
adjustHeating: The Heater have a physical button to adjust automatically the temperature. The adjustHeating method must take the value of the temperatureSensor of the house and must automatically set the temperature of the heater based on the following rules:
- Less than 10 (inclusive) of external temperature --> 25
- From 11 to 25 (inclusive) of external temperature --> 20
- Greater than 26 (inclusive) of external temperature --> 15
pathToInitialRoom: The cleaning robot must have a pathToInitialRoom method that returns the path that the robot is going to follow to go to the first room of the house (the first room of the house is the first Room in the rooms list of the house). A Robot cannot go outside the house nor break the walls so it will return null if the initial room cannot be reached. The method must return the shortest possible path.
feed: A room could have one automatic cat feeder. The CatFeeder must have a feed method and a tankItems counter. This method, if the tank is empty returns -1, if everything was ok returns 0 and decrease the tankItems counter, if the feed method was already called less than 3 seconds ago then returns -2. This third case is to avoid several calls by mistake that could overfeed the cat.
To generate automatically the skeleton of the code, open house.genmodel, right click House -> Generate Model Code. This will create the interfaces and in the .impl package we will have the implementations. However, as we can see, the methods that we want to test will have a TODO comment. There is also a Factory to create instances of the house related classes. This is an example of creating a house and adding a room to it.
House house = HouseFactory.eINSTANCE.createHouse();
Room room = HouseFactory.eINSTANCE.createRoom();
house.getRooms().add(room);
-
Prioritize the Unit tests using a Risk Priority Table for all the requirements. Justify each row and discuss the ranking. The columns are: Feature (name), Occurrence Likelihood (1 to 3 which is Low to High), Failure Consequence, Priority (L x C)
-
Create Unit tests for all the requirements and create a TestSuite. Justify the design decisions of the Tests.
-
Imagine a new functionality of the House then create a specification that could serve as oracle and provide test cases to test it. Add these tests to the Test suite. Explain and justify the test cases.
-
Implement the production code (except the pathToInitialRoom method) and check that all tests on the Test Suite are passed (except the pathToInitialRoom method tests). Export the JUnit report (xml file). In the methods that you implement remember to change the EMF annotation @Generated to @Generated NOT. Otherwise they will be removed if you regenerate the model code.
-
Create screenshots of the Control Flow Graphs of all the production code implemented in previous point. (Using Source Code Visualizer).
-
Create and export an EclEmma report of the coverage of the TestSuite. Discuss the global coverage of instructions, branches, lines and methods of the whole project. Discuss the coverage of a class of your selection relating it to the Control Flow Graphs.
Important notes
-
In the design, the return type of the methods are not specified (void)... You can change it in the generated source code in the corresponding interface and impl classes. Do not forget to add NOT in @Generated NOT to avoid losing these changes if you re-generate the model code (through the house.genmodel). As alternative, you can change the properties of the method in the design diagram and select the correct EType attribute.
-
In the design, some elements are missing... Add temperature attribute (int) in the Heater, and add presenceSensor (boolean) in the House. Instead of modifying it in the ecorediag file, you can modify it in the ecore file because these two files are synchronized.
Frequently asked questions
- The ecorediag is not opened as a diagram, why? Check that you are using the Eclipse version recommended for the exercises. Download Eclipse Kepler Modeling