首页 > > 详细

data编程辅导、java程序设计调试、java编程辅导辅导R语言编程|辅导数据库SQL

The system to simulate
The system to be simulated is a vaccine fill/finish inspection station (Figure 1). The purpose of the inspection station is to ensure that no defective vials of vaccine are packaged and distributed. The simulated part of the system is responsible for moving the vials through the inspection station on a disc- shaped carousel, which is rotated in a clockwise direction by a carousel driver and has five compartments, each of which can hold a single vial of vaccine at a time.
Vials are placed into the compartment at the first position of the carousel at random intervals by a producer. A scanner mounted on the carousel in compartment three performs a rapid assessment of vials as they pass, sounding an alarm when it detects a defective vial that requires a more detailed visual inspection. The scanner has high sensitivity (ie, it will always detect defective vials) and high specificity (ie, it will only sound the alarm for defective vials).
When the alarm sounds, the vial currently in compartment three will be moved to a bay for a more detailed inspection by an inspector. There is a single inspection bay which can hold only one vial at a time. If the visual inspection determines that a vial is defective, it will be tagged for destruction.
The inspected vial (either tagged or not) is then returned to position three of the carousel. Movement of vials to and from the inspection bay is handled by a single bi-directional shuttle, which can also hold only one vial at a time. Upon reaching position five of the carousel, vials are removed from the inspection station by a consumer. Beyond the scope of the subsystem you will simulate, tagged vials will be recycled, while those that are not tagged will be packaged for distribution.
Figure 1: The vaccine fill/finish inspection station to be simulated, showing: the rotating carousel con- taining five numbered compartments, each of which may be empty, or contain a vial of vaccine; the producer that places new vials into compartment one (when it is empty); the consumer that removes vials from compartment five (when it contains a vial); the scanner (red) that detects whether a vial should be inspected; the inspection bay, where vials are inspected and potentially tagged for destruction; and the shuttle, that moves vials backwards and forwards between the carousel and the inspection bay.

A partial solution
In the context of Java, it makes sense to think of the carousel and inspection bay as monitors. A possible set of active processes would then be:
Producer: Generates new vials and places them in compartment one (when it is empty). The times between arrivals should vary.
Consumer: Removes vials from compartment five.
Carousel Driver: Rotates the carousel as often as possible, but only when there is at least one vial in compartments one to five.
Shuttle: Moves vials that have been flagged for inspection to the inspection bay, and then back onto the carousel.
We have made scaffold code available on LMS that follows this outline described above. The compo- nents we have provided are:
Producer.java and Consumer.java: , which are responsible for generating new vials and placing them on the carousel (producer), and removing vials from the carousel after inspection (consumer).
Carousel.java The carousel which holds vials of vaccine in compartment.
CarouselDrive.java Responsible for rotating the carousel.
Vial.java: Vials of vaccine can be generated as instances of this class.
Params.java: A class which, for convenience, gathers together various system-wide parameters, includ- ing a number of timing parameters.
Sim.java: The overall driver of the simulation. Note that this won’t compile until you have defined some additional classes.
This code will compile and run; however, the system does not perform as specified, as several compo- nents are missing and defective vials are not tagged before they are removed by the consumer.

Your tasks
Your first task is to implement a simulator for the system as described above. Use your simulator to explore the behaviour of the system, and identify any potential issues that may prevent the smooth operation of the vaccine fill/finish inspection station.
The simulator should produce a trace of events along the lines of that shown below:

V:001(d--) inserted
V:001(d--) [ c1 -> c2 ]
V:001(d--) [ c2 -> c3 ]
V:001(d--) [ c3 -> S ]
V:001(d--) [ S -> I ]
V:002(---) inserted
V:002(---) [ c1 -> c2 ]
V:002(---) [ c2 -> c3 ] V:001(dit) [ I -> S ] V:002(---) [ c3 -> c4 ] V:001(dit) [ S -> c3 ] V:002(---) [ c4 -> c5 ] V:001(dit) [ c3 -> c4 ]
V:002(---) removed
V:001(dit) [ c4 -> c5 ]
V:001(dit) removed
V:003(d--) inserted
V:003(d--) [ c1 -> c2 ]
V:003(d--) [ c2 -> c3 ]
V:003(d--) [ c3 -> S ]
V:003(d--) [ S -> I ]
:

In the above trace, the first vial (V:001) inserted into the carousel by the producer is defective (indicated by the “d” flag). Hence, when it reaches compartment 3 (c3) it is transferred to the shuttle
(S)and then to the inspection bay (I) to be inspected. Once the inspection is complete (indicated by the “i” flag), it is tagged to be recycled (indicated by the “t” flag) and transferred back to compartment 3 (c3) by the shuttle. Upon reaching compartment 5 (c5), it is removed from the carousel by the consumer. Note the second vial (V:002) was not defective, it didn’t need to be inspected, and could proceed around the carousel while the first vial was still being inspected and removed before the first vial.
You should provide two solutions in this project:

Solution 1: First assume that all vials are returned to compartment 3 of the carousel after they have been inspected. This is not an ideal solution, but we want to see it implemented because Assignment 1b will make use of it.
Solution 2: As a second solution, introduce an additional carousel to take vials from the inspection bay after they have been inspected. This carousel needs just two compartments, one to receive vials from the inspection bay, and the other from which vials are removed for destruction (by a consumer).

Your second task is to write a reflection of approximately 500 words that evaluates the success or otherwise of your implementation, and identifies critical design decisions or problems. You should sum- marise insights you gained from experimenting with the simulator, in particular any issues you identifed with the performance of the system, and how the second solution addresses these (or not).
Note: You should complete this task using the Java concurrency constructs that we have covered in class (ie, monitors, etc); you should not make use of the high-level concurrency objects from the concurrency library.

 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!