final final

61
0

Upload: syedah-maira-rizwi

Post on 21-Dec-2015

219 views

Category:

Documents


0 download

DESCRIPTION

file

TRANSCRIPT

Page 1: Final Final

0

Page 2: Final Final

1

Chapter: 1 INTRODUCTION

1.1 Overview: The need of simulating electronic circuits by using digital and analogue components is

booming nowadays. It is vast and it has so many application and engineering research areas. By

approaching a system at a higher level of abstraction, the designer is better able to understand the

behaviors and interactions of all the high level components within the system and is therefore

better equipped to counteract the complexity of overall system. As the designer better

understands the operation of the higher level components through the use of the simulator, the

lower level components may then be designed and subsequently simulated for verification and

performance evaluation.

1.2 Project Description: This project gets its backbone idea from Electronic Work Bench released back in 1996.

The success of EWB can be observed from the fact that it is still being used to educate and train

young Electronics, Computer, Telecommunication and Electrical Engineers and also at high

school level. Now a days several platforms other than desktop applications are available to train

the students. For example the training softwares are now web applets which can directly run on

websites. Another vastly growing platform is smart phones and tablet computers. These devices

can also be used in educational purposes. So we decided to make an application for android

based tablets for e.g. galaxy tab which can be easily accessible to all Professionals, Engineers,

and Students.

This project is the combination of classical concept of simulation built on the entirely new

technologies. Our android based electronic simulator enables the students, professionals and

engineers to simulate circuits with their ease and comfort as whenever they want without plug-in

Page 3: Final Final

2

the PC or Laptop. It is developed on a Virtual Vero board simulated in our android application.

Students can place components on the Vero board and these components will work the same as

the real hardware. This allows the designer to determine the correctness and efficiency of a

design before the system is actually constructed. Consequently, the user may explore the merits

of alternative designs without actually physically building the systems.

1.3 Main Features: This Android circuit simulation application will design and analyze circuits without using

breadboards, real components or actual instruments. Its touch-and-drag operations would make

editing a circuit fast and easy. You can change parameters and circuit components on the fly,

which makes analysis straight forward.

It first leads you through the fundamental steps of putting a circuit together and analyzing

its function using the instruments. It also tries to encourage you to apply the incremental

approach to circuit design. It will greatly help you to understand and to make changes to the

circuits you are working on, observe the effects that these changes have, and try to understand

them.

1.4 Objectives: ElectoSim will support the following objectives

To create Digital Circuits using Logic Gates, Switches, LEDs and

Combinational logic elements.

To simulate the behavior of entire circuit.

Measuring the output of the circuit with the help of LEDs and Seven Segment

Display.

Automatic conversion of logic equations into logic circuits and vice versa.

Page 4: Final Final

3

Maintaining the library/ database for the application so that user can save and

resume the work.

Maintaining the database for formulas.

1.5 Use Case Diagram:

Fig 1.1 Use Case Diagram showing different actions that can be performed by user

Open Application/ Splash Screen

Started

Create New Circuit

Save Circuit

Open Saved Circuit

Run Simulation

Pause Simulation

Check Output

View Help

View About

Close Project

Close Application

User

Page 5: Final Final

4

Chapter: 2

ESSENTIALS OF ANDROID DEVELOPMENT FOR ELECTROSIM

2.1 Android and Linux:

Android is a Linux-based operating system for mobile devices such as smart

phones and tablet computers Android is built on top of a solid and proven foundation: the Linux

kernel. Linux can be found today in everything from wristwatches to supercomputers. Linux

provides the hardware abstraction layer for Android, allowing Android to be ported to a wide

variety of platforms in the future.

Linux provides the hardware abstraction layer for Android, allowing Android to be

ported to a wide variety of platforms in the future. Internally, Android uses Linux for its memory

management, process management, networking, and other operating system services. The

Android phone user will never see Linux and your programs will not make Linux calls directly.

As a developer, though, you’ll need to beware it’s there. Some utilities you need during

development interact with Linux.

.

Fig 2.1 Major components of the Android operating system

Page 6: Final Final

5

2.2 Android and Java

Android applications are developed using the Java language. Android uses a standard

Java compiler to compile your source code into regular byte codes and then translates those byte

codes into Dalvik instructions. Therefore, the entire Java language is supported, not just a subset.

Compare this to the Google Web Toolkit (GWT), which has its own Java to JavaScript

translator. By using the stock compiler and byte codes, you don’t even need to have the source

code for libraries that you want to use in your applications .Java incorporate many of the

powerful features. The programming languages are only as powerful as their libraries. These

libraries exist to help developers build applications.

Some of the Java’s important core features are:

It’s easy to learn and understand

It’s designed to be platform-independent and secure, using

virtual machines

It’s object-oriented

Android relies heavily on these Java fundamentals. The Android SDK includes many

standard Java libraries (data structure libraries, math libraries, graphics libraries, networking

libraries and everything else you could want) as well as special Android libraries that will help

you develop awesome Android applications.

2.3 Android API Levels:

As you develop your application on Android, it's useful to understand the platform's

general and the role it plays in ensuring your application's compatibility with devices on which it

may be installed.

Page 7: Final Final

6

The sections below provide information about API level and how it affects your

applications. For information about how to use the "Filter by API level" control available in the

API reference documentation, see Filtering the documentation at the end of this document.

API level is an integer value that uniquely identifies the framework API revision offered by a

version of the Android platform. The Android platform provides a framework API that

applications can use to interact with the underlying Android system. The framework API

consists of:

A core set of packages and classes

A set of XML elements and attributes for declaring a manifest file

A set of XML elements and attributes for declaring and accessing resources

A set of Intents

A set of permissions that applications can request, as well as permission enforcements

included in the system

Each successive version of the Android platform can include updates to the Android

application framework API that it delivers.

Updates to the framework API are designed so that the new API remains compatible with earlier

versions of the API. That is, most changes in the API are additive and introduce new or

replacement functionality. As parts of the API are upgraded, the older replaced parts are

deprecated but are not removed, so that existing applications can still use them. In a very small

number of cases, parts of the API may be modified or removed, although typically such changes

are only needed to ensure API robustness and application or system security. All other API parts

from earlier revisions are carried forward without modification.

The framework API that an Android platform delivers is specified using an integer

identifier called "API level". Each Android platform version supports exactly one API level,

Page 8: Final Final

7

although support is implicit for all earlier API levels (down to API level 1). The initial release of

the Android platform provided API level 1 and subsequent releases have incremented the API

levels. The following table specifies the API level supported by each version of the Android

platform.

PLATFORM VERSION API LEVEL VERSION CODE

Android 4.0.3 15 ICE CREAM SANDWICH MR1

Android 4.0, 4.0.1, 4.0.2 14 ICE CREAM SANDWICH

Android 3.2 13 HONEYCOMB_MR2

Android 3.1.x 12 HONEYCOMB_MR1

Android 3.0.x 11 HONEYCOMB

Android 2.3.4

Android 2.3.3

10 GINGERBREAD_MR1

Android 2.3.2

Android 2.3.1

Android 2.3

9 GINGERBREAD

Android 2.2.x 8 FROYO

Android 2.1.x 7 ECLAIR_MR1

Android 2.0.1 6 ECLAIR_0_1

Android 2.0 5 ECLAIR

Android 1.6 4 DONUT

Android 1.5 3 CUPCAKE

Android 1.1 2 BASE_1_1

Android 1.0 1 BASE

Page 9: Final Final

8

2.4 Android Emulator:

The Android SDK includes a virtual mobile device emulator that runs on your computer.

The emulator lets you prototype, develop and test Android applications without using a physical

device.

The Android emulator mimics all of the hardware and software features of a typical

mobile device, except that it cannot place actual phone calls. It provides a variety of navigation

and control keys, which you can "press" using your mouse or keyboard to generate events for

your application. It also provides a screen in which your application is displayed, together with

any other active Android applications.

To let you model and test the application more easily, the emulator utilizes Android

Virtual Device (AVD) configurations. AVD let you define certain hardware aspects of your

emulated phone and allows creating many configurations to test many Android platforms and

hardware permutations. Once the application is running on the emulator, it can use the services

of the Android platform to invoke other applications, access the network, play audio and video,

store and retrieve data, notify the user, and render graphical transitions and themes.

The emulator also includes a variety of debug capabilities, such as a console from which

you can log kernel output, simulate application interrupts (such as arriving SMS messages or

phone calls), and simulate latency effects and dropouts on the data network

2.5 Android DDMS:

Android ships with a debugging tool called the Dalvik Debug Monitor Server (DDMS),

which provides port-forwarding services, screen capture on the device, thread and heap

information on the device, log cat, process, and radio state information, incoming call and SMS

Page 10: Final Final

9

spoofing, location data spoofing, and more. This page provides a modest discussion of DDMS

features; it is not an exhaustive exploration of all the features and capabilities.

Viewing heap usage for a process:

DDMS allows to view how much heap memory a process is using. This information is useful in

tracking heap usage at a certain point of time during the execution of the application.

To track memory allocation of objects:

DDMS provides a feature to track objects that are being allocated to memory and to see

which classes and threads are allocating the objects. This allows tracking, in real time,

where objects are being allocated when performing certain actions in the application.

This information is valuable for assessing memory usage that can affect application

performance.

2.6 Android User Interface:

In an Android application, the user interface is built using View and View Group objects.

There are many types of views and view groups, each of which is a descendant of the View class.

View objects are the basic units of user interface expression on the Android platform.

The View class serves as the base for subclasses called "widgets," which offer fully implemented

UI objects, like text fields and buttons. The View Group class serves as the base for subclasses

called "layouts," which offer different kinds of layout architecture, like linear, tabular and

relative.

A View object is a data structure whose properties store the layout parameters and

content for a specific rectangular area of the screen. A View object handles its own

Page 11: Final Final

10

measurement, layout, drawing, focus change, scrolling, and key/gesture interactions for the

rectangular area of the screen in which it resides. As an object in the user interface, a View is

also a point of interaction for the user and the receiver of the interaction events.

Fig 2.2 Hierarchy among views

2.6.1 Layouts:

The layout is the architecture for the user interface in an Activity. It defines the layout

structure and holds all the elements that appear to the user. Layout can be declared in two ways:

Declare UI elements in XML. Android provides a straightforward XML vocabulary that

corresponds to the View classes and subclasses, such as those for widgets and layouts.

Instantiate layout elements at runtime. Your application can create View and View Group

objects (and manipulate their properties) programmatically.

Page 12: Final Final

11

The Android framework gives the flexibility to use either or both of these methods for

declaring and managing your application's UI. For example, you could declare your application's

default layouts in XML, including the screen elements that will appear in them and their

properties. You could then add code in your application that would modify the state of the screen

objects, including those declared in XML, at run time.

The advantage to declaring the UI in XML is that it enables to better separate the

presentation of your application from the code that controls its behavior. Your UI descriptions

are external to your application code, which means that you can modify or adapt it without

having to modify your source code and recompile. For example, you can create XML layouts for

different screen orientations, different device screen sizes, and different languages. Additionally,

declaring the layout in XML makes it easier to visualize the structure of your UI, so it's easier to

debug problems.

Frame Layouts:

Frame Layout is the simplest type of layout object. It's basically a blank space on your screen

that you can later fill with a single object — for example, a picture that you'll swap in and out.

All child elements of the Frame Layout are pinned to the top left corner of the screen; you cannot

specify a different location for a child view. Subsequent child views will simply be drawn over

previous ones, partially or totally obscuring them (unless the newer object is transparent).

Linear Layout:

Linear Layout aligns all children in a single direction — vertically or horizontally, depending on

how you define the orientation attribute. All children are stacked one after the other, so a vertical

list will only have one child per row, no matter how wide they are, and a horizontal list will only

Page 13: Final Final

12

be one row high (the height of the tallest child, plus padding). A Linear Layout respects margins

between children and the gravity (right, center, or left alignment) of each child.

Linear Layout also supports assigning a weight to individual children. This attribute assigns

an "importance" value to a view, and allows it to expand to fill any remaining space in the parent

view. Child views can specify an integer weight value, and then any remaining space in the view

group is assigned to children in the proportion of their declared weight. Default weight is zero.

For example, if there are three text boxes and two of them declare a weight of 1, while the other

is given no weight (0), the third text box without weight will not grow and will only occupy the

area required by its content. The other two will expand equally to fill the space remaining after

all three boxes are measured. If the third box is then given a weight of 2 (instead of 0), then it is

now declared "more important" than both the others, so it gets half the total remaining space,

while the first two share the rest equally.

Table layout:

Table Layout positions its children into rows and columns. Table Layout containers do not

display border lines for their rows, columns, or cells. The table will have as many columns as the

row with the most cells. A table can leave cells empty, but cells cannot span columns, as they

can in HTML.

Table Row objects are the child views of a Table Layout (each Table Row defines a single row

in the table). Each row has zero or more cells, each of which is defined by any kind of other

View. So, the cells of a row may be composed of a variety of View objects, like Image View or

Text View objects. A cell may also be a View Group object (for example, you can nest another

Table Layout as a cell).

Relative Layout:

Page 14: Final Final

13

Relative Layout lets child views specify their position relative to the parent view or to each other

(specified by ID). So you can align two elements by right border, or make one below another,

centered in the screen, centered left, and so on. Elements are rendered in the order given, so if the

first element is centered in the screen, other elements aligning themselves to that element will be

aligned relative to screen center. Also, because of this ordering, if using XML to specify this

layout, the element that you will reference (in order to position other view objects) must be listed

in the XML file before you refer to it from the other views via its reference ID.

2.6.2 Activities:

An Activity is an application component that provides a screen with which users can

interact in order to do something, such as dial the phone, take a photo, send an email, or view a

map. Each activity is given a window in which to draw its user interface. The window typically

fills the screen, but may be smaller than the screen and float on top of other windows.

An application usually consists of multiple activities that are loosely bound to each other.

Typically, one activity in an application is specified as the "main" activity, which is presented to

the user when launching the application for the first time. Each activity can then start another

activity in order to perform different actions. Each time a new activity starts, the previous

activity is stopped, but the system preserves the activity in a stack (the "back stack"). When a

new activity starts, it is pushed onto the back stack and takes user focus. The back stack abides to

the basic "last in, first out" stack mechanism, so, when the user is done with the current activity

and presses the Back button, it is popped from the stack and the previous activity

resumes document.

Page 15: Final Final

14

When an activity is stopped because a new activity starts, it is notified of this change in

state through the activity's lifecycle callback methods. There are several callback methods that an

activity might receive, due to a change in its state whether the system is creating it, stopping it,

resuming it, or destroying it and each callback provides you the opportunity to perform specific

work that's appropriate to that state change. For instance, when stopped, your activity should

release any large objects, such as network or database connections. When the activity resumes,

you can reacquire the necessary resources and resume actions that were interrupted. These state

transitions are all part of the activity lifecycle.

Fig 2.3 Activity life cycle

Page 16: Final Final

15

2.6.4 Developing for Multiple Devices and Screen Sizes:

Android runs on a variety of devices that offer different screen sizes and densities. For

applications, the Android system provides a consistent development environment across devices

and handles most of the work to adjust each application's user interface to the screen on which it

is displayed. At the same time, the system provides APIs that allow you to control your

application's UI for specific screen sizes and densities, in order to optimize your UI design for

different screen configurations. For example, you might want a UI for tablets that's different

from the UI for handsets.

Although the system performs scaling and resizing to make your application work on

different screens, you should make the effort to optimize your application for different screen

sizes and densities. In doing so, you maximize the user experience for all devices and your users

believe that your application was actually designed for their devices rather than simply stretched

to fit the screen on their devices.

Supporting Different Screen Sizes:

There are a lot of different sized Android devices out there you’ve got big screens, little screens,

and everything in between. And it’s your job to support them all by:

Ensuring your layout can be adequately resized to fit the screen

Providing appropriate UI layout according to screen configuration

Ensuring the correct layout is applied to the correct screen

Providing bitmaps that scale correctly

Page 17: Final Final

16

2.7 Content Provider:

Content providers manage access to a structured set of data. They encapsulate the data,

and provide mechanisms for defining data security. Content providers are the standard interface

that connects data in one process with code running in another process.

When you want to access data in a content provider, you use the Content Resolver object

in your application's Context to communicate with the provider as a client. The Content

Resolver object communicates with the provider object, an instance of a class that

implements Content Provider. The provider object receives data requests from clients, performs

the requested action, and returns the results. Android itself includes content providers that

manage data such as audio, video, images, and personal contact information.

Page 18: Final Final

17

Chapter: 3

ACTIVITIES OF ELECTROSIM

3.1 Screen Navigation

It is important for developers to create proper paths in order to navigate through the

different screens of application. These paths can be two-way paths as well as one time (no

return) paths. Screens are arranged in a form of stack. The current screen visible to the user is top

of stack and rest screens are below it. Screen navigation schemes depend upon types of

application.

Fig 3.1 Screen Navigation in ElectroSim

Page 19: Final Final

18

3.2 Splash Screen:

When our project is started, the screen that appears first is called splash. In this screen the

title of the project is shown. Professional applications use splash screens to tell the user that the

program is loading and starting. It can make a large application appear to load and run faster,

since something appears on the screen while the rest of the application loads.

A Splash Screen is useful when the application has an initialization procedure that can

take a significant amount of time before the application becomes responsive. It may also contain

useful marketing or other information. In short the purpose of a splash screen is to entertain and

inform the user while the program is busy getting ready to respond. Another benefit of showing a

splash screen is that it helps the developer and end user understand how long each initialization

step takes and if for some reason the initialization doesn't complete we know which step caused

the problem.

After the splash screen our main menu interface is started which consist of four parts

Create circuit

Saved circuits

help

about

3.3 Create Circuit:

When we click create circuit button, a new activity is opened in which we can create a

circuit. It includes the following elements

A circuit drawing area

A scrollable Widget of components

Page 20: Final Final

19

Buttons to start simulation, save circuit and delete components

3.4 Saved Circuit:

In the saved circuit activity we can view the saved files. Files are arranged in a Grid View

layout which arranges its components in the form of a grid. A GridView is a View Group that

displays items in two-dimensional scrolling grid. The items in the grid come from the

ListAdapter associated with this view. On selecting any of the saved circuit, user is routed back

to create circuit screen in which the circuit is already drawn (see fig 3.1).

3.5 Help:

In the help section the elements along with their description, diagram and truth tables are

present .In case of any query the user will open the help section and get information about

particular gates etc. The information is shown inside a Scrollview Layout.

It is layout container for a view hierarchy that can be scrolled by the user, allowing it to

be larger than the physical display. A Scrollview is a FrameLayout, meaning you should place

one child in it containing the entire contents to scroll; this child may itself be a layout manager

with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical

orientation, presenting a vertical array of top-level items that the user can scroll through.

3.6 About:

In the about section the details of developers are present along with the project name.

This information is shown in a box theme. A theme is a style applied to an entire Activity or

Page 21: Final Final

20

application. When a style is applied as a theme, every View in the Activity or application will

apply each style property that it supports.

Page 22: Final Final

21

Chapter: 4

TECHNICAL ARCHITECTURE OF ELECTROSIM

4.1 Components of the Eclipse Project:

The design of software turns out to be the main criteria to judge it with respect to

openness, extendibility, maintenance and performance. The tools used develop this project help

to shape the project in a more engineered form.

Fig 4.1 Project explorer in eclipse IDE

Page 23: Final Final

22

This is not just exploration. By automatically arranging the related sets of files in appropriate

group, eclipse IDE reduces the time for production and maintenance.

Name

Purpose

src

The source folder contains Activity file, which is

stored at

(src/your/package/namespace/ActivityName.java). All

other source code files (such as .java or .AIDL

(Android Interface Definition Language) files go here

as well.

gen

The gen folder contains BuildConfig.java and R.java

file. The R.java file is the glue between the world of

Java and the world of resources. It is an automatically

generated file, and as such, never modified by

programmer. It is recreated every time programmer

changes anything in the res directory, for example,

when he adds an image or XML file.

Programmers don’t need to look at this file much. He

Page 24: Final Final

23

will use the data in it quite a bit, but he will use

Eclipse to help him refer to values stored in this file.

libs

The library folder which contains private external

libraries.

assets

The asset folder contains raw asset files. Files that we

save here are compiled into an .apk file as-is, and the

original filename is preserved. Programmer can

navigate this directory in the same way as a typical file

system using URIs and read files as a stream of bytes

using the Asset Manager. For example, this is a good

location for textures and game data.

bin

The binary folder contains output files of the build

process. This is where programmer can find the final

.apk file and other compiled resources.

jni

The JNI (Java Native Interface) folder contains native

code sources developed using the Android NDK

(Native Development Kit). Programmer will not have

this folder, if he does not have any native code.

Page 25: Final Final

24

res

The resource folder contains application resources,

such as drawable files, layout files, and string values

res\anim

The animation resource folder contains resource XML

files that are compiled into animation objects.

res\color

The color resource folder contains resource XML files

that describe colors.

res\drawable

The drawable resource folder which contains bitmap

files (PNG, JPEG, or GIF), 9-Patch image files, and

XML files that describe Drawable shapes or a

Drawable objects that contain multiple states (normal,

pressed, or focused).

res\layout

The layout resource folder which contains XML files

that are compiled into screen layouts (or part of a

screen).

Page 26: Final Final

25

res\menu

The menu resource folder which contains XML files

that define application menus.

res\raw

The raw resource folder which contains arbitrary raw

asset files. Saving asset files here instead of in the

assets/ directory only differs in the way that you access

them. These files are processed and must be

referenced from the application using a resource

identifier in the R class. For example, this is a good

place for media, such as MP3 or Ogg files.

res\values\

The value resource folder that contains XML files that

are compiled into many kinds of resource. Unlike

other resources in the res/ directory, resources written

to XML files in this folder are not referenced by the

file name. Instead, the XML element type controls

how the resources is defined within them are placed

into the R class.

res\xml\

The XML resource folder which contains

miscellaneous XML files that configure application

components. For example, an XML file that defines

Preference Screen, App Widget Provider Info, or

Search ability Metadata.

Page 27: Final Final

26

AndroidManifest.xml

The project manifest file that describes the nature of

the application and each of its components. For

instance, it describes: certain qualities about the

activities, services, intent receivers, and content

providers; what permissions are requested; what

external libraries are needed; what device features are

required, what API Levels are supported or required;

and others.

project.properties

The project properties files which contain project

settings, such as the build target. This file is integral to

the project, so maintain it in a source revision control

system. To edit project properties in Eclipse, right-

click the project folder and select Properties.

local.properties

The local properties file which contains customizable

computer-specific properties for the build system. If

you use Ant to build the project, this contains the path

to the SDK installation. Because the content of the file

is specific to the local installation of the SDK, the

local.properties should not be maintained in a source

revision control system. If you use Eclipse, this file is

not used.

The Ant properties file which contains customizable

properties for the build system. You can edit this file

Page 28: Final Final

27

ant.properties to override default build settings used by Ant and also

provide the location of your KEYSTORE and key alias

so that the build tools can sign your application when

building in release mode. This file is integral to the

project, so maintain it in a source revision control

system. If you use Eclipse, this file is not used.

build.xml

The Ant build file for your project. This is only

applicable for projects that you build with Ant.

4.2 Packages: A package is a collection of related Java entities (such as classes and interfaces)

Packages are used for:

1) Resolving naming conflict of classes by prefixing the class name with a package name.

For example, com.zzz.Circle and com.yyy.Circle are two distinct classes. Although

they share the same class name Circle, but they belong to two different packages:

com.zzz and com.yyy. These two classes can be used in the same program and

distinguished using the fully-qualified class name - package name plus class name.

This mechanism is called Namespace Management.

2) For distributing a collection of reusable classes, usually in a format known as Java

Archive (JAR) file.

Page 29: Final Final

28

3) One can allow types in one package to have unrestricted access to one another, still

restricting the access for the types outside the package.

The 3rd

point leads to feature named:

4.2.1 Access Modifiers

Access level modifiers determine whether other classes can use a particular field or invoke

a particular method. There are two levels of access control:

At the top level—public, or package-private (no explicit modifier).

At the member level—public, private, protected, or package-private (no explicit

modifier).

A class may be declared with the modifier public, in which case that class is visible to all

classes everywhere. If a class has no modifier (the default, also known as package-private), it is

visible only within its own package.

At the member level, you can also use the public modifier or no modifier (package-

private) just as with top-level classes, and with the same meaning. For members, there are two

additional access modifiers: private and protected.

Private Access Modifier

The private modifier specifies that the member can only be accessed in its own class.

Protected Access Modifier

Page 30: Final Final

29

The protected modifier specifies that the member can only be accessed within its own package

(as with package-private) and, in addition, by a subclass of its class in another package.

ACCESS LEVELS

Modifier

Class

Package

Subclass

World

public

Y

Y

Y

N

protected

Y

Y

Y

N

No modifier

Y

Y

N

N

private

Y

N

N

N

4.3 Package Naming Convention:

A package name is made up of the reverse of the Internet Domain Name (to ensure

uniqueness) plus your own organization's internal project name, separated by dots '.'. Package

names are in lowercase. For example, suppose that your Internet Domain Name is "zzz.com",

you can name your package as "com.zzz.project1.subproject2".

The prefix "java" and "javax" are reserved for core Java packages and Java extensions,

respectively.

Page 31: Final Final

30

4.4 Package Name And The Directory Structure:

The package name is closely associated with the directory structure used to store the

classes. The classes (and other entities) belonging to a specific package are stored together in the

same directory. Furthermore, they are stored in a sub-directory structure specified by its package

name. For example, the class Circle of package com.zzz.project1.subproject2 is stored as

"$BASE_DIR\com\zzz\project1\subproject2\Circle.class", where $BASE_DIR denotes the base

directory of the package. Clearly, the "dot" in the package name corresponds to a sub-directory

of the file system.

The base directory ($BASE_DIR) could be located anywhere in the file system. Hence,

the Java compiler and runtime must be informed about the location of the $BASE_DIR so as to

locate the classes. This is accomplished by an environment variable called CLASSPATH.

CLASSPATH is similar to another environment variable PATH, which is used by the command

shell to search for the executable programs.

4.5 Creating Packages:

To make a class as part of a package, you have to include the package statement as the first

statement in the source file.

For Example: package com.electrosim;

One of the requirements for a package is that the source file should be contained in a

directory structure that resembles the name of the package. This is simply creating a set of

directories with the names given in the package name.

Take the package name and split it up according to where the periods (.) occur, for

example, com.mycompany.myproject can easily be split up into three components, namely: com,

Page 32: Final Final

31

mycompany and myproject. These will be the three directories that you create. The first directory

will be the com directory and within this directory we will create a sub directory namely the

mycompany directory and within that directory a sub directory, namely the myproject directory.

Finally, all the source files that are part of the package will go into the myproject directory

Fig 4.2

4.6 Import Keyword If a class wants to use another class in the same package, the package name does not need

to be used. Classes in the same package find each other without any special syntax.

If a class wants to use another class in the some other package, then class must then use

one of the following techniques for referring to a class in a different package.

The fully qualified name of the class can be used.

The package can be imported using the import keyword and the wild card (*).

A class file can contain any number of import statements.

The import statements must appear after the package statement and before the class

declaration.

Package designation;

import payroll.Employee;

Page 33: Final Final

32

public class Boss

{

public void payEmployee(Employee e)

{

e.mailCheck();

}

}

4. 7 Interfaces:

An interface is a collection of instance variables and instance methods without having any

body, i.e., the methods do not have any definition. Once an interface is declared, any number of

classes can implement that method. In other words, the classes contain all the members of the

interface and they implement the definition of the method declared in the interface. By

implementing an interface, we can achieve multiple and hierarchical inheritance as well as

achieve dynamic (run time) polymorphism.

4.7.1 Declaring an Interface

The syntax for declaring an interface is:

Access_specifier interface interface_name

{

specifier datatype variable = value;

specifier returntype methodname(parameter);

}

In the above example interface is a keyword.

Page 34: Final Final

33

Access specifiers – This must be public or it can be omitted as well. If the access specified is

omitted, then the classes of the same package can only implement that interface in which the

interface is present and if the access specified is public then classes of any package can

implement the interface.

4.7.2 Implementing an Interface

The classes which implement an interface contain all the members of the interface as well

as some of its own member. The syntax of implementing an interface is a shown below.

class class_name implements interface_name

{

own members;

public void display()

{

}

}

Page 35: Final Final

34

4.8 The System Architecture:

Fig 4.3 System Architecture of ElectroSim

com.electrosim com.electrosim .simulation com.electrosim.component

Package 1

Graphics

Engine

Package 2

Simulation

Engine

Package 3

Components

Behavior

R.Java

Layout Files Application

Sounds

Application

Strings

Application

Images

Page 36: Final Final

35

com.electrosim

Classes

About.java

Connector.java

Container.java

Element.java

GridViewActivity.java

ImplementButtonActivity.java

LinkPoint.java

LineBreakPoint.java

Help.java

MainActivity.java

Interfaces

ConnectorInterface.java

ElementInterface.java

ConnectorFactory.java

LinkPointInterface.java

Page 37: Final Final

36

com.electrosim.component

Classes

AndGate.java

Extension.java

Ground.java

Led.java

NandGate.java

NorGate.java

NotGate.java

OrGate.java

Vcc.java

XnorGate.java

com.electrosim.adapter

Classes

ImageAdapter.java

Page 38: Final Final

37

XorGate.java

com.electrosim.simulation

Classes

InputPort.java

OutPort.java

SimConnector.java

SimContainer.java

SimElement.java

SimPort.java

Interfaces

SimConnectorFactory.java

Page 39: Final Final

38

Chapter: 5

SIMULATION PROGRAMMING

5.1 Simulation Level In ElectroSim

After the graphics programming level, the next thing to discuss is the heart of the project.

The design of ElectroSim follows a top-to-down hierarchy. The package which contains the

graphics related classes is termed as graphics engine, while the simulation classes have been

packaged to be a simulation engine. Following diagram illustrates this hierarchy.

Fig 5.1 Inheritance Hierarchy of ElectroSim

5.2 Classes in Simulation Engine

The classes of simulation level have their base classes in the graphics level. Each action

taken by user is propagated via these classes. For example, if user has connected two AND gates

then this interconnection is managed by Simulation Engine.

Simulation Engine effectively manages the structure of wires drawn by the circuit. This

effectiveness has its advantages on the components behavioral level. To add new components, no

change is required in simulation level.

Components Behaviour

Simulation Engine

Graphics Engine

Application UI Files

Page 40: Final Final

39

5.2.1 SimElement Class:

The SimElement class extends Element Class. It controls the amount input and output

ports of elements. It contains a virtual function simulate() which must be implemented by each

component at component level. A class which is declared as abstract must contains atleast one

abstract function which in this case simulate(). It is not necessary that all function of an abstract

class should be abstract. To give default behavior to components, this class gives functionality to

some methods.

Unlike interfaces, abstract classes can contain fields that are not static and final, and they

can contain implemented methods. Such abstract classes are similar to interfaces, except that

they provide a partial implementation, leaving it to subclasses to complete the implementation. If

an abstract class contains only abstract method declarations, it should be declared as an interface

instead.

Multiple interfaces can be implemented by classes anywhere in the class hierarchy,

whether or not they are related to one another in any way. Think of Comparable or Cloneable,

for example.

By comparison, abstract classes are most commonly subclassed to share pieces of

implementation. A single abstract class is subclassed by similar classes that have a lot in

common (the implemented parts of the abstract class), but also have some differences (the

abstract methods).

5.2.2 SimPort Class:

Page 41: Final Final

40

SimPort Class extends the functionality of LinkPoint Class which represents a port in

graphics level. It is a challenging task to keep track of all ports and their association with

Elements. The successful mapping between Ports and Elements are bases for the functionality of

Wire drawing.

This class defines the standards of all the ports which include the default radius of each

port. This Default radius is used at graphics level to conduct a Port-hit-test. The purpose of this

test is to determine whether the finger of the user is inside a port or not.

It manages some methods to which are essential for multithreading, particularly in thread

synchronization. Ports of the Elements are characterized as

InputPort

OutputPort

5.2.2.1 InputPort Class:

By sub-classing SimPort, the hierarchy is further improved. This helps in drawing a line from an

output port only. In particular this helps in knowing the fact that a wire has been drawn from a certain

output port to any input or output port.

5.2.2.2 OutputPort Class:

There is no difference between an input port and an output port physically and

programmatically. Their classification is helpful with respect to component level. Both input and

output port constructor carries same information.

5.2.3 SimConnector Class and Factory Interface:

SimConnector class and its associated factory interface follows the advanced and state of

the art Factory Design Pattern which is part of GOF (Gang-Of-Four) programming model.

SimConnector manages the entire wire network and behavior of wires

Page 42: Final Final

41

The factory method pattern is an object-oriented creational design pattern to implement

the concept of factories and deals with the problem of creating objects (products) without

specifying the exact class of object that will be created. The essence of this pattern is to define an

interface for creating an object, but let the classes that implement the interface decide which

class to instantiate. The Factory method lets a class defer instantiation to subclasses.

Creating an object often requires complex processes not appropriate to include within a

composing object. The object's creation may lead to a significant duplication of code, may

require information not accessible to the composing object, may not provide a sufficient level of

abstraction, or may otherwise not be part of the composing object's concerns. The factory

method design pattern handles these problems by defining a separate method for creating the

objects, which subclasses can then override to specify the derived type of product that will be

created.

Some of the processes required in the creation of an object include determining which

object to create, managing the lifetime of the object, and managing specialized build-up and tear-

down concerns of the object. Outside the scope of design patterns, the term factory method can

also refer to a method of a factory whose main purpose is creation of objects.

The factory method pattern relies on inheritance, as object creation is delegated to

subclasses that implement the factory method to create objects.

Fig 5.2 Example of Factory Design Pattern

Page 43: Final Final

42

In our implementation the drawing framework is the client and the shapes are the

products. All the shapes are derived from an abstract shape class (or interface). The Shape class

defines the draw and move operations which must be implemented by the concrete shapes. Let's

assume a command is selected from the menu to create a new wire. The framework receives the

starting and ending point type as a string parameter; it asks the factory to create a new wire

sending the parameter received from menu. The factory creates a new wire and returns it to the

framework, casted to an abstract connector. Then the framework uses the object as casted to the

abstract class without being aware of the concrete object type.

5.2.4 SimContainer Class:

SimContainer class extends the functionality of basic Graphics Engine class. It also

implements Multi-threading interface. The main objective of this class is to spawn a new thread

for simulation, manage this thread and finally destroy this thread. This class is extensively

explained in the next chapter.

5.3 Portability of Simulation Engine:

Simulation engine of ElectroSim is extremely portable. A developer, who wants to

develop a voice controlled interface instead of touch controlled simulator, can use this engine.

He just needs to create voice controlled panel and connect it to this engine. Several other similar

examples can be possible.

Page 44: Final Final

43

Chapter: 6

PROGRAMMING TECHNIQUES FOR COMPONENTS’S BEHAVIOUR

6.1 Organization of Components

In ElectroSim, There is a wide variety of available components. By using these

components, users can develop any kind of combinational logic. From programmer’s point of

view, these components are divided according to the number of input and output ports, and their

functionality. Each Component is a subclass of SimElement. What user sees on screen is the

image of the component, the data and behavior of the component is written in a separate java

file.

Fig 6.1 each component at screen has a class

With each component button in the ‘create circuit’ screen, an associated integer id used just as

described in chapter 5. For every element to be created, certain information is passed to

constructor of the component for initialization. For example

ComponentXYZ(int x, int y, Container container,3)

This will create an object of component xyz at position x and y and 3 is the number of input

ports.

SCREEN

Page 45: Final Final

44

ElectroSim has following components:

1. Logic Gates

2. Power Sources

3. Extension Component

4. Switches

5. Indicating Components

6. Flip Flops (Future enhancement)

7. Multiplexers and Decoders ( Future Enhancement)

6.2 Logic Gates:

A logic gate is an elementary building block of a digital circuit. It is an idealized or

physical device implementing a Boolean function, that is, it performs a logical operation on one

or more logic inputs and produces a single logic output. Depending on the context, the term may

refer to an ideal logic gate, one that has for instance zero rise time and unlimited fan-out, or it

may refer to a non-ideal physical device. Most logic gates have two inputs and one output. At

any given moment, every terminal is in one of the two binary conditions low (0) or high (1),

represented by different voltage levels. The logic state of a terminal can, and generally does,

change often, as the circuit processes data. In most logic gates, the low state is approximately

zero volts (0 V), while the high state is approximately five volts positive (+5 V). This voltage

does not have any kind of significance for the end user of ElectroSim. For the user, only binary

data is important.

6.2.1 OR Gate:

The OR gate is a digital logic gate that implements logical disjunction - it behaves

according to the truth table below. A HIGH output (1) results if one or both the inputs to the gate

Page 46: Final Final

45

are HIGH (1). If neither input is HIGH, a LOW output (0) results. In another sense, the function

of OR effectively finds the maximum between two binary digits.

Fig 6.2 OR gate truth table and symbol

6.2.2 AND Gate

The AND gate is a basic digital logic gate that implements logical conjunction - it behaves

according to the truth table below. A HIGH output (1) results only if both the inputs to the AND

gate are HIGH (1). If neither or only one input to the AND gate is HIGH, a LOW output results.

In another sense, the function of AND effectively finds the minimum between two binary digits.

Therefore, the output is always 0 except when all the inputs are 1s.

Fig 6.3 AND gate truth table and symbol

Page 47: Final Final

46

6.2.3 XOR Gate:

The XOR gate (sometimes EOR gate, or EXOR gate) is a digital logic gate that

implements an exclusive or; that is, a true output (1) results if one, and only one, of the inputs to

the gate is true (1). If both inputs are false (0) and both are true (1), a false output (0) results. Its

behavior is summarized in the truth table shown below. A way to remember XOR is "one or the

other but not both". It represents the inequality function, i.e., the output is HIGH (1) if the inputs

are not alike otherwise the output is LOW (0).

Fig 6.4 XOR gate truth table and symbol

6.2.4 XNOR Gate:

The XNOR gate (sometimes spelled "exnor" or "enor" and rarely written NXOR) is a

digital logic gate whose function is the inverse of the exclusive OR (XOR) gate. The two-input

version implements logical equality, behaving according to the truth table below. A HIGH output

(1) results if both of the inputs to the gate are the same. If one but not both inputs are HIGH (1),

a LOW output (0) results.

Fig 6.5 XNOR gate truth table, symbol and Equivalent circuit

Page 48: Final Final

47

6.2.5 NOR Gate:

The NOR gate is a digital logic gate that implements logical NOR - it behaves according

to the truth table to the right. A HIGH output (1) results if both the inputs to the gate are

LOW (0); if one or both input is HIGH (1), a LOW output (0) results. NOR is the result of

the negation of the OR operator. It can also be seen as an AND gate with all the inputs

inverted. NOR is a functionally complete operation; combinations of NOR gates can be

combined to generate any other logical function. By contrast, the OR operator is

monotonic as it can only change LOW to HIGH but not vice versa.

Fig 6.6 NOR gate truth table and symbol

6.2.6 NOT Gate:

A NOT gate, often called an inverter, is a nice digital logic gate to start with because it has

only a single input with simple behavior. A NOT gate performs logical negation on its input. In

other words, if the input is HIGH, then the output will be LOW. Similarly, a LOW input results

in a HIGH output:

Fig 6.7 NOT gate truth table and symbol

Page 49: Final Final

48

6.2.7 NAND Gate

In digital electronics, a NAND gate (Negated AND or NOT AND) is a logic gate which

produces an output that is false only if all its inputs are true. A LOW (0) output results only if

both the inputs to the gate are HIGH (1); if one or both inputs are LOW (0), a HIGH (1) output

results. It is made using transistors.

The NAND gate is significant because any Boolean function can be implemented by

using a combination of NAND gates. This property is called functional completeness.

Digital systems employing certain logic circuits take advantage of NAND's functional

completeness. In complicated logical expressions, normally written in terms of other logic

functions such as AND, OR, and NOT, writing these in terms of NAND saves on cost, because

implementing such circuits using NAND gate yields a more compact result than the alternatives.

Fig 6.8 NAND gate truth table and symbol

6.2.8 Extension Component:

Extension component reduces the complexity of the circuit by reducing number of

components placed on the drawing area. It has one input port and two output ports. Whatever

signal comes to the input ports, it is transferred to the output ports without any transformation or

calculation. However, there is a limitation of using this custom built component, that is one must

Page 50: Final Final

49

utilize both of its output ports to work. It is a passive component means there is no need to

supply an external power source connection to this extension component.

Fig 6.9 Extension component in ElectroSim

6.2.9 LED and Seven Segment Display:

An instrument in which the present value of the quantity being measured is visually

indicated. ElectroSim Essentially has two indicating instruments so far. One is completely

modeled and one is still under development. Here only LED will be discussed since it has been

successfully tested in ElectroSim.

A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator

lamps in many devices and are increasingly used for other lighting. Appearing as practical

electronic components in 1962, early LEDs emitted low-intensity red light, but modern versions

are available across the visible, ultraviolet, and infrared wavelengths, with very high brightness.

Fig 6.10 LED in ElectroSim

6.2.10 Power Sources:

Power Sources of ElectroSim are:

Page 51: Final Final

50

1. Vcc

Vcc refers to positive voltage that derives the entire digital circuitry. In practical systems,

it is atleast 5V. But since we are dealing with binary data at simulation level, it provides a

continuous HIGH signal.

Fig 6.11 VCC in ElectroSim

2. Ground

Ground in electrical systems, is way to complete the flow of circuit current, But not in

digital circuits. ElectroSim User uses it for constant supply of LOW signal.

Fig 6.12 Ground Source in ElectroSim

6.3 Future Expansion Of Components:

ElectroSim is capable of providing hundreds of components to its users. Its design does

not limit the programmer to add new components, nor does it become memory leaking software

by doing this.

It has been proposed that ElectroSim will be extended to incorporate digital as well as

analog circuits. Some Electrical functions such as motor control and generator load control can

also be implemented to measure the rpm and of motors and test the motors and generators under

different electrical conditions.

Page 52: Final Final

51

Chapter: 7

ADVANCE GRAPHICS AND MULTITHREADING

7.1 Introduction to Touch Based Designs

One of the most widespread changes seen in the use of touch screen devices in the last

couple of years has been the adoption of finger gestures, such as swipes and flings. They allow

the interaction between user and device to become very intuitive and natural feeling

Touch-enabled devices are proliferating at an astonishing rate. Touch, multi touch and gesture

user interfaces are here to stay, but the wide variation between platforms – and even between

applications on one platform – in what each touch action means, will lead to increasing user

frustration. Applying some simple principles can help designers avoid the worst mistakes in

touch interaction design.

Designing for touch is very different than designing for mouse interaction. You can’t

position your cursor and then decide on the action. Touching the screen not only indicates the

point of interest on the screen but also invokes an action. Most often the finger obscures the

object with which you are trying to interact.

Feedback becomes absolutely critical in touch interfaces to know what and when

something has been activated. Often this involves multiple modalities – visual, haptic (vibration),

and auditory feedback.

With the mouse, all interactions are abstracted and indirect. For example, when we want

to scroll, we move a mouse on our desk, which moves a cursor on the screen, which adjusts the

position of a scroll bar, which in turn causes the content to scroll. All these actions have to be

learned whereas just grabbing something and pushing it where you want it feels much more

natural.

Page 53: Final Final

52

One advantage of touch is that it can leverage our existing understanding of the physical world.

We see what looks like a button and tap or press it to make something happen. To scroll, we

touch the content and push it in the direction we want it to move.

7.2 Motion Events and Screen Coordinates Detection:

Motion events describe movements in terms of an action code and a set of axis values.

The action code specifies the state change that occurred such as a pointer going down or up. The

axis values describe the position and other movement properties.

For example, when the user first touches the screen, the system delivers a touch event to

the appropriate View with the action code ACTION_DOWN and a set of axis values that include

the X and Y coordinates of the touch and information about the pressure, size and orientation of

the contact area.

Some devices can report multiple movement traces at the same time. Multi-touch screens

emit one movement trace for each finger. The individual fingers or other objects that generate

movement traces are referred to as pointers. Motion events contain information about all of the

pointers that are currently active even if some of them have not moved since the last event was

delivered.

The number of pointers only ever changes by one as individual pointers go up and down,

except when the gesture is canceled. Each pointer has a unique id that is assigned when it first

goes down (indicated by ACTION_DOWN or ACTION_POINTER_DOWN). A pointer id

remains valid until the pointer eventually goes up (indicated by ACTION_UP or

ACTION_POINTER_UP) or when the gesture is canceled (indicated by ACTION_CANCEL).

Page 54: Final Final

53

The MotionEvent class provides many methods to query the position and other properties

of pointers, such as getX(int), getY(int), getAxisValue(int), getPointerId(int), getToolType(int),

and many others. Most of these methods accept the pointer index as a parameter rather than the

pointer id. The pointer index of each pointer in the event ranges from 0 to one less than the value

returned by getPointerCount().

The order in which individual pointers appear within a motion event is undefined. Thus

the pointer index of a pointer can change from one event to the next but the pointer id of a

pointer is guaranteed to remain constant as long as the pointer remains active. Use the

getPointerId(int) method to obtain the pointer id of a pointer to track it across all subsequent

motion events in a gesture. Then for successive motion events, use the findPointerIndex(int)

method to obtain the pointer index for a given pointer id in that motion event.

Mouse and stylus buttons can be retrieved using getButtonState(). It is a good idea to

check the button state while handling ACTION_DOWN as part of a touch event. The application

may choose to perform some different action if the touch event starts due to a secondary button

click, such as presenting a context menu.

7.3 Drawing programmatically:

The Android framework APIs provides a set 2D drawing APIs that allow you to render

your own custom graphics onto a canvas or to modify existing Views to customize their look and

feel. When drawing 2D graphics, you'll typically do so in one of two ways:

1. Draw your graphics or animations into a View object from your layout. In this manner,

the drawing of your graphics is handled by the system's normal View hierarchy drawing

process — you simply define the graphics to go inside the View.

Page 55: Final Final

54

2. Draw your graphics directly to a Canvas. This way, you personally call the appropriate

class's onDraw() method (passing it your Canvas), or one of the Canvas draw...() methods

(like drawPicture()).

When you're writing an application in which you would like to perform specialized drawing

and/or control the animation of graphics, you should do so by drawing through a Canvas. A

Canvas works for you as a pretense, or interface, to the actual surface upon which your graphics

will be drawn — it holds all of your "draw" calls. Via the Canvas, your drawing is actually

performed upon an underlying Bitmap, which is placed into the window.

In the event that you're drawing within the onDraw() callback method, the Canvas is

provided for you and you need only place your drawing calls upon it. You can also acquire a

Canvas from SurfaceHolder.lockCanvas(), when dealing with a SurfaceView object. (Both of

these scenarios are discussed in the following sections.) However, if you need to create a new

Canvas, then you must define the Bitmap upon which drawing will actually be performed.

7.4 Drawing via Surface View

It is a gaming engine which provides a dedicated drawing surface embedded inside of a

view hierarchy. You can control the format of this surface and, if you like, its size; the

SurfaceView takes care of placing the surface at the correct location on the screen

The surface is Z ordered so that it is behind the window holding its SurfaceView; the

SurfaceView punches a hole in its window to allow its surface to be displayed. The view

hierarchy will take care of correctly compositing with the Surface any siblings of the

SurfaceView that would normally appear on top of it. This can be used to place overlays such as

Page 56: Final Final

55

buttons on top of the Surface, though note however that it can have an impact on performance

since a full alpha-blended composite will be performed each time the Surface changes.

The transparent region that makes the surface visible is based on the layout positions in

the view hierarchy. If the post-layout transform properties are used to draw a sibling view on top

of the SurfaceView, the view may not be properly composited with the surface.

Access to the underlying surface is provided via the SurfaceHolder interface, which can

be retrieved by calling getHolder().

The Surface will be created for you while the SurfaceView's window is visible; you should

implement surfaceCreated(SurfaceHolder) and surfaceDestroyed(SurfaceHolder) to discover

when the Surface is created and destroyed as the window is shown and hidden.

7.5 Introduction to Threading in ElectroSim:

Conceptually, the notion of a thread is not difficult to grasp: it's an independent path of

execution through program code. When multiple threads execute, one thread's path through the

same code usually differs from the others. For example, suppose one thread executes the byte

code equivalent of an if-else statement's if part, while another thread executes the byte code

equivalent of the else part. How does the JVM keep track of each thread's execution? The JVM

gives each thread its own method-call stack. In addition to tracking the current byte code

instruction, the method-call stack tracks local variables, parameters the JVM passes to a method,

and the method's return value.

Page 57: Final Final

56

When multiple threads execute byte-code instruction sequences in the same program, that action

is known as multithreading. Multithreading benefits a program in various ways:

Multithreaded GUI (graphical user interface)-based programs remain responsive to users

while performing other tasks, such as repaginating or printing a document.

Threaded programs typically finish faster than their nonthreaded counterparts. This is

especially true of threads running on a multiprocessor machine, where each thread has its

own processor.

Java accomplishes multithreading through its java.lang.Thread class. Each Thread object

describes a single thread of execution. That execution occurs in Thread's run() method. Because

the default run() method does nothing, you must subclass Thread and override run() to

accomplish useful work.

7.6 Data Synchronization While Multithreading in Progress:

Multithreaded programs often function erratically or produce erroneous values due to the

lack of thread synchronization. Synchronization is the act of serializing (or ordering one at a

time) thread access to those code sequences that let multiple threads manipulate class and

instance field variables, and other shared resources.

In ElectroSim, for synchronization purpose, Special methods are used which are :

PrepareToStart( )

PrepareToStop( )

The role of these methods is to make data null on input and output ports and allow one

change on data at a time.

Page 58: Final Final

57

7.7 ElectroSim Threading Model:

New Process

First thread (temporary)

Graphics Thread

Simulation Thread Parallel Execution

Android Kernel

ElectroSim Splash Thread

Simulation

Thread

Drawing Thread

Page 59: Final Final

58

Chapter: 8

CONCLUSION

ElectroSim is result of efficient engineering techniques. It is one of those few products which

maximize the productivity from mobile devices. Advance Graphics and simulation engine

combined with Multithreading capabilities make ElectroSim a worth try product for engineers

and students.

ElectroSim will keep on Expanding with addition in components and simulation

Environments. The Aim of ElectroSim is to replace conventional Desktop simulators to teach

students about electronics. ElectroSim has started to do that perfectly.

Page 60: Final Final

59

Bibliography

Wei-Meng Lee. Android Table Application Development. Wrox Programmer

to Pragrammer

Ed Burnette. Hello.Android.new. The Pragmatic Programmers

Marko Gargenta. Learning Android. O'REILLY

Ivor Horton's. Beginning Java 2. Programmer to Programmer

Herbert Schildt. Java 2 The Complete Reference. OSBORNE

Page 61: Final Final

60

References

1. http://www.droidnova.com/playing-with-graphics-in-android-part-i,147.html

2. http://developer.android.com/reference/android/view/MotionEvent.html

3. http://developer.android.com/reference/android/view/SurfaceHolder.html

4. http://android.nakatome.net/2010/04/graphics-basics.html