I'm developing a realtime data acquisition program. I have gotten the data to be acquired realtime from an analog source and output to a .csv file. I am now using the API LiveGraph to graph this data in realtime. Works well. My problem is that I want my program to automatically open LiveGraph and the file when it begins. However, I'm only familiar with the system() command, which closes the program immediately after opening it. When dealing with GnuPlot, one had to put pause -1 at the end of the GnuPlot code. Is there an easier, more efficient way to open the program, or does anybody know of a way to keep it open using the system() command. Code looks like this:
Code:
#include <iostream>
using std::cerr;
using std::endl;
#include <windows.h>
#include <cbw.h>
#include <stdio.h>
#include <conio.h>
#include <fstream>
using std::ofstream;
#include <cstdlib>
using namespace std;
int main()
{
int I;
int J=0;
int L=0;
int BoardNum=0;
int ULStat=0;
int LowChan=0;
int HighChan=0;
int Gain=BIP5VOLTS;
long Count=100;
long Rate=10000;
WORD ADData[1000];
unsigned Options=CONVERTDATA;
float RevLevel=(float)CURRENTREVNUM;
ULStat=cbDeclareRevision(&RevLevel);
cbErrHandling(PRINTALL,DONTSTOP);
ofstream outdata;
outdata.open("realtime.csv");
outdata<<"Data Number,Voltage"<<endl;
printf("Beginning Real-Time Data Acquisition...");
system("LiveGraph.jar realtime.csv");
for(J=0;J<100;J++)
{
for (I=0;I<100;I++)
{
ULStat=cbAInScan(BoardNum,LowChan,HighChan,Count,&Rate,Gain,ADData,Options);
outdata<<""<<L<<","<<ADData[I]<<endl;
cout<<""<<ADData[I]<<endl;
L=L+1;
if(_kbhit())
{
I=100;
J=100;
}
}
I=0;
}
outdata.close();
_getch();
}