2015-02-27 Fred Gleason <fredg@paravelsystems.com>

* Renamed the 'SAS User Serial Interface' driver to
	'SAS USI (3 digit)'.
	* Added an 'SAS USI (2 digit)' swticher driver in
	'ripcd/sasusi2digit.cpp' and 'ripcd/sasusi2digit.h'.
This commit is contained in:
Fred Gleason
2015-02-27 15:51:09 -05:00
parent d1962d1c4f
commit f9022eb4a7
9 changed files with 241 additions and 8 deletions

View File

@@ -63,6 +63,7 @@ dist_ripcd_SOURCES = acu1p.cpp acu1p.h\
sas32000.cpp sas32000.h\
sas64000.cpp sas64000.h\
sas64000gpi.cpp sas64000gpi.h\
sasusi2digit.cpp sasusi2digit.h\
sasusi3digit.cpp sasusi3digit.h\
starguide3.cpp starguide3.h\
starguide_feed.cpp starguide_feed.h\
@@ -101,6 +102,7 @@ nodist_ripcd_SOURCES = moc_am16.cpp\
moc_sas32000.cpp\
moc_sas64000.cpp\
moc_sas64000gpi.cpp\
moc_sasusi2digit.cpp\
moc_sasusi3digit.cpp\
moc_starguide3.cpp\
moc_swauthority.cpp\

View File

@@ -52,6 +52,7 @@
#include <sas32000.h>
#include <sas64000.h>
#include <sas64000gpi.h>
#include <sasusi2digit.h>
#include <sasusi3digit.h>
#include <starguide3.h>
#include <swauthority.h>
@@ -175,6 +176,10 @@ bool MainObject::LoadSwitchDriver(int matrix_num)
ripcd_switcher[matrix_num]=new Sas64000Gpi(matrix,this);
break;
case RDMatrix::SasUsi2Digit:
ripcd_switcher[matrix_num]=new SasUsi2Digit(matrix,this);
break;
case RDMatrix::SasUsi3Digit:
ripcd_switcher[matrix_num]=new SasUsi3Digit(matrix,this);
break;

132
ripcd/sasusi2digit.cpp Normal file
View File

@@ -0,0 +1,132 @@
// sasusi2digit.cpp
//
// A Rivendell switcher driver for the SAS USI Protocol (2 digit)
//
// (C) Copyright 2002-2015 Fred Gleason <fredg@paravelsystems.com>
//
// 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 <rddb.h>
#include <globals.h>
#include <sasusi2digit.h>
SasUsi2Digit::SasUsi2Digit(RDMatrix *matrix,QObject *parent,const char *name)
: Switcher(matrix,parent,name)
{
RDTty *tty;
sas_matrix=matrix->matrix();
sas_ptr=0;
//
// Get Matrix Parameters
//
sas_inputs=matrix->inputs();
sas_outputs=matrix->outputs();
sas_gpis=matrix->gpis();
sas_gpos=matrix->gpos();
//
// Initialize the connection
//
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;
}
RDMatrix::Type SasUsi2Digit::type()
{
return RDMatrix::SasUsi2Digit;
}
unsigned SasUsi2Digit::gpiQuantity()
{
return sas_gpis;
}
unsigned SasUsi2Digit::gpoQuantity()
{
return sas_gpos;
}
bool SasUsi2Digit::primaryTtyActive()
{
return true;
}
bool SasUsi2Digit::secondaryTtyActive()
{
return false;
}
void SasUsi2Digit::processCommand(RDMacro *cmd)
{
char str[256];
switch(cmd->command()) {
case RDMacro::ST:
if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>sas_inputs)||
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>sas_outputs)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
snprintf(str,256,"%c%02d%02d\x0D\x0A",20,
cmd->arg(1).toInt(),cmd->arg(2).toInt());
SendCommand(str);
cmd->acknowledge(true);
emit rmlEcho(cmd);
break;
default:
cmd->acknowledge(false);
emit rmlEcho(cmd);
break;
}
}
void SasUsi2Digit::SendCommand(char *str)
{
LogLine(RDConfig::LogDebug,QString().sprintf("sending USI cmd: %s",(const char *)PrettifyCommand(str)));
sas_device->writeBlock(str,strlen(str));
}
QString SasUsi2Digit::PrettifyCommand(const char *cmd) const
{
QString ret;
if(cmd[0]<26) {
ret=QString().sprintf("^%c%s",'@'+cmd[0],cmd+1);
}
else {
ret=cmd;
}
return ret;
}

65
ripcd/sasusi2digit.h Normal file
View File

@@ -0,0 +1,65 @@
// sasusi2digit.h
//
// A Rivendell switcher driver for the SAS USI Protocol (2 digit)
//
// (C) Copyright 2002-2015 Fred Gleason <fredg@paravelsystems.com>
//
// 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.
//
#ifndef SASUSI2DIGIT_H
#define SASUSI2DIGIT_H
#include <vector>
#include <qsocket.h>
#include <qhostaddress.h>
#include <rd.h>
#include <rdmatrix.h>
#include <rdmacro.h>
#include <rdtty.h>
#include <switcher.h>
#define SASUSI2DIGIT_MAX_LENGTH 256
class SasUsi2Digit : public Switcher
{
Q_OBJECT
public:
SasUsi2Digit(RDMatrix *matrix,QObject *parent=0,const char *name=0);
RDMatrix::Type type();
unsigned gpiQuantity();
unsigned gpoQuantity();
bool primaryTtyActive();
bool secondaryTtyActive();
void processCommand(RDMacro *cmd);
private:
void SendCommand(char *str);
QString PrettifyCommand(const char *cmd) const;
RDTTYDevice *sas_device;
char sas_buffer[SASUSI2DIGIT_MAX_LENGTH];
unsigned sas_ptr;
int sas_matrix;
int sas_ipport;
int sas_inputs;
int sas_outputs;
int sas_gpis;
int sas_gpos;
};
#endif // SASUSI2DIGIT_H

View File

@@ -1,4 +1,4 @@
// sasusi.cpp
// sasusi3digit.cpp
//
// A Rivendell switcher driver for the SAS USI Protocol (3 digit)
//