程序代写代做 graph go C Java The University of Queensland

The University of Queensland
School of Information Technology and Electrical Engineering Semester 1, 2020
CSSE4004 – Assignment 1 (Version 2) Due: 5pm on Tuesday 28/04/2020 Weighting: 25%
Changelog
Section 2.0:
Clarification that the context manager should receive a message from the weather alarm every 60 seconds.
Section 2.1:
Clarification that you need to execute an instance of AllSensors for each user that you have (e.g. Bryan and James).
Section 4:
The number for each subsection has been fixed. There was previously a repeated heading number.
Section 4.1
has been created from information at start of section 4. Clarification has been provided for whether indoor and/or outdoor locations must be returned for temperature threshold warning, APO threshold warning, and global weather alarm.
Sections 4.6, 5.1 & 5.2:
The format and purpose of requests made from the context manager to the preference repository has been clarified. This includes simplifying the process for temperature threshold, where “TEMP” is now passed instead of the temperature value from the sensor.
It has been clarified that the Context Manager must establish whether locations are indoors or not (instead of the Preference Repository – this was noted on Piazza as being unclear before). The Preference Repository only returns (to the Context Manager) a list of suggestions based upon the alarm type. The Context Manager then has to tell if there is a weather alarm when a temperature threshold is reached (where is must only suggest indoor locations) and suggest applicable locations. The Context Manger is also responsible for always suggesting only indoor locations for APO threshold alarms.
Section 6.1:
Clarification has been provided that multiple versions of the AllSensors program are to be running at any given time, and each instance of EnviroAppUI can only communicate with one AllSensors program at a time.
Clarification that the other programs should only stop if the last EnviroAppUI exited.

Section 6.2:
Subheadings added to section.
Information to be printed to screen is improved so that it is clear whether suggested locations are indoors, outdoors, or both.
The need to print the global weather alarm status whenever there is a temperature threshold warning has been added (this will make it easier to debug and mark your assignments).
Section 9:
Changes to the number of run configuration has been noted to reflect that AllSensors needs to be run twice.
Section 10:
Clarified that printing only needs to be for RMI only.
Section 11:
Section explaining the need for input file validation has been added, based on instructions from Piazza.
Appendix A:
Output updated to match what is expected from current version of specification. Amended issue where outdoor locations were previously suggested for an APO threshold alarm.
Figures throughout:
Updated to reflect specification updates.
Files Changelog
preference_file.txt updated. “jamesgover” changed to “james” to match the sensor file names.
AllSensors.launch deleted. Replaced with AllSensorsJames.launch and AllSensorsBryan.launch
AllSensorsJames.launch changed so input argument is “james” instead of “jamesgover”.
“Run All Components Except User Interface.launch” updated so that it launches both AllSensorsJames.launch and AllSensorsBryan.launch.
1. Introduction
In this assignment, students will be required to develop an application, namely Enviro Smart, which makes use of sensed environmental and weather information to provide users with suggestions and warnings on their potential risk from the current environmental conditions. This sensed environmental information is also referred to as “context information”. Applications that adjust to changes in context information are considered to be context-aware and fall under the research field of pervasive computing.
Using the context-aware Enviro Smart application, users will be able to receive warnings when various environmental conditions such as incoming heavy rain or the air pollution level is above a predefined threshold as well as receive suggestions for activities/places that will minimise the exposure. These suggestions are based on user-specified preferences.

The Enviro Smart application will make use of the both Remote Method Invocation (RMI) and Publish/Subscribe architecture for communication between its components.
1.1 Ice Distributed Computing Platform
You will be introduced to Ice in the lab class tasks.
Ice provides two communication paradigms: RMI and notifications (publish/subscribe). You should use both in the assignment and for this you need to evaluate which communication should be of the type RMI and which one is more suitable for publish/subscribe.
Publish/subscribe is provided in Ice by IceStorm, as discussed in the labs.
1.2 Assignment components
We assume for the scenario used in this assignment that each person will have the latest smart watch. The smart watch has several sensors or sensor-like devices (accelerometer, GPS, light, microphone, camera). However, for the purpose of this assignment we assume that our smart watches not only have an improved location sensor that can work indoor and outdoor (not only outdoor as GPS does), but also include an Air Pollution (AP) sensor that can measure Air Quality Index (AQI), a temperature sensor, and also a weather alarm.
The readings from the sensors are gathered by a Context Manager as described in the following sections. The location information produced by the location sensor is pre-processed by a Location Server before it is sent to the Context Manager. The Context Manager evaluates the context (such as the current temperature, AQI, and location) and issues warnings to the user if an AP overexposure (APO) threshold or a temperature threshold is reached, or a weather alarm is triggered. The Context Manager also provides suggestions on alternative places/activities based on user preferences. The application has a user interface that allows multiple users to query the application on items of interest.
The application, Enviro Smart, has the following components:
• Sensors (Location sensor, Air Pollution (AP) sensor and a Temperature sensor). AllSensors.java
• Weather alarm provides alarms on extreme weather conditions such as heavy rain, hail storm, strong wind. WeatherAlarm.java
• A Location Server provides Indoor/Outdoor mapping of location coordinates to Context Manager. LocationServer.java
• A Context Manager evaluates extreme weather warnings, current temperature and APO thresholds so as to make appropriate suggestions to users based on user preferences captured in the Preference Repository. ContextManager.java
• A Preference Repository responds to queries issued by the Context Manager regarding preferences on how the application should make recommendations to users. PreferenceRepository.java
• User Interfaces for users to manage the Enviro Smart application. EnviroAppUI.java

For this assignment, we are not interfacing with actual physical sensors. Instead, your sensor components will simulate sensor behaviour by reading values from files, and exporting that sensor data in the appropriate manner for consumption by other system components.
Students are asked to figure out the order in which the components should start, the order in which they exit, and which communication paradigm (RMI or Publish/Subscribe) to use when communicating between each component.
1.2 Deliverables
For this assignment, you will deliver:
• Java programs for each of the system components described and named in Section 1.1
• Associated ICE data files, including ‘Slice’ files necessary to build and run the full system
• Test data files that define the behaviour and sensor data produced by the various components,
according to the specifications in Sections 2 through 5 below
• A PDF document describing your design (see Section 10 for details).
See Section 11 for full details on deliverables.
2. Sensors and global weather alarm
The context-awareness of the Enviro Smart application is based on context information collected by three types of sensors and a global weather alarm. These are:
• A temperature sensor that produces integer readings in the range 0 to 50
• A location sensor that monitors the user’s location.
• An AP sensor that shows the current level of air pollution in the unit of AQI (Air Quality Index) from 0 to 200.
• A global weather alarm that returns monitoring of extreme weather. The value is one of these integers:
o 0 – normal weather condition – no alarm is triggered and no weather warning is delivered o 1-heavyrain
o 2-hailstorm
o 3 – strong wind
All sensors produce readings every second. The information sent by sensors is in the format: username, sensor type, sensor reading.
The context manager should receive a message from the weather alarm every 60 seconds. 2.1 Starting the sensors and the weather alarm
The temperature sensor, the AP sensor and the location sensor are all started in Eclipse together at the same time in one java file, AllSensors.java, accepting the following argument:

[username]
where [username] is the name of a user logged into a user Interface, and every user has his/her own sensors.
AllSensors reads in three different predefined files at start-up. The three files contain readings of the three sensors for each person.
The name of each predefined files must be named:
Temperature.txt AQI.txt
Location.txt the format:
e.g. JamesTemperature.txt
e.g. JamesAQI.txt
e.g. JamesLocation.txtEach line of the predefined files is in
value, number of seconds
value is the value that should be in the update notification.
number of seconds is the number of seconds that value should be used.
The sensors produce the “value” every second for “number of seconds”.
An example content for the predefined file of the location sensor for Alice (i.e., AliceLocation.txt) are as follows:
A,20 C,10 B,20 D,10
This can be interpreted that the location sensor will report the user to have the location A for the first 20 readings (seconds), then the location B for the next 10 seconds then the location C for the 20 seconds after that. The location of the user will then be D for 10 seconds.
Once the end of the file is reached, the sensor will return to the beginning i.e. after sending D for 10 seconds, the location tracker will send A for 20 seconds and so on until the application exits.
NOTE:
You are required to run the sensors for each users at the same time. Therefore, you will need to start one instance of the AllSensors program for each user which is present in your program (the example users here are Bryan and James). You will do this using different Run Configurations, one for each of the users (e.g. AllSensorsBryan and AllSensorsJames).
See section 6.1 for more information.

2.2 Shutting down the Sensors and weather alarm
The sensors and weather alarm shut down (and stop sending information) when the user exits the User Interface.
3. Location Server (LS)
The Location Server receives location coordinates from the location sensor, determines the current indoor/outdoor status of the user, and forwards these context information to the Context Manager. The mapping of the status to location coordinates is specified in the server’s configuration file using the following structure:
Status : Location Coordinates Indoor : A, B,
Outdoor : C, D,
The server notifies the Context Manager about the current location coordinate of the user and its indoor/outdoor status. The server also is responsible for returning a list of all indoor locations to the Context Manager upon request.
The Location Server is started in Eclipse, and must take the following argument:
location_file.txt
where location_file.txt is the file containing the mapping of the indoor/outdoor status to location coordinates.
4. Context Manager (CM)
4.1 Context Manager Overview
The Context Manager:
• gathers information about Air Quality Index (0-200), weather alarm, and user location from sensors.
• gathers personal information about temperature threshold and air pollution tolerance threshold of a user from the Preference Manager.
• calculates a threshold for AP overexposure, and sends a warning together with suggestions of items of interest when the APO threshold of the user is reached.
o ThesuggestionsforAPOarebasedonuserpreferencesandtheymustbelocatedindoors.
• evaluates temperature and sends a warning together with suggestions of items of interest when the
temperature threshold for a user is reached.
o The suggestions are based on user preferences, and the locations may be indoors or outdoors.

• evaluates the weather alarm status, and sends a warning together with suggestions of items of interest
o Thesuggestionsforweatheralarmarebasedonuserpreferencesandtheymustbelocated indoors.
• responds to queries from the User Interface. 4.2 Evaluating AP Overexposure (APO)
The AQ Index (AQI) gives an indication of the level of air pollution and the potential danger of exposure to air pollutants. The Context Manager uses AQI, personal medical type and duration of AP exposure to calculate an AP Overexposure (APO) threshold. The following AQI exposure recommendations is used by the context manager in the evaluation of a user’s APO threshold.
AQI Air Quality Recommendation
Base time
0 to 50 Good You can safely enjoy being outside!
30 seconds
51 to 100 Moderate
People with medical conditions should consider reducing prolonged or heavy exertion.
15 seconds
101 to 150
Unhealthy for People with heart or lung disease, older adults, and Sensitive Groups children should reduce prolonged or heavy exertion.
10 seconds
People with heart or lung disease, older adults, and 150 to 200 Unhealthy children should avoid all physical activity outdoors. Everyone should avoid prolonged or heavy exertion
5 seconds
Table 1. AQI exposure recommendations
A AP Overexposure Threshold of a user is calculated by multiplying a Base Time of the current AQI (according to Table 1) and the user personal reference to air pollution level (i.e., APO Threshold = Base Time * Medical Condition Type).
Medical condition types are categorised as follows:
Medical Condition Type 1: People with heart and lung disease, and asthma
Definition: People with heart or lung such as coronary artery disease, congestive heart failure, and asthma or chronic obstructive pulmonary disease.
Medical Condition Type 2: Children and old adults
Definition: Children age between 0-17 and old adults age above 45.
Medical Condition Type 3: Healthy adults
Definition: Adults age between 18-45 without medical history relevant to lung and heart diseases
The medical condition type of particular users is stored in the Preference Repository. The context manager queries the Preference Repository for the medical condition type when the user first login to the User Interface.

A user is considered to be overexposed when the AP Overexposure Threshold is said to be reached. That is, when the amount of time a user has been located outdoor is greater or equal to the current APO threshold of the user (i.e. APO Threshold reached = outdoor time ≥ APO threshold).
For example, for user with Medical Condition Type 2 exposed under an AQI of 90, the APO Threshold is 30 (2*15 seconds). The threshold will be reached when the user spent 30 seconds or more in outdoor locations.
When a user is overexposed (or the APO threshold is reached) the Context Manager will send an AP Overexposure Warning to the particular user, and make suggestions for items of interest base on his/her preferences, providing the items of interest are located indoor. The Context Manager is required to query the location server regarding a list of indoor location, so as to make appropriate suggestions to users.
NOTE:
• The timer (for counting the outdoor duration of a user) starts counting from zero when: (1) the user moves from an indoor to an outdoor location, or (2) there is a change to current AQ Index (the APO threshold of the user is also re-evaluated).
• The timer continues to count when the user moves from an outdoor to an outdoor location, providing the AQ Index stays constant and the APO threshold for the user has not been reached.
• The timer stops counting when: (1) the user is located indoor, or (2) the APO threshold is reached. 4.3 Evaluating weather alarm
The weather alarm takes the highest priority in suggesting users to stay outdoor or to move indoor. The alarm events must be stored in a predefined weather_alarm.txt file. The context manager queries the next weather alarm every 60 seconds.
When a weather alarm is triggered (i.e., warning of incoming heavy rain or strong wind), the Context Manager will send a Weather Warning event to the user and make suggestions for items of interest base on user’s preferences in any location.
In addition, because the weather alarm has the highest priority in suggesting users to stay outdoor/indoor, the Context Manager will only give suggestions which are located indoor until the weather condition has changed to ‘normal’ (i.e. no alarm). This means that when there is active weather condition, the locations returned for temperature threshold warnings must be indoors (suggestions are already always indoor locations for APO threshold warnings).
4.4 Evaluating temperature
The temperature threshold for a particular user is stored in the Preference Repository. The context manager queries the Preference Repository for the temperature threshold when the user first login to the User Interface.
When the threshold is reached (i.e., the current temperature is equal to the threshold predefined in the user preference), the Context Manager will send a Temperature Warning to the user and make suggestions for items of interest base on user’s preferences in any location.

NOTE:
• When a temperature threshold is reached, the temperature is not evaluated again until there is a change of temperature.
4.5 Storing information about the city
The Context Manager maintains a knowledge base which it populates using a city information file read at start-up.
This file contains a number of entries corresponding to items of interest within the city. Each entry has:
• a unique name for an item of interest, indicated with name
• a location coordinate exists in the accepted by the Location Server (such as A, B, C, D).
• a short paragraph of information about the item of interest
• a list of services offered at the item of interest An example of an item of interest entry in the file is:
name: Indooroopilly Shopping Centre
location: A
information: Indooroopilly Shopping Centre is a major regional shopping centre in the western suburb of Indooroopilly, Brisbane, Queensland, Australia. It is the largest shopping centre in the western suburbs of Brisbane, by gross area, and contains the only Myer store in that region.
services: cinema, restaurants, pool, shops
name: Garden City
location: B
information: Garden City Shopping Centre is located 10km South of the Brisbane central business district (CBD) and includes Myer, David Jones, Hoyts Cinema, Freedom and over 230 specialty stores. services: cinema, restaurants, pool, shops
name: South Bank Parklands
location: C
information: The South Bank Parklands area was created as part of the rejuvenation
of the industrial water front undertaken for World Expo 1988. The Parklands area contains many shops, a cinema complex, and a large number of restaurants as well as a man-made beach. A river promenade stretches the length of South Bank Parklands.
services: restaurants, pool, shops, Ferris wheel
name: Brisbane City
location: D
information: The Brisbane central business district (CBD), or ‘the City’ is located on a point on the northern bank of the Brisbane River. The triangular shaped area is bounded by the Brisbane River to the east, south and west. The point, known at its tip as Gardens Point, slopes upward to the north-west where ‘the city’ is bounded by parkland and the inner city suburb of Spring Hill to the north. The City is bounded to the north-east by the suburb of Fortitude Valley.

services: restaurants, shops, market, bowling
name: Grey Street
location: C
information: Grey Street is south of the South Bank Parklands and hosts many restaurants and bars. The street is 1.4km in length and is home to attractions such as the Cineplex Cinema, Queensland Museum and Brisbane Convention & Exhibition Centre.
services: restaurants, cinema, conference centre, museum
Note: If you are using real-world points of interest (this is optional), the places of interest for a given location should be reasonably close by so this does not confuse the user (e.g. South Bank Parklands and Grey Street are both close to Location C).
4.6 Making suggestions to users
The Context Manager makes suggestions of items of interest when either a weather alarm is triggered, or the AQI or temperature thresholds of a particular user is reached. In order to take into account the user preferences, the Context Manager must indicate to the Preference Manager which threshold has been reached. Refer to sections 5.1 and 5.2 for more details on the formatting of these requests.
[Username], weather in the case when a weather alarm has been triggered, or [Username], APO in the case when the APO threshold has been reached, or [Username], TEMP in the case when the temperature threshold has been reached.
The Preference Repository returns a list of services the Context Manager should suggest to the user. The weather alarm, which is updated every 60 seconds, has the highest priority. Should both temperature and APO threshold are reached at the same time, the APO threshold take higher precedence, and the Context Manager should only request a list of services corresponding to the APO preference.
Upon the return of the list of services from the Preference Repository, the Context Manager sends a list of items of interest that provide those services to the User Interface of the Enviro Smart Application, but:
• ensures these items of interest are located indoor if the user’s AP threshold is reached.
• ensures these items of interest are located indoor if the user’s temperature threshold is reached
and there is a current weather alarm.
To determine whether a list of items of interest is located indoor, the CM queries the Location Server regarding the indoor/outdoor mapping of the location of the list of items. Such query should be made to the Location Server for every suggestion.
4.7 Responding to queries from User Interface
The Context Manager is also required to respond to queries issued by the User Interface. Two queries are supported:
• Search for items of interest in the current location

• Search for information about a specific item of interest Search for item of interest in the current location
The Context Manager responds with an item of interest in the user’s current location.
Search for information about a specific item of interest
The Context Manager searches for the specified item of interest in its knowledge base and returns the information associated with that item of interest.
More detailed information regarding how the queries are generated is specified in the User Interface section 6.1.
4.8 Starting the Context Manager
The Context Manager is started from Eclipse, accepting the following argument:
cm_file.txt
where cm_file.txt is the name of the text file containing the information about the city.
4.9 Shutting down the Context Manager
The Context Manager shuts down automatically when all User Interfaces have exited. The shutdown process of the Context Manager involves deregistering its subscriptions with Ice Storm and exits. The exit will also trigger shutdown of other components.
5. Preference Repository (PM)
The Preference Repository stores user preferences and evaluates these preferences when requested by the Context Manager.
5.1 Preference format
A weather alarm preference is in the following format: when weather suggest [service]
An APO preference is in the following format:
when APO suggest [service]
A temperature preference is in the following format: when TEMP suggest [service]
[service] is the name of a service (e.g., shops) provided by item of interests
APO is just a word indicating the user is being overexposed to air pollution.
Preferences must be loaded from a preference file when the Preference Repository starts up.

The preference file contains multiple users. For each user in the file, there is:
• exactly one temperature preference
• exactly one weather alarm preference
• exactly one APO preference
The preference file is formatted as follows:
• Each entry has the name of the preference owner
• Each field in the entry is terminated with a new line character
• Each entry is separated from other entries by an empty line
An example entry in the preference file is:
name: bryan
Medical Condition Type: 2
pref-1: when TEMP suggest pool pref-2: when APO suggest cinema pref-3: when weather suggest cinema
5.2 Preference Evaluation
//temp. threshold example //APO threshold example //weather alarm example
Preference evaluation is initiated by a request from the Context Manager when either:
• The temperature threshold is reached
• The APO threshold is reached
• A global weather alarm is triggered
If the temperature threshold is reached, this request contains:
• the name of the user whose preferences should be checked
• the word “TEMP”
If the APO threshold is reached, this request contains:
• the name of the user whose preferences should be checked
• the word “APO”
If the weather alarm is triggered, this request contains:
• the name of the user whose preferences should be checked
• the word “weather”
The Preference Repository checks the preferences for the specified user to see if the there is a preference for the temperature threshold, APO threshold, or weather alarm, respectively. The preference information must then be returned to the Context Manager as a result of the request.

The Context Manager will then be responsible for suggesting locations that are appropriate based on the current status of the global alarm.
5.3 Starting the Preference Repository
The Preference Repository is started from Eclipse, accepting the following argument:
preference_file.txt
where: preference_file.txt is the name of the file containing the user preferences.
5.4 Shutting down the Preference Repository
The Preference Repository shuts down when it receives a notification from the Context Manager instructing it to do so. The Preference Repository deregisters its subscription with Ice Storm before exiting.
6. The User Interface (UI)
The Enviro Smart Application provides an interface through which users can issue queries for information about the city, and also receive warnings and suggestions based on predefined preferences when user’s APO threshold is reached.
Users interact with the Enviro Smart Application using a text-based menu. User menu choices must be read off standard in. All spec-related Enviro Smart Application output is printed to standard out. All non-spec Enviro Smart Application output must be printed to standard error.
6.1 Initialisation and queries
The Enviro Smart Application initially asks for a name of the user:
Context-aware Enviro Smart Application
Please enter your user name: If an invalid name is entered, an error message must appear, and the
program must terminate.
Error: The provided name was not found. Please check the name, restart the user interface, and enter the name again.
NOTE:
You will set up and start running the AllSensors program for each user, then utilise the EnviroAppUI menu to indicate which user you wish to obtain information about. The AllSensors programs are not started based upon the username entered in the EnviroAppUI menu.
This means that although multiple versions of the AllSensors program are running at any given time (one for each user), you will only be able to use the menu to see information for one user. To be able to see information from the other user, you will need to stop the EnviroAppUI program from running, then start it running again. Or run another EnviroAppUI.

• This is to make the solution implementation easier; this is not an ideal real-world solution. You are not expected to implement a method which allows the user to change the username once the program has started.
• you should be able to concurrently start multiple separate instances of the EnviroAppUI program, then enter different usernames into the multiple console windows in Eclipse. This will allow you to engage with each of the AllSensors programs that are running, one in each console window.
Then a main menu will initially appear as:
Context-aware Enviro Smart Application Main Menu
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
The user then has the option of selecting 1, 2 or E.
Option 1: Search for a specific item of interest
The user is presented with a prompt requesting the name of an item of interest.
Please enter name of item of interest:
The user enters the name of an item of interest. A request is then made to the Context Manager querying for information on the item of interest.
The information returned by the Context Manager is then displayed on the screen in the format:
Information about

If a user searched for South Bank Parklands the following would be printed:
Information about South Bank Parklands:
The South Bank Parklands area was created as part of the rejuvenation of the industrial water front undertaken for World Expo 1988. The Parklands area contains many shops, a cinema complex, and a large number of restaurants as well as a man- made beach. A river promenade stretches the length of South Bank Parklands.
If the item of interest is not recognised (not in the city information file) the Enviro Smart Application prints the following:
No match found for item of interest
Irrespective of whether the query succeeds or fails, pressing the Enter key should return the user to the Main Menu.
Option 2: Search for items of interest in current location

A request is made to the Context Manager querying for the names of items of interest in the user’s current location. For example, the current location of the user is A and A has two items of interest (South Bank Parklands and The IMAX cinema), the Context Manager will respond with a list of names of items of interest in the user’s current location (printed one per line) as below:
The following items of interest are in your location: South Bank Parklands
The IMAX cinema
If there are no items of interest in the user’s current location, the following message is printed to the screen:
There are no items of interest in your current location.
Irrespective of whether the query succeeds or fails, pressing the Enter key returns to the Main Menu.
Option E: Exit
A message is sent to the Context Manager informing it that the Enviro Smart Application is exiting. The Enviro Smart Application then deregisters with the Ice Storm and exits.
The other programs should only stop if the last EnviroAppUI exited.
6.2 Receiving warnings and suggestions
Weather Alarm
If a weather alarm is triggered, the Enviro Smart Application will issue a warning of the following format:
—————— ——————
Warning, EXTREME WEATHER is detected, the current weather alarm is
Current location:
Suggestion – please go to an indoor at one of these locations: , .
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
APO Threshold Alarm
If user’s APO threshold is reached, the Enviro Smart Application will issue a warning of the following format.
—————— ——————
Warning, SIGNIFICANT AIR POLLUTION LEVEL detected, the current AQI is (user limit is ).

Current location:
Suggestion – please go to an indoor at one of these locations: , .
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
Temperature Threshold Alarm
If user’s predefined temperature is reached, the Enviro Smart application will issue a warning with the menu appear as:
—————— —————— Warning, TEMPERATURE is now (user limit is ). Current location:
Current weather alarm status:
Suggestion – please go to an at one of these locations: , .
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
General Information
Suggestions are printed out as soon as they are received. It may happen that a suggestion is printed to the screen while a user is typing information for one of the other menu options. This is acceptable behaviour for the Enviro Smart Application.
6.3 Starting the Interface of the Enviro Smart Application
The Enviro Smart Application is started in Eclipse, taking no arguments.
7. Designing the start and exit of the application and choosing appropriate communication paradigms
It is necessary to design the order in which the components start and exit, as well as determine the communication paradigm (i.e., RMI and/or Publish/Subscribe Notification) employed between each component.

The final electronic submission must include a file called “Design details”. This file must describe this design, and annotates Figure 1 below with appropriate arrows to show all the communications that occurs between components. Each annotated arrow must have a number associated with it for identification purpose when completing Table 2 below the figure. There can be more than one arrow between two components, and each arrow should occupy at least one row in the table.
Figure 1.
Table 2.
8. Eclipse Project Structure
In order to aid your project to be marked in an efficient manner, your Eclipse project must adopt the
following file structure.
This assignment includes numerous components which must work together correctly. If there are any issues with your assignment submission (including those you may not be aware of) which prevent it from running correctly, it may take the assignment marker time to locate the issue and resolve it. This will impede the marking process, meaning that you may not receive feedback as quickly. Please use the exact folder names and files names presented here to reduce the possibility of this from occurring.
The following java files must be inside the src/components package (rename the default package to “components”). If the package is not named “components” then the provided Run Configurations (see section 9) will not work.
• AllSensors.java
• ContextManager.java
Arrow Num.
Sending Component
Receiving Component
Communication paradigm
Brief description of the communication taking place
e.g., 1
Sensor 1
Server A
Publish/Subscribe
Sensor 1 sends sensor readings to Server A



• EnviroAppUI.java
• LocationServer.java
• PreferenceRepository.java • WeatherAlarm.java
Slice files must be placed inside a folder named “slice”.
• The number of slice files is not specified as this is something you are required to work out. You
may name the slice files anything you wish, as long as it has a meaningful name.
• The contents of the “generated” folder will be automatically created (by the Eclipse Ice Builder
plugin) based upon the contents of your slice files.
ice.jar and icestorm.jar must be placed in a folder named “jarfiles”.
• Ensure that these two libraries are included in the Java Build Path.
All config files must be placed inside a folder named “configfiles”. E.g. • config.icebox
• config.sub
All data files must be placed in the root directory of the Eclipse project (please do not place these files inside another folder).
• The purpose of this is to simplify the process of accessing these files using the command line arguments as required above.

9. Run Configurations and Launch Group
Your project will include in six java programs (mentioned in section 1.1) which will need to run concurrently (all on the one computer) to perform correctly. Note that AllSensors runs several times, once for each user. This makes a total of seven java programs.
To simplify the process of starting six programs at once in Eclipse, you will use a Run Configuration for each program. A Run Configuration allows us to specify the initial conditions for running the program, including the necessary input arguments.
• Seven Run Configuration files have been provided on blackboard. These must be used (by the Launch Group noted below) to run your programs.
• There are Run Configurations for each of the following files: AllSensors.java (2 – one for each user James and Bryan), ContextManager.java, EnvrioAppUI.java, LocationServer.java, PreferenceRepository,java, WeatherAlarm.java. Each Run Configuration includes the input arguments for each respective program.
A Launch Group allows several Run Configurations to be started at the same time (and in a specific order). Using a Launch Group which will enable all six programs to be started at the same time.
• A Seven Launch Configuration file has been provided. These must be used to run your programs in your final submission.
Instructions for setting up and using the Run Configurations and Launch Group provided on blackboard are shown in Appendix B.
10. Showing communication between programs on the consoles
For each of the following programs you must print a log message to the console when data is sent or received from another program (e.g. via RMI or Publish-Subscribe).
• AllSensors
• ContextManager
• LocationServer
• PreferenceRepository • WeatherAlarm
The purpose of this is to assist both yourself and your assignment marker to understand the communication that is occurring in real-time between the various components in the overall system. Providing this log on each console will also help with debugging.
The format of these messages must be:

• The PreferenceRepository console should log: 11:10:15 Sent ContextManager “data value”.
• And the ContextManager console should log: 11:10:15 Received PreferenceRepository “data value”
Note: The EnvrioAppUI program only needs to show the information described in section 6.
11. Input Data File Validation
For each data file that you read data from, you need to implement checks to ensure that the nominated file exists, and can be opened. However, you can assume that the file will use the correct format (as long as you use the files provided on blackboard).
This includes the following files:
• cm_file.txt
• location_file.txt
• preference_file.txt
• weather_alarm.txt
Temperature.txt
AQI.txt
Location.txt
Temperature.txt
AQI.txt
Location.txt
e.g. JamesTemperature.txt e.g. JamesAQI.txt
e.g. JamesLocation.txt e.g. BryanTemperature.txt e.g. BryanAQI.txt
e.g. BryanLocation.txt
If the file does not exist, print the following message to the user on the console, then exit the program: “Error: Cannot access . Check the file name, and that the file exists. Program exiting.”
If the file exists but cannot be opened (e.g. it might be corrupted), print the following message to the user on the console, then exit the ContentManager program:
“Error: Cannot open . Verify that the file can be opened. Program exiting.”
12. Assessment
Marks are allocated for the different components of the assignment as follows:
Assessment item
Marks allocated
Design Details File
– describes the appropriate design of the start and exit of the application, including the order in which the components start and any assumptions which have been made
5

– annotated Figure 1 is included with appropriate arrows to show all the communications that occurs between components
– Table 2 is included and describes each annotated arrow in Figure 1 including the arrow number, sending component, receiving component, communication paradigm, and brief description
Context Manager
– correctly responds to Enviro Smart Application queries – correctly evaluate APO and temperature threshold
– correctly deliver extreme weather warnings
– correctly makes suggestions and warnings
– request to shutdown supported as per specification (i.e., shutdown when all UIs have exited)
7
Preference Repository
– responds to queries as per specification – correctly evaluates user preferences
3
Sensors
– all types of sensor supported
– sensors provide appropriate readings
– deregistration of subscription on IceStorm and exiting when receiving shutdown notification
– each user has data sensors running via separate AllSensors instances
3
Location Server
– location mapping supported
– forward location and indoor/outdoor status to context manager as per specification
– deregistration of subscription on IceStorm and exiting when receiving shutdown notification
2
Enviro Smart Application
– user interface as per specification
– queries sent to Context Manager
– correctly output suggestions and warning – support multiple users
– issues shutdown request, deregister subscription on IceStorm and exits
3

General
– Ice Version 3.7.0, coding style and documentations (code commented, neat layout, minimal spelling and grammar mistakes)
2
TOTAL
25
Partial marks will be awarded for assignments that are missing components, do not compile, or only partially fulfil the stated specifications. Assignments will be returned to students no later than 2 weeks after the assignment submission deadline. Assignment marks will be accessible on the course website.
13. Submission details
The assignment must be submitted as a zipped file through Blackboard by the 5pm deadline on Tuesday 21/04/2020. Students may submit their assignment multiple times, but only the latest submission will be marked. Unless advised in the Course Profile, assessment items received after the due date will receive a zero mark unless you have been approved to submit the assessment item after the due date.
You are required to submit the “Design details” file. The must be either a Microsoft Word or PDF file. You are required to submit a zip (.zip) file of your entire Eclipse project (see how below).
i.e.
• This includes the Design details” file
• This includes all .java files mentioned in section 1.2
• This includes any “helper” classes
• This includes all configuration files
• This includes all Slice files
• This includes all Run Configuration files (at least the 6 provided) and the Launch Group (at least
the 1 provided)
• This includes the text files:
o city information file for the ContextManager
o preference files for the PreferenceRepository
o predefined files for each of the sensors including:
▪ location files for each user
▪ temperature files for each user ▪ air quality files for each user ▪ etc.
To make a .zip file of your Eclipse project:
1. Locate the folder on your computer which contains the Eclipse project (this will be inside your Eclipse workspace).
2. Place your “design details” file in the folder on your computer which contains the Eclipse project.
3. Right click the folder > Send to > Compressed (zipped) folder.

4. Title the zipped folder with the following format:
____a1.zip
e.g.
14. Updates to the specification
Clarifications and updates to this specification may be made up to one week prior to the submission deadline. If such clarifications or updates are made they will be communicated to students via the Discussion Board on Blackboard and also emailed directly to students’ UQ email accounts. It is expected that students will check the course discussion board and their email on a daily basis.
15. Plagiarism
The assignment should be an individual work. All students should read and understand the University’s policy on plagiarism. Any cases of plagiarism detected will be dealt with according to the University’s Plagiarism Policy.
Please be aware that all work may be checked for academic integrity using tools including, but not limited to, Measure of Software Similarity and TurnItIn.

Appendix A: Example Output
The information below is designed to show students what the output may look like. This will depend on the context-dependant information for each student in their predefined files for each of the sensors. It is not expected that students will have this exact output, and is only meant to act as a guide. User input is in green.
Context-aware Enviro Smart Application
Please enter your user name:
james
————————- 2020/02/19 11:14:51————————- Context-aware Enviro Smart Application Main Menu
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
————————- 2020/02/19 11:14:53————————- Warning, TEMPERATURE is now 36 (james’s limit is 35)
Current Location: B
Current weather alarm status: no alarm
Suggestion – please go to an indoor or outdoor pool at one of these locations: Indooroopilly Shopping Centre, South Bank Parklands, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
————————- 2020/02/19 11:15:06————————-
Warning, SIGNIFICANT AIR POLLUTION LEVEL detected, the current AQI is 188 (james’s limit is 15)
Current Location: B
Suggestion – please go to an indoor cinema at one of these locations: Indooroopilly Shopping Centre, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
————————- 2020/02/19 11:15:09————————- Warning, TEMPERATURE is now 36 (james’s limit is 35)
Current Location: B
Current weather alarm status: no alarm
Suggestion – please go to an indoor or outdoor pool at one of these locations: Indooroopilly Shopping Centre, South Bank Parklands, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location

E. Exit
2
The following items of interest are in your location: Garden City
————————- 2020/02/19 11:15:25————————- Warning, TEMPERATURE is now 36 (james’s limit is 35)
Current Location: C
Current weather alarm status: no alarm
Suggestion – please go to an indoor or outdoor pool at one of these locations: Indooroopilly Shopping Centre, South Bank Parklands, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
2
The following items of interest are in your location: Grey Street
South Bank Parklands
————————- 2020/02/19 11:15:41————————-
Warning, TEMPERATURE is now 36 (james’s limit is 35)
Current Location: C
Current weather alarm status: no alarmSuggestion – please go to an indoor or outdoor pool at one of these locations: Indooroopilly Shopping Centre, South Bank Parklands, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest
2. Search for items of interest in current location
E. Exit
1
Please enter name of item of interest:
Brisbane City
Information about Brisbane City:
The Brisbane central business district (CBD), or ‘the City’ is located on a point on the northern bank of the Brisbane River. The triangular shaped area is bounded by the Brisbane River to the east, south and west. The point, known at its tip as Gardens Point, slopes upward to the north-west where ‘the city’ is bounded by parkland and the inner city suburb of Spring Hill to the north. The City is bounded to the north-east by the suburb of Fortitude Valley.
————————- 2020/02/19 11:15:57————————- Warning, TEMPERATURE is now 36 (james’s limit is 35)
Current Location: A
Current weather alarm status: no alarm
Suggestion – please go to an indoor or outdoor pool at one of these locations: Indooroopilly Shopping Centre, South Bank Parklands, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit

————————- 2020/02/19 11:16:13————————- Warning, TEMPERATURE is now 36 (james’s limit is 35)
Current Location: B
Current weather alarm status: no alarm
Suggestion – please go to an indoor or outdoor pool at one of these locations: Indooroopilly Shopping Centre, South Bank Parklands, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
————————- 2020/02/19 11:16:29————————- Warning, TEMPERATURE is now 36 (james’s limit is 35)
Current Location: B
Current weather alarm status: no alarm
Suggestion – please go to an indoor or outdoor pool at one of these locations: Indooroopilly Shopping Centre, South Bank Parklands, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
————————- 2020/02/19 11:16:34————————-
Warning, EXTREME WEATHER is detected, the current weather event is HEAVY RAIN
Current Location: C
Suggestion – please go to an indoor pool at one of these locations: Indooroopilly Shopping Centre, South Bank Parklands, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
————————- 2020/02/19 11:16:45————————- Warning, TEMPERATURE is now 36 (james’s limit is 35)
Current Location: C
Current weather alarm status: alarm
Suggestion – please go to an indoor pool at one of these locations: Indooroopilly Shopping Centre, Garden City.
–Please select an option–:
1. Search for information on a specific item of interest 2. Search for items of interest in current location
E. Exit
E
CLOSING, May take up to 60 seconds

The content of the relevant datafiles used in this example are available on BlackBoard. This includes the following files (note that James and Bryan are two users. James was used in the example output above):

Appendix B: Import the provided Run Configurations and Launch Group
In Eclipse, create a folder called “runconfigurations”.
Locate the six Run Configuration and one Group Launch files (all have the .launch extension) from blackboard, download the files, and save the files in the “runconfigurations” folder.
Right click the “runconfigurations” folder in Eclipse and select Refresh. You should now see the seven .launch files in the folder.
Refreshing the “runconfigurations” folder in Eclipse should import the launch files to the project.
To see the imported Run Configurations and Launch group, select the Run drop down menu, then Run Configurations.
Under Java Application, you should see the six imported Run Configurations. Under Launch Group, you should see the imported Launch Group.

For each of the six Run Configurations:
• Under the Main tab:
o Ensure that the project matches the name of your Eclipse project (i.e. change from
NewProject if required).
o EnsurethattheMainclassmatchesthecorrect.javafileinyoursrc\componentspackage
(if you have set up project correctly as noted in section 8 this should already be correct).
• Under the Arguments tab:
o Ensure that the input arguments matches those which are required. E.g. “cm_file.txt” for ContextManager.

Click on the Launch Group.
• You can change the order of the Run Configurations, remove Run Configurations (e.g. for testing a partial solution), or add new Run Configurations, if required.
Starting one program
To start one program (e.g. AllSensors), select the Run Configuration, then select the Run button.

Always start programs using the applicable Run Configuration (either directly or through the Launch Group). This will ensure the program always starts running with the correct settings.
Starting multiple programs
To start all six Run Configurations in the Launch Group (or a new Launch Group you have created), select the Launch Group, then select the Run button.
In the Console window, click the down arrow next to the Display Selected Console button. This will show you a list of all the java programs which are running. Each program has its own console.
Terminating a specific program
You can stop programs from running by selecting the console for the specific program, then pressing the red square. Clicking the down arrow next to the Display Selected Console button will show that the program has been terminated.
Terminating all running programs
Right click the console area, then select “Terminate/Disconnect All”. Clicking the down arrow next to the Display Selected Console button will show that all programs have been terminated.