/* Simple test-program for live-xgraphs. Compile with: Linux cc livetest.c -o livetest Sun cc livetest.c -lsocket -lnsl -o livetest Use as: xgraph -soc 13330 -x_range 0 10 -y_range 0 7 -pl & livetest */ #include "soc_lib.h" #include "soc_lib.c" /* From www.atl.lmco.com/proj/xgraph/soclib.tar */ int main() { int soc, socno=13330; char message[100]; float x=1.0, y=1.0; soc = makeConnect( "localhost", socno ); printf("Client made socket %d\n",socno); system("sleep 1"); send_soc( soc, "title_x = Velocity (KM/H)"); send_soc( soc, "title_y = Inertia (NM)"); send_soc( soc, "title = Example Live Graph"); send_soc( soc, "thickness = 1.5"); /* Set line thickness. */ while (x<10.0) { sprintf(message,"%f %f", x, y ); send_soc( soc, message ); /* Send data to Xgraph. */ x = x + 0.5; y = y + 0.1 * y; system("sleep 1"); /* Slowdown to see plot-actions. */ } send_soc( soc, "EndOfSocket"); close_soc( soc ); return 0; }