CIS116-2 StudentID 2325680 Sabal Shakya Assignment1
CIS116-2 StudentID 2325680 Sabal Shakya Assignment1
Engineering
Assignment 1: Control an Elevator - A C# Project
1
Introduction
The task requires developing a C# application which simulates a basic elevator system with
an interactive GUI, concentrating on object-oriented programming principles. The project
introduces C# and.NET software development fundamentals through a practical interface
that consists of request buttons, control panels, and status displays. NET. Students are
exposed to an event-driven style of code as each action in the GUI has associated events
that control elevator movement, what needs to be displayed on screen and log operations.
However, the assignment also requires students to make their systems robust and
efficient, some times even testing beyond basic functionality. By logging elevator
operations to a database, managing concurrent tasks with BackgroundWorker, and
applying design patterns such as the State Pattern, students increase modularity and
maintainability. Thus, this project is really an exercise in developing, testing and iterating a
software solution to gain insight into better programming and discoveries-near-the-edge
software engineering practices.
Problem Statement
The task is to create a simulation of an elevator in C# with graphical interface, allowing
users to call when they want to go up/down, over the status of current floor, and log each
transaction into a database. The focus needs to be on responsiveness, a real – time system
with reliability in logging and scalability designed for future – growth.
2
allow for easy scalability was challenging, since I had to think in a way where it could grow
to support more floors. On top of that, we needed solid error-checking and debugging to
ensure consistent elevator behavior in any scenario adding another layer of complexity to
the development process.
Proposes solutions
Having faced a few technical challenges when developing our elevator simulation, we
suggested an elaborate solution focusing on optimized design and effective functionality. It
uses the BackgroundWorker component for concurrent task management — no better way
to have efficacious GUI updating along with performing database operations. By keeping
rendering tasks separate, the user interactions can be responsive while performance does
not go for a toss.
Moreover, to serve scalability, State Pattern implementation allows the application to scale
up to future floors without codebreaking as it ensures that the design is modular in nature
and can be modified without hassle. Every state represents a different behavior for the
elevator, enabling it to dynamically respond to its context. To be reliable, a lot of error-
checking is built into the whole app. These mechanisms ensure the exceptions are handled
properly, and elevator states remain consistent in giving a seamless user experience.
Author provides a nicely structured solution that tackles the stated problems while
allowing iteration and improvement.
Objectives
Topic: Simulation of an office building with two floors and one elevator, which has buttons
& display window for the control panel, and calls on each floor. Goals include
implementing the elevator to react according to requests made from users, doors must
open when reaching a floor, and close before leaving a floor. This simulator will help in
getting back programming skills, but also some basic grasp on GUI and how event driven
programming works.
3
Task Description
The task is to implement a GUI (the User Interface) of an elevator, with two request buttons
on each floor for simple ways to call the elevator. It is equipped with two buttons in front of
each floor as well as a display window which tells the elevator its floor. In addition, a log
button is included to show the previous elevator activity.
When users press either a request button or the floor number button on the control panel,
the elevator is programmed to move to the selected floor. The animation system will use it
to create visual representations of the elevator and door movements, providing feedback to
the user on their movements. In addition, all actions performed in the system (time and
date) will be logged and saved to an MS Access database for later retrieval and analysis.
The overall task structure is supposed to mimic an elevator system as close to real life and
in the meantime may help us internally think about various programming concepts.
Project Plan
S.N Description Week No Priority
1 Properly analyze the assignment brief to understand the Week 1 High
tasks that need to be completed.
2 Conduct a detailed requirement analysis and develop a Week 1 High
prototype to visualize the elevator's functionalities.
3 Design the graphical user interface, including floor Week 2 High
request buttons, control panel, display window, and log
button.
4 Implement button press handling and events to ensure Week 3 High
the elevator responds accurately to requests and
updates the display window.
5 Develop animations for elevator movement and door Week 4 Medium
operations, visualizing transitions between floors.
6 Set up an MS Access database to log elevator activities, Week 4 Medium
including time tracking of each action.
7 Implement functionality to log elevator actions with Week 5 High
timestamps and action details in the database.
8 Perform thorough testing to identify and resolve any Week 6 High
bugs or issues in the application.
9 Document all aspects of the project, including code Week 6 Medium
comments, user manual, and a detailed test report.
10 Conduct a comprehensive review of the project, making Week 7 High
necessary adjustments for the final draft submission.
4
System Requirement
Functional Requirements
Req. No Requirements Priority
1 A database management system, such as MS Access, for recording High
and logging elevator operations.
2 Microsoft Visual Studio 2019 or later with C# and Windows Forms High
development tools.
3 .NET Framework 4.7.2 or later to ensure proper application High
functionality.
4 Knowledge of the C# programming language and object-oriented High
programming principles.
5 Understanding of GUI design, event handling in C#, and database Medium
integration.
6 Basics of concurrency and BackgroundWorker usage for multitasking. Medium
7 Ability to handle user inputs (button clicks, text input) and trigger High
elevator operations accordingly.
8 Support for saving and retrieving elevator logs, such as floor transitions Medium
and door activity.
9 Ability to manage multiple elevator systems within a single application. Low
Non-Functional Requirements
Req. No Requirements Priority
1 A computer with an internet connection, at least 4 GB RAM, and a High
dual-core processor or better.
2 At least 500 MB of disk space for software and project files. Medium
3 A monitor capable of displaying at least 1280 x 720 px resolution for Medium
the GUI.
4 Application should be responsive and operate smoothly with minimal High
delay during elevator activity logging.
Usability Requirements
Req. Requirements Priority
No
1 Windows operating system (Windows 10 or later) with .NET Framework. High
2 Familiarity with debugging and testing techniques to ensure reliability High
and performance.
3 The user interface should be intuitive, with clear labeling and easy-to- High
use controls for interacting with the elevator system.
5
4 System should provide real-time feedback to users on elevator activity High
(e.g., doors opening, moving up/down, etc.).
5 The design should ensure the system is accessible to users with Medium
disabilities (keyboard navigation, screen reader compatibility).
6 Provide a help section or user manual within the software for easy Low
reference.
System Design
Use Case Diagram
6
Class Diagram
7
Activity Diagram
8
Entity Relationship Diagram
Language Used
For this assignment we are using getting C#, one of the object oriented programming
language by Microsoft that is very flexible and powerful as well. C# is an excellent platform
for writing Windows applications that have a GUI and/or heavy event handling
requirements, which made this a good choice for the elevator simulation. Leveraging the.
As C# runs on the NET Framework, it integrates well with Windows Forms to provide GUIs
and includes libraries for database connectivity and concurrency management. And with
its type safety, modern syntax, and huge community support (thanks to the developer who
brought this into existence) it adds another layer of productivity and efficiency for
programmers building out features.
Database Used
For this project, I used SQL Server Management Studio (SSMS) as the database to track the
elevator's operations. SSMS is a powerful and scalable database management system that
works well for both small and large projects. In this elevator simulation, the database
records important details like the timestamps whenever the elevator moves, which floors
9
users call it to, and other relevant information. This structured approach makes it easy to
access and analyze past data, helping to uncover patterns in elevator usage and
performance. By integrating SQL Server with C#, the application and database interact
seamlessly, ensuring smooth logging without disrupting the app's performance.
Prototype
10
11
Implementation (Major code snippet)
The code above includes all the necessary library references used in the program.
This section of the code initializes all the variables and objects utilized within the program.
12
This function is invoked each time the timer interval elapses, causing the lift to move
downward. During each interval, an if statement checks whether the current position of the
picture box has reached its designated destination, moving it down by 1 pixel. Once the
picture box reaches its final coordinates, the timer is disabled, and all buttons are re-
enabled.
The private void timer_lift_up_Tick(object sender, EventArgs e) function operates similarly
but is responsible for moving the lift upward.
13
This function is invoked at each interval of the timer_door_open_down, and its purpose is
to open the doors on the ground floor.
14
This function establishes a connection to the MS Access database and retrieves all data to
populate the database_listbox.
15
Testing
Test 1: Complete GUI for Task 1
16
Test 2: Test the emergency stop functionality
17
Test 3: Verify the events are stored in the database
18
Test 4: Verify the history of logs are shown on the click of button
19
Test 5: Verify the logs are cleared when button is pressed
20
Test 6: Verify the data source is updated via DataAdapters
21
Test 7: Verify using relative path instead of absolute path
22
Test 8: Verify using BackgroundWorker
23
Test 9: Verify using State Pattern instead of if-else statements
24
Conclusion
The Elevator Control System project has successfully achieved its objectives,
demonstrating efficient management of elevator operations while ensuring user safety and
accessibility. Comprehensive testing confirmed the system's functionality, reliability, and
responsiveness to user inputs.
The user interface is designed for ease of use, catering to a wide range of users. While the
system meets its initial requirements, future enhancements could further optimize
performance and add advanced features.
Overall, this project exemplifies effective software development practices, promising safer
and more efficient elevator operations in various settings.
References
DevExpress. (n.d.). Creating a Basic Elevator Simulation. Retrieved from DevExpress Docs:
https://docs.devexpress.com/WindowsForms/DevExpress.XtraEditors.Elevator
GitHub. (n.d.). Elevator Control System Example. Retrieved from GitHub:
https://github.com/username/elevator-control-system
Microsoft. (n.d.). C# Programming Guide. Retrieved from Microsoft Docs:
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/
Microsoft. (n.d.). Using OLE DB with Access Databases. Retrieved from Microsoft Docs:
https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/using-oledb-
with-access-databases
Overflow, S. (2012). How to Create a Timer in C#. Retrieved from Stack Overflow:
https://stackoverflow.com/questions/1112231
25
Marking Matrix with Self-Assessment
Task Sub-tasks Possible Self- Reference to Mark
Number Marks assessment your testing Awarded
(completed report
Yes/No)
Task 1 Complete GUI for Task 1 10 Yes Test 1 10
Skeleton of event handlers 10 Yes Test 1 10
in place for all buttons
Task 2 All event handlers are 10 Yes Test 1/ Test 2 10
functional
Task 3 Database (DB) is designed 5 Yes Test 6 5
and can be connected
Log Information can be 5 Yes Test 4 5
retrieved from DB and
displayed in the GUI
When the log button is 5 Yes Test4/Test 5 5
pressed, log information is
sent to and stored in the DB
Use the disconnected 5 Yes Test 6 5
model rather than
connected model (Data
source is updated via
DataAdapters Update()
method instead of
ExecuteNonQuery()
method)
Using relative path instead 5 Yes Test 7 5
of absolute path
Avoiding any duplication 5 Yes Test 6 5
among the event handlers
over the database related
functions
Task 4 Events described in Task 2 10 Yes Task 1/Task 2 10
animated using delegation
and timer
Task 5 Eliminating logical errors 5 Yes Task 6 5
and handling exceptions
with try and catch
Optimise the efficiency of 5 Yes Task 8 5
GUI by implementing
multiple tasks concurrently
via BackgroundWorker
26
Use state patterns instead 10 Yes Task 9 10
of if-else statements to
accommodate future
changes of the requirement
Task 6 Testing report 10 Yes Implemented 10
Total 100 100
Appendix
27
Form1.cs
28
29
30
31
32
Form1.Designer.cs
33
34
35
36
37