* The preview only shows a few pages of manuals at random. You can get the complete content by filling out the form below.
Description
Introduction When it came to C++ programming, there was broad to cover during the time of this internship and it included some of the topics discussed briefly below. C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. This C++ tutorial adopts a simple and practical approach to describe the concepts of C++ for beginners to advanced software engineers. C++ fully supports object-oriented programming, including the four pillars of object-oriented development which are Encapsulation, Data hiding, Inheritance and Polymorphism. Use of C++ C++ is used by hundreds of thousands of programmers in essentially every application domain. C++ is being highly used to write device drivers and other software that rely on direct manipulation of hardware under real-time constraints. Anyone who has used either an Apple Macintosh or a PC running Windows has indirectly used C++ because the primary user interfaces of these systems are written in C++. Local Environment Setup To set up your environment for C++, you need to have a text editor to type your program e.g. Windows Notepad and a C++ compiler like GNU C/C++. C++ BASIC SYNTAX C++ program can be defined as a collection of objects that communicate via invoking each other's methods. Let us now briefly look into what a class, object, methods, and instant variables mean. Object − Objects have states and behaviors. Example: A dog has states - color, breed as well as behaviors - wagging, barking, and eating. An object is an instance of a class. Class − A class can be defined as a template/blueprint that describes the behaviors/states that object of its type support. Methods − A method is basically a behavior. A class can contain many methods. It is in methods where the logics are written, data is manipulated and all the actions are executed. Instance Variables − Each object has its unique set of instance variables. An object's state is created by the values assigned to these instance variables. Semicolons and Blocks in C++ In C++, the semicolon is a statement terminator. A block is a set of logically connected statements
C++ Identifiers A C++ identifier is a name used to identify a variable, function, class, module, or any other user-defined item. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9).C++ does not allow punctuation characters such as @, $, and % within identifiers. C++ is a case-sensitive programming language. C++ Keywords These are reserved words that may not be used as constant or variable or any other identifier names as they have a function. To see them go to the link https://www.tutorialspoint.com/cplusplus/cpp_basic_syntax.htm Whitespace in C++ A line containing only whitespace, possibly with a comment, is known as a blank line, and C++ compiler totally ignores it. Comments in C++ Program comments are explanatory statements that you can include in the C++ code. These comments help anyone reading the source code. Multiple paragraph C++ comments start with /* and end with */ while single line comments begin with //. The compiler usually ignores the comments for execution. C++ DATATYPES You may like to store information of various data types like character, wide character, integer etc. Based on the data type of a variable, the operating system allocates memory and decides what can be stored in the reserved memory. Primitive Built-in Data types There are seven basic built-in data types of C++ and they include:
Typedef Declarations
You can create a new name for an existing type using typedef. Following is the simple syntax to define a new type using typedef − typedef
type
newname;
Enumerated Types This is a data type that uses basic data types with prescribed values in their representation Syntax: Enum {list}; variable;
C++ VARIABLE TYPES A variable provides us with named storage that our programs can manipulate. Each variable in C++ has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable. The name of a variable can be composed of letters, digits, and the underscore character. It must begin with either a letter or an underscore. Upper and lowercase letters are distinct because C++ is case-sensitive − There are following basic types of variable in C++ as explained in last chapter – bool: Stores either value true or false. char: typically a single octet. This is an integer type int: The most natural size of an integer for the machine. float:A single precision floating point value double: A double-precision floating point value void: Represents the absence of type wchar_t:Wide character type. Variable Declaration in C++ A variable definition specifies a data type, and contains a list of one or more variables of that type as follows − type variable_list; Variables can be initialized (assigned an initial value) in their declaration. type variable_name = value;
VARIABLE SCOPE IN C++ A scope is a region of the program and broadly speaking there are three places, where variables can be declared − Inside a function or a block which is called local variables, they can be used only by statements that are inside that function or block of code. Local variables are not known to functions outside their own In the definition of function parameters which is called formal parameters. Outside of all functions which is called global variables. Global variables are defined outside of all the functions, usually on top of the program. The global variables will hold their value throughout the life-time of your program. A global variable can be accessed by any function. That is, a global variable is available for use throughout your entire program after its declaration. C++ CONSTANTS/LITERALS Constants refer to fixed values that the program may not alter and they are called literals. Constants can be of any of the basic data types and they include: Integer Literals An integer literal can be a decimal, octal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 for octal, and nothing for decimal. An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. The suffix can be uppercase or lowercase and can be in any order. Floating-point Literals A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form. Boolean Literals There are two Boolean literals and they are part of standard C++ keywords −
A value of true representing true.
A value of false representing false.
You should not consider the value of true equal to 1 and value of false equal to 0. Character Literals Character literals are enclosed in single quotes. If the literal begins with L (uppercase only), it is a wide character literal (e.g., L'x') and should be stored in wchar_t type of variable . Otherwise, it is a narrow character literal (e.g., 'x') and can be stored in a simple variable of char type.
A character literal can be a plain character (e.g., 'x'), an escape sequence (e.g., '\t'), or a universal character (e.g., '\u02C0'). There are certain characters in C++ when they are preceded by a backslash they will have special meaning and they are used to represent like newline (\n) or tab (\t). String Literals String literals are enclosed in double quotes. A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters. You can break a long line into multiple lines using string literals and separate them using whitespaces. Defining Constants There are two simple ways in C++ to define constants − Using #define preprocessor(#define identifier value) Using const keyword (const type variable = value;) C++ MODIFIER TYPES C++ allows the char, int, and double data types to have modifiers preceding them. A modifier is used to alter the meaning of the base type so that it more precisely fits the needs of various situations. The data type modifiers are signed, unsigned, long and short. The modifiers signed, unsigned, long, and short can be applied to integer base types. In addition, signed and unsigned can be applied to char, and long can be applied to double. The modifiers signed and unsigned can also be used as prefix to long or short modifiers. For example, unsigned long int. C++ allows a shorthand notation for declaring unsigned, short, or long integers. You can simply use the word unsigned, short, or long, without int. It automatically implies int. C++ OPERATORS An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in operators and provide the following types of operators Arithmetic Operators: The Arithmetic operators supported by C++ are: +, -, /,*,%, ++ and --. Relational Operators: The Relational Operators supported by C++ are =, !=, <, >, >= and <=. Logical Operators: The Logical operators supported by C++ are &&-AND, ||-OR and !-NOT.
Bitwise Operators: The Bitwise operators supported by C++ language are &,|,^,WAVE,>> and << Assignment Operators The assignment operators supported by C++ are =,+=,-+,/=,*=,&=,|=,^=,>>=,<<= and %=. CONTROL STRUCTURES It is an order for executing statements in which statements are executed were control is transferred along the coarse of logic flow. There are three categories of control structures and they are: Sequential control structures It is where control flows from one statement to another. It is always involved with the general flow of one statement after one is fulfilled, if one statement fails, an error is generated. Selective control structures It is where control flows and executes one of the statements provided with alternatives provided that a condition is fulfilled. It includes the if statement, if…else statement, if…else if…else statement and the switch statement. If statement Syntax: if (condition) This means that if the condition returns a true value the following block of code will be executed, otherwise nothing will be done. If statement Syntax: if (condition) This means that if the condition returns a true value the following block of code will be executed, otherwise nothing will be done. If..else statement Syntax: if (condition) else< statement/block of statements>;
This means that if the condition returns a true value the following block of code will be executed, otherwise the action after the else keyword will be executed. If..else if..else statement Syntax: if (condition) else if (condition) < statement/block of statements> else ;
This means that if the condition returns a true value the following block of code will be executed, otherwise the condition after the else if keyword examined and if it returns true then
the following statements are executed below it, otherwise the statements of the else keyword will be executed. Switch Statement The switch provides for a multi-way branch. Thus, it enables a program to select among several alternatives. Syntax: •
The switch expression can be of type char, byte, short, or int. (Floating-point expressions, for example, are not allowed.
•
No two case constants in the same switch can have identical values. The default statement sequence is executed if no case constant matches the expression.
•
The default is optional; if it is not present, no action takes place if all matches fail.
•
When a match is found, the statements associated with that case are executed until the break is encountered or, in the case of default or the last case, until the end of the switch is reached
Repetition Control Structures It is used to execute a certain set of actions for a predefined number of times or until a particular condition is satisfied. It includes the following: For loop The general form of the for loop for repeating a statement/block of statements is for(initialization; condition; iteration) ; ■ The initialization is usually an assignment statement that sets the initial value of the loop control variable, which acts as the counter that controls the loop. ■ The condition is a Boolean expression that determines whether or not the loop will repeat ■ The iteration expression defines the amount by which the loop control variable will change each time the loop is repeated. Notice that these three major sections of the loop must be separated by semicolons. The for loop will continue to execute as long as the condition tests true. Once the condition becomes false, the loop will exit, and program execution will resume on the statement following the for. While loop The general form of the while loop is:
while(condition) ; where condition defines the condition that controls the loop, and it may be any valid Boolean expression then a loop counter which is an integer should be declared and initialised outside plus the increment /iteration be included in the body of the statement. The loop repeats while the condition is true. When the condition becomes false, program control passes to the line immediately following the loop do-While loop The general form of the while loop is: do ; while(condition) where condition defines the condition that controls the loop, and it may be any valid Boolean expression then a loop counter which is an integer should be declared and initialised outside plus the increment /iteration be included in the body of the statement. The loop repeats while the condition is true. When the condition becomes false, program control passes to the line immediately following the loop. How do-while loop works? First, the statements inside loop execute and then the condition gets evaluated, if the condition returns true then the control gets transferred to the “do” else it jumps to the next statement after do-while NB: With all due respect, time was limited due to the state of the world with covid-19 so we had to stop at this point of control structures, but I managed to do more research on Arrays as described briefly below. ARRAYS An array is a group of contiguous or related data items that share a common name.It is used when programs have to handle large amount of data Each value in an array is stored at a specific position. This position is called a index or superscript and the base-index is zero. The ability to use a single name to represent a collection of items and refer to an item by specifying the item number enables us to develop concise and efficient programs. For example, a loop with index as the control variable can be used to read the entire array, perform calculations, and print out the results. Declaration of Arrays: Form 1: Type arrayname[] Form 2: Type [] arrayname Creation of arrays After declaring arrays, we need to allocate memory for storage array items. In Java, this is carried out by using “new” operator, as follows: arrayname = new type[size]; //size is an integer
Initialisation of Arrays Once arrays are created, they need to be initialised with some values before access their content. A general form of initialisation is: Arrayname [index/subscript] = value; Like C, C++ creates arrays starting with subscript 0 and ends with value one less than the size specified. Array Length Arrays are fixed length and their length is specified at create time then in C++, all arrays store the allocated size in a variable named “length”. We can access the length of arrays as arrayName.length: e.g. int x = students.length;
//x = 7
Accessed using the index e.g. int x = students [1];
//
x = 40
Arrays can also be initialised like standard variables at the time of their declaration. Type arrayname[] = {list of values};// In this case it is not necessary to use the new operator. Two dimensional Arrays This is an array that has elements that are also arrays but their elements contain elements that are not arrays Two dimensional arrays allows us to store data that are recorded in tabular form 2D Array manipulations Declaration: int myArray [][];
Creation: myArray = new int[4][3]; // OR int myArray [][] = new int[4][3];
Initialisation: Single Value; myArray[0][0] = 10; Multiple values: int tableA[2][3] = {{10, 15, 30}, {14, 30, 33}};//OR int tableA[][] = {{10, 15, 30}, {14, 30, 33}};
POWER SUPPLIES Types of power supplies
Switch Mode Power Supply Description Schematic Circuit Explanation Line Filter: This is a circuit for eliminating harming frequencies in ac input that may cause an equipment to malfunction. It contains live capacitors which are non-polarized and a cored inductor There is also a surge protector in some circuits that makes a short circuit and blows off the fuse incase of very high voltage and this can be replaced with a fuse when blown for normal operation of the power supply unit. Rectifiers: This is a unit responsible for the conversion of ac input into dc or at the sametime stepping up ro stepping down the ac first. It can be made of power diodes(centre-tap and bridge structures) with transformers for the stepping purpose. Filtering Circuit:This is for the purpose of removing of the ripples resulting from the pulsating output of the rectifier unit. It can contain a polarized capacitor(which causes shock if shorted since it stores charge even when supply is off) alone or an inductor alone or both of them in conjunction of work to do better smoothening process. Regulators: This circuit is for the purpose of maintaining the output from the filter circuit at a constant voltage. Zener diodes or transistors or Integrated Circuits can be used for this with their respective circuits. Feedback Circuit: This circuit monitor and ensure that output is correct then power the remaining circuit.It works hand in hand with the optoisolator(a LED and a phototransistor). Isolation Transformer/Chopper Transformer:This circuit is for splittung voltages for different circuits on the load board depending on the magnitude of voltage each circuit requires.It works in conjunction with a diode(allow current in only one direction) and a capacitor(removing square wave like ripples due to mutual inductance of the transformer from the output of the transfromer through the diode). As from the schematic, it takes the voltage from regulator and mutual inductance occurs, then the secondary depending on the coil turns will produce different voltages of different magnitudes. To make the voltage negative, a diode is reversed.
POWER SUPPLIES In this area, we covered the basics of a power supply with some deep practical explanation and a hands-on session which I is described below. Aims -To become well equipped with the basics power supplies all round.
-To have the ability to practically troubleshoot and repair power supplies. Objectives -Repair a device with a malfunctioning power supply. Routine Work Do research on the various types of power supplies available to get well equipped with the schematics and techniques for maintenance. Practice One: Control Structures: Selection Structures Date of Practical: 12th January 2021 and 19th January 2021 Tools/Equipment Used; -HP 255 G1 Laptop with DevC++ software installed. Procedures;
CCTV SYSTEMS A CCTV system links a camera to a video monitor using a direct transmission system. This differs from broadcast television where the signal is transmitted over the air and viewed with a television. System Requirements The system requirements for establishing a CCTV system include:
Multidisciplinary System Design Team: A team of people with relevant knowledge to help guide the CCTV system design process should be recruited.
Needs Assessment: Locations or assets that will benefit from CCTV surveillance should be identified
CCTV Site Survey: Successful integration requires a comprehensive site survey which supports the development of detailed equipment specifications, installation design, and ultimately a thorough system test.
System Layout Considerations: A key input to the design and specification of the layout of an outdoor CCTV system is the site survey team’s collection and analysis of aerial photographs plus architecture for indoor CCTV systems.
CCTV System Design Considerations System design considerations include factors such as:
Lighting: This is to ensure optimum performance and to prevent operational environment conflicts.
Power Distribution: It is prudent to consult licensed engineers and electricians in the design and installation of a CCTV power distribution system.
Video Transmission: Selecting the appropriate video transmission media, such as coaxial cable or unshielded twisted pair (UTP), is very important in designing a quality CCTV system.
Scalability: This refers to the system’s ability to accommodate additional components such as cameras, increased video storage, and additional monitors.
Cost: Cost estimates for a CCTV system should cover all aspects of the system’s life cycle including planning, design, installation, operation, maintenance, and personnel costs.
Infrastructure: Each camera deployed in a CCTV system requires power and the means to transmit video data to monitoring and storage systems.
Reliability and Maintainability :Predicting the reliability and maintainability of a new CCTV system is difficult without a demonstration period.
COMPONENTS OF CCTV SYSTEMS CCTV uses components that are directly connected to generate, transmit, display, and store video data. This system can include the following: • Cameras: Cameras are for the capturing of the required video hence essential part of the system. Parts of a camera are the image sensor (converting light into electronic signals),lens(gathers light reflected from the subject and directs to the image sensor) and Image processing circuitry(Organizes, optimizes, and transmits video signals). -There are various types of cameras available and one chooses them according to the required features for example if the area of interest is always in smoke or fog one will use Thermal Imaging Cameras. And most importantly are the cameras categorized into analog and Network
cameras (connect to IP-based networks, including the Internet, and provide remote viewing and recording.) • Lenses; The lens on a CCTV camera is the first element in the imaging chain, which consists of the lens, camera, transmission system, image management and analysis software, and monitor. Other components of the imaging chain cannot compensate for an inferior lens. Lenses are available in three basic types: fixed focal length, varifocal (variable focal length), and zoom. A lens has certain components and characteristics that further determine its capabilities. These include the focal length, type of aperture and focus control, wavelength of light or energy the lens is optimized to transmit, and image sensor size the lens is designed for.
• Housings and mounts; Part of designing and installing an effective CCTV system includes selection of the camera housings and mounts. In any application, the housing and mounting hardware is selected on the basis of several criteria like Environmental conditions, Architectural considerations Installation and other special considerations that match the installed materials to the system’s intended use and planned maintenance. • Monitors; The function of monitors is to display video images for viewing. The monitors used in a camera system can include Televisions, PC Monitors, Monochrome Monitors, CCTV Monitors, OLED Monitors, Front Projection Monitor and HD LCD Display Monitors. • Switchers and multiplexers; Switchers: Switchers are simpler in concept than multiplexers. They can be set manually or automatically to send analog video or a TV signal to a monitor or a recorder.
Multiplexers: Multiplexing began the transition from analog to digital video; these devices receive an analog video signal and then digitize it. • Video recorders. Recording capability is essential for assessment, investigation, and evidence collection. Video recording has transformed from tape-based systems to digital hard drive systems. While some systems still use tape, the popularity of digital video has driven the demand for recorders with hard drive storage. For us we mostly discussed digital recorders as reviewed below: Digital Video Recorders: A CCTV system may send digital or analog video to the recording system. A DVR receiving analog video takes two fields of the analog signal and builds one image, which is then digitized and compressed. If the video going to the DVR is digital, it is normally compressed to save storage space. Various data compression methods can be used that offer varying degrees of performance, quality, and storage economy. Other recording options apart from DVRs is NVRs, Hard Drive Recorders, Hybrid DVRs and Mobile recorders. CCTV SYSTEMS Introduction In this area, we had two sessions in one day, one session for the basics in theory and second for the survey of the CCTV System of our 201 and 202 rooms which was more practical. Aims -Configure a functional CCTV System Objectives -To become well equipped with the basics of CCTV Systems for earlier preparation for more in near future -To know the popular CCTV Systems in our neighboring environments.
Routine Work Doing research on the different CCTV Systems plus their components during free time to expand my horizon in the area.
Practical : Survey of the 201 and 202 CCTV System Date of Practical: 19th January 2021 Tools/Equipment Used;
A fully functional CCTV System containing LG Monitor
A network switch
4 cameras
CP PLUS Krypto Series DVR with software installed.
UTP Cables and Coaxial cables.
Procedures; -We were introduced into the server room and everything was disconnected. The monitor was checked and there was no display. -With explanation the instructor reconnected the items as follows -The switch connection was directly to the DVR (via an Ethernet cable) from which the four cameras were also connected (using Coax Siamese cables) and the LG Monitor (via the VGA port with VGA cable). -We were then assigned with the task of drawing the topology of the system which is as follows:
Lessons Learnt
-How to connect transmission cables of a simple CCTV system.
C++ PROGRAMMING In this area, we covered the basics of the programming language with mostly pen and book practice and some little computer coding done in the labs thereafter. Aims -To become well equipped with the basics of C++ programming language for earlier preparation for more in near future -To have the ability to practically code C++ using any provided computers. Objectives -Create a simple program using C++. -Apply C++ knowledge in Hardware related development. Routine Work Make sure I do some coding at home with my laptop or at the computer lab while covering some of the past topics and doing my own research. Practice One: Control Structures: Selection Structures Date of Practical: 12th January 2021 and 19th January 2021 Tools/Equipment Used; -HP 255 G1 Laptop with DevC++ software installed. Procedures; --Launch the DevC++ Software then went to File—New—Source File.
-We started with doing some of the practices on if...Statement, among which was requiring us to write the code for manipulating between two variable x and y such that if x is less than 10 OR greater than 2 then y is 7 whose shorthand C++ statement was written as below. int x, y; If ((x<10) ||(x>2)) Y=7;
-Followed with practices on if...else statement, among which was requiring us to write code for manipulating the same variables such that if x is less 10 OR greater then 2 then y is 5 and if not then y is 6 whose shorthand C++ statement was written as below int x, y; If ((x<10) ||(x>2)) Y=5; else y=6
-The followed with practices on if...else if…else statement, among which was requiring us to write code for manipulating the same variables such that if x is less 10 OR greater then 2 then y is 5 and if not and at the same time x is equal to 11 then y is 6 otherwise y=4 whose shorthand C++ statement was written as below int x, y; If ((x<10) ||(x>2)) Y=5; else if(x==11) y=6 else y=4
Lessons learnt; -We learnt how to use the selection control structures to manipulate the flow of the source code.
Practice Two: Control Structures: Iteration Structures Date of Practical: 21st January 2021 Tools/Equipment Used; -HP 255 G1 Laptop with DevC++ installed. Procedures; --Launch the DevC++ Software then went to File—New—Source File. -We started with doing some of the practices on for loop, among which was as below which required us to print integers from 1 t0 10 incase given a loop counter i 1<=1<=10 for(int i=1;i<=10;i++){cout<< “\n”<
-Followed with practices on While loop statement, among which was as below which required us to print integers from 1 t0 10 incase given a loop counter i 1<=1<=10 int i=1; while(i<=10){ cout<< “\n”<
-Followed with practices on do While Loop, among which was as below(do it in DevC++ then show the results) int i=1; do{ cout<< “\n”<
--Followed with practices sentinel controlled loops, among which was to make one enter only positive values into the computer using while loop as below. int n; cout<< “Enter positive number”; cin>>in; while !(n<0){cout<< “Enter positive number”; cin>>n};
-Followed with practices on flag controlled loops, among which was to make one enter only positive values into the computer using while loop as below. int n, flag=0; cout<< “Enter positive number”; cin>>in; if (n<0) flag =1; while !(flag==1){cout<< “Enter positive number”; cin>>n; if(n>0) flag =1}
-Followed with practices on end of file loops, among which was one required to find the sum of several numbers and print them as below int n,sum=0; cout<< “Enter a number”; cin<>n;} cout<<”The sum is”<< sum;
-Then followed with practices on count controlled loops, among which was one required to print even numbers from 1 to 19 them as below for(int i=2;i<=20;i+=2){cout<< “\n”<