Wednesday, October 26, 2016

Unit 14 Assignment 1 Event Driven Programming

Unit 14 Assignment 1

Task 1
What is and event driven language?

An event driven language is a language that creates programs that are controlled by user input or interaction, the program will then react depending on the input from the user as oppose to following a procedure.

Event driven programs tend to be used all of the time and can range from washing machines to microwaves, most of the events that happen are initiated by the user this means they are event driven; the functions that happen would not take place unless these are triggered by something or someone.

Features

There are many to features to an event driven programming language and language that I have chosen to use in particular which I python. Here are a few of the features I will be talking about:

·        Service Orientated
·         Time Driven 
·         Event Handlers
·         Trigger Functions
·         Mouse Events
·         Keyboard
·         External Events


Service Orientated

Service orientated can happen within event driven programming; this feature tends to run in the background and will take minimal power to process. For example when a device is plugged into a USB port the computer will attempt to locate the driver for the device that has been plugged in this would then allow the device to be used.

Time Driven

This comes down to events that take place at a certain time for example in a computer sense this  would be a virus system, this would be something a user would set up so a time of day, a day of the week or maybe even a day of a month depending on the severity of the program.

Event Handlers

An event handler within the terms of event driven programming will execute a specific task in result of a specific trigger this could range from a device picking up a voice command and trying to work out what has been said. It could also something such as pressing the windows key and L to lock the machine on the newer versions of windows.

Trigger Functions

This in simple terms is what triggers a function to run, what input is needed to prompt the function which would display the correct output. Trigger functions tend to be used to dictate what event handler should be used for the specified output. For example this could be such things as a keypad for a gate or door only the correct sequence would be able to trigger the door to open.

Mouse
The mouse has many user input functions that can be used for example it can be moved around the screen to help a user navigate to the correct part of the screen, in addition to this there is a left and a right click that can be used these provide a plethora of features dependant on when program or screen you are using.

Keyboard
 Each key of the keyboard has its own function primarily just displaying the retrospective letter or    number in addition to this they have extra functions which can be used by pressing such keys as the shift or control keys, these are all built in functions or keyboard shortcuts that be used to speed up user interaction.

External Events
   External events are something which allows a program to either launch or access another program through the current program. This could be a game asking for permission to pass a firewall to be able to connect to the internet.

Advantages
There  are many advantages to this programming language, here are a few:
·         Many Platforms
·         Free to use
·            Raspberry Pi
·         Education
·         Easy to learn
·         Can embed with other languages

Many Platforms
One advantage of python is that it can be coded and read on a plethora of platforms, this is excellent when wanting to create programs that can be ran on multiple devices, and it also gives the programmer flexibility when it comes to choosing the system that they would like to use when creating the programs.

Raspberry Pi
A raspberry pi is a standalone device which allows the user to program the device to do or be anything, for example the device can be programmed to make a robotic pet they would be able to react to the use input, python can be used to trigger events upon request from the user and would not just run in a step by step fashion.

Free to use
The python programming language is free to use the application you use can be downloaded from the internet and installed to the preferred device, this is a basic command shell style of program but add ons can be downloaded to give the program and the programmer the ability make more in depth programs.

Education
Python and event driven programming tends to be used in all depths of education, for example most students would be able to learn the programming language in schools, but would then be able to transfer what they have learnt to bigger and better projects. The flexibility of python means it can be used to code the smallest programs but could then be used in a bigger much complex program too.


Easy to learn
Python in comparison to other languages is a lot easier to learn this is due to it being able to write very basic command line programming this would be typing the code into a shell and this would be able to generate a response by declaring a value for variable and then asking the system to display it.

Use with other programming languages
Event programming languages can be embedded within other programming languages to be able to add additional functions to things such as a website. The base of the website would be made with html but any functioning parts adding an online calculator for instance would be able to be coded in python.

Disadvantages
As with anything there are also disadvantages as well as the advantages, the ones I am going to be talking about are as follow:
·        
Text based
·         Correcting
·         Indentations within code
·         Usually just a shell

Text Based
The programming that has to be done when using python is very text heavy, this means that the programmer will have to use a lot of coding to create programs, it tends not to have extra help as oppose to some of the other programming languages such as html and Dreamweaver.

Correcting
Python coded can be extremely difficult to correct this is due to the fact that the program used doesn’t give much feedback where the errors are and how to fix them other programs and language tend to tell the user why the error has occurred and where and which line.

Indentations with code
If the indentations are not correct the code will not display and will error, all of the code has to be in the correct indentations to run, the code will not compile and will result in stating there is an error with indentation, this will then need to be fixed.

Mainly Shell based
The main way python is coded is in a shell, this is a command line where the programmer can type code into the shell and the program will run, for example the programmer will declare the variables or ask the user questions and then store them as variables, and it would then run the program on the user’s request. It is mainly text based and has no additional help this is why it wouldn’t be very useful for making something as such as a 3D game.

Operating Systems
You may not know it but the operating systems that you use today are event driven, this means that whenever I user performs an action it tells the computer to initiate the function, for example a click of the mouse or a press of the keyboard would mean that operating system would load exactly what the user requested.
An operating system is something that allows a user to navigate around a system, tasks can be performed creating, deleting or modifying files, and this can be done text based without any graphical help of buttons to click, that being said it is still event driven due to the user having to input the correct command to ensure that they end up obtaining the right information. That being said most modern day modern day operating systems that tend to be installed on most people’s computers when they buy them have a built in GUI; this is the how the user will allow control the system and how they are able to initiate the system functions all throughout the operating system.
I will be discussing a few different event driven functions within this part the assignment the events I am going to discuss are the following:

·         Search Bar
·         Launching Program
·         Personalisation

Search Bar
The search bar in the start menu is a good example of the event driven programming, the search bar has the ability to scan and search the whole computer and return the value in this case would be the search results of the value the user is searching. This would require both typing using the keyboard and then clicking the magnifying glass to initiate the search or clicking the enter button, this would then run the function which it is meant for in this case searching the system to return all of the results that match the specified value. This is event driven as it has needed the user input to perform task, if this was not event driven it would have happened on its own without the user needing to interact with it.
The print screen to the left shows the start menu as it is before the user has initiated the search; this would be by typing the relevant value to search for.
The print screen on the right shows the menu after the user has typed in the relevant value it wants to find, in this case I have asked it to search for the python program. In this version of Windows the search already takes place after only the first letter is typed it well then automatically narrow down the values until the user finds the value that they are looking for.

























Launching a Program/Application
The actual launching of the program is also event driven programming taking the same principle as the search bar in the fact it actually needs the user input to force the function to process, in this example I will be launching the python program that we searched for in the previous point. To do this I will be using the clicking feature as discussed in the features part of this article, when the target is highlighted the left click is used as a selection function this will then tell the operating system that the user has selected a file to execute and will the launch the file due to the clicking the left button on the mouse, the below print screens show the process in a before and after state.
The screenshot to the left shows the program I would like executing, the reason the line has lit up blue is due to the cursor being hovered over the value, the hovering over the icon is also an event that has been initiated by the user therefore the blue highlighting is a result of even driven programming as it wouldn’t happen on its own
When the left click is operated it would then perform the function, the print screen below will show the result after the function has been carried out and the program has been executed.
The program has now been launched which is the result in which I was hoping for this is another way the operating system is event driven.




Personalisation
We have focused on the left click this time we are going to focus on the right click of the mouse this brings up a different set of options that are all event driven due to the user having to select them for them to work.
The image on the left is a result of the right click it has forced the operating system to bring up a menu this menu would otherwise not have been shown, following the same theme it is only because the user has initiated the event that the menu is showing. Again the user chooses the option they would like and in this case it is to personalise the desktop by changing the back image.
This has shown a screen that allows me to change the background image of the computer. In the image below I have changed the image selection to the United Kingdom theme, this has changed the background, and it is event driven due to the fact the user has had to initiate it to allow the image to change.





Task 3
In this part of the assignment I am to discuss the suitability of event driving programming for the following appliances:
·         Standard computers
·         Windows
·         Mobile platforms
·         Thermostats
·         Alarm systems
·         DVD players
·         Washing Machines – choose right setting without a visual aspect of knowledge number 3 sets temp, cycle and other factors
Standard Computers
Standard basic computers such as the raspberry pi would be suitable for non-graphical event driven programming a program can be uploaded to the raspberry pi and then this could be used to operate a plethora of different task due to the nature of the programming. It could be used to control a robotic item, as a timer for house tasks such as a toaster being operated at a specific time.
Windows
It would be possible to use a non-graphical event driven programming for a Windows operating system but wouldn’t be very practical for the everyday user and a graphical version would be more beneficial but the functions will still be there but it would need a more experienced user to use it.
Mobile Platforms
In today’s era a mobile platform whether it be a phone or tablet tends to be a necessity I do not think it would be useful having an event driven program without graphics on these devices, tablets and mobile platforms are for the everyday user event driven would be fine but I feel it would need to have graphics.
Thermostats
I think thermostats have the ability to be event driven without this use of graphics as they would refer back to the older forms of thermostats and the analogue thermostats they used to have for example, the user will put the pins down to tell the system when to turn the heating on and off, there could also be a regulator for heat to ensure the heating kicks in if the temperature is below a certain amount.
Alarm Systems
These would also be suitable for non-graphical programming; most alarms tend not to have graphics that will have buttons that the user will be able to interact with and will be able to perform functions to set the alarm and also turn it off. This can all be done very easily without the need of graphics.
DVD players
This would be suitable for non-graphical programming the user would have button whether it be on the remote control or the player itself, it would not need any additional graphics the user could have enough control with the buttons on the player.
Washing machine
Lastly a washing machine would not only be suitable but would benefit from having event driven programming and would not be in dire need or it needing graphical functions also as the programs are explained to the user this would allow the user to pick the correct number of program that they want this would force the program to choose the settings that the user would like to use.