course home↑  
Course Assignments
COP 4380 Hierarchical State Machines and Reactive Systems Programming
Summer Semester 2016  © 2016 R. C. Lacher.
Instructions for Assignments
There are generally four kinds of activities in assignments: reading, software, discussion, and exercises. (Not every assignment will have every kind of activity.) All portions of an assignment should be completed by the due date.
The exerices in an assignment should be submitted for grade by the due date. These should be prepared and submitted as follows:
- Specs. Prepare a complete document:
- Provide a header that identifies the document and its author, for example:
COP 4380 Assignment xx (your name) (date)- Number your pages
- For each exercise:
- State the exercise
- Provide your solution to the exercise
- Submissions. Submit your assignments via the Blackboard Assignments button. Written documents and graphics should be in pdf format (NOT MS Word source code). Computer code should be left as is, a text file with appropriate suffix. Zip'ed collections may be submitted.
- Deadlines. I am more interested in quality than time, within practical limits. Therefore I am leaving five extra days to complete each assignment, measured from the posted due date. Please make sure that your use of this extra time shows in the quality of your submission.
- Collaboration is encouraged. You are encouraged to collaborate (only with other students in this class) on ideas behind assignments, including design. However: each student is required to type (not copy) their own words and code and submit this work individually. Copying files or copy/paste from files is strictly prohibited for any assignment. Type your own sentenecs and your own code files. All collaboration on programming must be disclosed in your log.txt file.
Assignment 1
- Review Course Syllabus
- Read Chapter 1 of [Sam2]
- Locate the Visual Basic Calculator on the textbook support web site, download and launch it. Try the sequence of operations: 1 , / , - , = , 2 , = and watch it crash. Launch again and try 2 , x , CE , 2 , = and notice that CE had no effect, even though it appeared to cancel the entry 2. See how many ways you can break the VB calculator.
- Find and launch the Quantum Calculator QCalc. Run QCalc and try to alighn actions with the statechart on Slide 1-8 in the lecture notes. (Note the State display.) Can you break QCalc? See how it handles the unary + and - operators.
- Not all states of QCalc can be active. For example, ready, operand1 and operand2 can never be active. Explain why.
- Download/Install the latest version of Quantum Event Processor QP/C++ (baseline code) for C++. Install in your CS files system in this directory: ~/cop4380/qpcpp. Use the "make" command in the directory qpcpp/ports/posix/ to build the library. Then test build some of the examples in qpcpp/examples/posix/. The supplied makefiles should work without modification.
- (Optional.) You may also want to install both qpcpp and the associated modelling tools on your personal workstation. Any code you develope there should be tested on linprog before submission.
Assignment 2
- Read Chapter 2 of [Sam2]
- Read OMG UML Statecharts Specification Section 2.12. (Download or click-to-read the OMG document here.)
- Modify the portion of QCalc illustrated in the figure to the right to allow the user to enter any number of unary "-" operations with the effect of reducing an even number of "-" entries to none and an odd number to one, as in:
--2 = 2 ---2 = -2 ----2 = 2 . . .- Propose HSM to model ...
- Postfix (reverse Polish) logic calculator
- A nifty app for desktop or handheld device
Assignment 3
- Read Chapter 3 of [Sam2]
- CParser Revisions
- Find the source code cparser4.h implementing CParser, along with the accompanying test harness test4.cpp. (See the course code library ~cop4380p/LIB/proj3.) Make sure you can compile and run the test.
- Extend the CParser4 FSM to a C++ Comment Parser FSM by adding appropriate states, events, and transitions to handle the double slash comment style.
- Extend each of the implementation to this new FSM. Test the code using an extension of the test harness distibuted. Call the extension CPPParser4
- Describe systematically the kind of effort required to make these modifications: what new things need to be created? Where is code added? How spread out is the upgrade with respect to the original code?
- Revise CPPParser4 to CPPParser4a by adding initial, entry, and exit actions to states:
Use the following enumerations for this implementation:
- Initial action (defined for initial state): calls initial transition
- Entry action: announces entry to state (and possibly more)
- Exit action: announces exit from state (and possibly more)
enum FsmEvent // system events { INIT_SIG = 0, ENTRY_SIG, EXIT_SIG, USER_SIG }; enum CParserEvent // CParser events { CHAR_SIG = USER_SIG, STAR_SIG, SLASH_SIG, BLANK_SIG };Literary Deliverables: (submit to Blackboard under Assignment 3)
- Responses to questions
- Evaluation report, source code, and discussion of working code.
Code Deliverables: (submit from shell via submit script under the name "proj3")
- cppparser4a.h
- test4a.cpp
- log.txt # your work log, which should outline both development, including all collaboration information, and testing
When these two files are in a directory on linprog, the command
g++ -I. -otest4a.x -Wall -Wextra test4a.cpp
should build without warnings the executable ./test4a.x.Optionally, you may use the distributed test harness test4acpp.cpp (requiring a couple of additions to CPPParser4a). See area51/test4acpp.x for behavior illustration.
Assignment 4
- Read Chapters 4 of [Sam2]
- Extend the statechart on the right to a C/C++ comment parser. This machine should correctly process C++ code with both C style comments and C++ style comments.
Note: You may use a text-based description of the statechart in place of graphics, provided that you (1) describe the original statechart shown and (2) use color to highlight the changes you make in extending the original to include C++ comments.
Literary Deliverables: (submit to Blackboard under Assignment 4)
- Revised statechart diagram or precise discussion
- Brief discussion of product and development process
Assignment 5
- Modify QHsmTest as follows:
- Begin with the code distributed in the course code library: ~cop4380p/LIB/proj5.
- Add new state s22 with parent state s2
- Change transition d:s211 -> s21
to d:s21 -> s22- Add new signal J_SIG
- Add new transition j:s22 -> s11 triggered by j_SIG
- Add new transition j:s11 -> s22 triggered by j_SIG
Literary Deliverables: (submit to Blackboard under Assignment 5)
- Revised statechart diagram or precise discussion
QHsmTest Statechart from Fig 4.3 of [SAM, p95].
We are working with the new version, depicted in Fig 2.11 of [SAM2, p88]. The essential differences are the way init signals are processed.
Code Deliverables: (submit from shell via submit script under the name "proj5")
- qhsmtest2m.h
- qhsmtest2m.cpp
- main2m.cpp
- qhsmtest2mx.h
- qhsmtest2mx.cpp
- main2mx.cpp
- log.txt # work log, which should outline development, testing, and collaboration
The supplied makefiles should build the two projects separately.
See area51/ace2m.x area51/ace2mx.x for behavior illustrations.
Assignment 6
- Using QHsmTest as a model, create a working QHsm implementation of the C++ comment parser CPPParser that functions as (or improves upon) the stand-alone FSM implementation from assignment 3. See area51/cppparser6.x for behavior illustration.
Follow the convention established in the QHsmTest, wherein:
cppparser.h: contains the CPPParser signals and external declaration of the_hsm
cppparser.cpp: contains the class definition and implementation
main.cpp: contains event loop, stand-alone (static - file scope) dispatch, and any other special stuff such as BSP functions.Literary Deliverables: (submit to Blackboard under Assignment 6)
- Revised statechart diagram (may be identical with assignment 4)
Code Deliverables: (submit from shell via "submit.sh deliverables.sh" - be sure you have copied LIB/proj6/deliverables.sh)
- cppparser.h
- cppparser.cpp
- main.cpp # note that example main.eg is supplied
- log.txt # work log, which should outline development, testing, and collaboration
Note that there is a supplied makefile. When your files are in a directory on linprog together with the supplied makefile, the "make" command should build the debug version as dbg/cppparser.x, and "make CONF=rel" should build the release version as rel/cppparser.x
Note also that there is an example main supplied under the name "main.eg".
See area51/cppparser.x for behavior illustration.
Philosophers Banquet (level 1)
Open for discussion in the Project forum - be sure to attend there for possible refinements.
- Extend the DPP model to include:
- A new Philosopher state "working" with substates "thinking" and "writing"
- The TIMEOUT-triggered transition to "hungry" would be handled by this parent state.
- A transition to "working" descends into the substate occupied (or triggered) most recently.
- The new signal AHHA would trigger a transition from "thinking" to "writing", and the new signal "HMM" would trigger the transition from "writing" to "thinking". Your solution should be in the form of new statechart models with adequate descriptions of terms.
DPP Statecharts before changes
- The new system should process two additional signals (annotated for a specific philosopher). The AHHA[n] event and the HMM[n] event are generated by philosophers and trigger a transition one substate or working to the other. Note that the AHHA and HMM events should be consumed by all reallizable Philosopher states (except the one that is the target of the triggered transition). When a philosopher is not in a working substate, these signals should trigger an internal transition that revises the work_history target.
- Note the material distributed in LIB/proj7. This is a working implementation of the DPP as described in the text, with 5 philosophers. Make an ordered list of the tasks required to upgrade the Dining Philosophers Problem QF implementation for your new model.
- Implement your new model, as described above, including calls to BSP_displyPhilStat that announce the current state for each philosopher. Use "1" appended to file names for this new implementation.
Hints:
- You may find it convenient to move the calls to BSP_displyPhilStat from table1.cpp to philo1.cpp, since some of the new state transitions will not involve table. (Do this before any other modifications, to be sure you have it right. The obvious place for these calls is in the case handling Q_ENTRY_SIG.)
- Note that the sub-states of "working" don't affect transitions to "hungry" and "eating".
- You will need a private pseudo-state of the appropriate type to remember the working history - a slight misnomer, since this history can be revised when the philosopher is in the hungry or eating states - which is the target of transitions out of eating. (See the Transition to History state pattern.)
- The transitions between thinking and writing should be triggered by the (upgraded) random signal generator used in the original simulation. The effect should be to shift all subsequent transitions into working to that substate, until the opposit transition is triggered for that philosopher.
Literary Deliverables: (submit to Blackboard under Project)
- Revised Philosopher statechart accompanied by discussion of operation
Code Deliverables: (submit from shell via submit script "submit.sh deliverables1.sh")
dpp1.h # defines api for problem bsp1.h # "board specific" stuff bsp1.cpp # implements bsp1.h philo1.cpp # implements philosopher table1.cpp # implements table main1.cpp # driver program makefile1 # builds project log.txt # work log, which should outline development, testing, and collaborationWhen these files are in a directory on linprog, the "make -f makefile1" command should build the debug version as dbg/dpp1.x and "make -f makefile1 CONF=rel" should build the release version as rel/dpp1.x
Note: This represents a level 1 project, the minimum for a passing grade. The assessment process will first look at the "2" version and, only if necessary, revert to the "1" version.
Philosophers Banquet (level 2)
- Extend the DPP model from assignment 7 (with the more complex philosophers who think and write) to allow a number of philosophers to be determined by the user. This may be at compile time (setting a constant in the file "main2.cpp") or at runtime (supplying a command line argument). If there are good reasons to do so, this number of philosophers may be limited by an upper bound determined by these good reasons. Explain in your log.txt.
Literary Deliverables: (submit to Blackboard under Project)
- Revised Philosopher statechart accompanied by discussion of operation
- Discussion of modification process, what major hurdles needed to be overcome, and how it was accomplished.
Code Deliverables: (submit from shell via submit script "submit.sh deliverables2.sh")
dpp2.h # defines api for problem bsp2.h # "board specific" stuff bsp2.cpp # implements bsp2.h philo2.cpp # implements philosopher table2.cpp # implements table main2.cpp # driver program makefile2 # builds project log.txt # work log, which should outline development, testing, and collaborationWhen these files are in a directory on linprog, the "make -f makefile2" command should build the debug version as dbg/dpp2.x and "make -f makefile2 CONF=rel" should build the release version as rel/dpp2.x.
Note: This represents a level 2 project, the minimum for a grade of B. The assessment process will first look at the "2" version and, only if necessary, revert to the "1" version.
Philosophers Banquet (level 3)
- Add an active object to the level 2 DPP that is a control module. This module should accept commands beginning with 'C' and provide a way to control the parameters of the banquet. The design, implementation, and integration of this control object into the level 2 banquet is open-ended.
Literary Deliverables: (submit to Blackboard under Project)
- Revised Philosopher statechart accompanied by discussion of operation
- Discussion of modification process, what major hurdles needed to be overcome, and how it was accomplished.
Code Deliverables: (submit from shell via submit script "submit.sh deliverables3.sh")
dpp3.h # defines api for problem bsp3.h # "board specific" stuff bsp3.cpp # implements bsp2.h philo3.cpp # implements philosopher table3.cpp # implements table cont.h # defines controller cont.cpp # implements cont.h main3.cpp # driver program makefile3 # builds project log.txt # work log, which should outline development, testing, and collaborationWhen these files are in a directory on linprog, the "make -f makefile3" command should build the debug version as dbg/dpp3.x and "make -f makefile3 CONF=rel" should build the release version as rel/dpp3.x.
Note: This represents a level 3 project, the minimum for a grade of A. The assessment process will first look at the "3" version and, only if necessary, revert to the "2" version.