/ tests / build / ui / nml-position-logger.cc
nml-position-logger.cc
 1  // g++ nml-position-logger.cc -I include -L lib -l nml -l linuxcnc
 2  #include "emc.hh"
 3  #include "emc_nml.hh"
 4  #include <unistd.h>
 5  #include <iostream>
 6  #include <cstdlib>
 7  
 8  int main(int argc, char **argv) {
 9      if(argc < 2) { std::cerr << "Usage: " << argv[0] << " NMLFILE\n"; abort(); }
10      const char *nmlfile = argv[1];
11      RCS_STAT_CHANNEL *stat = new RCS_STAT_CHANNEL(emcFormat, "emcStatus", "xemc", nmlfile);
12      while(1) {
13          usleep(100*1000);
14          if(!stat->valid()) continue;
15          if(stat->peek() != EMC_STAT_TYPE) continue;
16          EMC_STAT *emcStatus = static_cast<EMC_STAT*>(stat->get_address());
17          std::cout << emcStatus->motion.traj.position.tran.x << " "
18              << emcStatus->motion.traj.position.tran.y << " "
19              << emcStatus->motion.traj.position.tran.z << "\n";
20      }
21      return 0;
22  }