A Object-Oriented Implementation of a Chemical Waste Consolidation Expert System
Return to front page 1. Background and Rationale 2. Interface Design
3. System Design
4. Evaluation and Results 5. Future Work 6. Conclusions Bibliography and References Appendix A. Example Drum Report Appendix B. Chemical Compatibility Testing Data |
3.5. The Drum Library: Class DrumBook
The last class used in the software is the DrumBook class, which is the data representation of the large storage drums in the waste storage facility. In many ways, it represents the culmination of the library classes because it is composed of bottles which are composed of chemicals. This class is closest in structure to the BottleBook class with a linked-list of activeDrumData structures and the ingredient list of those drums. The DrumData structure is missing the destinationDrum, pH and activeOxidizer members when compared to theTransportData structure. The class has an additional linked list to track the generators of the waste in the drums. Functionally, it is similar to the ChemBook class with slight data structure and code differences. The utilities DrumMenu, DisplayDrumInfo, AddDrumToList and InitializeDrumDataStruct perform the same general functions as the preceding classes by activating the corresponding functions in the DrumData class. The building block for the DrumBook linked list is the DrumData structure, as shown below. struct DrumData { DrumData* next; // POINTER TO NEXT DRUM STRUCT int drumID; // TRANSPORT CONTAINER NUMBER int numIngredients; // NUMBER OF INGREDIENTS float volume; // TRANSPORTER VOLUME IN LITERS float mass; // CONTAINER MASS float acidMoles; // MOLES OF ACID OR BASE IN BOTTLE float oxidizerVolume; // VOLUME OF OXIDIZER IN DRUM float organicVolume; // VOLUME OF ORGANICS IN DRUM float corrosiveVolume; // VOLUME OF CORROSIVES IN DRUM float halogenatedVolume;// VOLUME OF HALOGENATED IN DRUM float drumFlam; // BOTTLE NFPA FLAMMABILITY float drumHealth; // BOTTLE NFPA HEALTH float drumReact; // BOTTLE NFPA REACTIVITY float drumContact; // BOTTLE NFPA CONTACT int day, month, year; // DATE RECEIVED int wasteType; // WASTE TYPE DESIGNATOR FOR DRUM }; The drums can be loaded in two distinct ways. First, since all the TransportData bottles have a destinationDrum index, the drums can be loaded as the bottle list dictates. This method allows the user to load the library as a previous work in progress and then fine tune the drums. The second method of loading bottles lets the software perform the initial sort by waste type and generate the requisite drums. The first loading type is performed by the LoadDrumData function. It begins by querying the drum library to determine if there are existing drums. The DrumBook function EmptyLists is used to deallocate the drum and ingredient linked lists, and the BottleBook bottle list is read to initialize the new drums. The destinationDrum variable is read from each bottle to determine the drumID numbers to create. The drums are created and inserted into the linked list. Each drum is read into the function and a static array of ingredients is created as a workspace to receive the bottle additions. For each successive bottle, the BottleBook ingredient list is reset and the ingredients are sequentially added to the static array of drum ingredients. No compatibility checking is performed since this drum arrangement is from the stored input file and was checked for chemical compatibility during initial creation. Upon completion of the bottle additions, the array holds the complete contents of the drum. The DrumBookingredients list is filled with the contents of the static array and the drum structure is updated. The function continues until it has processed all of the new drums. The alternate method of loading the bottles is using the LoadBottleListIntoDrums function. It begins by calling the BottleBook functionSortBottlesByReactivity. This resorts the bottle list in increasing order of the bottleReact member of the structure. This number is a representation of the reactivity of the waste mixture and helps prioritize the order of addition of the bottles to the drums so that more reactive bottles are added last. As in the previous loading method, the DrumBook linked lists are deallocated and the bottle list is used to create the new drums. The change is that the drums are created based upon the wasteType member of the structure. The drums are numbered according to thewasteType designator, and there is a drum for each wasteType in the bottle library. The routine displays the proposed new drums by cycling through the bottle list and displaying all the bottles in each drum. The display is depicted in Figure 2.12. The user is prompted to accept these drum assignations. Once the user has input Y, the cycle of deallocation and creation of the new drums begins. This also overwrites thedestinationDrum member of each bottle structure with the wasteType number, which is also the drum structure drumID. Each drum is loaded in turn and the ingredients are processed just as in the previous loading function. By calling the ChemBook routine ChemicalCompatibility, this function checks chemical compatibility as it adds the ingredients and alerts the user about any significant concerns. From this point, the user may process the drums by merging partially-filled drums or migrating bottles from one drum to the other. The CombineDrums function prompts the user to choose two drums to merge together. It loads the first drum into the static array and then adds the second drum ingredient by ingredient while checking for chemical compatibility of each addition. If the addition is finally approved by the user, the function commits to the changes by a series of automatic steps that are nearly instantaneous. It first deletes the linked list ingredients of both drums and then inserts the static array representation of the new combined drum ingredients. The second drum structure is removed from the linked list and the new, modified first drum structure is updated by running the RecalculateDrum function. The bottle library list is searched for the old drum number in the destinationDrum field and, when found, is updated to the new drum number. This completes altering the drum and bottle libraries to reflect the new situation. MigrateBottle is the function to manually move a bottle from one drum to another. An interrogatory sequence obtains the bottle number to be moved and the destination storage drum. The function begins by loading the ingredients of the source drum into the static array for manipulation and removing the ingredients of the selected bottle. The linked ingredient list for the source drum is updated by deleting the linked list nodes of the source drum and inserting the contents of the static array representation. The static array is reset and loaded with the ingredients of the destination drum. As each ingredient from the selected bottle is added to the static array, chemical compatibility checking is performed and the user is warned of any significant concerns. When completed, the linked list of ingredients for the destination drum is updated to reflect the new bottle migration. The calculated source drum and destination drum parameters are updated using RecalculateDrum. The GenerateReports function creates the text reports for dissemination. The first document is a listing of each drum and the ingredients contained in that drum. It appears very similar to the output from the DisplayDrumInfo function. It also includes a listing of the original generators of the waste and the percentage of the drum for which they are responsible. The final waste disposal bill can be easily apportioned from the information contained in this report. It also generates a report for the University Police Department to be held for emergency situations involving the chemical waste storage area. This report has roughly the same information without the waste generator information. Another recipient is the Environmental Health and Safety department, which will use the report to fulfill the RCRA requirements of waste documentation. Appendix A contains an example of a drum report. |