StarGuide3::StarGuide3(RDMatrix *matrix,QObject *parent)
  : Switcher(matrix,parent)
{
  QString sql;
  RDSqlQuery *q;

  //
  // Get Matrix Parameters
  //
  sg_inputs=matrix->inputs();
  sg_outputs=matrix->outputs();

  //
  // Load Feed Data
  //
  sql=QString().sprintf("select NUMBER,ENGINE_NUM,DEVICE_NUM,CHANNEL_MODE\
                         from INPUTS  where STATION_NAME=\"%s\" && MATRIX=%d \
                         order by NUMBER",
			(const char *)rda->station()->name(),
			matrix->matrix());
  q=new RDSqlQuery(sql);
  q->first();
  for(int i=0;i<sg_inputs;i++) {
    sg_feed.push_back(StarGuideFeed());
    if(q->isValid()&&(q->value(0).toInt()==(i+1))) {
      sg_feed.back().setProviderId(q->value(1).toInt());
      sg_feed.back().setServiceId(q->value(2).toInt());
      sg_feed.back().setMode((RDMatrix::Mode)q->value(3).toInt());
      q->next();
    }
  }
  delete q;

  //
  // Initialize the TTY Port
  //
  RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary));
  sg_device=new RDTTYDevice();
  if(tty->active()) {
    sg_device->setName(tty->port());
    sg_device->setSpeed(tty->baudRate());
    sg_device->setWordLength(tty->dataBits());
    sg_device->setParity(tty->parity());
    sg_device->open(IO_Raw|IO_ReadWrite);
  }
  delete tty;
}
Beispiel #2
0
Unity4000::Unity4000(RDMatrix *matrix,QObject *parent,const char *name)
  : Switcher(matrix,parent,name)
{
  QString sql;
  RDSqlQuery *q;

  //
  // Get Matrix Parameters
  //
  unity_inputs=matrix->inputs();
  unity_outputs=matrix->outputs();

  //
  // Load Feed Data
  //
  sql=QString().sprintf("select NUMBER,FEED_NAME,CHANNEL_MODE from INPUTS \
                         where STATION_NAME=\"%s\" && MATRIX=%d \
                         order by NUMBER",
			(const char *)rdstation->name(),
			matrix->matrix());
  q=new RDSqlQuery(sql);
  q->first();
  for(int i=0;i<unity_inputs;i++) {
    unity_feed.push_back(UnityFeed());
    if(q->isValid()&&(q->value(0).toInt()==(i+1))) {
      unity_feed.back().setFeed(q->value(1).toString());
      unity_feed.back().setMode((RDMatrix::Mode)q->value(2).toInt());
      q->next();
    }
  }
  delete q;

  //
  // Initialize the TTY Port
  //
  RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary));
  unity_device=new RDTTYDevice();
  if(tty->active()) {
    unity_device->setName(tty->port());
    unity_device->setSpeed(tty->baudRate());
    unity_device->setWordLength(tty->dataBits());
    unity_device->setParity(tty->parity());
    unity_device->open(IO_Raw|IO_ReadWrite);
  }
  delete tty;
}
Beispiel #3
0
ListGpis::ListGpis(RDMatrix *matrix,RDMatrix::GpioType type,
		   QWidget *parent,const char *name)
  : QDialog(parent,name,true)
{
  QString sql;
  RDSqlQuery *q;
  QListViewItem *l;
  QString list_label;

  list_matrix=matrix;
  list_type=type;
  switch(type) {
    case RDMatrix::GpioInput:
      list_tablename="GPIS";
      list_size=list_matrix->gpis();
      list_label=tr("GPI Lines");
      setCaption(tr("List GPIs"));
      break;

    case RDMatrix::GpioOutput:
      list_tablename="GPOS";
      list_size=list_matrix->gpos();
      list_label=tr("GPO Lines");
      setCaption(tr("List GPOs"));
      break;
  }

  //
  // Fix the Window Size
  //
  setMinimumWidth(sizeHint().width());
  setMinimumHeight(sizeHint().height());

  //
  // Create Fonts
  //
  QFont bold_font=QFont("Helvetica",12,QFont::Bold);
  bold_font.setPixelSize(12);
  QFont font=QFont("Helvetica",12,QFont::Normal);
  font.setPixelSize(12);

  //
  // Gpis List Box
  //
  list_list_view=new QListView(this,"list_box");
  list_list_label=
    new QLabel(list_list_view,list_label,this,"list_view_label");
  list_list_label->setFont(bold_font);
  list_list_view->setAllColumnsShowFocus(true);
  list_list_view->setItemMargin(5);
  connect(list_list_view,
	  SIGNAL(doubleClicked(QListViewItem *,const QPoint &,int)),
	  this,
	  SLOT(doubleClickedData(QListViewItem *,const QPoint &,int)));

  switch(list_type) {
    case RDMatrix::GpioInput:
      list_list_view->addColumn(tr("GPI"));
      break;

    case RDMatrix::GpioOutput:
      list_list_view->addColumn(tr("GPO"));
      break;
  }
  list_list_view->setColumnAlignment(0,Qt::AlignHCenter);

  list_list_view->addColumn(tr("ON MACRO CART"));
  list_list_view->setColumnAlignment(1,Qt::AlignHCenter);

  list_list_view->addColumn(tr("ON DESCRIPTION"));
  list_list_view->setColumnAlignment(2,Qt::AlignLeft);

  list_list_view->addColumn(tr("OFF MACRO CART"));
  list_list_view->setColumnAlignment(3,Qt::AlignHCenter);

  list_list_view->addColumn(tr("OFF DESCRIPTION"));
  list_list_view->setColumnAlignment(4,Qt::AlignLeft);

  //
  //  Edit Button
  //
  list_edit_button=new QPushButton(this,"list_edit_button");
  list_edit_button->setFont(bold_font);
  list_edit_button->setText(tr("&Edit"));
  connect(list_edit_button,SIGNAL(clicked()),this,SLOT(editData()));

  //
  //  Ok Button
  //
  list_ok_button=new QPushButton(this,"list_ok_button");
  list_ok_button->setDefault(true);
  list_ok_button->setFont(bold_font);
  list_ok_button->setText(tr("&OK"));
  connect(list_ok_button,SIGNAL(clicked()),this,SLOT(okData()));

  //
  //  Cancel Button
  //
  list_cancel_button=new QPushButton(this,"list_cancel_button");
  list_cancel_button->setFont(bold_font);
  list_cancel_button->setText(tr("&Cancel"));
  connect(list_cancel_button,SIGNAL(clicked()),this,SLOT(cancelData()));

  //
  // Load Values
  //
  sql=QString().sprintf("select %s.NUMBER,%s.MACRO_CART,%s.OFF_MACRO_CART,\
                         CART.TITLE \
                         from %s left join CART \
                         on %s.MACRO_CART=CART.NUMBER \
                         where (%s.STATION_NAME=\"%s\")&&(%s.MATRIX=%d)\
                         order by %s.NUMBER",
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_tablename,
			(const char *)list_matrix->station(),
			(const char *)list_tablename,
			list_matrix->matrix(),
			(const char *)list_tablename);
  q=new RDSqlQuery(sql);
  if(list_matrix->type()==RDMatrix::LiveWireLwrpAudio) {
    while(q->next()) {
      l=new QListViewItem(list_list_view);
      l->setText(0,QString().sprintf("%05d",q->value(0).toInt()));
      if(q->value(1).toInt()>0) {
	l->setText(1,QString().sprintf("%06d",q->value(1).toInt()));
      }
      if(q->value(2).toInt()>0) {
	l->setText(3,QString().sprintf("%06d",q->value(2).toInt()));
      }
      if(q->value(1).toInt()>0) {
	l->setText(2,q->value(3).toString());
      }
      else {
	l->setText(2,tr("[unassigned]"));
      }
    }
  }
  else {
    q->first();
    for(int i=0;i<list_size;i++) {
      l=new QListViewItem(list_list_view); 
      l->setText(0,QString().sprintf("%03d",i+1));
      if(q->isValid()&&(q->value(0).toInt()==(i+1))){
	if(q->value(1).toInt()>0) {
	  l->setText(1,QString().sprintf("%06d",q->value(1).toInt()));
	}
	if(q->value(2).toInt()>0) {
	  l->setText(3,QString().sprintf("%06d",q->value(2).toInt()));
	}
	if(q->value(1).toInt()>0) {
	  l->setText(2,q->value(3).toString());
	}
	else {
	  l->setText(2,tr("[unassigned]"));
	}
	q->next();
      }
      else {
	l->setText(2,tr("[unassigned]"));
      }
    }
  }
  delete q;

  //
  // Now go back and get the descriptions for the 'Off' carts
  //
  l=list_list_view->firstChild();
  while(l!=NULL) {
    if(l->text(0).toInt()>0) {
      if(l->text(3).toInt()>0) {
	RDCart *cart=new RDCart(l->text(3).toUInt());
	l->setText(4,cart->title());
	delete cart;
      }
      else {
	l->setText(4,tr("[unassigned]"));
      }
    }
    l=l->nextSibling();
  }

}