installation design project
TRANSCRIPT
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
CHAPTER FOUR
IMPLEMENTATION OF THE SOFTWARE
4.1 The C# language and .NETIf 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 Microsoft’s
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.
We’ve talked in general terms about how great .NET is, but we haven’t said much
about how it helps to make your life as a developer easier. In this section, we’ll discuss
some of the improved features of .NET in brief.
Object-Oriented Programming—both the .NET Framework and C# are entirely
based on object-oriented principles right from the start.
Good Design—a base class library, which is designed from the ground up in a highly
intuitive way.
Language Independence—with .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.
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
32
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________Efficient Data Access—a 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 Security—each 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 didn’t 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 object-
oriented, so that large applications quickly become disorganized and hard to maintain. As
well as this, because Visual Basic’s syntax was inherited from early versions of BASIC
(which, in turn, was designed to be intuitively simple for beginning programmers to
understand, rather than to write large commercial applications), it didn’t really lend itself
to well-structured or object-oriented programs.
C++ has its roots in the ANSI C++ language definition. It isn’t completely ANSI
compliant for the simple reason that Microsoft first wrote its C++ compiler before the
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
33
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________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 they’ve 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 .NET—a 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.
It’s in this context that Microsoft has decided to give developers an alternative—a
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, object-
oriented, 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
({}) 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
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
34
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________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 won’t 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).
4.2 Classes in OEIDUSPWhen 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
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
35
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
3) Luminaries
4) Data access
5) ID base
6) Form ( )
Room ClassThis 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
{
/// <summary>
/// get and set the room width
/// </summary>
///
}
public float RoomLength
{
/// <summary>
/// get and set the room length
/// </summary>
///
}
public float RoomHeight
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
36
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________ {
/// <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>
/// it will calculate the intensity of the room.
/// </summary>
///
}
}
}
Project ClassIn 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
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
37
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________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>
///
}
#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>
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
38
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________ ///
}
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>
///
}
#endregion
}
}
Luminary ClassThis 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
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
39
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________ {
#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
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
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
40
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
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()
{
/// <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.
}
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
41
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________ public static int ExecuteNonQuery(string Sql)
{
/// region of accessing the database to insert,update and delete a
/// database.
}
#endregion
}
}
ID Base ClassThis 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
{
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>
///
}
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
42
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________ #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.
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
43
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
Fig 4.1. General Steps
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
Enter luminary data to the Database
Start
Enter room parameters&
Draw room
Select luminary from Database &
Calculate number of lamps
Draw Luminary on the room
44
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
End
Calculate cable size &
Breaker rating
Close application
Enter supply voltage&
Cable length
45
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
4.4. Flow Chart of OEIDUSP
Fig 4.2. Flow Chart________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
Fill room fields.
If room! =null
Start
Draw room.Give the room to the room
class.
Wait until user inputs the fields
Click on data & select project
luminary.
If room is selected
Create a new project.Click on data.
A
B
JED
46
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
Populate housing
B
If family selected
If housing selected
Wait till it is selected
Wait till it is selected
Populate Distributors
If distributors selected
Wait till it is selectedPopulate Lamps.
C
If lamp is selected
D
ED
F
G
Do nothing
47
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
If selected family changed
Display flux, color, calculate number of lamps & display number.
D
If selected Housing changedE
D
If selected Distributor
changedF
If selected Lamp changed
G
H
C
48
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
IfVoltage drop > 4% of supply voltage
Click on ok.Draw the luminary.
H
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.
Select the next larger cable size.
Display cable size & breaker rating
End
49
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
A
Enter the luminary database.
Click on ok.Add the luminary to the database
J
50
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
4.5. User InterfacesIn 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
Fig 4.3. Main Form
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
51
1. Click on it to
open new form
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
Fig 4.4. New Main Form
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
52
2. This is new form
3. Click here to enter room parameters
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
Fig 4.5. Room Form
Fig 4.6. Top view of the room
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
53
4. This is room form
5. Click here to draw the room after filling the parameters
6. Top view of the room
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
Fig 4.7. Room selecting luminary
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
54
7. Click here to select luminary types
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
Fig 4.8. Luminary selection
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
55
9. Click here to select family
types
8. Project luminary form
10. Click here to select luminaries’ preference
from a list11. Select maint. and util. factors
13. This shows the calculated number
of liminaries
12. This displays lamp specifications
14. Click here to see the luminaries inside the room
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
Fig 4.9. Displayed luminaries and calculation of cable size
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
56
15. Displayed output
17. Click here to calculate cable size and breaker rating
16. Enter the supply voltage, cable length and
temp
18. Displays cable size and breaker rating
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
Fig 4.10. Selecting data entry form
Fig 4.11.Data entry form
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
57
21. Add the specifications of the luminary
19. Click here to add
luminary to the data base
20. Click here to save the specification to the data
base.
20. Data Entry form
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________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.
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 lamp’s 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).
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
58
OEIDUSP IMPLEMENTATION OF THE SOFTWARE________________________________________________________________________
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).
Fig 4.12. Database diagram of OEIDUSP.
________________________________________________________________________Electrical Engineering Department Arba Minch UniversityFaculty of Engineering June 2007
59