4/9/2019
Programming Assignment 2
Programming Assignment 2
Date Posted: February 27 Preliminary Class Diagram: March 6 Class Outline: March 11 Functionality Outline: March 25 Final Project Due: Monday, April 1
Programming Assignment 2
Background Information
Drilling for oil in the United States has become a high tech industry. The oil production companies relie on a complex array of sensors on each drilling rig to monitor the state of all operations. These sensors feed data to a server mounted on the rig. The server is connected to a network which enables workers on the rig as well as managers back at the company offices to monitor all aspects of the operations.*
Your Assignment
OI-USA is very pleased with the first version of the oil field monitor simulation, but they need to make some changes to make the application more usable for their purposes of testing. The way sensors are implemented and function in version 1 of the simulation limits the usefulness. OI-USA really needs to be able to test new sensors rapidly and to have the data generated by the sensors be more realistic. They have identified five different algorithms (described below) for data generation. They would really like to be able to easily define new sensors, give them appropriate limiting values and possibly links to another sensor, assign a particular data generation algorithm and then assign the new sensor to a well.
You are to create a simulation program that meets these requirements. This programming assignment is to be version 2.0 of the program created for programming assignment 1. The following is a list of additional/modified requirements based on further discussions with representatives of Oilfield Instrumentation-USA (OI-USA)*. All requirements from programming assignment 1 which are not modified by a paragraph below shall also be required for programming assignment 2.
1. The application shall allow the user to select any number of wells to monitor. At any time while the application is running the user shall be able to add or remove wells being monitored.
2. The application shall allow the user to select any number of sensors to monitor on each selected well. At any time while the application is running the user shall be able to add or remove sensors being monitored for each selected well. In programming assignment 1 all wells had the same number and type of sensors. In this assignment the sensors on each well will vary. Exactly which sensors are mounted on a well will be defined in a new data file which shall be provided.
3. All data defining the list of active wells and the sensors on each shall be read from a data file in a modified XML format (different from programming assignment 1). A new data parser class will be provided to read and parse the new data file.
4. Each sensor will be defined by the following data:
A character array defining the sensor type. Examples: “HOLE_DEPTH”, “BIT_DEPTH”, etc.
A character array giving the display name for a sensor of this type. Examples: “Hole Depth”, “Bit Depth”, etc.
A double giving the minimum value this sensor can have. If this value is given as UNDEFINED then it means this sensor does not have a minimum value, i.e it can go negative and you should use zero as the starting value.
A double giving the maximum value this sensor can have. If this value is given as UNDEFINED then it means this sensor does not have a maximum value.
www.cs.uah.edu/~rcoleman/CS307/ProgAssign/cs307Prog2.html 1/3
4/9/2019 Programming Assignment 2
A double giving the maximum step value this sensor can have. If the algorithm the sensor uses to generate data uses a step value for each increment or decrement then the actual value used will randomly vary between zero and this value.
A character array defining the sensor reading units for display. Examples: “feet”, “feet per hour”, etc.
A character array defining the sensor reading units abbreviation for display. Examples: “ft”, “ft/hr”, etc.
A character array defining the algorithm this sensor will use for generating its simulation data. Examples: “RAND_MIN2MAX”, “STEPINC_MIN2MAX”, etc.
A pointer to a linked sensor (which may be NULL) if the algorithm this sensor uses to generate data requires getting the reading from another sensor.
5. The algorithms for generating data by each sensor shall be implemented as a set of classes following the Strategy design pattern. Each Sensor class/sub-class will have a pointer to the appropriate data generation class. The following list describes how each algorithm will work.
Algorithm 1 — Randomly generate a value between min and max. Algorithm name: RAND_MIN2MAX Algorithm 2 — Starting from min randomly generate an increment between 0 and Step until max is reached then stop. Algorithm name: STEPINC_MIN2MAX
Algorithm 3 — Starting from max randomly generate a decrement between 0 and Step until min is reached then stop. Algorithm name: STEPDEC_MAX2MIN
Algorithm 4 — If a linked sensor generates a value greater than this sensor¡¯s current value use the linked sensor¡¯s value as the current value for this sensor, else continue to use the previously generated value. Algorithm name: FOLLOWLINK_IFGREATER
Algorithm 5 — If a linked sensor¡¯s value changed from the last reading then randomly generate a value between min and max otherwise set the value to zero. Algorithm name: FOLLOWLINK_IFCHANGED
6. It is the intention of OI-USA to add additional sensors to the simulation in the near future by adding the sensor definitions to the XML data file. New sensors will be defined as described above and will use one of the five data generation algorithms to generate their simulation value. This version of the simulation shall be designed so that additional sensor types can be added without requiring any additional code.
7. The creation of Oil Well objects, creation of sensors for each well, creation and attaching of data generation classes, and attaching of sensors to wells shall be handled by an OilWellFactory class which follows a modified version of the Abstract Factory design pattern sometimes referred to as a Simple Factory. This factory class shall also be implemented as a Singleton following that design pattern. While not required you may find it useful and a very good idea to also implement a SensorFactory and a DataGenAlgorithmFactory, again as simple factories and singletons.
Deliverables
These products as specified below shall be delivered electronically via e-mail to the instructor.
Preliminary Class Diagram — The class diagram shall be drawn using standard UML notation and shall show all of the classes to be implemented in the software and their relationships (dependencies, associations, generalizations, realizations, etc.) The PCD shall be submitted for instructor approval NLT (Not Later Than) Wednesday, March 6.
Class Outline — The class outline shall list all proposed variables and functions in each proposed class with a brief description of what each does. The class outline shall be submitted for instructor approval NLT (Not Later Than) Monday, March 11.
Functionality Outline — The functionality outline shall be an outline which will show the step-by-step functionality of the program. This should be taken out to a fair amount of detail. The functionality outline shall be submitted for instructor approval NLT (Not Later Than) Monday, March 25.
Final Project — The entire Visual Studio solution (compatible with Microsoft Visual Studio 2012, or 2015) shall be compressed into a zip file and submitted for instructor approval NLT Monday, April 1. Just turning in your source files is not acceptable.
We will have several class periods in which we will meet as a team to discuss and plan this project. We will be doing a lot of brainstorming and planning together, but remember you are responsibility for implementing the final design on your own.
www.cs.uah.edu/~rcoleman/CS307/ProgAssign/cs307Prog2.html
2/3
4/9/2019 Programming Assignment 2
To download a sample executable as well as a data file and a parser for the data file click here. Sensors
Two new requirements added to Programming Assignment 2 may cause a reexamination of how sensors are implemented. Because of the requirement that OIUSA may add new sensor types, defined in the XML data file, it makes it difficult to create new subclasses of Sensors without knowing in advance what those classes will be. However, a closer examination of the Sensor class will show that the only thing different about the subclasses is how they generate their data.
This can be handled by moving that action to a separate class and eliminate all subclasses of Sensor. Different “types” of sensors can then be created by setting the appropriate strings in Sensor and by giving each Sensor an instance of the appropriate data generation algorithm as described in programming assignment 2, paragraph 4.
This programming assignment is based on a real-life situation and a software project that the instructor worked on while employed at SAIC. To see information on this project check out the Oil Field Instrumentation – USA (OI-USA) site and click on the link to “Drilling Instrumentation Systems” in the lower left portion of the display.
www.cs.uah.edu/~rcoleman/CS307/ProgAssign/cs307Prog2.html
3/3