Giga System Builder Guide
3.2 Modelling a System
In this section, we model the system, by fleshing out the .osm file.
To start adding to the model, double-click on the .osm file in the Package Explorer window.
This will open the file and show this:
3.2.1 Modelling Properties|
Note that the CongestionChargeModel.osm window is selected.
To ensure the Properties View is visible, right-click on and
select 'Show Properties View'
The properties view is context sensitive and allows you to set the values of appropriate properties.
Expand the model and you will see
3.2.2 Amending The Application|
Select the Application row. In the properties view you will see
In the properties view, amend the name of the application to 'CongestionChargeApp'. On pressing 'Enter' the model will change to
By the way, if you prefer to navigate by typing rather than using the mouse, once you have selected an element on the model,
you can navigate up/down and open/close up the model using the up/down/left/right keys.
You can also use the Delete key to delete objects, and use Ctrl-Z and Ctrl-Y for Edit-Undo and Edit-Redo.
Now we are going to add some sub-elements to the Application. The sub-elements of Application are
3.2.3 Adding A Jar|
Let's add a Jar which will hold some Java beans.
A Jar is used to hold common objects - Java beans - and any beans in it will be available
to all PUs.
A PU can also declare Java beans, but they will not be available outside the PU.
Right click on the Application row and select
New Child -> Jar
A new Jar 'jar1' is added to the model
In the properties view change the name of the Jar to 'BeanJar' and set the package to 'com.cc.beans'.
Now for the Vehicle bean.
3.2.4 Adding the Vehicle Bean to the Jar|
To add a Java Bean, right click on the Jar row and select
New Child -> Java Bean
A Java Bean is added to the model
In the properties view change the name of the Java Bean to a 'Vehicle'.
Now we'll add 4 fields to the bean - they are 'children' of the bean. To do this, right-click on the Bean row and select
New Child -> Field
In the properties view set the names and types of the fields as follows
||String. ('String' is the default so you don't have to enter it.)
You can duplicate an item by holding down the control, selecting it with the mouse and moving and dropping it
(while the '+' sign is showing) to another valid point in the diagram.
The model should now be:
Now add another bean to the Jar and name it 'Payment'. Add three fields
3.2.5 Adding the Payment Bean to the Jar|
Now add a third bean to the Jar and name it 'CongestionCharge'. Make it extend the Payment bean. This is done by using the dropdown on the
'Extends Object' property:
3.2.6 Adding the Congestion Charge Bean to the Jar|
Add one field
Now add a fourth bean to the Jar and name it 'Fine'. Make it also extend the Payment bean.
3.2.7 Adding the Fine Bean to the Jar|
Add one field:
Note: Notice that as well as the option to add a 'New Child' you could also add a 'New Sibling'.
3.2.8 Siblings or Children|
Now add a Processing Unit below the application. Call it 'CongestionZoneProcessor' and give it package of 'com.cc.zone.
This processing unit is going to contain a space into which the CongestionCharge and Vehicles are fed. So, create a space below the Processing
Unit and call it 'CongestionZone'
3.2.9 Adding a Processing Unit with a Space|
When a Vehicle enters the CongestionZone it will trigger an event which will call an Action. So we need an event in the Space and an Action that
the event will call. Create an Action under the CongestionZoneProcessor and call it 'ProcessVehicle'. It should have an Input Object of Vehicle.
and a Result Object of Fine.
3.2.10 Adding a Action|
Add a SelectionEvent to the CongestionZone and set the Action to be ProcessVehicle. Also set the style to be 'subscriber' and the template-
bean to be Vehicle
3.2.11 Adding a Selection-Event|
In the same way when a CongestionCharge enters the space an event will be triggered which will call and action. To model this create an Action
called 'ProcessCharge'. It should take a 'CongestionCharge' as the Input Object. Leave the Result Object blank
3.2.12 Another Action and Another Selection-Event|
Then create the selection-event that links the space to the action. Set the style to be subscriber and the template-bean to CongestionCharge.
Lifecycle events are used to adjust the objects . We need two lifecycle-events. The first will be used to filter out any vehicles made before the
year 1972 before it enters the space. The second will be used to log the vehicles that once they enter the space. To do this select the
'CongestionZone' space and add a lifecycle-event sub-element. Name it 'removeOldCars'. Select the operations to be 'before-write'.
3.2.13 Adding the Lifecycle-Events|
In a similar way create the second lifecycle-event. Set its name to be 'logVehicle' and its operation to be 'after-write':
Add another Processing Unit and call it 'RoadUsers'. Give it a package of 'com.cc.road'. This is going to simply feed the CongestionCharge and
Vehicles in to the CongestionZone.
3.2.14 Another Processing Unit|
The next couple of steps will result in a helper class with a couple of methods on it which will make the implementation easier.
Add an action to 'RoadUsers' and call it 'payCongestionCharge'. Make its inputObject be 'CongestionCharge'. Leave the resultObject blank.
Add a second action and call it 'driveVehicleIntoZone'. Make its inputObject be Vehicle. Again leave the resultObject blank.
Next add a bean to the Road Users Processing Unit. Name this bean 'Generator'. We will add some code to this bean to generate vehicles and
congestionCharges and add them to the CongestionZone space. On the 'Generator' bean add two methods 'startGeneration' and 'stopGeneration'.
Set these methods to be the 'Init Method' and 'Destroy Method' respectively. These will be used to start and stop the generation of the
vehicles and congestionCharges.
Add another Processing Unit and call it 'DVLA'. Give it a package of 'com.cc.dvla'.
In Britain the DVLA is the Driving and Vehicle Licensing Authority. This Processing Unit is going to contain a service which will check
the licencePlate on a vechicle. The service will be passed a String and will return either true or false depending on whether the licencePlate
3.2.15 Yet Another Processing Unit|
The current version of the GigaSystem Builder requires there to be a space in the same processing unit that contains the service. This
space will be used as the transport mechanism for the service. So before we add a service to the DVLA Processing Unit we need to add a space.
Call it the dvlaSpace. Then add a service to the DVLA Processing Unit and call the service 'LicenceService'. Also specify the space as 'dvlaSpace'
3.2.16 Adding a Service|
Now we need to add business method to the service. Call the businessMethod 'isLicenceValid'. The Return Type should be 'Boolean'.
Also add to the business method a parameter called 'licence' and of type 'String'.
Nearly there. One last thing to do. The service has been defined but nothing is making use of it yet. The Processing Unit that will call the
LicenceService is the CongestionZoneProcessor. So, add a Service Call to this Processing Unit. Select the service to use. There should be only
3.2.17 Calling a Service|
Right! That's it modelling over. Save your model and have a cup of tea. The next chapter will describe how to build the system and
how to add the implementation code (the business logic).
Copyright (c) 2001-2008 New Technology/enterprise Ltd.