This Section Includes the Design Report for the active object. And includes the Comment report on the active object as well.

This Section Includes the Active Object System Called MyATM.

This Section includes the following Information.

  • Screen Shots of the program running.
  • Program Code.
  • Design Report

This Code includes

  • Program.cs
  • ActiveObject.cs
  • ChannelActiveObject.cs
    • ClientListener.cs
    • ProcessMessage.cs
    • CreateAccount.cs
    • BalanceAccount.cs
    • DepositAccount.cs
    • WithdrawAccount.cs
    • OutputMessagecs
  • Account.cs

Design Report

This report is going to go over the active object program that I have made. This is called the MyATM system, this allows users to connect to the program via telnet and then allows users to send commands to an ATM system.

Overview

This program was set out to do a simple job, this was to allow multiple users via another interface to add accounts and then allow users to add money to this account, Remove money from this account and check the balance of this account.

Class Diagram

Class Diagram

Overview of Threads within the program

The threads that run in this program are based on the active object itself, this allows the program to then turn on a functionality of the program as it needs to as well, This is shown by the process message to the Four abilities of the ATM system, The below diagram shows the turning on of the threads in order and the flow of the system.

Thread Overview

These threads will be described here.

Client Listener

  • Accepts Telnet connections
  • Passes text received from telnet and sends it to Process message

Process Message

  • Receives Text from Client listener
  • Interprets commands sent
    • Set the right thread for the Command in Motion
    • If no Command found, Send message to Output Message Thread

Create Account

  • Receives message from The Process Message Thread
  • Checks if there has been account created with the same name
    • If it has it Sends a message to the Client
  • Saves the Account
    • Sends a message to the Client

Deposit Account

  • Receives message from The Process Message Thread
  • Checks if there has been account created with the same name
    • If not, Sends a message to the client
  • Gets the account
    • Saves the new value
    • Sends a message to the Client

Withdraw Account

  • Receives message from The Process Message Thread
  • Checks if there has been account created with the same name
    • If not, Sends a message to the client
  • Gets the account
    • Saves the new value
    • Sends a message to the Client

Balance Account

  • Receives message from The Process Message Thread
  • Checks if there has been account created with the same name
    • If not, Sends a message to the client
  • Gets the account
    • Gets the Value of the account
    • Sends a message to the Client

Output Message

  • Receives Messages from Various Clients
  • Interprets the Text to send back
  • Interprets which client to send the message to
  • Sends the Message to the Telnet Client

Main Thread

  • Reads what Debugging the User wants
  • Sets up Variables for Clients connecting
  • Starts up the Client Listener, Output Message and process message threads

 

Description

The main tasks for this program to do is to interact with a base class, this class is an account class, and this program allows the connection to it via telnet. This program then assigns a number to the connection. This then allows the client to send messages to the program, be it Create, Balance, Withdraw, and Deposit.

This once received is processed by the Process Message Active object, this interprets the commands sent to the client. This then picks op on the Buzz words Listed below.

Create·         Create·         create·         C  Balance·         Balance·         balance·         B
Withdraw·         Withdraw·         withdraw·         W  Deposit·         Deposit·         deposit·         D 

These are then Comma or dot point delimited for what you want to achieve, I will list an example of commands below

C,(Account Name),                         Creates the Account named Mark

B, (Account Name),                        retrieves the account balance of Mark

W, (Account Name),1000,            Withdraw from the account of Mark by 1000

D, (Account Name),1000,             Deposits from the account of Mark by 1000

If the text does not resemble the same as above with the delimiters at the end it will throw a message to the client, stating that it is not a valid command.

This then once it has been notified as a valid command sees if the tread has been started, if it has not been started or interrupted it starts the thread running. This then sends the message to the thread via a channel.

For safety of the account method I use the reader writer tool in the threading utilities, When reading the accounts it uses a read acquire, this allows multiple clients to then read accounts at will. Editing the balance and creating accounts use the write acquire, this means that the accounts when creating are guaranteed to be unique and allows for edit of values to be safe from other terminals from writing values.

I will be talking through all of the methods that can run and what happens.

Create account method, it checks if there has been an account created with this name, this uses the read acquire for the reader writer, then once it validates that it is unique releases this token, it acquires the write acquire from the Reader writer and then saves the value, Once it is saved it then goes and releases the token again.

Balance Account Method, This reads if the account exists, this is done by the Read Acquire of the Reader writer. This then once it finds the account just gets the balance of the account, then releases the Reader Writer. This is to allow multiple reads at once, since there is no values changing. This then if the account does not exist, informs the client and releases the reader writer as per usual.

Deposit/Withdraw Account Method, This reads if the account exists, this is done by the Read acquire from the Reader writer, this then once it finds the account, releases the reader writer. This then if the account does not exist, informs the client and releases the reader writer as per usual. Then gets the Write Acquire, once it has acquired it saves the new balance, then releases the token.

Once this is done, it then sends a message to the Output Client active object, this sends a successful message of account creation. At any point the program runs in to difficulty it will not save the user and alert the client that requested the account to be saved.

– Mark Fulton