You are on page 1of 30

OEIDUSP

IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

CHAPTER FOUR
IMPLEMENTATION OF THE SOFTWARE
4.1 The C# language and .NET
If we were to describe the c# language and its associated environment, the .NET
framework, as the most important new technology for developers for many years, we
would not be exaggerating. .NET is designed to provide a new environment with in
which you can develop almost any application to run on windows, while C# is new
programming language that has been designed specifically to work within Dot Net. Using
C#, you can for example, write a dynamic webpage, an XML web service, a database
access component or a classic windows desktop application.
In the Dot Net label, the NET bit in the name is there to emphasize Microsofts
belief that distributed applications, in which the processing is distributed between client
and server are the way forward, but C# is not just a language for writing windows based
application. It provides a means for you to code up almost any type of software or
component that you might need to write for the windows platform between them. C# and
Dot Net are set both to revolutionize the way that you write programs, and to make
programming on windows much easier than it has ever been.
Weve talked in general terms about how great .NET is, but we havent said much
about how it helps to make your life as a developer easier. In this section, well discuss
some of the improved features of .NET in brief.
Object-Oriented Programmingboth the .NET Framework and C# are entirely
based on object-oriented principles right from the start.
Good Designa base class library, which is designed from the ground up in a highly
intuitive way.
Language Independencewith .NET, all of the languages Visual Basic .NET, C#,
J#, and managed C++ compile to a common Intermediate Language. This means
that languages are interoperable in a way that has not been seen before.
_______________________________________________________________________
32
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
Efficient Data Accessa set of .NET components, collectively known as
ADO.NET, provides efficient access to relational databases and a variety of data
sources. Components are also available to allow access to the file system, and to
directories. In particular, XML support is built into .NET, allowing you to manipulate
data, which may be imported from or exported to non-Windows platforms.
Code Sharing.NET has completely revamped the way that code is shared between
applications, introducing the concept of the assembly, which replaces the traditional
DLL. Assemblies have formal facilities for versioning, and different versions of
assemblies can exist side by side.
Improved Securityeach assembly can also contain built-in security information
that can indicate precisely who or what category of user or process is allowed to call
which methods on which classes. This gives you a very fine degree of control over
how the assemblies that you deploy can be used.
C# can be seen as being the same thing to programming languages as .NET is to
the Windows environment. Just as Microsoft has been adding more and more features to
Windows and the Windows API over the past decade, Visual Basic and C++ have
undergone expansion. Although Visual Basic and C++ have ended up as hugely powerful
languages as a result of this, both languages also suffer from problems due to the legacies
of how they have evolved.
In the case of Visual Basic 6 and earlier, the main strength of the language was
the fact that it was simple to understand and didnt make many programming tasks easy,
largely hiding the details of the Windows API and the COM component infrastructure
from the developer. The downside to this was that Visual Basic was never truly objectoriented, so that large applications quickly become disorganized and hard to maintain. As
well as this, because Visual Basics syntax was inherited from early versions of BASIC
(which, in turn, was designed to be intuitively simple for beginning programmers to

_______________________________________________________________________
33
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
understand, rather than to write large commercial applications), it didnt really lend itself
to well-structured or object-oriented programs.
C++ has its roots in the ANSI C++ language definition. It isnt completely ANSI
compliant for the simple reason that Microsoft first wrote its C++ compiler before the
ANSI definition had become official, but it comes close. Unfortunately, this has led to
two problems. First, ANSI C++ has its roots in a decade-old state of technology, and this
shows up in a lack of support for modern concepts (such as Unicode strings and
generating XML documentation), and in some archaic syntax structures designed for the
compilers of yesteryear (such as the separation of declaration from definition of member
functions). Second, Microsoft has been simultaneously trying to evolve C++ into a
language that is designed for high-performance tasks on Windows, and in order to
achieve that theyve been forced to add a huge number of Microsoft-specific keywords as
well as various libraries to the language. The result is that on Windows, the language has
become a complete mess.
Now enter .NETa completely new environment that is going to involve new
extensions to both languages. Microsoft has gotten around this by adding yet more
Microsoft-specific keywords to C++, and by completely revamping Visual Basic into
Visual Basic .NET, a language that retains some of the basic VB syntax but that is so
different in design that we can consider it to be, for all practical purposes, a new
language.
Its in this context that Microsoft has decided to give developers an alternativea
language designed specifically for .NET, and designed with a clean slate. Visual C#
.NET is the result. Officially, Microsoft describes C# as a simple, modern, objectoriented, and type-safe programming language derived from C and C++. Most
independent observers would probably change that to derived from C, C++, and Java.
Such descriptions are technically accurate but do little to convey the beauty or elegance
of the language.
Syntactically, C# is very similar to both C++ and Java, to such an extent that
many keywords are the same, and C# also shares the same block structure with braces
_______________________________________________________________________
34
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
({}) to mark blocks of code, and semicolons to separate statements. The first impression
of a piece of C# code is that it looks quite like C++ or Java code. Behind that initial
similarity, however, C# is a lot easier to learn than C++, and of comparable difficulty to
Java. Its design is more in tune with modern developer tools than both of those other
languages, and it has been designed to give us, simultaneously, the ease of use of Visual
Basic, and the high performance, low-level memory access of C++ if required.
Some of the features of C# are:
Full support for classes and object-oriented programming, including interface and
implementation inheritance, virtual functions, and operator overloading.
A consistent and well-defined set of basic types.
Built-in support for automatic generation of XML documentation.
Automatic cleanup of dynamically allocated memory.
The facility to mark classes or methods with user-defined attributes. This can be
useful for documentation and can have some effects on compilation (for example,
marking methods to be compiled only in debug builds).
Full access to the .NET base class library, as well as easy access to the Windows API
(if you really need it, which wont be all that often).
Pointers and direct memory access are available if required, but the language has been
designed in such a way that you can work without them in almost all cases.
Support for properties and events in the style of Visual Basic.
Just by changing the compiler options, you can compile either to an executable or to a
library of .NET components that can be called up by other code in the same way as
ActiveX controls (COM components).

_______________________________________________________________________
35
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

4.2 Classes in OEIDUSP


When we design our project, we have defined different classes. Each class has its
own parameters, methods, members, constructors and has their own specified purposes to
manipulate some actions.
The classes that we defined are listed below with their respective generalized
sample code structure.
1)

Room

2)

Project

3)

Luminaries

4)

Data access

5)

ID base

6)

Form ( )

Room Class
This class holds the required specifications that are crucial for the room object.
Some of the specifications are room length, room width, room height and required
illumination level. This class also holds the method draw to draw the room by taking the
length and width of the room that is entered from the room form. It also calculated the
intensity of the room that is entered from the room form.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace InstallationDesign
{
public class Room : IDBase
{
private float width;
private float length;
private float height;
public float requiredIllLevel;
public float RoomWidth

_______________________________________________________________________
36
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
{
/// <summary>
/// get and set the room width
/// </summary>
///
}
public float RoomLength
{
/// <summary>
/// get and set the room length
/// </summary>
///
}
public float RoomHeight
{
/// <summary>
/// fget and set the room height
/// </summary>
///
}
public float RequiredIllLevel
{
/// <summary>
/// get and set the required illumination level
/// </summary>
///
}
public Room()
{
/// <summary>
/// constructor
/// </summary>
///
}
public void Draw()
{
/// <summary>
/// It will draw on the panel when it is called
/// </summary>
///
}
public double intencity_n()
{
/// <summary>

_______________________________________________________________________
37
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
/// it will calculate the intensity of the room.
/// </summary>
///
}
}
}

Project Class
In this class, we defined some object like the room, luminary that has to be on the
current project and its own member variables such as project ID. Generally this class will
hold and organize the materials that are used for creating the current or new project. Each
method is partially described in their region briefly below
using System;
using System.Drawing;
using System.Data;
using System.Text;
namespace InstallationDesign
{
public class Project : IDBase
{
#region mem vars
#endregion
/// <summary>
/// Declaration of Member variables
/// </summary>
///
#region properties
/// <summary>
/// gets or sets the Member variables
/// </summary>
///
#region ctor and dpose
public Project()
{
/// <summary>
/// region of Constructor
/// </summary>

_______________________________________________________________________
38
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
///
}
#endregion
#region methods
public void Draw()
{
/// <summary>
/// it will call the draw method defined in the class room
/// </summary>
///
}
public int get_Hstarting_point()
{
/// <summary>
/// it will get the horizontal starting point of
/// the luminaire that will be drawn on the form.
/// </summary>
///
}
public int get_Vstarting_point()
{
/// <summary>
/// it will get the vertical starting point of
///

the luminaire that will be drawn on the form.

/// </summary>
///
}
public void DrawLuminaries()
{
/// <summary>
/// it will draw the lamps when it is called
/// </summary>
///
}
public int SaveLuminaire()
{
/// <summary>
/// it will save luminaires that are entered on the data entry
/// form
/// </summary>
///
}

_______________________________________________________________________
39
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
#endregion
}
}

Luminary Class
This class organizes the luminaries specifications like name, distributor name,
family name, the housing type they used, power, flux and color. When we draw and
calculate the number of luminaries needed, these properties will be considered and the
luminary will be drawn.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace InstallationDesign
{
public class Luminaire
{
#region mem vars
/// <summary>
/// Declaration of Member variables
/// </summary>
///
#endregion
#region properties
/// <summary>
/// gets or sets the Member variables
/// </summary>
///
#endregion
public Luminaire()
{
/// <summary>
/// region of Constructor
/// </summary>
///
}
#region methods

_______________________________________________________________________
40
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
public Double intencity_of_lamp()
{
/// <summary>
/// it will calculate the lamps intensity
/// </summary>
///
}
public Double get_total_power()
{
/// <summary>
/// it will calculate the total power of the lamps
/// </summary>
///
}
#endregion
}
}

Data Access Class


In this class all the actions that are related to the database are manipulated some
of the actions; insert and update return a specific value and also returning the whole data
table to the user. These actions are performed by using the methods that are listed below.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
namespace InstallationDesign
{
public class DataAcess
{
#region Global Variables
/// <summary>
/// it will assign variables
/// </summary>
///
#endregion
#region ctor
public DataAcess()

_______________________________________________________________________
41
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
{
/// <summary>
/// region of Constructor
/// </summary>
///

}
#endregion
#region Methods
/// <summary>
/// region of database access.
/// </summary>
///
public static DataTable ExecuteDataTable(string Sql)
{
/// region of accessing the database to return a table.
}
public static object ExecuteScalar(string Sql)
{
/// region of accessing the database to return a single value.
}
public static int ExecuteNonQuery(string Sql)
{
/// region of accessing the database to insert,update and delete a
/// database.
}
#endregion
}
}

ID Base Class
This is a base class for project and room classes and it contains the graphics
materials that are crucial for drawing the room and the luminary on the panel.
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
namespace InstallationDesign

_______________________________________________________________________
42
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
{
public abstract class IDBase
{
#region mem vars
/// <summary>
/// declaration of member variables for the graphics object and
/// pen with which the graphics on the project is to be drawn
/// </summary>
///
#endregion
#region properties
/// <summary>
/// gets or sets the IDGraphics values
/// </summary>
#endregion
#region ctor
public IDBase()
{
/// <summary>
/// region of constructor
/// </summary>
///
}
#endregion
}
}

4.3 General Steps


In this section, we tried to show the general steps that we go through in executing
the developed system from the beginning of the software until the end of the process.
This can be easily shown using flow chart diagram.

_______________________________________________________________________
43
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
Start

Enter luminary data to the


Database

Enter room parameters


&
Draw room

Select luminary from Database


&
Calculate number of lamps

Draw Luminary on the room

Fig 4.1. General Steps

_______________________________________________________________________
44
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

Enter supply voltage


&
Cable length

Calculate cable size


&
Breaker rating

Close application

End

_______________________________________________________________________
45
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

4.4. Flow Chart of OEIDUSP

_______________________________________________________________________
46
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
Start

Create a new project.


Click on data.

If room is
selected

A
Fill room fields.
J
E
D
If room! =null
Wait until user
inputs the fields
Draw room.
Give the room to the room
class.

Click on data &


select project
luminary.

B
Fig 4.2. Flow Chart
_______________________________________________________________________
47
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
B

If family
selected
Wait till it is
selected
Populate housing
D

If housing
selected

E
D

Populate Distributors

Wait till it is
selected

If distributors
selected

Populate Lamps.

Wait till it is
selected

If lamp is
selected

Do nothing
_______________________________________________________________________
48 C
_
G Department
Electrical Engineering
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
C

Display flux, color, calculate number


of lamps & display number.

If selected
family changed
If selected
Housing
changed

E
D

If selected
Distributor
changed

If selected
Lamp changed
G
_______________________________________________________________________
49
_
H
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
H

Click on ok.
Draw the luminary.

Enter the supply voltage,


cable length, temperature &
check for fuse.

Calculate the design current.


Select the breaker rating current.
Select the cable size.

Calculate voltage drop.

If
Voltage drop > 4%
of supply voltage

Select the next


larger cable size.

Display cable size &


breaker rating

_______________________________________________________________________
50End
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
A

Enter the
luminary
database.
Click on ok.
Add the luminary to the database

_______________________________________________________________________
51
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

4.5. User Interfaces


In this section, we will describe each and every user interfaces that are developed
in our system sequentially when the program is running. Our developed system
comprises four different user interfaces. These are:
1)

Main Form

2)

Project Luminary Form

3)

Room Form

4)

Data Entry Form

it to
n
o
m
lick w for
C
1. n ne
ope

Fig 4.3. Main Form

_______________________________________________________________________
52
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

3. Click here to enter room


parameters

2. This is new
form

Fig 4.4. New Main Form

_______________________________________________________________________
53
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

4. This is room form

5. Click here to draw the room


after filling the parameters

Fig 4.5. Room Form

6. Top view of the room

_______________________________________________________________________
54
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
Fig 4.6. Top view of the room

7. Click here to
select luminary
types

Fig 4.7. Room selecting luminary

_______________________________________________________________________
55
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

8. Project luminary
form

10. Click here to select


luminaries preference
from a list

9. Click here to
select family
types

11. Select maint.


and util. factors

12. This displays


lamp specifications

14. Click here to


see the luminaries
inside the room

13. This shows the


calculated number
_______________________________________________________________________
56
of liminaries
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

Fig 4.8. Luminary selection

16. Enter the


supply voltage,
cable length and
temp

17. Click here to


calculate cable size
and breaker rating

18. Displays
cable size and
breaker rating

15. Displayed output

Fig 4.9. Displayed luminaries and calculation of cable size


_______________________________________________________________________
57
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

19. Click here


to add
luminary to the
data base

Fig 4.10. Selecting data entry form

_______________________________________________________________________
58
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
20. Data
Entry form

21. Add the specifications


of the luminary

20. Click here to save the


specification to the data
base.

Fig 4.11.Data entry form

4.6. Database Selection


In this OEIDUSP system, data such as Luminary type, Lamp family, Housing
Lamps, are persistent. In addition we have noted that the nature of the system is highly
queried intensive. In light of the above reasons, relational database is found to be the
right choice.
We have also selected Microsoft SQL server 2000 as our database management
system. Microsoft SQL server 2000 is widely available and many trained manpower can
be found easily. In addition to the above services, Microsoft SQL server 2000 provides
connectivity standards such as ODBC that can provide data abstraction enabling us to
encapsulate data into subsystems and define high level interface that is vendor
independent.

_______________________________________________________________________
59
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_
In our designed system we use the following data table diagram to manipulate the
data execution of the system. Each table contains its own data type for its own column.
The tables that are used are:
i.

Voltage_drop table: In this table the data for voltage drop of some
specific cable is stored. The cable is determined by its size & the voltage drop is
in mm volts.

ii.

Breaker table: in this table the breaker rating current with the design current
is stored.

iii.

Temperature table: In this table the temperature effect of the grouped cables
is determined according to the temperature of the cables inside the conduit.

iv.

Cable_size: In this table the current carrying conductors cross sectional area
is determined from its current carrying capacity (amount of current).

v.

Family: In this table the name of the lamp family is stored with its own id.

vi.

Housing: In this table the lamps housing type is stored with its foreign key
from the family table (i.e. family id) & its own id.

vii.

Distributor: In this table the name of lamp distributor is stored with its own
row id, & the foreign key from the housing table (i.e. the id of the housing table).

viii.

Lamp: In this table each & every property of the lamp are stored. These are
color, name, power, amount of flux & distributor they use (i.e. foreign key from
the distributor table).

_______________________________________________________________________
60
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

OEIDUSP
IMPLEMENTATION OF THE
SOFTWARE
_______________________________________________________________________
_

Fig 4.12. Database diagram of OEIDUSP.

_______________________________________________________________________
61
_
Electrical Engineering Department
Arba Minch University
Faculty of Engineering
June 2007

You might also like