Specifications

CONSTRUCTION
s=inp(0x379);t=s;while(s==t)s=inp(0x379);break;
default:textcolor(YELLOW+BLINK);cprintf
(Trigger mode: Manual ..Press any key to
Start); getch();break;
}
startgraphics();
for(int pointno=1;pointno<481;++pointno)
{
char in;
display(unit);
speedf=roundoff(speed);
infile<<speedf<<endl;
if (kbhit())
{
if ((in = getch()) == \x1B)break;
}
}
infile.close();//Close the file,clean up and return
to main//
restorecrtmode();
window(10,8,75,8);
textcolor(YELLOW+BLINK);
cprintf(Data Capture Interrupted or File full(960
sec)..Press any key..);
getch();
startgraphics();
openingmenu();
}
//Read the speed and convert into the asked
units//
float readspeed(int unit,int teeth)
{
int sett=255;int tes=255;mid=0;
clock_t start, end=0;
sett=inp(0x379);
tes=sett;
for(start=clock();(end-start)/CLK_TCK<2.0;
end=clock())
{
sett=inp(0x379);
if(sett!=tes)++mid;
tes=sett;
}
//Calculation of the speed depending on unit
selected//
switch(unit)
{
case 1:return(mid*15.0/(teeth));
case 2:return(mid/(4.0*teeth));
case 3:return(mid*900.0/teeth);
default:return(mid/(4.0*teeth));
}
}
//Display the speed on the screen update every 2
secs//
void display(int unit)
{
char msgd[80];
char msgf[80];
fstream infile;
setcolor(LIGHTRED);
setbkcolor(LIGHTGREEN);
settextstyle(1,HORIZ_DIR,4);
rectangle(5,5,630,470);
outtextxy(175,30,”SPEED MASTER”);
moveto(150,400);
outtext(Press ESC to exit.....);
outtextxy(150,300,Capture file =);
sprintf(msgf, %s, monitorfile);
outtextxy(400,300,msgf);
moveto(150,100);
outtext(Speed );
switch(unit)
{
case 1:outtextxy(250,100,in Revs/Min);break;
case 2:outtextxy(250,100,in Revs/Sec);break;
case 3:outtextxy(250,100,in Revs/Hr);break;
}
speed=readspeed(unit,teeth);
cleardevice();
sprintf(msgd, %f, speed);
outtextxy(250,200,msgd);
}
void view()//View a speed vs time graph//
{
VIEWSTART:
closegraph();
int xscale=1;int yscale;
char msgx[2];char msgmaxy[5];char msgmaxx
[5];char msgy[2];char msgun[8];char gunits[8];
char msgfile[10];
char filename[8];
char msgpoint[5];
int coordinate[10000];
int errorcode;
fstream infile;
window(1,1,80,25);
clrscr();
textcolor(RED);
textbackground(BLUE);
gotoxy(25,3);
cprintf( - S P E E D M A S T E R - );
gotoxy(25,5);
cprintf( VIEW FILE PAGE );
window(10,8,50,8);
textcolor(YELLOW);
clrscr();
cprintf( Enter name of file to view - );
scanf(%8s, &filename);
scalefactor:
int i=0;int pointcount=0;
XAXIS:
clrscr();
cprintf( Enter X axis scale factor - );
scanf(%d, &xscale);
if(xscale<0||xscale>9) goto XAXIS;
infile.open(filename,ios::in);
if(infile.fail())
{
window(10,8,70,9);
textcolor(YELLOW+BLINK);
clrscr;
cprintf(..Error opening file or file does not
exist..\n\r Press F3 to exit,F4 to re-enter );
ERRORGRAPH:
while (!kbhit())
{ }
char choicegraph;
choicegraph=getch();
switch(choicegraph)
{
case (char(62)):goto VIEWSTART;
case (char (61)):main();break;
default:goto ERRORGRAPH;
}
}
infile>>gunits>>yscale;
while(!infile.eof())
{
infile>>coordinate[i];
++i;
++pointcount;
}
infile.close();
startgraphics();
cleardevice();
setcolor(CYAN);
setbkcolor(DARKGRAY);
rectangle(10,40,490,440);
settextstyle(2,HORIZ_DIR,6);
outtextxy(140,15,Speed Master..GRAPH VIEW
PAGE..);
setcolor(GREEN);
outtextxy(492,40,Graph Variables);
outtextxy(492,60,X scale =);
outtextxy(492,75,Y scale =);
outtextxy(492,90,Units = );
outtextxy(492,105,File = );
outtextxy(492,120,Points = );
setcolor(GREEN);
outtextxy(492,150,Options:);
outtextxy(492,165,F1= New Graph);
outtextxy(492,180,F2= Main Menu);
outtextxy(492,210,NOTE:);
outtextxy(492,225,X axis=960sec);
outtextxy(492,240,Y axis=400units);
outtextxy(492,255,For Xscale=1);
outtextxy(492,270,and Yscale=1);
setcolor(YELLOW);
sprintf(msgx, %d, xscale);
outtextxy(580,60, msgx);
sprintf(msgy, %d, yscale);
outtextxy(580,75, msgy);
sprintf(msgun, %s, gunits);
outtextxy(580,90, msgun);
sprintf(msgfile, %5s, filename);
outtextxy(565,105, msgfile);
sprintf(msgpoint, %d, pointcount);
outtextxy(567,120, msgpoint);
sprintf(msgmaxx, %d, (960/xscale));
outtextxy(480,450,msgmaxx);
sprintf(msgmaxy, %d, (400*yscale));
outtextxy(10,20,msgmaxy);
outtextxy(60,20,msgun);
outtextxy(480,460,Seconds);
grid();
setviewport(10,40,490,440,1);
setcolor(GREEN);
int x1=0;int y1=0;
int j;
for (j=0;j<pointcount-1;++j)
{
line(x1*xscale,400-y1/yscale,(j+1)*xscale,400-
coordinate[j]/yscale);
x1=j+1;
y1=coordinate[j];
}
GRAPHMENU:
while (!kbhit())
{ }
char choiceg;
choiceg=getch();
switch(choiceg)
{
case (char(59)):goto VIEWSTART;
case (char (60)):closegraph();main();break;
default:goto GRAPHMENU;
}
}
//To draw the graph grid//
void grid()
{
int i;
setcolor(RED);
for(i=140;i<440;i=i+100)
line(10,i,490,i);
setcolor(BLUE);
for (i=70;i<490;i=i+60)
line(i,40,i,440);
}
//Main help call function//
void help()
{
closegraph();
clrscr();
displayhelp(HELPS.PG1);
getch();
}
//Exit to shell with graphics clean up//
void exiit()
{
28