#include "engineerctrlpanel.h"
#include "ui_engineerctrlpanel.h"

engineerCtrlPanel::engineerCtrlPanel(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::engineerCtrlPanel)
{
  ui->setupUi(this);
  connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()));
}

engineerCtrlPanel::~engineerCtrlPanel()
{
  delete ui;
}

void engineerCtrlPanel::tiptilt_button_clicked()
{
  QProcess procTiptiltCtrl;
  QString program = "niceQUI";
  QStringList arguments;
  arguments << "--TIPTILT_CTRL.CONFIG:Endpoint=[NAME=tiptilt_ctrl-svr-DUMMY,TCP=localhost:60100]";
  arguments << "--NICEQUI_WINDOW_TITLE:String=\"SHARK-NIR:Tip/Tilt_Control\"";
  procTiptiltCtrl.startDetached(program, arguments);
  procTiptiltCtrl.waitForStarted();
}

void engineerCtrlPanel::motion_button_clicked()
{
  QProcess procMotionCtrl;
  QString program = "niceQUI";
  QStringList arguments;
  arguments << "--MOTION_CTRL.CONFIG:Endpoint=[NAME=motion_ctrl-svr-DUMMY,TCP=localhost:60200]";
  arguments << "--NICEQUI_WINDOW_TITLE:String=\"SHARK-NIR:Motion_Control\"";
  procMotionCtrl.startDetached(program, arguments);
  procMotionCtrl.waitForStarted();
}

void engineerCtrlPanel::track_button_clicked()
{
  QProcess procTrackCtrl;
  QString program = "niceQUI";
  QStringList arguments;
  arguments << "--TRACK_CTRL.CONFIG:Endpoint=[NAME=track_ctrl-svr-DUMMY,TCP=localhost:60300]";
  arguments << "--NICEQUI_WINDOW_TITLE:String=\"SHARK-NIR:Tracking_Control\"";
  procTrackCtrl.startDetached(program, arguments);
  procTrackCtrl.waitForStarted();
}

void engineerCtrlPanel::calunit_button_clicked()
{
  QProcess procCalibCtrl;
  QString program = "niceQUI";
  QStringList arguments;
  arguments << "--CALIB_CTRL.CONFIG:Endpoint=[NAME=calib_ctrl-svr-DUMMY,TCP=localhost:60400]";
  arguments << "--NICEQUI_WINDOW_TITLE:String=\"SHARK-NIR:Calibration_Unit_Control\"";
  procCalibCtrl.startDetached(program, arguments);
  procCalibCtrl.waitForStarted();
}
