Rivendellaudio/ripcd/sas64000gpi.cpp
Fred Gleason 89b846f7d6 2014-08-14 Fred Gleason <fredg@paravelsystems.com>
* Fixed warnings in 'lib/rdaudioconvert.cpp'.
	* Fixed warnings in 'lib/rdaudioexport.cpp'.
	* Fixed warnings in 'lib/rdaudioimport.cpp'.
	* Fixed warnings in 'lib/rdcart_dialog.cpp'.
	* Fixed warnings in 'lib/rdconf.cpp'.
	* Fixed warnings in 'lib/rdcopyaudio.cpp'.
	* Fixed warnings in 'lib/rdescape_string.cpp'.
	* Fixed warnings in 'lib/rdevent_line.cpp'.
	* Fixed warnings in 'lib/rdfeed.cpp'.
	* Refactored 'RDOneShot' to use int values in 'lib/rdoneshot.cpp'
	and 'lib/rdoneshot.h'.
	* Fixed warnings in 'lib/rdpeaksexport.cpp'.
	* Fixed warnings in 'lib/rdtrimaudio.cpp'.
	* Fixed warnings in 'lib/rdwavefile.cpp'.
	* Fixed warnings in 'rdhpi/rdhpiplaystream.cpp'.
	* Fixed warnings in 'rdhpi/rdhpirecordstream.cpp'.
	* Fixed warnings in 'rdhpi/rdhpisoundcard.cpp'.
	* Fixed warnings in 'pam_rd/pam_rd.cpp'.
	* Fixed warnings in 'rdadmin/edit_rdairplay.cpp'.
	* Fixed warnings in 'rdairplay/list_log.cpp'.
	* Fixed warnings in 'rdairplay/log_play.cpp'.
	* Fixed warnings in 'rdairplay/pie_counter.cpp'.
	* Fixed warnings in 'rdairplay/rlm_host.cpp'.
	* Fixed warnings in 'rdcatchd/rdcatchd.cpp'.
	* Fixed warnings in 'rdlogedit/editlog.cpp'.
	* Fixed warnings in 'rdlogmanager/rdlogmanager.cpp'.
	* Fixed warnings in 'rdrepl/replfactory.h'.
	* Fixed warnings in 'ripcd/acu1p.cpp' and 'ripcd/acu1p.h'.
	* Fixed warnings in 'ripcd/bt16x2.cpp' and 'ripcd/bt16x2.h'.
	* Fixed warnings in 'ripcd/btss164.cpp' and 'ripcd/btss164.h'.
	* Fixed warnings in 'ripcd/btss42.cpp' and 'ripcd/btss42.h'.
	* Fixed warnings in 'ripcd/btss44.cpp' and 'ripcd/btss44.h'.
	* Fixed warnings in 'ripcd/btss82.cpp' and 'ripcd/btss82.h'.
	* Fixed warnings in 'ripcd/btsrc16.cpp' and 'ripcd/btsrc16.h'.
	* Fixed warnings in 'ripcd/btsrc8iii.cpp' and 'ripcd/btsrc8iii.h'.
	* Fixed warnings in 'ripcd/livewire_mcastgpio.cpp'.
	* Fixed warnings in 'ripcd/local_gpio.cpp' and 'ripcd/local_gpio.h'.
	* Fixed warnings in 'ripcd/sas64000gpi.cpp' and 'ripcd/sas64000gpi.h'.
	* Fixed warnings in 'ripcd/vguest.cpp' and 'ripcd/vguest.h'.
	* Fixed warnings in 'utils/rdhpiinfo/rdhpiinfo.cpp'
	* Fixed warnings in 'utils/rdgen/wavlib.cpp'
	* Fixed warnings in 'utils/rdimport/rdimport.cpp'
	* Fixed warnings in 'utils/rdsoftkeys/rdsoftkeys.cpp'
	* Fixed warnings in 'web/rdxport/export.cpp'
2014-08-14 19:08:38 -04:00

171 lines
3.8 KiB
C++

// sas64000gpi.cpp
//
// A Rivendell switcher driver for the SAS64000 connected via
// a GPI-1600
//
// (C) Copyright 2002-2004 Fred Gleason <fredg@paravelsystems.com>
//
// $Id: sas64000gpi.cpp,v 1.13 2010/08/03 23:39:26 cvs Exp $
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
#include <stdlib.h>
#include <globals.h>
#include <sas64000gpi.h>
Sas64000Gpi::Sas64000Gpi(RDMatrix *matrix,QObject *parent,const char *name)
: Switcher(matrix,parent,name)
{
//
// Get Matrix Parameters
//
sas_matrix=matrix->matrix();
sas_inputs=matrix->inputs();
sas_outputs=matrix->outputs();
sas_gpis=matrix->gpis();
sas_gpos=matrix->gpos();
//
// Initialize the TTY Port
//
RDTty *tty=new RDTty(rdstation->name(),matrix->port(RDMatrix::Primary));
sas_device=new RDTTYDevice();
if(tty->active()) {
sas_device->setName(tty->port());
sas_device->setSpeed(tty->baudRate());
sas_device->setWordLength(tty->dataBits());
sas_device->setParity(tty->parity());
sas_device->open(IO_Raw|IO_ReadWrite);
}
delete tty;
//
// Interval OneShots
//
sas_gpo_oneshot=new RDOneShot(this);
connect(sas_gpo_oneshot,SIGNAL(timeout(int value)),
this,SLOT(gpoOneshotData(int)));
}
Sas64000Gpi::~Sas64000Gpi()
{
delete sas_device;
}
RDMatrix::Type Sas64000Gpi::type()
{
return RDMatrix::Sas64000Gpi;
}
unsigned Sas64000Gpi::gpiQuantity()
{
return sas_gpis;
}
unsigned Sas64000Gpi::gpoQuantity()
{
return sas_gpos;
}
bool Sas64000Gpi::primaryTtyActive()
{
return true;
}
bool Sas64000Gpi::secondaryTtyActive()
{
return false;
}
void Sas64000Gpi::processCommand(RDMacro *cmd)
{
char str[9];
char cmd_byte;
switch(cmd->command()) {
case RDMacro::ST:
if((cmd->arg(1).toInt()<1)||(cmd->arg(1).toInt()>sas_inputs)||
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>sas_outputs)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
sprintf(str,"\xFE%c%c%c%c%c\xFF",
(char)((cmd->arg(2).toInt()-1)/16)&0x0F,
(char)((cmd->arg(2).toInt()-1)%16)&0x0F,
(char)((cmd->arg(1).toInt()-1)%128),
(char)((cmd->arg(1).toInt()-1)/128),
(char)(((cmd->arg(1).toInt()-1)%128)+
((cmd->arg(1).toInt()-1)/128))&0x7F);
sas_device->writeBlock(str,7);
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
case RDMacro::GO:
if((cmd->arg(1).toString().lower()!="o")||
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>sas_gpos)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(4).toInt()==0) { // Latch
if(cmd->arg(3).toInt()==0) { // Off
cmd_byte=0xF9;
emit gpoChanged(sas_matrix,cmd->arg(2).toInt()-1,false);
}
else {
cmd_byte=0xFA;
emit gpoChanged(sas_matrix,cmd->arg(2).toInt()-1,true);
}
}
else { // Pulse
if(cmd->arg(3).toInt()==0) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
cmd_byte=0xFB;
sas_gpo_oneshot->start(cmd->arg(2).toInt()-1,500);
emit gpoChanged(sas_matrix,cmd->arg(2).toInt()-1,true);
}
sprintf(str,"%c%c\xFF",cmd_byte,cmd->arg(2).toInt()-1);
sas_device->writeBlock(str,3);
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
default:
cmd->acknowledge(false);
emit rmlEcho(cmd);
break;
}
}
void Sas64000Gpi::gpoOneshotData(int value)
{
emit gpoChanged(sas_matrix,value,false);
}