You are on page 1of 4

PROGRAMME FOR COMPUTER BASED EQUIPMENT PERFORMANCE MONITORING SYSTEM IN C++

#include<iostream>
#include<fstream>
#include<math.h>
#include<conio.h>
using namespace std;
int main()
{
int time[3],pos[4],curr[2],pre[2],breakdown,idle,count,i,t;
float avail,usage,util;
/*
time[0]=TotalTime; time[1]=CapacityTime; time[2]=MaintenanceTime;
pos[0]=Load(x); pos[1]=Load[y]; pos[2]=Unload[x];
pos[3]=Unload[y];
Curr[0]=Curr[x]; Curr[1]=Curr[y]; Pre[2]=Pre[x]; Pre[3]=Pre[y];
*/
//Opening & reading from the input file
string line;
ifstream iFile("input.txt");
if(iFile.is_open())
{
i=0;
while(iFile.good() && i<3)
{
getline(iFile,line);
time[i]=atoi(line.c_str());
i++;
}
i=0;

while(iFile.good() && i<4)


{
getline(iFile,line);
pos[i]=atoi(line.c_str());
i++;
}
}
else
{
cout<<"Unable to open input file";
getch();
return 0;
}
//Opening the output file
ofstream oFile("output.txt");
if(!oFile.is_open())
{
cout<<"Unable to open output file";
getch();
return 0;
}
//Calculating breakdown and idle time
breakdown=0, idle=0, count=0, pre[0]=0, pre[1]=0;
for(t=0; t<time[0]; t++)
{
if(iFile.is_open())
{
i=0;
while(iFile.good()&&i<2)

{
getline(iFile,line);
curr[i]=atoi(line.c_str());
i++;
}
}
if((curr[0]!=pre[0])||(curr[1]!=pre[1]))//CurrLoc!=PrevLoc
{
if((curr[0]==pos[2])&&(curr[1]==pos[3]))//CurrLoc==UnloadPoint
count++;
}
else
if((curr[0]==pre[0])&&(curr[1]==pre[1]))//CurrLoc==PrevLoc
{
if(((curr[0]==pos[2])&&(curr[1]==pos[3]))||((curr[0]==pos[0])&&(curr[1
]==pos[1])))//CurrLoc=LoadPoint or CurrLoc=UnloadPoint
{
idle++;
}
else
breakdown++;
}
pre[0]=curr[0], pre[1]=curr[1];
}
//calculating availability, utilization and usage time
avail=(time[0]-time[2]-breakdown)/time[0];
util=(time[0]-time[2]-breakdown-idle)/time[0];
usage = time[1]*count;
//Writing to output file

oFile<<"Availability Time = "<<avail<<endl;


oFile<<"Utilization Time = "<<util<<endl;
oFile<<"Usage Time = "<<usage<<endl;
oFile<<"Breakdown Time = "<<breakdown<<endl;
oFile<<"Idle Time = "<<idle<<endl;
iFile.close();
oFile.close();
cout<<"Automization Completed!! Please check output file for
details.";
getch();
return 0;
}
The Input to be given: for equipment performance monitoring
Total time
Capacity time
Maintenance time
Load position (x coordinate)
Load position (y coordinate)
Unload position (x coordinate)
Unload position (y coordinate)
Current position (x coordinate)
Current position (y coordinate)
Multiple instances of current position at different times
The Output that we will obtain for the above given input is:
Availability Time
Utilization Time
Usage Time
Breakdown Time
Idle Time

You might also like