2018-06-22 Fred Gleason <fredg@paravelsystems.com>

* Added GPIO support for HPI devices to the 'Local Audio Adapter'
	switcher/gpio driver.
This commit is contained in:
Fred Gleason 2018-08-23 01:23:59 +00:00
parent 8f2fbcab9f
commit 58fa103f6e
8 changed files with 813 additions and 53 deletions

View File

@ -16663,3 +16663,6 @@
of rd.conf(5).
2018-06-21 Fred Gleason <fredg@paravelsystems.com>
* Added support for the Broadcast Tools SS 2.1 switcher.
2018-06-22 Fred Gleason <fredg@paravelsystems.com>
* Added GPIO support for HPI devices to the 'Local Audio Adapter'
switcher/gpio driver.

View File

@ -1016,6 +1016,9 @@
<listitem>
<para>
<simplelist>
<member>GPI Enable ['<command>GE</command>']</member>
<member>GPI Set ['<command>GI</command>']</member>
<member>GPO Set ['<command>GO</command>']</member>
<member>Switch Add ['<command>SA</command>']</member>
<member>Switch Add With Gain ['<command>SX</command>']</member>
<member>Switch Remove ['<command>SR</command>']</member>

View File

@ -2,7 +2,7 @@
##
## Rivendell Interprocess Communication Daemon Makefile.am
##
## (C) Copyright 2002-2006 Fred Gleason <fredg@paravelsystems.com>
## (C) Copyright 2002-2018 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
@ -21,7 +21,7 @@
## Use automake to process this into a Makefile.in
AM_CPPFLAGS = -Wall -DPREFIX=\"$(prefix)\" -DQTDIR=\"@QT_DIR@\" @QT_CXXFLAGS@ -I$(top_srcdir)/lib
LIBS = @QT_LIBS@ -L$(top_srcdir)/lib
LIBS = @QT_LIBS@ -L$(top_srcdir)/lib -L$(top_srcdir)/rdhpi
MOC = @QT_MOC@
# The dependency for qt's Meta Object Compiler (moc)
@ -128,7 +128,7 @@ nodist_ripcd_SOURCES = moc_am16.cpp\
moc_wheatnet_lio.cpp\
moc_wheatnet_slio.cpp
ripcd_LDADD = @LIB_RDLIBS@ @LIBVORBIS@
ripcd_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @LIBHPI@
EXTRA_DIST = ripcd.pro

425
ripcd/hpigpio.cpp Normal file
View File

@ -0,0 +1,425 @@
// hpigpio.cpp
//
// A Rivendell switcher driver for AudioScience HPI GPIO devices
//
// (C) Copyright 2002-2018 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 <qtimer.h>
#include <stdlib.h>
#include "globals.h"
#include "hpigpio.h"
HpiGpio::HpiGpio(RDMatrix *matrix,QObject *parent)
: Switcher(matrix,parent)
{
/*
//
// Initialize Data Structures
//
hpi_istate=0;
for(int i=0;i<HPIGPIO_GPIO_PINS;i++) {
hpi_gpi_state[i]=false;
hpi_gpi_mask[i]=false;
}
*/
//
// Get Matrix Parameters
//
hpi_matrix=matrix->matrix();
hpi_card=matrix->card();
hpi_gpis=0;
hpi_gpos=0;
#ifdef HPI
struct hpi_control_t cntl;
hpi_handle_t block;
size_t value_size=0;
size_t value_items=0;
uint8_t *value;
//
// Open Mixer
//
if(LogHpi(HPI_MixerOpen(NULL,hpi_card,&hpi_mixer),__LINE__)!=0) {
UpdateDb(matrix);
return;
}
memset(&cntl,0,sizeof(cntl));
cntl.wSrcNodeType=HPI_SOURCENODE_ADAPTER;
if(LogHpi(HPI_Object_BlockHandle(hpi_mixer,HPI_SOURCENODE_ADAPTER,0,0,0,
"GPIO",&block),__LINE__)!=0) {
UpdateDb(matrix);
return;
}
//
// GPIs Handle
//
if(LogHpi(HPI_Object_ParameterHandle(hpi_mixer,block,"Inputs",&hpi_gpis_param),__LINE__)!=0) {
UpdateDb(matrix);
return;
}
if(LogHpi(HPI_Object_GetInfo(hpi_gpis_param,entity_type_boolean,
entity_role_value,NULL,&value_size,&value_items),
__LINE__)!=0) {
UpdateDb(matrix);
return;
}
hpi_gpis=value_items;
//
// GPOs Handle
//
if(LogHpi(HPI_Object_ParameterHandle(hpi_mixer,block,"Outputs",&hpi_gpos_param),__LINE__)!=0) {
return;
}
if(LogHpi(HPI_Object_GetInfo(hpi_gpos_param,entity_type_boolean,
entity_role_value,NULL,&value_size,&value_items),
__LINE__)!=0) {
hpi_gpis=0;
UpdateDb(matrix);
return;
}
hpi_gpos=value_items;
UpdateDb(matrix);
/*
//
// Interval OneShots
//
hpi_gpi_oneshot=new RDOneShot(this);
connect(hpi_gpi_oneshot,SIGNAL(timeout(int)),this,SLOT(gpiOneshotData(int)));
hpi_gpo_oneshot=new RDOneShot(this);
connect(hpi_gpo_oneshot,SIGNAL(timeout(int)),this,SLOT(gpoOneshotData(int)));
//
// The Poll Timer
//
QTimer *timer=new QTimer(this,"poll_timer");
connect(timer,SIGNAL(timeout()),this,SLOT(processStatus()));
timer->start(HPIGPIO_POLL_INTERVAL);
*/
#endif // HPI
}
HpiGpio::~HpiGpio()
{
#ifdef HPI
/*
delete hpi_device;
delete hpi_gpi_oneshot;
delete hpi_gpo_oneshot;
*/
#endif // HPI
}
RDMatrix::Type HpiGpio::type()
{
return RDMatrix::HpiGpio;
}
unsigned HpiGpio::gpiQuantity()
{
return hpi_gpis;
}
unsigned HpiGpio::gpoQuantity()
{
return hpi_gpos;
}
bool HpiGpio::primaryTtyActive()
{
return false;
}
bool HpiGpio::secondaryTtyActive()
{
return false;
}
void HpiGpio::processCommand(RDMacro *cmd)
{
#ifdef HPI
/*
char str[20];
switch(cmd->command()) {
case RDMacro::GO:
if((cmd->argQuantity()!=5)||
((cmd->arg(1).toString().lower()!="i")&&
(cmd->arg(1).toString().lower()!="o"))||
(cmd->arg(2).toInt()<1)||(cmd->arg(3).toInt()>hpi_gpos)||
(cmd->arg(2).toInt()>hpi_gpos)||
((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
(cmd->arg(1).toString().lower()!="i"))||
((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
(cmd->arg(3).toInt()!=-1)&&(cmd->arg(1).toString().lower()=="i"))||
(cmd->arg(4).toInt()<0)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(3).toInt()==0) { // Turn OFF
if(cmd->arg(4).toInt()==0) {
if(cmd->arg(1).toString().lower()=="i") {
if(hpi_gpi_state[cmd->arg(2).toInt()-1]) {
emit gpiChanged(hpi_matrix,cmd->arg(2).toInt()-1,false);
hpi_gpi_state[cmd->arg(2).toInt()-1]=false;
}
hpi_gpi_mask[cmd->arg(2).toInt()-1]=true;
}
if(cmd->arg(1).toString().lower()=="o") {
sprintf(str,"*%dOR%02dF\r\n",HPIGPIO_UNIT_ID,cmd->arg(2).toInt());
hpi_device->writeBlock(str,9);
emit gpoChanged(hpi_matrix,cmd->arg(2).toInt()-1,false);
}
}
else {
if(cmd->echoRequested()) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
}
return;
}
}
else {
if(cmd->arg(3).toInt()==-1) { // Clear input
hpi_gpi_mask[cmd->arg(2).toInt()-1]=false;
hpi_device->writeBlock("*0SPA\r\n",7);
}
else {
if(cmd->arg(4).toInt()==0) { // Turn ON
if(cmd->arg(1).toString().lower()=="i") {
if(!hpi_gpi_state[cmd->arg(2).toInt()-1]) {
emit gpiChanged(hpi_matrix,cmd->arg(2).toInt()-1,true);
hpi_gpi_state[cmd->arg(2).toInt()-1]=true;
}
hpi_gpi_mask[cmd->arg(2).toInt()-1]=true;
}
if(cmd->arg(1).toString().lower()=="o") {
sprintf(str,"*%dOR%02dL\r\n",
HPIGPIO_UNIT_ID,cmd->arg(2).toInt());
hpi_device->writeBlock(str,9);
emit gpoChanged(hpi_matrix,cmd->arg(2).toInt()-1,true);
}
}
else { // Pulse
if(cmd->arg(1).toString().lower()=="i") {
if(!hpi_gpi_state[cmd->arg(2).toInt()-1]) {
emit gpiChanged(hpi_matrix,cmd->arg(2).toInt()-1,true);
hpi_gpi_state[cmd->arg(2).toInt()-1]=true;
}
hpi_gpi_mask[cmd->arg(2).toInt()-1]=true;
hpi_gpi_oneshot->start(cmd->arg(2).toInt()-1,500);
}
if(cmd->arg(1).toString().lower()=="o") {
sprintf(str,"*%dOR%02dP%02d\r\n",
HPIGPIO_UNIT_ID,cmd->arg(2).toInt(),
cmd->arg(4).toInt()/100+1);
hpi_device->writeBlock(str,11);
emit gpoChanged(hpi_matrix,cmd->arg(2).toInt()-1,true);
hpi_gpo_oneshot->start(cmd->arg(2).toInt()-1,500);
}
}
}
}
if(cmd->echoRequested()) {
cmd->acknowledge(true);
emit rmlEcho(cmd);
}
break;
default:
cmd->acknowledge(false);
emit rmlEcho(cmd);
break;
}
*/
#endif // HPI
}
void HpiGpio::processStatus()
{
#ifdef HPI
/*
char buffer[256];
int n;
int gpi;
while((n=hpi_device->readBlock(buffer,255))>0) {
for(int i=0;i<n;i++) {
switch(hpi_istate) {
case 0:
if(buffer[i]=='S') {
hpi_istate=1;
}
break;
case 1:
if(buffer[i]==(HPIGPIO_UNIT_ID+'0')) {
hpi_istate=2;
}
else {
hpi_istate=0;
}
break;
case 2:
if(buffer[i]=='P') {
hpi_istate=3;
}
else {
hpi_istate=0;
}
break;
case 3:
if(buffer[i]==',') {
hpi_istate=4;
}
else {
hpi_istate=0;
}
break;
case 4:
if(buffer[i]=='A') {
hpi_istate=5;
}
else {
hpi_istate=0;
}
break;
case 5:
case 7:
case 9:
case 11:
case 13:
case 15:
case 17:
case 19:
case 21:
case 23:
case 25:
case 27:
case 29:
case 31:
case 33:
case 35:
if(buffer[i]==',') {
hpi_istate++;
}
else {
hpi_istate=0;
}
break;
case 6:
case 8:
case 10:
case 12:
case 14:
case 16:
case 18:
case 20:
case 22:
case 24:
case 26:
case 28:
case 30:
case 32:
case 34:
case 36:
if(buffer[i]=='1') {
gpi=(hpi_istate-6)/2;
if(hpi_gpi_state[gpi]&&(!hpi_gpi_mask[gpi])) {
emit gpiChanged(hpi_matrix,gpi,false);
hpi_gpi_state[gpi]=false;
}
hpi_istate++;
}
if(buffer[i]=='0') {
gpi=(hpi_istate-6)/2;
if((!hpi_gpi_state[gpi])&&(!hpi_gpi_mask[gpi])) {
emit gpiChanged(hpi_matrix,gpi,true);
hpi_gpi_state[gpi]=true;
}
hpi_istate++;
}
break;
default:
hpi_istate=0;
}
}
}
*/
#endif // HPI
}
void HpiGpio::gpiOneshotData(int value)
{
#ifdef HPI
/*
hpi_gpi_mask[value]=false;
hpi_device->writeBlock("*0SPA",5);
*/
#endif // HPI
}
void HpiGpio::gpoOneshotData(int value)
{
#ifdef HPI
// emit gpoChanged(hpi_matrix,value,false);
#endif // HPI
}
void HpiGpio::UpdateDb(RDMatrix *matrix) const
{
matrix->setGpis(hpi_gpis);
matrix->setGpos(hpi_gpos);
}
#ifdef HPI
hpi_err_t HpiGpio::LogHpi(hpi_err_t err,int lineno)
{
char err_txt[200];
if(err!=0) {
HPI_GetErrorText(err,err_txt);
syslog(LOG_NOTICE,"HPI Error: %s, %s line %d",err_txt,__FILE__,lineno);
}
return err;
}
#endif // HPI

77
ripcd/hpigpio.h Normal file
View File

@ -0,0 +1,77 @@
// hpigpio.h
//
// A Rivendell switcher driver for AudioScience HPI GPIO devices
//
// (C) Copyright 2002-2018 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 HPIGPIO_H
#define HPIGPIO_H
#include <rd.h>
#include <rdmatrix.h>
#include <rdmacro.h>
#include <rdtty.h>
#include <rdoneshot.h>
#ifdef HPI
#include <asihpi/hpi.h>
#endif // HPI
#include "switcher.h"
#define HPIGPIO_POLL_INTERVAL 100
#define HPIGPIO_GPIO_PINS 16
class HpiGpio : public Switcher
{
Q_OBJECT
public:
HpiGpio(RDMatrix *matrix,QObject *parent=0);
~HpiGpio();
RDMatrix::Type type();
unsigned gpiQuantity();
unsigned gpoQuantity();
bool primaryTtyActive();
bool secondaryTtyActive();
void processCommand(RDMacro *cmd);
private slots:
void processStatus();
void gpiOneshotData(int value);
void gpoOneshotData(int value);
private:
#ifdef HPI
void UpdateDb(RDMatrix *matrix) const;
hpi_err_t LogHpi(hpi_err_t err,int lineno);
hpi_handle_t hpi_mixer;
hpi_handle_t hpi_gpis_param;
hpi_handle_t hpi_gpos_param;
#endif // HPI
RDOneShot *hpi_gpi_oneshot;
RDOneShot *hpi_gpo_oneshot;
int hpi_matrix;
int hpi_card;
int hpi_gpis;
int hpi_gpos;
int hpi_istate;
bool hpi_gpi_state[HPIGPIO_GPIO_PINS];
bool hpi_gpi_mask[HPIGPIO_GPIO_PINS];
};
#endif // HPIGPIO_H

View File

@ -20,51 +20,51 @@
#include <stdlib.h>
#include <ripcd.h>
#include <switcher.h>
#include <globals.h>
#include <acu1p.h>
#include <am16.h>
#include <bt10x1.h>
#include <bt16x1.h>
#include <bt16x2.h>
#include <bt8x2.h>
#include <btacs82.h>
#include <btadms4422.h>
#include <btgpi16.h>
#include <btsentinel4web.h>
#include <btsrc16.h>
#include <btsrc8iii.h>
#include <btss124.h>
#include <btss164.h>
#include <btss21.h>
#include <btss41mlr.h>
#include <btss42.h>
#include <btss44.h>
#include <btss82.h>
#include <btu41mlrweb.h>
#include <harlond.h>
#include <kernelgpio.h>
#include <livewire_lwrpaudio.h>
#include <livewire_lwrpgpio.h>
#include <livewire_mcastgpio.h>
#include <local_audio.h>
#include <local_gpio.h>
#include <modbus.h>
#include <modemlines.h>
#include <quartz1.h>
#include <rossnkscp.h>
#include <sas16000.h>
#include <sas32000.h>
#include <sas64000.h>
#include <sas64000gpi.h>
#include <sasusi.h>
#include <starguide3.h>
#include <swauthority.h>
#include <unity4000.h>
#include <vguest.h>
#include <wheatnet_lio.h>
#include <wheatnet_slio.h>
#include "ripcd.h"
#include "switcher.h"
#include "globals.h"
#include "acu1p.h"
#include "am16.h"
#include "bt10x1.h"
#include "bt16x1.h"
#include "bt16x2.h"
#include "bt8x2.h"
#include "btacs82.h"
#include "btadms4422.h"
#include "btgpi16.h"
#include "btsentinel4web.h"
#include "btsrc16.h"
#include "btsrc8iii.h"
#include "btss124.h"
#include "btss164.h"
#include "btss21.h"
#include "btss41mlr.h"
#include "btss42.h"
#include "btss44.h"
#include "btss82.h"
#include "btu41mlrweb.h"
#include "harlond.h"
#include "kernelgpio.h"
#include "livewire_lwrpaudio.h"
#include "livewire_lwrpgpio.h"
#include "livewire_mcastgpio.h"
#include "local_audio.h"
#include "local_gpio.h"
#include "modbus.h"
#include "modemlines.h"
#include "quartz1.h"
#include "rossnkscp.h"
#include "sas16000.h"
#include "sas32000.h"
#include "sas64000.h"
#include "sas64000gpi.h"
#include "sasusi.h"
#include "starguide3.h"
#include "swauthority.h"
#include "unity4000.h"
#include "vguest.h"
#include "wheatnet_lio.h"
#include "wheatnet_slio.h"
bool MainObject::LoadSwitchDriver(int matrix_num)
{

View File

@ -1,8 +1,8 @@
// local_audio.cpp
//
// A Rivendell switcher driver for the BroadcastTools 10x1
// A Rivendell switcher driver for local audio cards.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 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
@ -28,17 +28,40 @@
LocalAudio::LocalAudio(RDMatrix *matrix,QObject *parent)
: Switcher(matrix,parent)
{
bt_poll_timer=NULL;
bt_gpi_values=NULL;
bt_gpo_values=NULL;
//
// Get Matrix Parameters
//
bt_inputs=matrix->inputs();
bt_outputs=matrix->outputs();
bt_card=matrix->card();
bt_gpis=0;
bt_gpos=0;
//
// Interval OneShot
//
bt_gpo_oneshot=new RDOneShot(this);
connect(bt_gpo_oneshot,SIGNAL(timeout(int)),this,SLOT(gpoOneshotData(int)));
InitializeHpi(matrix);
}
LocalAudio::~LocalAudio()
{
if(bt_poll_timer!=NULL) {
delete bt_poll_timer;
}
if(bt_gpi_values!=NULL) {
delete bt_gpi_values;
}
if(bt_gpo_values!=NULL) {
delete bt_gpo_values;
}
}
@ -75,6 +98,60 @@ bool LocalAudio::secondaryTtyActive()
void LocalAudio::processCommand(RDMacro *cmd)
{
switch(cmd->command()) {
case RDMacro::GO:
if((cmd->argQuantity()!=5)||
((cmd->arg(1).toString().lower()!="i")&&
(cmd->arg(1).toString().lower()!="o"))||
(cmd->arg(2).toInt()<1)||(cmd->arg(3).toInt()>bt_gpos)||
(cmd->arg(2).toInt()>bt_gpos)||
((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
(cmd->arg(1).toString().lower()!="i"))||
((cmd->arg(3).toInt()!=1)&&(cmd->arg(3).toInt()!=0)&&
(cmd->arg(3).toInt()!=-1)&&(cmd->arg(1).toString().lower()=="i"))||
(cmd->arg(4).toInt()<0)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
return;
}
if(cmd->arg(3).toInt()==0) { // Turn OFF
if(cmd->arg(4).toInt()==0) {
if(cmd->arg(1).toString().lower()=="o") {
SetGpo(cmd->arg(2).toInt()-1,false);
emit gpoChanged(matrixNumber(),cmd->arg(2).toInt()-1,false);
}
}
else {
if(cmd->echoRequested()) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
}
return;
}
}
else {
if(cmd->arg(3).toInt()!=-1) {
if(cmd->arg(4).toInt()==0) { // Turn ON
if(cmd->arg(1).toString().lower()=="o") {
SetGpo(cmd->arg(2).toInt()-1,true);
emit gpoChanged(matrixNumber(),cmd->arg(2).toInt()-1,true);
}
}
else { // Pulse
if(cmd->arg(1).toString().lower()=="o") {
SetGpo(cmd->arg(2).toInt()-1,true);
emit gpoChanged(matrixNumber(),cmd->arg(2).toInt()-1,true);
bt_gpo_oneshot->
start(cmd->arg(2).toInt()-1,cmd->arg(4).toInt());
}
}
}
}
if(cmd->echoRequested()) {
cmd->acknowledge(true);
emit rmlEcho(cmd);
}
break;
case RDMacro::ST:
if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>bt_inputs)||
(cmd->arg(2).toInt()<=0)||(cmd->arg(2).toInt()>bt_outputs)) {
@ -150,3 +227,147 @@ void LocalAudio::processCommand(RDMacro *cmd)
break;
}
}
void LocalAudio::pollData()
{
#ifdef HPI
if(LogHpi(HPI_Object_GetValue(bt_gpis_param,entity_type_boolean,
bt_gpis,bt_gpi_values,
bt_gpis),__LINE__)==0) {
for(int i=0;i<bt_gpis;i++) {
if((bt_gpi_values[i]=='T')!=bt_gpi_states[i]) {
bt_gpi_states[i]=(bt_gpi_values[i]=='T');
emit gpiChanged(matrixNumber(),i,bt_gpi_states[i]);
}
}
}
#endif // HPI
}
void LocalAudio::gpoOneshotData(int value)
{
SetGpo(value,false);
emit gpoChanged(matrixNumber(),value,false);
}
void LocalAudio::InitializeHpi(RDMatrix *matrix)
{
#ifdef HPI
struct hpi_control_t cntl;
hpi_handle_t block;
size_t value_size=0;
size_t value_items=0;
bt_gpis=0;
bt_gpos=0;
//
// Open Mixer
//
if(HPI_MixerOpen(NULL,bt_card,&bt_mixer)!=0) {
UpdateDb(matrix);
return;
}
memset(&cntl,0,sizeof(cntl));
cntl.wSrcNodeType=HPI_SOURCENODE_ADAPTER;
if(HPI_Object_BlockHandle(bt_mixer,HPI_SOURCENODE_ADAPTER,0,0,0,
"GPIO",&block)!=0) {
UpdateDb(matrix);
return;
}
//
// GPIs Handle
//
if(LogHpi(HPI_Object_ParameterHandle(bt_mixer,block,"Inputs",&bt_gpis_param),__LINE__)!=0) {
UpdateDb(matrix);
return;
}
if(LogHpi(HPI_Object_GetInfo(bt_gpis_param,entity_type_boolean,
entity_role_value,NULL,&value_size,&value_items),
__LINE__)!=0) {
UpdateDb(matrix);
return;
}
bt_gpis=value_items;
bt_gpi_values=new uint8_t[bt_gpis];
if(LogHpi(HPI_Object_GetValue(bt_gpis_param,entity_type_boolean,value_items,bt_gpi_values,value_size),__LINE__)!=0) {
bt_gpis=0;
UpdateDb(matrix);
return;
}
for(int i=0;i<bt_gpis;i++) {
bt_gpi_states.push_back(bt_gpi_values[i]=='T');
}
bt_poll_timer=new QTimer(this);
connect(bt_poll_timer,SIGNAL(timeout()),this,SLOT(pollData()));
bt_poll_timer->start(LOCALAUDIO_POLL_INTERVAL);
//
// GPOs Handle
//
if(LogHpi(HPI_Object_ParameterHandle(bt_mixer,block,"Outputs",&bt_gpos_param),__LINE__)!=0) {
return;
}
if(LogHpi(HPI_Object_GetInfo(bt_gpos_param,entity_type_boolean,
entity_role_value,NULL,&value_size,&value_items),
__LINE__)!=0) {
bt_gpis=0;
UpdateDb(matrix);
return;
}
bt_gpos=value_items;
bt_gpo_values=new uint8_t[bt_gpos];
if(LogHpi(HPI_Object_GetValue(bt_gpos_param,entity_type_boolean,value_items,bt_gpo_values,value_size),__LINE__)!=0) {
bt_gpis=0;
bt_gpos=0;
UpdateDb(matrix);
return;
}
UpdateDb(matrix);
#endif // HPI
}
void LocalAudio::SetGpo(int line,bool state)
{
#ifdef HPI
if(LogHpi(HPI_Object_GetValue(bt_gpos_param,entity_type_boolean,
bt_gpos,bt_gpo_values,
bt_gpos),__LINE__)==0) {
if(state) {
bt_gpo_values[line]='T';
}
else {
bt_gpo_values[line]='F';
}
LogHpi(HPI_Object_SetValue(bt_gpos_param,entity_type_boolean,bt_gpos,
bt_gpo_values,bt_gpos),__LINE__);
}
#endif // HPI
}
void LocalAudio::UpdateDb(RDMatrix *matrix) const
{
matrix->setGpis(bt_gpis);
matrix->setGpos(bt_gpos);
}
#ifdef HPI
hpi_err_t LocalAudio::LogHpi(hpi_err_t err,int lineno)
{
char err_txt[200];
if(err!=0) {
HPI_GetErrorText(err,err_txt);
syslog(LOG_NOTICE,"HPI Error: %s, %s line %d",err_txt,__FILE__,lineno);
}
return err;
}
#endif // HPI

View File

@ -1,8 +1,8 @@
// local_audio.h
//
// A Rivendell switcher driver for the BroadcastTools 10x1
// A Rivendell switcher driver for local audio cards.
//
// (C) Copyright 2002-2003,2016 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2002-2018 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
@ -21,12 +21,23 @@
#ifndef LOCAL_AUDIO_H
#define LOCAL_AUDIO_H
#include <vector>
#include <qtimer.h>
#include <rd.h>
#include <rdmatrix.h>
#include <rdmacro.h>
#include <rdoneshot.h>
#include <rdtty.h>
#include <switcher.h>
#ifdef HPI
#include <asihpi/hpi.h>
#endif // HPI
#include "switcher.h"
#define LOCALAUDIO_POLL_INTERVAL 100
class LocalAudio : public Switcher
{
@ -41,9 +52,29 @@ class LocalAudio : public Switcher
bool secondaryTtyActive();
void processCommand(RDMacro *cmd);
private slots:
void pollData();
void gpoOneshotData(int value);
private:
void InitializeHpi(RDMatrix *matrix);
void SetGpo(int line,bool state);
void UpdateDb(RDMatrix *matrix) const;
#ifdef HPI
hpi_err_t LogHpi(hpi_err_t err,int lineno);
hpi_handle_t bt_mixer;
hpi_handle_t bt_gpis_param;
hpi_handle_t bt_gpos_param;
std::vector<uint8_t> bt_gpi_states;
#endif // HPI
RDOneShot *bt_gpo_oneshot;
uint8_t *bt_gpi_values;
uint8_t *bt_gpo_values;
QTimer *bt_poll_timer;
int bt_inputs;
int bt_outputs;
int bt_gpis;
int bt_gpos;
int bt_card;
};