mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2026-01-12 07:35:55 +01:00
2019-07-05 Fred Gleason <fredg@paravelsystems.com>
* Added switcher support for Grass Valley Series 7000 protocol.
This commit is contained in:
@@ -51,6 +51,7 @@ dist_ripcd_SOURCES = acu1p.cpp acu1p.h\
|
||||
btsrc16.cpp btsrc16.h\
|
||||
btsrc8iii.cpp btsrc8iii.h\
|
||||
btu41mlrweb.cpp btu41mlrweb.h\
|
||||
gvc7000.cpp gvc7000.h\
|
||||
harlond.cpp harlond.h\
|
||||
kernelgpio.cpp kernelgpio.h\
|
||||
livewire_lwrpaudio.cpp livewire_lwrpaudio.h\
|
||||
@@ -102,6 +103,7 @@ nodist_ripcd_SOURCES = moc_am16.cpp\
|
||||
moc_btss44.cpp\
|
||||
moc_btss82.cpp\
|
||||
moc_btu41mlrweb.cpp\
|
||||
moc_gvc7000.cpp\
|
||||
moc_harlond.cpp\
|
||||
moc_kernelgpio.cpp\
|
||||
moc_livewire_lwrpaudio.cpp\
|
||||
|
||||
210
ripcd/gvc7000.cpp
Normal file
210
ripcd/gvc7000.cpp
Normal file
@@ -0,0 +1,210 @@
|
||||
// gvc7000.cpp
|
||||
//
|
||||
// A Rivendell switcher driver for Grass Valley Series 7000 Protocol
|
||||
//
|
||||
// (C) Copyright 2002-2019 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 <syslog.h>
|
||||
|
||||
#include <qsignalmapper.h>
|
||||
|
||||
#include <rdapplication.h>
|
||||
|
||||
#include "gvc7000.h"
|
||||
|
||||
Gvc7000::Gvc7000(RDMatrix *matrix,QObject *parent)
|
||||
: Switcher(matrix,parent)
|
||||
{
|
||||
gvc_matrix=matrix->matrix();
|
||||
|
||||
//
|
||||
// Get Matrix Parameters
|
||||
//
|
||||
gvc_ipaddress=matrix->ipAddress(RDMatrix::Primary);
|
||||
gvc_ipport=matrix->ipPort(RDMatrix::Primary);
|
||||
gvc_inputs=matrix->inputs();
|
||||
gvc_outputs=matrix->outputs();
|
||||
|
||||
//
|
||||
// Keepalive Timer
|
||||
//
|
||||
gvc_keepalive_timer=new QTimer(this);
|
||||
connect(gvc_keepalive_timer,SIGNAL(timeout()),this,SLOT(keepaliveData()));
|
||||
gvc_keepalive_timer->start(GVC7000_KEEPALIVE_INTERVAL);
|
||||
|
||||
//
|
||||
// Reconnection Timer
|
||||
//
|
||||
gvc_reconnect_timer=new QTimer(this);
|
||||
gvc_reconnect_timer->setSingleShot(true);
|
||||
connect(gvc_reconnect_timer,SIGNAL(timeout()),this,SLOT(ipConnect()));
|
||||
|
||||
//
|
||||
// Initialize the connection
|
||||
//
|
||||
gvc_socket=new QTcpSocket(this);
|
||||
connect(gvc_socket,SIGNAL(connected()),this,SLOT(connectedData()));
|
||||
connect(gvc_socket,SIGNAL(disconnected()),this,SLOT(disconnectedData()));
|
||||
connect(gvc_socket,SIGNAL(error(QAbstractSocket::SocketError)),
|
||||
this,SLOT(errorData(QAbstractSocket::SocketError)));
|
||||
ipConnect();
|
||||
}
|
||||
|
||||
|
||||
RDMatrix::Type Gvc7000::type()
|
||||
{
|
||||
return RDMatrix::Gvc7000;
|
||||
}
|
||||
|
||||
|
||||
unsigned Gvc7000::gpiQuantity()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned Gvc7000::gpoQuantity()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool Gvc7000::primaryTtyActive()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Gvc7000::secondaryTtyActive()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Gvc7000::processCommand(RDMacro *cmd)
|
||||
{
|
||||
switch(cmd->command()) {
|
||||
case RDMacro::ST:
|
||||
if((cmd->arg(1).toInt()<1)||(cmd->arg(1).toInt()>gvc_inputs)||
|
||||
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>gvc_outputs)) {
|
||||
cmd->acknowledge(false);
|
||||
emit rmlEcho(cmd);
|
||||
return;
|
||||
}
|
||||
SendCommand(ToSeries7000Native(QString().sprintf("TI,%04X,%04X",cmd->arg(2).toInt()-1,cmd->arg(1).toInt()-1)));
|
||||
cmd->acknowledge(true);
|
||||
emit rmlEcho(cmd);
|
||||
break;
|
||||
|
||||
default:
|
||||
cmd->acknowledge(false);
|
||||
emit rmlEcho(cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Gvc7000::ipConnect()
|
||||
{
|
||||
gvc_socket->connectToHost(gvc_ipaddress.toString(),gvc_ipport);
|
||||
}
|
||||
|
||||
|
||||
void Gvc7000::keepaliveData()
|
||||
{
|
||||
SendCommand(ToSeries7000Native("QJ"));
|
||||
}
|
||||
|
||||
|
||||
void Gvc7000::connectedData()
|
||||
{
|
||||
rda->syslog(LOG_INFO,"connection to Gvc7000 device at %s:%d established",
|
||||
(const char *)gvc_ipaddress.toString().toUtf8(),gvc_ipport);
|
||||
}
|
||||
|
||||
|
||||
void Gvc7000::disconnectedData()
|
||||
{
|
||||
rda->syslog(LOG_WARNING,
|
||||
"connection to Gvc7000 device at %s:%d closed unexpectedly, attempting reconnect",
|
||||
(const char *)gvc_ipaddress.toString().toUtf8(),gvc_ipport);
|
||||
gvc_reconnect_timer->start(GVC7000_RECONNECT_INTERVAL,true);
|
||||
}
|
||||
|
||||
|
||||
void Gvc7000::errorData(QAbstractSocket::SocketError err)
|
||||
{
|
||||
switch(err) {
|
||||
case QAbstractSocket::ConnectionRefusedError:
|
||||
rda->syslog(LOG_WARNING,
|
||||
"connection to Gvc7000 device at %s:%d refused, attempting reconnect",
|
||||
(const char *)gvc_ipaddress.toString().toUtf8(),gvc_ipport);
|
||||
gvc_reconnect_timer->start(GVC7000_RECONNECT_INTERVAL,true);
|
||||
break;
|
||||
|
||||
case QAbstractSocket::HostNotFoundError:
|
||||
rda->syslog(LOG_WARNING,
|
||||
"error on connection to Gvc7000 device at %s:%d: Host Not Found",
|
||||
(const char *)gvc_ipaddress.toString().toUtf8(),
|
||||
gvc_ipport);
|
||||
break;
|
||||
|
||||
case QAbstractSocket::RemoteHostClosedError:
|
||||
break;
|
||||
|
||||
default:
|
||||
rda->syslog(LOG_WARNING,
|
||||
"socket error %d on connection to Gvc7000 device at %s:%d: Socket Read Error",
|
||||
err,
|
||||
(const char *)gvc_ipaddress.toString().toUtf8(),gvc_ipport);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Gvc7000::SendCommand(const QString &str)
|
||||
{
|
||||
syslog(LOG_DEBUG,"gvc7000 sending \"%s\"",(const char *)str.toAscii());
|
||||
gvc_socket->write(str.toAscii());
|
||||
}
|
||||
|
||||
|
||||
QString Gvc7000::ToSeries7000Native(const QString &str) const
|
||||
{
|
||||
QString ret=str;
|
||||
|
||||
ret.replace(",","\t");
|
||||
if(ret.right(1)!="\t") {
|
||||
ret+="\t";
|
||||
}
|
||||
|
||||
QString msg=QString("N")+ // Protocol ID
|
||||
"0"+ // Sequence Flag
|
||||
ret; // Data
|
||||
|
||||
uint8_t sum=0;
|
||||
for(int i=0;i<msg.length();i++) {
|
||||
sum+=msg.at(i).toAscii();
|
||||
}
|
||||
sum=0x100-sum;
|
||||
|
||||
return QChar(1)+ // Header
|
||||
msg+ // Message
|
||||
QString().sprintf("%02X",sum)+ // Checksum
|
||||
QChar(4); // Footer
|
||||
}
|
||||
72
ripcd/gvc7000.h
Normal file
72
ripcd/gvc7000.h
Normal file
@@ -0,0 +1,72 @@
|
||||
// gvc7000.h
|
||||
//
|
||||
// A Rivendell switcher driver for Grass Valley Series 7000 Protocol
|
||||
//
|
||||
// (C) Copyright 2002-2019 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 GVC7000_H
|
||||
#define GVC7000_H
|
||||
|
||||
#include <qhostaddress.h>
|
||||
#include <qtcpsocket.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
#include <rd.h>
|
||||
#include <rdmatrix.h>
|
||||
#include <rdmacro.h>
|
||||
|
||||
#include <switcher.h>
|
||||
|
||||
#define GVC7000_RECONNECT_INTERVAL 10000
|
||||
#define GVC7000_KEEPALIVE_INTERVAL 5000
|
||||
|
||||
class Gvc7000 : public Switcher
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Gvc7000(RDMatrix *matrix,QObject *parent=0);
|
||||
RDMatrix::Type type();
|
||||
unsigned gpiQuantity();
|
||||
unsigned gpoQuantity();
|
||||
bool primaryTtyActive();
|
||||
bool secondaryTtyActive();
|
||||
void processCommand(RDMacro *cmd);
|
||||
|
||||
private slots:
|
||||
void ipConnect();
|
||||
void keepaliveData();
|
||||
void connectedData();
|
||||
void disconnectedData();
|
||||
void errorData(QAbstractSocket::SocketError err);
|
||||
|
||||
private:
|
||||
void SendCommand(const QString &str);
|
||||
QString ToSeries7000Native(const QString &str) const;
|
||||
QTcpSocket *gvc_socket;
|
||||
QHostAddress gvc_ipaddress;
|
||||
int gvc_matrix;
|
||||
int gvc_ipport;
|
||||
int gvc_inputs;
|
||||
int gvc_outputs;
|
||||
QTimer *gvc_keepalive_timer;
|
||||
QTimer *gvc_reconnect_timer;
|
||||
int gvc_input_line;
|
||||
int gvc_output_line;
|
||||
};
|
||||
|
||||
|
||||
#endif // GVC7000_H
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "btss44.h"
|
||||
#include "btss82.h"
|
||||
#include "btu41mlrweb.h"
|
||||
#include "gvc7000.h"
|
||||
#include "harlond.h"
|
||||
#include "kernelgpio.h"
|
||||
#include "livewire_lwrpaudio.h"
|
||||
@@ -153,6 +154,10 @@ bool MainObject::LoadSwitchDriver(int matrix_num)
|
||||
ripcd_switcher[matrix_num]=new BtU41MlrWeb(matrix,this);
|
||||
break;
|
||||
|
||||
case RDMatrix::Gvc7000:
|
||||
ripcd_switcher[matrix_num]=new Gvc7000(matrix,this);
|
||||
break;
|
||||
|
||||
case RDMatrix::Harlond:
|
||||
ripcd_switcher[matrix_num]=new Harlond(matrix,this);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user