diff --git a/ripcd/hpigpio.cpp b/ripcd/hpigpio.cpp deleted file mode 100644 index 268d80f5..00000000 --- a/ripcd/hpigpio.cpp +++ /dev/null @@ -1,425 +0,0 @@ -// hpigpio.cpp -// -// A Rivendell switcher driver for AudioScience HPI GPIO devices -// -// (C) Copyright 2002-2018 Fred Gleason -// -// 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 - -#include - -#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;imatrix(); - 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;iwriteBlock("*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 diff --git a/ripcd/hpigpio.h b/ripcd/hpigpio.h deleted file mode 100644 index cdd24244..00000000 --- a/ripcd/hpigpio.h +++ /dev/null @@ -1,77 +0,0 @@ -// hpigpio.h -// -// A Rivendell switcher driver for AudioScience HPI GPIO devices -// -// (C) Copyright 2002-2018 Fred Gleason -// -// 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 -#include -#include -#include -#include - -#ifdef HPI -#include -#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