mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-07-27 06:08:01 +02:00
2015-02-21 Fred Gleason <fredg@paravelsystems.com>
* Added support for GPIO to the Software Authority Protocol driver in 'ripcd/swauthority.cpp' and 'ripcd/swauthority.h'.
This commit is contained in:
parent
8f91f7cf07
commit
61baaf2197
@ -14773,3 +14773,6 @@
|
|||||||
* Added support for selecting router number when using Software
|
* Added support for selecting router number when using Software
|
||||||
Authority Protocol in 'ripcd/swauthority.cpp' and
|
Authority Protocol in 'ripcd/swauthority.cpp' and
|
||||||
'ripcd/swauthority.h'.
|
'ripcd/swauthority.h'.
|
||||||
|
2015-02-21 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Added support for GPIO to the Software Authority Protocol driver
|
||||||
|
in 'ripcd/swauthority.cpp' and 'ripcd/swauthority.h'.
|
||||||
|
@ -640,12 +640,15 @@ Driver Name: Software Authority Protocol
|
|||||||
|
|
||||||
Supported RML Commands:
|
Supported RML Commands:
|
||||||
Switch Take ('ST')
|
Switch Take ('ST')
|
||||||
|
GPO Set ('GO')
|
||||||
|
|
||||||
GENERAL NOTES:
|
GENERAL NOTES:
|
||||||
Used to control devices (such as the Axia 'PathFinder' system) by means of
|
Used to control devices (such as the Axia 'PathFinder' system) by means of
|
||||||
the 'Software Authority' protocol. Control is by means of a
|
the 'Software Authority' protocol. Control is by means of a
|
||||||
TCP/IP connection (typically to port 9500) on the controled system. Most
|
TCP/IP connection (typically to port 9500) on the controled system. The 'Card'
|
||||||
parameters, including the number of inputs and outputs as well as the
|
parameter should be set to the 'Router Number' of the router to be controlled.
|
||||||
|
|
||||||
|
Most parameters, including the number of inputs and outputs as well as the
|
||||||
endpoint names, are autodetected by the driver.
|
endpoint names, are autodetected by the driver.
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ SoftwareAuthority::SoftwareAuthority(RDMatrix *matrix,QObject *parent,const char
|
|||||||
swa_card=matrix->card();
|
swa_card=matrix->card();
|
||||||
swa_inputs=0;
|
swa_inputs=0;
|
||||||
swa_outputs=0;
|
swa_outputs=0;
|
||||||
swa_gpis=matrix->gpis();
|
swa_gpis=0;
|
||||||
swa_gpos=matrix->gpos();
|
swa_gpos=0;
|
||||||
swa_start_cart=matrix->startCart(RDMatrix::Primary);
|
swa_start_cart=matrix->startCart(RDMatrix::Primary);
|
||||||
swa_stop_cart=matrix->stopCart(RDMatrix::Primary);
|
swa_stop_cart=matrix->stopCart(RDMatrix::Primary);
|
||||||
|
|
||||||
@ -102,22 +102,9 @@ bool SoftwareAuthority::secondaryTtyActive()
|
|||||||
|
|
||||||
void SoftwareAuthority::processCommand(RDMacro *cmd)
|
void SoftwareAuthority::processCommand(RDMacro *cmd)
|
||||||
{
|
{
|
||||||
switch(cmd->command()) {
|
QString str;
|
||||||
/*
|
|
||||||
case RDMacro::FS:
|
|
||||||
if((cmd->arg(1).toInt()<1)||(cmd->arg(1).toInt()>256)||
|
|
||||||
(swa_porttype!=RDMatrix::TcpPort)) {
|
|
||||||
cmd->acknowledge(false);
|
|
||||||
emit rmlEcho(cmd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
snprintf(str,256,"%c1%03d\x0D\x0A",0x13,cmd->arg(1).toInt());
|
|
||||||
SendCommand(str);
|
|
||||||
cmd->acknowledge(true);
|
|
||||||
emit rmlEcho(cmd);
|
|
||||||
break;
|
|
||||||
|
|
||||||
*/
|
switch(cmd->command()) {
|
||||||
case RDMacro::ST:
|
case RDMacro::ST:
|
||||||
if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>swa_inputs)||
|
if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>swa_inputs)||
|
||||||
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>swa_outputs)) {
|
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>swa_outputs)) {
|
||||||
@ -130,58 +117,32 @@ void SoftwareAuthority::processCommand(RDMacro *cmd)
|
|||||||
cmd->acknowledge(true);
|
cmd->acknowledge(true);
|
||||||
emit rmlEcho(cmd);
|
emit rmlEcho(cmd);
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
case RDMacro::GO:
|
case RDMacro::GO:
|
||||||
if((cmd->arg(1).toString().lower()!="o")||
|
if(((cmd->arg(1).toString().lower()!="i")&&
|
||||||
|
(cmd->arg(1).toString().lower()!="o"))||
|
||||||
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>swa_gpos)) {
|
(cmd->arg(2).toInt()<1)||(cmd->arg(2).toInt()>swa_gpos)) {
|
||||||
cmd->acknowledge(false);
|
cmd->acknowledge(false);
|
||||||
emit rmlEcho(cmd);
|
emit rmlEcho(cmd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(cmd->arg(4).toInt()==0) { // Latch
|
if(cmd->arg(1).toString().lower()=="i") {
|
||||||
if(cmd->arg(3).toInt()==0) { // Off
|
str="triggergpi";
|
||||||
cmd_byte=0x03;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cmd_byte=0x02;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(cmd->arg(3).toInt()==0) {
|
str="triggergpo";
|
||||||
cmd->acknowledge(false);
|
|
||||||
emit rmlEcho(cmd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cmd_byte=0x01;
|
|
||||||
}
|
}
|
||||||
if(cmd->arg(2).toUInt()<swa_relay_numbers.size()) {
|
str+=QString().sprintf(" %d",swa_card);
|
||||||
if(swa_relay_numbers[cmd->arg(2).toUInt()-1]>=0) {
|
str+=QString().sprintf(" %d ",
|
||||||
snprintf(str,256,"\x05R%d%04d\x0D\x0A",cmd_byte,
|
1+(cmd->arg(2).toInt()-1)/RD_LIVEWIRE_GPIO_BUNDLE_SIZE);
|
||||||
swa_relay_numbers[cmd->arg(2).toUInt()-1]);
|
str+=BundleString((cmd->arg(2).toInt()-1)%RD_LIVEWIRE_GPIO_BUNDLE_SIZE,
|
||||||
SendCommand(str);
|
cmd->arg(3).toInt()!=0);
|
||||||
cmd->acknowledge(true);
|
if(cmd->arg(4).toInt()>0) { // Momentary
|
||||||
emit rmlEcho(cmd);
|
str+=QString().sprintf(" %d",cmd->arg(4).toInt());
|
||||||
}
|
|
||||||
else {
|
|
||||||
if((swa_console_numbers[cmd->arg(2).toUInt()-1]>=0)&&
|
|
||||||
(swa_source_numbers[cmd->arg(2).toUInt()-1]>=0)) {
|
|
||||||
if(cmd->arg(3).toInt()==0) { // Off
|
|
||||||
cmd_byte=0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cmd_byte=1;
|
|
||||||
}
|
|
||||||
snprintf(str,256,"\x1A%s%d%03d%04d\x0D\x0A","20",cmd_byte,
|
|
||||||
swa_console_numbers[cmd->arg(2).toUInt()-1],
|
|
||||||
swa_source_numbers[cmd->arg(2).toUInt()-1]);
|
|
||||||
SendCommand(str);
|
|
||||||
cmd->acknowledge(true);
|
|
||||||
emit rmlEcho(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
SendCommand(str);
|
||||||
break;
|
break;
|
||||||
*/
|
|
||||||
default:
|
default:
|
||||||
cmd->acknowledge(false);
|
cmd->acknowledge(false);
|
||||||
emit rmlEcho(cmd);
|
emit rmlEcho(cmd);
|
||||||
@ -295,6 +256,10 @@ void SoftwareAuthority::DispatchCommand()
|
|||||||
// Startup Sequence. Get the input and output lists.
|
// Startup Sequence. Get the input and output lists.
|
||||||
//
|
//
|
||||||
if(section=="login successful") {
|
if(section=="login successful") {
|
||||||
|
sprintf(buffer,"gpistat %d\x0D\x0A",swa_card); // Request GPI States
|
||||||
|
SendCommand(buffer);
|
||||||
|
sprintf(buffer,"gpostat %d\x0D\x0A",swa_card); // Request GPO States
|
||||||
|
SendCommand(buffer);
|
||||||
sprintf(buffer,"sourcenames %d\x0D\x0A",swa_card); // Request Input List
|
sprintf(buffer,"sourcenames %d\x0D\x0A",swa_card); // Request Input List
|
||||||
SendCommand(buffer);
|
SendCommand(buffer);
|
||||||
sprintf(buffer,"destnames %d\x0D\x0A",swa_card); // Request Output List
|
sprintf(buffer,"destnames %d\x0D\x0A",swa_card); // Request Output List
|
||||||
@ -326,6 +291,9 @@ void SoftwareAuthority::DispatchCommand()
|
|||||||
|
|
||||||
case 1: // Source List
|
case 1: // Source List
|
||||||
if(section==QString().sprintf("end sourcenames - %d",swa_card)) {
|
if(section==QString().sprintf("end sourcenames - %d",swa_card)) {
|
||||||
|
//
|
||||||
|
// Write Sources Data
|
||||||
|
//
|
||||||
swa_istate=0;
|
swa_istate=0;
|
||||||
sql=QString("update MATRICES set ")+
|
sql=QString("update MATRICES set ")+
|
||||||
QString().sprintf("INPUTS=%d ",swa_inputs)+
|
QString().sprintf("INPUTS=%d ",swa_inputs)+
|
||||||
@ -369,6 +337,9 @@ void SoftwareAuthority::DispatchCommand()
|
|||||||
|
|
||||||
case 2: // Destinations List
|
case 2: // Destinations List
|
||||||
if(section==QString().sprintf("end destnames - %d",swa_card)) {
|
if(section==QString().sprintf("end destnames - %d",swa_card)) {
|
||||||
|
//
|
||||||
|
// Write Destinations Data
|
||||||
|
//
|
||||||
swa_istate=0;
|
swa_istate=0;
|
||||||
sql=QString("update MATRICES set ")+
|
sql=QString("update MATRICES set ")+
|
||||||
QString().sprintf("OUTPUTS=%d ",swa_outputs)+
|
QString().sprintf("OUTPUTS=%d ",swa_outputs)+
|
||||||
@ -416,8 +387,57 @@ void SoftwareAuthority::DispatchCommand()
|
|||||||
delete q;
|
delete q;
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
delete q;
|
delete q;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Write GPIO Data
|
||||||
|
//
|
||||||
|
sql=QString("update MATRICES set ")+
|
||||||
|
QString().sprintf("GPIS=%d,GPOS=%d where ",swa_gpis,swa_gpos)+
|
||||||
|
"(STATION_NAME=\""+RDEscapeString(rdstation->name())+"\")&&"+
|
||||||
|
QString().sprintf("(MATRIX=%d)",swa_matrix);
|
||||||
|
q=new RDSqlQuery(sql);
|
||||||
|
delete q;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// GPIO State Parser
|
||||||
|
//
|
||||||
|
f0=f0.split(" ",section);
|
||||||
|
if((f0.size()==4)&&(f0[0].lower()=="gpistat")&&(f0[1].toInt()==swa_card)) {
|
||||||
|
if(swa_gpi_states[f0[2].toInt()].isEmpty()) {
|
||||||
|
swa_gpi_states[f0[2].toInt()]=f0[3];
|
||||||
|
if((RD_LIVEWIRE_GPIO_BUNDLE_SIZE*f0[2].toInt())>swa_gpis) {
|
||||||
|
swa_gpis=RD_LIVEWIRE_GPIO_BUNDLE_SIZE*f0[2].toInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(unsigned i=0;i<RD_LIVEWIRE_GPIO_BUNDLE_SIZE;i++) {
|
||||||
|
int gpi=(f0[2].toInt()-1)*RD_LIVEWIRE_GPIO_BUNDLE_SIZE+i;
|
||||||
|
if(f0[3].at(i)!=swa_gpi_states[f0[2].toInt()].at(i)) {
|
||||||
|
emit gpiChanged(swa_matrix,gpi,f0[3].at(i)=='l');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swa_gpi_states[f0[2].toInt()]=f0[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if((f0.size()==4)&&(f0[0].lower()=="gpostat")&&(f0[1].toInt()==swa_card)) {
|
||||||
|
if(swa_gpo_states[f0[2].toInt()].isEmpty()) {
|
||||||
|
swa_gpo_states[f0[2].toInt()]=f0[3];
|
||||||
|
if((RD_LIVEWIRE_GPIO_BUNDLE_SIZE*f0[2].toInt())>swa_gpos) {
|
||||||
|
swa_gpos=RD_LIVEWIRE_GPIO_BUNDLE_SIZE*f0[2].toInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(unsigned i=0;i<RD_LIVEWIRE_GPIO_BUNDLE_SIZE;i++) {
|
||||||
|
int gpo=(f0[2].toInt()-1)*RD_LIVEWIRE_GPIO_BUNDLE_SIZE+i;
|
||||||
|
if(f0[3].at(i)!=swa_gpo_states[f0[2].toInt()].at(i)) {
|
||||||
|
emit gpoChanged(swa_matrix,gpo,f0[3].at(i)=='l');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swa_gpo_states[f0[2].toInt()]=f0[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -445,3 +465,25 @@ QString SoftwareAuthority::PrettifyCommand(const char *cmd) const
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString SoftwareAuthority::BundleString(int offset,bool state)
|
||||||
|
{
|
||||||
|
QString ret="";
|
||||||
|
|
||||||
|
for(int i=0;i<RD_LIVEWIRE_GPIO_BUNDLE_SIZE;i++) {
|
||||||
|
if(i==offset) {
|
||||||
|
if(state) {
|
||||||
|
ret+="l";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret+="h";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ret+="x";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#ifndef SWAUTHORITY_H
|
#ifndef SWAUTHORITY_H
|
||||||
#define SWAUTHORITY_H
|
#define SWAUTHORITY_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <qsocket.h>
|
#include <qsocket.h>
|
||||||
@ -60,6 +61,7 @@ class SoftwareAuthority : public Switcher
|
|||||||
void DispatchCommand();
|
void DispatchCommand();
|
||||||
void ExecuteMacroCart(unsigned cartnum);
|
void ExecuteMacroCart(unsigned cartnum);
|
||||||
QString PrettifyCommand(const char *cmd) const;
|
QString PrettifyCommand(const char *cmd) const;
|
||||||
|
QString BundleString(int offset,bool state);
|
||||||
QSocket *swa_socket;
|
QSocket *swa_socket;
|
||||||
char swa_buffer[SWAUTHORITY_MAX_LENGTH];
|
char swa_buffer[SWAUTHORITY_MAX_LENGTH];
|
||||||
unsigned swa_ptr;
|
unsigned swa_ptr;
|
||||||
@ -78,6 +80,8 @@ class SoftwareAuthority : public Switcher
|
|||||||
unsigned swa_stop_cart;
|
unsigned swa_stop_cart;
|
||||||
int swa_istate;
|
int swa_istate;
|
||||||
RDMatrix::PortType swa_porttype;
|
RDMatrix::PortType swa_porttype;
|
||||||
|
std::map<int,QString> swa_gpi_states;
|
||||||
|
std::map<int,QString> swa_gpo_states;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user