Specifications

CONSTRUCTION
#include<conio.h>
#include<iostream.h>
#include<graphics.h>
#include<dos.h>
#include<stdio.h>
#include<time.h>
#include<fstream.h>
#include<process.h>
#include<stdlib.h>
void startgraphics();//start graphics system//
void openingmenu();//opening menu//
void monitor();//monitor and save to file//
float readspeed(int unit,int teeth);//read the
speed//
void display(int unit);//display the speed//
void view();//View a Speed vs Time Graph//
void grid();//Draw the graph grid//
void displayhelp(char helpfilename[10]);
void exiit();
void help();
int roundoff(float number);
//Global Variables//
int unit;int teeth;
float speed;
char monitorfile[8];
int gdriver;int gmode;
int mid;
//Program main menu//
void main()
{
startgraphics();
openingmenu();
}
//Graphics initialisation//
void startgraphics()
{
registerbgidriver(EGAVGA_driver);
registerbgifont(small_font);
registerbgifont(triplex_font);
int gdriver = DETECT, gmode;
initgraph(&gdriver, &gmode, “”);
}
//Opening menu//
void openingmenu()
{
setfillstyle(LTSLASH_FILL,5);
bar(10, 10, 635, 470);
setlinestyle(SOLID_LINE,0,2);
rectangle(10,10,635,470);
setlinestyle(SOLID_LINE,0,2);
rectangle(200,40,400,90);
setcolor(BLUE);
line(200,91,400,91);
line(200,92,400,92);
line(401,90,401,40);
settextstyle(2,HORIZ_DIR,8);
setcolor(YELLOW);
outtextxy(220,50,SPEED TRACK);
setcolor(LIGHTBLUE);
outtextxy(150,120,1.SPEED MONITOR &
CAPTURE - F1);
setcolor(LIGHTRED);
outtextxy(150,180,2.VIEW SPEED vs TIME
GRAPH - F2);
setcolor(LIGHTMAGENTA);
outtextxy(150,240,3.SPEED TRACK HELP -
F3);
setcolor(LIGHTCYAN);
outtextxy(150,300,4.EXIT TO SHELL - F4);
setcolor(LIGHTGREEN);
outtextxy(180,360,Enter your choice );
outtextxy(200,383,(F1 TO F4) );
USERCHOICE:
while(!kbhit())
{ }
char userchoice=getch();
switch(userchoice)
{
case (char(59)):monitor();break;
case (char(60)):view();break;
case (char(61)):help();break;
case (char(62)):exiit();break;
default:goto USERCHOICE;
}
}
//Monitoring the speed online and storing the
data//
void monitor()
{
int s;int t;
int trigger;
int yrange;
char unitf[8];
int speedf;
restorecrtmode();
clrscr();
window(1,1,80,25);
clrscr();
textcolor(YELLOW);
textbackground(LIGHTBLUE);
gotoxy(25,3);
cprintf( - S P E E D T R A C K -);
gotoxy(25,4);
cprintf(=========================);
gotoxy(25,6);
cprintf(MONITOR & CAPTURE PAGE);
window(10,8,75,8);
textcolor(YELLOW);
clrscr();
cprintf(Enter file name to store Speed data
(****.***) - );
scanf(%8s, &monitorfile);
GETTRIGGER:
textcolor(YELLOW);
clrscr();
cprintf(Enter trigger mode(1=Manual,2=First
pulse) - );
scanf(%d, &trigger);
if(trigger<1 || trigger>2)
{
clrscr();
textcolor(YELLOW+BLINK);
cprintf(........Value out of range,Enter 1 or
2........);
delay(2000);
goto GETTRIGGER;
}
GETUNIT:
textcolor(YELLOW);
clrscr();
cprintf(Enter Unit for Speed(1=Rev/min,2=Revs/
sec,3=Revs/Hr) - );
scanf(%d, &unit);
if(unit<1 || unit>3)
{
textcolor(YELLOW+BLINK);
clrscr();
cprintf( ........Value out of range............ );
delay(2000);
goto GETUNIT;
}
GETRANGE:
textcolor(YELLOW);
clrscr();
cprintf(Enter Range for Speed(1=400 units,
2=800 units..etc) - );
scanf(%d, &yrange);
if(yrange<1 || yrange>100)
{
textcolor(YELLOW+BLINK);
clrscr();
cprintf( ........Value out of range............ );
delay(2000);
goto GETRANGE;
}
GETTEETH:
textcolor(YELLOW);
clrscr();
cprintf( Enter Number of teeth for Sensor - );
scanf(%d, &teeth);
if(teeth<1 || teeth>100)
{
textcolor(YELLOW+BLINK);
clrscr();
cprintf( ........Value out of range............ );
delay(2000);
goto GETTEETH;
}
//Open the file for data storage
fstream infile;
infile.open(monitorfile,ios::out);
//Store the units
char *unitf1 = Rev/min”;
char *unitf2 = Rev/sec”;
char *unitf3 = Rev/hr ;
switch(unit)
{
case 1:infile<<unitf1<<endl;break;
case 2:infile<<unitf2<<endl;break;
case 3:infile<<unitf3<<endl;break;
}
//Entering the units and y scale to capture file//
//fstream infile;
//infile.open(monitorfile,ios::out);
infile<<yrange<<endl;
clrscr();
//Setting the trigger mode//
switch(trigger)
{
case 1:textcolor(YELLOW+BLINK);cprintf
(Trigger mode: Manual ..Press any key
to Start);getch();break;
case 2:textcolor(YELLOW+BLINK);cprintf
(“Trigger mode: Auto..Waiting for first pulse..);
with extension.
(b) Enter the x-axis scale factor to en-
able the graph to be stretched on the x-
axis to observe cramped points properly.
After entering the x-axis scale, the graph
appears along with all relevant data, like
scale factors for x and y axis, file name,
Program Listing for SPEEDM.CPP
and units, etc.
(c) While still in the graph mode, you
may view a new graph after pressing F1.
For returning to the main menu, press
F2.
3. Help. This module provides one
page of help and reads from a file called
HELPS.PG1. If this file cannot be opened,
or is not available, the software prompts
with Help file not found or cannot be
opened. Pressing any key from the help
page returns one to main menu. The con-
tents of HELPS.PG1 are given in the box
(on previous page).
27