Document Sample
Exam ACIMS Powered By Docstoc
					                                             Midterm Exam
                                         ECE 473/573 (Spring 2003)
                                           Wednesday April 2
                                            Open Book/Notes
                                               75 Minutes

Name:      SOLUTIONS
ID used for homework______________________

Total Points:
Do all problems. 100 pts.

NOTE: Answer all questions. Read questions carefully and answer what is asked for. If something is unclear,
make the assumptions you need to clarify it and be sure to write down your assumptions.

   1. Design a distributed irrigation control system for a farm which has fields, each growing a single crop such
      as rice, potatoes and corn. Each field is controlled by a single computer and has a different crop and its
      water allocation will be based on the needs of that crop. Crops with wider leaves and deeper roots need
      more water. The computers are networked to each other and to a central PC in the farm house. This PC
      allows the farmer to set the water spraying intervals and amounts each day and send these as commands
      to the field computers. These divide the water delivery amounts equally among the sprayers in the field.
      Sensors in the ground measure the moisture periodically and report these measurements to the field
      computer. The computer in each field maintains an independent record of the history of sprayings in this
      field and moisture readings. These local computers also compile the moisture information and send it to
      the central PC as an average moisture reading for the field. The central PC stores this information in a
      database. It also compares these records with the farmer's desired settings and if they differ significantly
      then it warns the farmer. The farmer can modify the spraying policy based on this information.
      Alternatively, s/he can call upon an irrigation equipment service person to check the the pipes or sprays
      in a field or a moisture sensor expert to check on whether the sensors have gone bad. These persons can
      access the field computer for the more detailed information it has stored.
a) Draw a use-case diagram in which the system boundary is drawn around the central PC with the actors
   considered to be the farmer and the field computers.

                                           CENTRAL PC

                           Set Water Spraying Interval


                                                 Modify Spraying Interval


                            Receive Mositure Info

                                             Store Info in database

                                                 <<extend>> Extn point:

                                 Issue Warning

                                                    Compare Settings

                                      Call Irrigation Equipment Service
b) Draw a use-case diagram in which the system boundary is drawn around a field computer with the
   appropriate actors included.

                                        FIELD COMPUTER

                               Report Measurements
                                                    Compute Average Measurements

    Central PC       Update Spraying/Moisture Reading

                                     Set Spraying Interval

                                           Divide Amounts and Send
c) Given the use-cases above, complete the table below:

                distributed          Should be a          Of the objects
                irrigation system    (class,              selected in analysis
                                     attribute, not       indicate the category
                                     included) in         from the following:
                                     analysis             {sensor = se
                                     (indicate Obj,       actuator = ac
                                     At, or None)         state info object = sio
                                                          result object = ro
                                                          planning object = po
                                                          control model object
                                                          = cmo}
                barn                      None
                spray controller          Obj                  cmo
                field                     Obj                  Sio
                Crop                      Obj                  Po
                leaf size                 At
                root depth                At
                Water                     None
                water allocation          Obj                  Ro
                farm house                Obj                  Cmo
                spraying interval         At
                spraying amount           At
                irrigation record         Obj                  Po
                moisture sensor           Obj                  Se
                sensor reading            Obj                  Sio
                Pipe                      None
                Sprayer                   Obj                  Ac
                valve                     Obj                  Ac
                field average             Obj                  Ro
                moisture record
                record of                 Obj                  Po
                comparisons of
                moisture with
                desired values
c) Draw a class diagram showing the following:

i) the relationship between a farm and its fields
ii) the relationship between fields and crops
iii) the relationship between fields and computers
iv) the relationship between a general concept of computer and the ones mentioned in the description

                                        Field     1                1     Crop


       Farm                                   1
                                   Field Computer


                                    Central Computer
             d) Limit the consideration to a farm with two fields. Draw a top level architecture in which there is a
             coordinator component hosted on the central PC and field manager components each hosted on the two field
             computers. Show all input and output ports for distributing the irrigation commands and receiving the
             moisture reports.


                               Irrigation         Irrigation
                               Cmds Out           Cmds In         Field
Moisture                                                          Computer 1
Info In                                                                            Moisture
             Coordinator                                                           Info Out

  Moisture                     Irrigation                         Field
  Info In                      Cmds Out                           Computer 1
                                                    Irrigation                     Moisture
                                                    Cmds In                        Info Out
e) Open up one of the field managers and show its components including a local coordinator and (for simplicity)
two spray controllers and two moisture sensors. Show how the relevant information objects in the above table are
associated with the components.


                                                                    Info In
                          Info In
Sensor 1
             Moisture                Local
             Info Out                                    Spray
                                                         Info Out

Sensor 2
                              Moisture                                        SC2
           Moisture           Info In              Spray
           Info Out                                Info Out         Spray
                                                                    Info In

Local Coordinator: Water Allocation, Irrigation Record, Field Average Moisture Record
Spray Controller: Spray Controller, Sprayer
Sensor: Moisture Sensor, Sensor Reading,
f) For the objects in a field manager component, draw a sequence diagram in which the following occur in the
given order: 1) a spray command is received from the outside spray 100 gallons for 10 minutes at 5 AM, 2)
corresponding commands to turn on the sprayers are issued, 3)corresponding commands to turn off the sprayers
are issued, 4) moisture sensor readers are received some time later, and 5) an average moisture value is sent out.


          : Central PC        : Coordinator             : Sensor                     :                   : Sprayer

     Spray (100 Gallons, 10 Minutes, 5:00PM)

                                                   Start Spray (100 gallons)                     Start

                                                            Stop Spray                           Stop

                                      Send Mositure Value

                         Calculate Average Mositure Value

           Send Average Mositure Value
2. Cameras can be extremely demanding to use and manufacturers have been striving to incorporate more and
more intelligence into them to reduce the expertise required. The following camera is designed to be “point and
click” so that that all default settings are defined for normal use, i.e., the resolution is set at low and 10 pictures
can be taken. Normally, the user just aims and then takes a picture and repeats this sequence until the memory is
exhausted. At that point, the user must press the clear button to continue taking pictures. With more experience, a
user can change the resolution to take more (or less) detailed pictures before aiming and taking. A high resolution
picture consumes 2.5 times as much memory as that of a low resolution one. Eventually, some users will attempt
to change the resolution or clear the memory right after aiming. The camera does not stay focused in these cases.
Also a user can watch the “pictures left” icon to avoid trying to take a picture when there isn’t enough space left.
(A picture can be taken if and only if there is enough memory for all its pixels needed at the given resolution and
it is focused.)

An Object Behavior Specification (OBS) for this camera defines a class, cam with one constructor and is based on
the following:

        aim – sets the focus
        take – consumes the memory required for one picture at the given resolution
        setRes – sets the resolution (number of pixels)
        clear – clears the memory
        focused? – tells whether the camera has been focused
        memoryLeft? – tells how much room, in pixels, is left
        res? – tells the current resolution
        picturesLeft? – translates the available memory into the number of pictures at the current resolution that
can be taken.

Note: in the following questions “Describe” means you can give the answer using obs syntax or you can provide
enough informal description to show you know how to do this (without actually doing it). One approach is to do
an informal answer first and then fill in the formal equivalent as time permits.

Answer the following questions:

    1) Looking at the above English description, indicate an aspect in which it is not complete. Describe a qts
       that would reveal this situation if one attempted to derive the OBS response. (An aspect here means a
       query/command or query/constructor pair.)
       Aspect: focused?(take(cam))
               Does not tell us whether the camera remains focused after taking a picture.

                 cam = make-cam()
                 cam’ = aim(cam)
                 cam’’ = take(cam)
                 cam’’’ = take(cam)
  2) Explain why memoryLeft? should be a hidden query and why picturesLeft? should be a non-hidden
      picturesLeft? uses memoryLeft? in order to calculate the number of pictures that can be taken (at the current
       resolution). Sp picturesLeft? can be defined using memoryLeft? and res? memoryLeft? is not a function that has to
       be directly accessed by the user. Hence it’s a hidden query. Since picturesLeft? is a function provided to the user, it
       should be non-hidden.

  3) Which queries form the smallest state representing set?

      Explanation: because of (2)

 4) Describe the domain restrictions for the take command.
      take(cam) is defined provided picturesLeft?(cam) >= 1 and focused?(cam) = T

  5) Describe the effect of the take command on the two queries memoryLeft? and res?
     memoryLeft?(take(cam)) = memoryLeft?(cam) – res?(cam)
     res?(take(cam) = res?(cam)

  6) Describe the effect of the setRes command on the two queries memoryLeft? and res?
     memoryLeft?(setRes(cam)) = memoryLeft?(cam)
     res?(setRes(cam, res)) = res

  7) How many state equations are needed for a complete OBS? Explain your answer.
     There are three queries, four commands and one definition.

      No of state equations = 3 queries*(4commands+1constructor) = 15.

  8) What is the minimum number of test cases required to verify an implementation of this OBS? Explain.
     At least one test case for each state equation.  15.

  9) Explain why an OBS is better than a state chart specification for cameras such as this. (Answer in terms
     of ease of specification, size of specification, ease of test generation, etc.)
     OBS is better because : (i) there are many states and (ii) it is difficult to describe the state transitions.
10) Describe a normal query terminated sequence (qts) with exactly three commands ending with focused?
   cam = make-Cam()
   cam’ = aim(cam)
   cam’’ = take(cam’)
   cam’’’ = aim(cam’’)
   focused?(cam’’’) = T

11) Describe an abnormal query terminated sequence with exactly two different commands ending with
   cam = make-Cam()
   cam’ = setRes(cam)
   cam’’ = take(cam’) // Illegal operation – camera is not focused
   focused?(cam’’) = F

Shared By: