You are on page 1of 8

RV College of Engineering, Bangalore

R. V. COLLEGE OF ENGINEERING,
BANGALORE-560059
(Autonomous Institution Affiliated to VTU, Belgaum)

TITLE OF THE SELF STUDY

File Representation using C++

Submitted by

NAME OF THE CANDIDATE: Darshan KN


Gowtham J
Mohan S
Vinay Kumar H.
Yatish Kumar S
Semester:V

Submitted to
Naga Madhuri KG

Department of Electronics and Communication Engineering


R V College of Engineering

Department of Electronics and Communication


RV College of Engineering, Bangalore

R.V. COLLEGE OF ENGINEERING, BANGALORE - 560059

(Autonomous Institution Affiliated to VTU, Belgaum)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION

CERTIFICATE

Certified that the Self Study work titled File Representation using C++ is carried out by Darshan.K.N,
Gowtham.J, Mohan.S, Vinay.Kumar.H.S and Yatish.Kumar.S, who are bonafide student of R.V College
of Engineering, Bangalore, in partial fulfillment for the award of degree of Bachelor of Engineering in
Electronics And Communication of the Visvesvaraya Technological University, Belgaum during the year
2016. It is certified that all corrections/suggestions indicated for the internal Assessment have been
incorporated in the report deposited in the departmental library. The Self Study report has been
approved as it satisfies the academic requirements in respect of Self Study work prescribed by the
institution for the said degree.

Marks awarded = (Evaluation1+ Evaluation2) = 20


10

Signature of Staff In-charge Signature of Head of the Department


Signature of Principal:

Department of Electronics and Communication 1


RV College of Engineering, Bangalore

CONTENTS

1. Introduction....3
2. Methodology ....3
3. Flowchart and code.................3
4. Result...................5
5. References...6

Department of Electronics and Communication 2


RV College of Engineering, Bangalore

Introduction
Flowchart and Code
The DQS system present in the electric car
has the record of data such as voltages,
currents, temperatures, etc at different
subsystems recorded at regular intervals of
time. This data is stored in a nonvolatile
memory, in the form of hex numbers. When
this data is copied into text file in a computer,
the hex numbers are stored in ASCII format
as shown in fig 2. It is possible to interpret
this data manually for small set of values but
when the number of values increases, it turns
out to be impractical to do it manually,
leading to the need of a software support for
interpretation. The current software developed
for this purpose converts the Hex represented
using ASCII values into Decimal, and
classifies it, forming a readable output.

Methodology

The data recorded by DQS is stored in


EEPROM is copied into a text file in a
computer. The text file is read by the
software developed, using file management
functions in fstream header file. The numbers
with valid information is selected and is
converted into hex from ASCII and from hex
to decimal. Later these values are classified
and stored in another text file arranged in a
readable format as shown in Fig 3.
The C++ code is compiled using Dev C++
Fig 1 flow chart
compiler.
#include <iostream>
#include <fstream>
#include<string>
using namespace std;
class time
{
int h,m,s;
public:

Department of Electronics and Communication 3


RV College of Engineering, Bangalore

time(int a=0,int b=0, int c=0) write_file_name= new char [500]; // name
{ in array will be not be deleted completely and
h=a;m=b;s=c; remaining char will join the newly given
} name at end
setime(int a,int b, int c) // dynamic is deleted at end;
{
h=a;m=b;s=c; cout<< "enter read file name with extension
} or entire address path with name and
void operator ++() extension(use '\\\\' insted of '\\') (space in
{ between is not allowed)"<<endl; // '\\' will
s=s+10; print '\'
if(s>59) cin>>read_file_name;
{ cout<< "enter write file name with extension
s=s-60; or entire address path with name and
m++; extension(use '\\\\' insted of '\\') (space in
if(m>59) between is not allowed)"<<endl; // '\\' will
{ print '\'
m-=60; cin>>write_file_name;
h++;
if(h>24)
{
h=0; ifstream read(read_file_name); // opening
} the read file with mode input; with name
} inside read_file_name;
}
} if ( read.is_open() )
friend ostream& operator<<(ostream& out, {
time& T) ofstream write (write_file_name); // opening
{ write file with name inside write_file_name;
out <<T.h<<": "<<T.m<<": "<<T.s; with mode output; previous file is opened if
return out; present else newly created
}
}; if (write.is_open())
{
int main () {
char *read_file_name,*write_file_name,ch[3];
unsigned int retry ,decimal,a[3],i,j=0,k,F=0; time T(10,10,10);
string buffer; // buffer.size();
start: will get size of buffer; now buffer is object of
class string; whose size varies according to
the data stored in it;
read_file_name= new char [500]; // if write<<"\t\t\t\t\t\t Project \t File
static array is used when retrying the code, Management\t\t\t\t\t\n";
when new name is smaller than previous
name, previous while(getline (read,buffer))
{

Department of Electronics and Communication 4


RV College of Engineering, Bangalore

if(buffer[71]=='F' && buffer[72]=='F') }


//Checking car start write<<"\n Car
{ Switched Off \n";
write<<"\n Car write.close();
Switched ON \n"; read.close();
write<<" \t Time \t BMS \t motor cout<<"task successful\n";
controller BMS \t Subsystems \t Driver \t
Battery \n";
write<<"Sl\thr min sec \t voltage1 \t voltage2 }
\t current1 \t current2 \t temprature1 \t else cout << "\n Unable to open write file \n";
temperature2 \n"; }
else cout << "\n Unable to open read file \n";
F=1;
for(k=0,i=65;k<3;k++,i=i+2) cout<<" \n press 1 to retry : ";
{a[k]= (buffer[i+1]>'9')?(buffer[i+1]-
'A'+11):(buffer[i+1]-'0'); // delete[]write_file_name;
Hex to decimal conversion for time delete[]read_file_name;
a[k]= a[k]+(((buffer[i]>'9')?(buffer[i]-
'A'+10):(buffer[i]-'0'))*16); cin>>retry;
} if(retry==1)
T.setime(a[0],a[1],a[2]); {cout<<"\n \n \n";
} goto start;
if(buffer[71]=='E' && buffer[72]=='E') }
//chcking car off
F=0; return 0;
}
if(F==1)
// start flag
{

write <<j<<"\t"<< T<<"\t";


for( i=10;i<61;i=i+10)
{ Result
decimal= (buffer[i+1]>'9')?(buffer[i+1]-
'A'+11):(buffer[i+1]-'0'); //
Hex to decimal conversion
decimal= decimal+(((buffer[i]>'9')?(buffer[i]-
'A'+10):(buffer[i]-'0'))*16); // Hex to
decimal conversion
write<<" "<<(float)decimal/4<<"\t\t";

} Fig 2(data from DQS in text file)


write<<endl;
++T;
++j;
}

Department of Electronics and Communication 5


RV College of Engineering, Bangalore

Fig 3(Output text file generated by Software)

Reference

[1] File input and output function . [Online].


http://http://www.cplusplus.com/doc/tuto
rial/files/

Department of Electronics and Communication 6


RV College of Engineering, Bangalore

Department of Electronics and Communication 7

You might also like