- Why only one commit
- Functionality describtion
- Configuration files
- Possible values
- Launching
- Reports
- Design patterns used
- Functional requirements
This project has been implemented as a semestral work in university, so original git repository is in private university's system. I found it impossible to fork it with keeping commits history.
The application reads a file of configuration, which is loaded by name as arguments of the program (view Launching) as well as filenames of reports. During the simulation, every living creature acts randomly (within defined limits and rules) and interacts with devices. Some devices such as cercuit breakout and fire alarm can react to outer events.
All events that had place during the simulation are written to reports in chronological order.
In our program you can choose your own home configuration. This configuration you should right in the file using .XML or .JSON format according to the structure:
-
DaysCount
-
Floor 1
- number
- Room 1
- name
- Device 1
- Device 2
- Room 2
- name
- Device 1
-
Floor 2
- number
- Room 1
- name
- Device 1
- Device 2
- Device 3
-
Living 1
- stuff
- name
- floor number
- room name
-
Living 2
Attention!!!
In case .xml file is sent as config file, the app will create identical .json file. So if you have 2 different configurations (in .xml and .json format) but with same name, (Ex. config.xml and config.json), rename one of them so the app does not delete your config.json
- room name: Bathroom, Bedroom, Garage, Kitchen, LivingRoom, Toilet
- device name: Bath, Car, CircuitBreaker, Console, Cooker, FireAlarm, Fridge, Heating, Light, Rag, Remote, Skis, Television, Thermometer, Washer
- living stuff: Father, Mother, Son, Daughter, Cat, Dog
- living name: Whatever you want
- floor number and room name: this floor and this room must be at home
Also there are some rules for the configuration:
- Home must have at least 1 floor
- Each floor must have at least 1 room
- Each room must have at least 1 device
Examples for configuration are in the foulder "configurations"
To launch the application you need to start it with 4 parameters:
- name of configuration file
- name of file for the Event Report
- name of file for the Consumption Report
- name of file for the Activity And Usage Report
- In EventReport we have all events, which happened in the house
- In CosumptionReport we have information about the amount of water, gas and electricity that was used by each device
- In ActivityAndUsageReport we have information about which person switched a device on and how many times they did it
-
Singleton
Classes House, SmartHome, EventObserver, all classes that are responsible for reports
-
Observer
EventObserver notifies classes that implement EventListner interface
-
Builder
Classes RoomBuilder, FloorBuilder, StrategyBuilder
-
State machine
Devices can be Active, Broken and Broken. Each state defines device's behavior and can only be changed according to defined rules
-
Strategy
Every living creature chooses new strategy for each day, which defines it behaviour
-
Decorator
Every living creature reacts differently to same events. This is implemented with update() method in interface Eventlistener. Each class calls update() method of its parent and than adds it's own reacts, which is special for it.
-
Chain od responsibility
In case someone broke a device, son tries to repair it (in case son is present in the house). If he succeeds, the device can be used again. If he did not, he asks father to help
-
Adapter
Class XMLtoJSON creates .json file out of .xml to read the configuration
-
Lazy loading
All the events are stored ass class instances and are converted to strings only when it is requested
-
Marker
Empty interfaces PersonStrategy and PetStrategy make using unappropriate strategy impossible
-
Null object
NoRoom class is used instead of null in order to avoid NullPointerException