CDT501 2015 period 3

ADVANCED COMPONENT-BASED SOFTWARE ENGINEERING, 7.5 ECTS

Labs

Lab 1 Modeling a CB system and reuse

 

Estimated workload: 2.5 days full time

 

Description:

 

The Key Word in Context (KWIC) index system accepts an ordered set of lines and each line is an ordered set of words. Any line may be “circularly shifted” by repeatedly removing the first word and appending it at the end of the line. The KWIC index system outputs a list of all circular shifts of all lines in alphabetical order.

 

Exercise 0:

The main task of Exercise 0 is to get familiar with Fractal and Eclipse IDE. Set up the Java environment and Eclipse on your PC or Mac, and run the example “Hello World” program.

 

Exercise 1:

The main tasks of Exercise 1 are to design a component-based architecture for the KWIC index system in Fractal ADL and to create a prototype implementation in Java language with Eclipse IDE that realizes your design. In detail:

1)   Design a component-based architecture for KWIC index system in Fractal. Follow the principle of concern hiding (i.e., changing any of these decisions should only require updating the corresponding component).

2)   The components should at least encapsulate the following design decisions:

·      The input media and data format

·      The algorithm for computing the circularly shifted lines and the format for storing the result

·      The algorithm for sorting the circularly shifted lines and the format for storing the result

·      The output media and data format

3)   Implement the KWIC index system in Java language. Your system must be able to read the input data from a text (.txt) file and display the outputs on the screen. It is only necessary to handle input files consisting of lines of space-separated words correctly, e.g., “Joe is a good student”.

 

Exercise 2:

The main task of Exercise 2 is to reuse the components developed in Exercise 1 to implement a new KWIC index system. In detail:

1)   The new KWIC index system accepts an ordered set of lines, and each line is an ordered set of words. Each line is preprocessed before circularly shifted, including: removing stop-words according to the given stop-word list (which includes a, an, and the). Then, any line may be “circularly shifted” by repeatedly removing the first word and appending it at the end of the preprocessed line. The new KWIC index system outputs a list of all circular shifts of all preprocessed lines in alphabetical order.

2)   The components should encapsulate the following design decisions:

·      The input media and data format

·      The functionality of preprocessing lines

·      The algorithm for computing the circularly shifted lines and the format for storing the result

·      The algorithm for sorting the circularly shifted lines and the format for storing the result

·      The output media and data format

3)   Reuse the components developed in Exercise 1 and implement the new KWIC index system in Java language. Your system must be able to read the input data from a text (.txt) file and display the output on the screen. It is only necessary to handle input files consisting of lines of space-separated words correctly, e.g., “Joe is a good student”.

 

Exercise 3 (Optional):

The main task is to dynamically add or remove components developed in Exercise 1&2 to implement a mixed KWIC system:

1)   The new KWIC index system should process several txt files and be configured dynamically according to the input files. In each file, the first line indicates if the contained lines should be preprocessed or not by using “PREPROCESS” or “NO PREPROCESS”. The other are an ordered set of lines similar to those in Exercise 1&2.  When reading in a “PREPROCESS” file, the KWIC index system should preprocess the lines in this file as described in Exercise 2. Otherwise, it copes with the lines as described in Exercise 1.

2)   Your task is to reuse the components defined in Exercise 1&2 as many as possible and implement such a mixed KWIC system. If needed, you can add some new components or modify the implementation of existing components.

 

 

 

 

Submission:

The outputs of this Lab are two parts:

1)   three Fractal projects consisting a set of ”.fractal” and “.java” files which can be correctly executed and,

2)   a PDF file briefly describing the design of your KWIC is necessary as well.

A zip file containing all these outputs should be submitted to:

http://www.idt.mdh.se/kurser/assignments/cdt501/

 

Lab 2 CBD for ES and Using EFPs

 

Estimated workload: 3 days full time

 

Description:

 

In the second lab assignment, you will use “Cecilia” which is a development environment for programming Fractal components on top of the C programming language. The purpose of this lab is to do a component-based model of a system, to reuse components and to get hands on Extra Functional Properties (EFPs).

 

Exercise 0:

In this exercise, you are supposed to get familiar with “Cecilia” through the basic concrete example “HelloWorld”. The example shows how to implement the traditional HelloWorld Fractal example with the “Cecilia” framework.

 

Exercise 1:

The main task in this exercise is to do the component-based model of an electric kettle (Max 1 Liter capacity) using Cecilia framework. You may start with the overall component-based model using the Cecilia ADL language. Then showing the definition of the interfaces of the components involved based on the Cecilia IDL language. Finally, the implementation of the components can be done in the thinkMC language.

 

The electric kettle heats the water until it starts boiling (100°c). Then, it automatically goes off. Your task in this exercise is to define appropriate component(s) and come up with a working implementation.

 

Tips:

In order to have a working system, you may consider the following tips:

1)   First, take the water amount as the user input by displaying a prompt string on the screen.

2)   Consider the fact that more water takes more time to reach 100°c i.e., water temperature is a function of water amount.

3)   Define a component called “KettleStatus” that generates random e.g., boolean values "True"/"False" indicating whether the kettle is on or off.

4)   We don not have actual sensor to sense the water temperature! So, you may define a component called “Sensor” with a method called “IncTemp” that generates random numbers in an ascending order in the range [0, 100] i.e., every time “IncTemp” method is called, it generates a bigger value.

5)   To read the temperature, other components call the “IncTemp” method from the “Sensor” component.

 

Exercise 2:

The main task here is to do a component-based model of a “Food Sterilizer” machine that comprises two composite components: “Pre-sterilizer” and “Ready for Production”.

 

The machine starts operation and leaves standby mode upon receiving “Machine Cleaned” signal and is filled by water/steam. The “Pre-sterilizer” component heats the water/steam up to 130°c, then, keeps the water/steam in this temperature for 30 minutes. It has to continuously monitor the temperature by appropriate sensors. When temperature == 130°c, a timer is activated. When timer == 30 minutes, the “Pre-sterilizer” finishes the job and sends out “Pre-sterilized” signal to the next component. While timer < 30, if temperature falls below 130°c, the timer is reset and as soon as the temperature >= 130, it is re-activated.

 

Upon receiving the “Pre-sterilized” signal from “Pre-sterilizer” component and the external “Raw Product Ready” signal, “Ready for Production” component is activated. It heats the raw product till 140°c. Then, keeps the product for 5 sec in this temperature. Then, it cools down the product to 20°c. The machine is in operation until this component receives “Raw Product Finished” or the external “Operator Stops Production” signal. Then the machine finishes the current job and goes to standby mode afterwards. You are supposed to define the appropriate components within each composite component.

 

Exercise 3:

In this exercise, you will get hands on EFPs considering timing property in the “Food sterilizer” machine.

 

Your task is to define a “Delay Alarm” for temperature in “Ready for Production” component such that in case of missing the deadline production is aborted i.e., if the temperature in “Ready for Production” component falls below 140°c for time interval 5 sec (deadline) then, the product is aborted and the machine goes to the standby mode. This means that machine can only tolerate temperature falling the threshold for 5 sec.

 

Exercise 4 (Optional):

You are supposed to reuse the previously defined components in this exercise by adding the “Standardization” component to the “Ready for Production” composite component.

 

In case of raw milk as the input product, the “Standardization” component separates cream from raw milk. Then, it mixes the desired percentage of cream e.g., 0.5%, 1%, 3% with milk and delivers the final product. It is assumed that the product is milk in this exercise.

 

Tips:

In order to have a working system, you may consider the following tips:

1)   The temperature values from sensors can be generated similar to Exercise 1.

2)   External signals can be generated similar to “On”/”Off” states in Exercise 1 i.e., “True” or “False” for the signal where “True” means the signal is active.

 

 

 

 

Submission:

The essential outputs of this Lab are within two parts:

1)   four Fractal projects consisting a set of ”.fractal”, ".idl" and “.c” files which can be correctly executed and,

2)   a PDF file that clearly describes your design of the system in different exercises.

A zip file containing all these outputs should be submitted to:

http://www.idt.mdh.se/kurser/assignments/cdt501/