2018-07-18 Fred Gleason <fredg@paravelsystems.com>

* Cleaned up SQL quieries in 'ripcd/' to ensure UTF-8
	compatibility.
This commit is contained in:
Fred Gleason 2018-07-18 20:58:22 +00:00
parent 6e2b2a7e0b
commit f7bae36307
12 changed files with 215 additions and 191 deletions

View File

@ -17161,3 +17161,6 @@
2018-07-17 Fred Gleason <fredg@paravelsystems.com> 2018-07-17 Fred Gleason <fredg@paravelsystems.com>
* Cleaned up SQL quieries in 'rdrepld/' to ensure UTF-8 * Cleaned up SQL quieries in 'rdrepld/' to ensure UTF-8
compatibility. compatibility.
2018-07-18 Fred Gleason <fredg@paravelsystems.com>
* Cleaned up SQL quieries in 'ripcd/' to ensure UTF-8
compatibility.

View File

@ -22,6 +22,7 @@
#include <rdapplication.h> #include <rdapplication.h>
#include <rddb.h> #include <rddb.h>
#include <rdescape_string.h>
#include "globals.h" #include "globals.h"
#include "livewire_lwrpaudio.h" #include "livewire_lwrpaudio.h"
@ -41,10 +42,14 @@ LiveWireLwrpAudio::LiveWireLwrpAudio(RDMatrix *matrix,QObject *parent)
// //
// Load The Node List // Load The Node List
// //
sql=QString().sprintf("select HOSTNAME,TCP_PORT,PASSWORD,BASE_OUTPUT \ sql=QString("select ")+
from SWITCHER_NODES where (STATION_NAME=\"%s\")&&\ "HOSTNAME,"+ // 00
(MATRIX=%d)",(const char *)livewire_stationname, "TCP_PORT,"+ // 01
livewire_matrix); "PASSWORD,"+ // 02
"BASE_OUTPUT "+ // 03
"from SWITCHER_NODES where "+
"(STATION_NAME=\""+RDEscapeString(livewire_stationname)+"\")&&"+
QString().sprintf("(MATRIX=%d)",livewire_matrix);
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
while(q->next()) { while(q->next()) {
livewire_nodes.push_back(new RDLiveWire(livewire_nodes.size(),this)); livewire_nodes.push_back(new RDLiveWire(livewire_nodes.size(),this));
@ -58,20 +63,6 @@ LiveWireLwrpAudio::LiveWireLwrpAudio(RDMatrix *matrix,QObject *parent)
SIGNAL(destinationChanged(unsigned,RDLiveWireDestination *)), SIGNAL(destinationChanged(unsigned,RDLiveWireDestination *)),
this, this,
SLOT(destinationChangedData(unsigned,RDLiveWireDestination *))); SLOT(destinationChangedData(unsigned,RDLiveWireDestination *)));
/*
connect(livewire_nodes.back(),
SIGNAL(gpoConfigChanged(unsigned,unsigned,unsigned)),
this,
SLOT(gpoConfigChangedData(unsigned,unsigned,unsigned)));
connect(livewire_nodes.back(),
SIGNAL(gpiChanged(unsigned,unsigned,unsigned,bool)),
this,
SLOT(gpiChangedData(unsigned,unsigned,unsigned,bool)));
connect(livewire_nodes.back(),
SIGNAL(gpoChanged(unsigned,unsigned,unsigned,bool)),
this,
SLOT(gpoChangedData(unsigned,unsigned,unsigned,bool)));
*/
connect(livewire_nodes.back(), connect(livewire_nodes.back(),
SIGNAL(watchdogStateChanged(unsigned,const QString &)), SIGNAL(watchdogStateChanged(unsigned,const QString &)),
this,SLOT(watchdogStateChangedData(unsigned,const QString &))); this,SLOT(watchdogStateChangedData(unsigned,const QString &)));
@ -187,36 +178,24 @@ void LiveWireLwrpAudio::sourceChangedData(unsigned id,RDLiveWireSource *src)
QString sql; QString sql;
RDSqlQuery *q; RDSqlQuery *q;
sql=QString().sprintf("delete from INPUTS where \ sql=QString("delete from INPUTS where ")+
(STATION_NAME=\"%s\")&&\ "(STATION_NAME=\""+RDEscapeString(livewire_stationname)+"\")&&"+
(MATRIX=%d)&&\ QString().sprintf("(MATRIX=%d)&&",livewire_matrix)+
(NODE_HOSTNAME=\"%s\")&&\ "(NODE_HOSTNAME=\""+RDEscapeString(livewire_nodes[id]->hostname())+"\")&&"+
(NODE_TCP_PORT=%d)&&\ QString().sprintf("(NODE_TCP_PORT=%d)&&",livewire_nodes[id]->tcpPort())+
(NODE_SLOT=%d)", QString().sprintf("(NODE_SLOT=%d)",src->slotNumber());
(const char *)livewire_stationname,
livewire_matrix,
(const char *)livewire_nodes[id]->hostname(),
livewire_nodes[id]->tcpPort(),
src->slotNumber());
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
delete q; delete q;
if(src->rtpEnabled()) { if(src->rtpEnabled()) {
sql=QString().sprintf("insert into INPUTS set \ sql=QString("insert into INPUTS set ")+
STATION_NAME=\"%s\",\ "STATION_NAME=\""+RDEscapeString(livewire_stationname)+"\","+
MATRIX=%d,\ QString().sprintf("MATRIX=%d,",livewire_matrix)+
NODE_HOSTNAME=\"%s\",\ "NODE_HOSTNAME=\""+RDEscapeString(livewire_nodes[id]->hostname())+"\","+
NODE_TCP_PORT=%d,\ QString().sprintf("NODE_TCP_PORT=%d,",livewire_nodes[id]->tcpPort())+
NODE_SLOT=%d,\ QString().sprintf("NODE_SLOT=%d,",src->slotNumber())+
NAME=\"%s\",\ "NAME=\""+RDEscapeString(src->primaryName())+"\","+
NUMBER=%d", QString().sprintf("NUMBER=%d",src->channelNumber());
(const char *)livewire_stationname,
livewire_matrix,
(const char *)livewire_nodes[id]->hostname(),
livewire_nodes[id]->tcpPort(),
src->slotNumber(),
(const char *)src->primaryName(),
src->channelNumber());
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
delete q; delete q;
} }
@ -228,35 +207,24 @@ void LiveWireLwrpAudio::destinationChangedData(unsigned id,RDLiveWireDestination
QString sql; QString sql;
RDSqlQuery *q; RDSqlQuery *q;
sql=QString().sprintf("delete from OUTPUTS where \ sql=QString("delete from OUTPUTS where ")+
(STATION_NAME=\"%s\")&&\ "(STATION_NAME=\""+RDEscapeString(livewire_stationname)+"\")&&"+
(MATRIX=%d)&&\ QString().sprintf("(MATRIX=%d)&&",livewire_matrix)+
(NODE_HOSTNAME=\"%s\")&&\ "(NODE_HOSTNAME=\""+RDEscapeString(livewire_nodes[id]->hostname())+"\")&&"+
(NODE_TCP_PORT=%d)&&\ QString().sprintf("(NODE_TCP_PORT=%d)&&",livewire_nodes[id]->tcpPort())+
(NODE_SLOT=%d)", QString().sprintf("(NODE_SLOT=%d)",dst->slotNumber());
(const char *)livewire_stationname,
livewire_matrix,
(const char *)livewire_nodes[id]->hostname(),
livewire_nodes[id]->tcpPort(),
dst->slotNumber());
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
delete q; delete q;
sql=QString().sprintf("insert into OUTPUTS set \ sql=QString("insert into OUTPUTS set ")+
STATION_NAME=\"%s\",\ "STATION_NAME=\""+RDEscapeString(livewire_stationname)+"\","+
MATRIX=%d,\ QString().sprintf("MATRIX=%d,",livewire_matrix)+
NODE_HOSTNAME=\"%s\",\ "NODE_HOSTNAME=\""+RDEscapeString(livewire_nodes[id]->hostname())+"\","+
NODE_TCP_PORT=%d,\ QString().sprintf("NODE_TCP_PORT=%d,",livewire_nodes[id]->tcpPort())+
NODE_SLOT=%d,\ QString().sprintf("NODE_SLOT=%d,",dst->slotNumber())+
NAME=\"%s\",\ "NAME=\""+RDEscapeString(dst->primaryName())+"\","+
NUMBER=%d", QString().sprintf("NUMBER=%d",
(const char *)livewire_stationname, livewire_nodes[id]->baseOutput()+dst->slotNumber()-1);
livewire_matrix,
(const char *)livewire_nodes[id]->hostname(),
livewire_nodes[id]->tcpPort(),
dst->slotNumber(),
(const char *)dst->primaryName(),
livewire_nodes[id]->baseOutput()+dst->slotNumber()-1);
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
delete q; delete q;
} }

View File

@ -2,7 +2,7 @@
// //
// A Rivendell LWRP GPIO driver for LiveWire networks. // A Rivendell LWRP GPIO driver for LiveWire networks.
// //
// (C) Copyright 2013,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2013,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as

View File

@ -138,7 +138,11 @@ LiveWireMcastGpio::LiveWireMcastGpio(RDMatrix *matrix,QObject *parent)
// //
// Source Table // Source Table
// //
sql=QString("select SLOT,SOURCE_NUMBER,IP_ADDRESS from LIVEWIRE_GPIO_SLOTS ")+ sql=QString("select ")+
"SLOT,"+ // 00
"SOURCE_NUMBER,"+ // 01
"IP_ADDRESS "+ // 02
"from LIVEWIRE_GPIO_SLOTS "+
"where (STATION_NAME=\""+RDEscapeString(livewire_stationname)+"\")&&"+ "where (STATION_NAME=\""+RDEscapeString(livewire_stationname)+"\")&&"+
QString().sprintf("(MATRIX=%d) ",livewire_matrix)+ QString().sprintf("(MATRIX=%d) ",livewire_matrix)+
"order by SLOT"; "order by SLOT";

View File

@ -161,9 +161,14 @@ void MainObject::LoadLocalMacros()
// //
// Initialize Matrices // Initialize Matrices
// //
sql=QString().sprintf("select MATRIX,TYPE,PORT,INPUTS,OUTPUTS from MATRICES \ sql=QString("select ")+
where STATION_NAME=\"%s\"", "MATRIX,"+ // 00
(const char *)rda->station()->name()); "TYPE,"+ // 01
"PORT,"+ // 02
"INPUTS,"+ // 03
"OUTPUTS "+ // 04
"from MATRICES where "+
"STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\"";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
while(q->next()) { while(q->next()) {
if(!LoadSwitchDriver(q->value(0).toInt())) { if(!LoadSwitchDriver(q->value(0).toInt())) {
@ -177,10 +182,16 @@ void MainObject::LoadLocalMacros()
// //
// Initialize TTYs // Initialize TTYs
// //
sql=QString().sprintf("select PORT_ID,PORT,BAUD_RATE,DATA_BITS,PARITY,\ sql=QString("select ")+
TERMINATION from TTYS where (STATION_NAME=\"%s\")&&\ "PORT_ID,"+ // 00
(ACTIVE=\"Y\")", "PORT,"+ // 01
(const char *)rda->station()->name()); "BAUD_RATE,"+ // 02
"DATA_BITS,"+ // 03
"PARITY,"+ // 04
"TERMINATION "+ // 05
"from TTYS where "+
"(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
"(ACTIVE=\"Y\")";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
while(q->next()) { while(q->next()) {
tty_port=q->value(0).toUInt(); tty_port=q->value(0).toUInt();
@ -778,10 +789,17 @@ void MainObject::RunLocalMacros(RDMacro *rml)
// //
// Try to Restart // Try to Restart
// //
sql=QString().sprintf("select PORT_ID,PORT,BAUD_RATE,DATA_BITS,PARITY,\ sql=QString("select ")+
TERMINATION from TTYS where (STATION_NAME=\"%s\")&& \ "PORT_ID,"+ // 00
(ACTIVE=\"Y\")&&(PORT_ID=%d)", "PORT,"+ // 01
(const char *)rda->station()->name(),tty_port); "BAUD_RATE,"+ // 02
"DATA_BITS,"+ // 03
"PARITY,"+ // 04
"TERMINATION "+ // 05
"from TTYS where "+
"(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
"(ACTIVE=\"Y\")&&"+
QString().sprintf("(PORT_ID=%d)",tty_port);
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
if(q->first()) { if(q->first()) {
if(!ripcd_tty_inuse[tty_port]) { if(!ripcd_tty_inuse[tty_port]) {

View File

@ -2,7 +2,7 @@
// //
// A Rivendell switcher driver for Modbus TCP // A Rivendell switcher driver for Modbus TCP
// //
// (C) Copyright 2017 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2017-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as

View File

@ -2,7 +2,7 @@
// //
// Rivendell Interprocess Communication Daemon // Rivendell Interprocess Communication Daemon
// //
// (C) Copyright 2002-2007,2010,2016 Fred Gleason <fredg@paravelsystems.com> // (C) Copyright 2002-2007,2010,2016-2018 Fred Gleason <fredg@paravelsystems.com>
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License version 2 as
@ -41,6 +41,7 @@
#include <rdapplication.h> #include <rdapplication.h>
#include <rdconf.h> #include <rdconf.h>
#include <rdcheck_daemons.h> #include <rdcheck_daemons.h>
#include <rdescape_string.h>
#include <rdnotification.h> #include <rdnotification.h>
#include "globals.h" #include "globals.h"
@ -772,10 +773,13 @@ void MainObject::LoadGpiTable()
} }
} }
} }
QString sql=QString().sprintf("select MATRIX,NUMBER,OFF_MACRO_CART,\ QString sql=QString("select ")+
MACRO_CART from GPIS \ "MATRIX,"+ // 00
where STATION_NAME=\"%s\"", "NUMBER,"+ // 01
(const char *)rda->config()->stationName()); "OFF_MACRO_CART,"+ // 02
"MACRO_CART "+ // 03
"from GPIS where "+
"STATION_NAME=\""+RDEscapeString(rda->config()->stationName())+"\"";
RDSqlQuery *q=new RDSqlQuery(sql); RDSqlQuery *q=new RDSqlQuery(sql);
while(q->next()) { while(q->next()) {
ripcd_gpi_macro[q->value(0).toInt()][q->value(1).toInt()-1][0]= ripcd_gpi_macro[q->value(0).toInt()][q->value(1).toInt()-1][0]=
@ -785,9 +789,13 @@ void MainObject::LoadGpiTable()
} }
delete q; delete q;
sql=QString().sprintf("select MATRIX,NUMBER,OFF_MACRO_CART,MACRO_CART \ sql=QString("select ")+
from GPOS where STATION_NAME=\"%s\"", "MATRIX,"+ // 00
(const char *)rda->config()->stationName()); "NUMBER,"+ // 01
"OFF_MACRO_CART,"+ // 02
"MACRO_CART "+ // 03
"from GPOS where "+
"STATION_NAME=\""+RDEscapeString(rda->config()->stationName())+"\"";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
while(q->next()) { while(q->next()) {
ripcd_gpo_macro[q->value(0).toInt()][q->value(1).toInt()-1][0]= ripcd_gpo_macro[q->value(0).toInt()][q->value(1).toInt()-1][0]=

View File

@ -22,6 +22,7 @@
#include <rdapplication.h> #include <rdapplication.h>
#include <rddb.h> #include <rddb.h>
#include <rdescape_string.h>
#include "globals.h" #include "globals.h"
#include "sasusi.h" #include "sasusi.h"
@ -52,12 +53,14 @@ SasUsi::SasUsi(RDMatrix *matrix,QObject *parent)
// //
// Load Switch Table // Load Switch Table
// //
sql=QString(). sql=QString("select ")+
sprintf("select ENGINE_NUM,DEVICE_NUM,RELAY_NUM \ "ENGINE_NUM,"+ // 00
from VGUEST_RESOURCES where (STATION_NAME=\"%s\")&&\ "DEVICE_NUM,"+ // 01
(MATRIX_NUM=%d) order by NUMBER", "RELAY_NUM "+ // 02
(const char *)rda->config()->stationName(), "from VGUEST_RESOURCES where "+
matrix->matrix()); "(STATION_NAME=\""+RDEscapeString(rda->config()->stationName())+"\")&&"+
QString().sprintf("(MATRIX_NUM=%d) ",matrix->matrix())+
"order by NUMBER";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
while(q->next()) { while(q->next()) {
sas_console_numbers.push_back(q->value(0).toInt()); sas_console_numbers.push_back(q->value(0).toInt());
@ -486,26 +489,24 @@ void SasUsi::DispatchCommand()
if(sscanf(sas_buffer+1,"%u",&input)!=1) { if(sscanf(sas_buffer+1,"%u",&input)!=1) {
return; return;
} }
sql=QString().sprintf("select NUMBER from INPUTS where \ sql=QString("select NUMBER from INPUTS where ")+
(STATION_NAME=\"%s\")&& \ "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
(MATRIX=%d)&&(NUMBER=%d)", QString().sprintf("(MATRIX=%d)&&",sas_matrix)+
(const char *)rda->station()->name(), QString().sprintf("(NUMBER=%d)",input);
sas_matrix,input);
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
if(q->first()) { if(q->first()) {
sql=QString().sprintf("update INPUTS set NAME=\"%s\" where \ sql=QString("update INPUTS set ")+
(STATION_NAME=\"%s\")&&\ "NAME=\""+RDEscapeString(label)+"\" where "+
(MATRIX=%d)&&(NUMBER=%d)", "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
(const char *)label, QString().sprintf("(MATRIX=%d)&&",sas_matrix)+
(const char *)rda->station()->name(), QString().sprintf("(NUMBER=%d)",input);
sas_matrix,input);
} }
else { else {
sql=QString().sprintf("insert into INPUTS set NAME=\"%s\",\ sql=QString("insert into INPUTS set ")+
STATION_NAME=\"%s\",MATRIX=%d,NUMBER=%d", "NAME=\""+RDEscapeString(label)+"\","+
(const char *)label, "STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\","+
(const char *)rda->station()->name(), QString().sprintf("MATRIX=%d,",sas_matrix)+
sas_matrix,input); QString().sprintf("NUMBER=%d",input);
} }
delete q; delete q;
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
@ -521,26 +522,24 @@ void SasUsi::DispatchCommand()
if(sscanf(sas_buffer+1,"%u",&output)!=1) { if(sscanf(sas_buffer+1,"%u",&output)!=1) {
return; return;
} }
sql=QString().sprintf("select NUMBER from OUTPUTS where \ sql=QString("select NUMBER from OUTPUTS where ")+
(STATION_NAME=\"%s\")&&\ "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
(MATRIX=%d)&&(NUMBER=%d)", QString().sprintf("(MATRIX=%d)&&",sas_matrix)+
(const char *)rda->station()->name(), QString().sprintf("(NUMBER=%d)",output);
sas_matrix,output);
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
if(q->first()) { if(q->first()) {
sql=QString().sprintf("update OUTPUTS set NAME=\"%s\" where \ sql=QString("update OUTPUTS set ")+
(STATION_NAME=\"%s\")&&\ "NAME=\""+RDEscapeString(label)+"\" where "+
(MATRIX=%d)&&(NUMBER=%d)", "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
(const char *)label, QString().sprintf("(MATRIX=%d)&&",sas_matrix)+
(const char *)rda->station()->name(), QString().sprintf("(NUMBER=%d)",output);
sas_matrix,output);
} }
else { else {
sql=QString().sprintf("insert into OUTPUTS set NAME=\"%s\",\ sql=QString("insert into OUTPUTS set ")+
STATION_NAME=\"%s\",MATRIX=%d,NUMBER=%d", "NAME=\""+RDEscapeString(label)+"\","+
(const char *)label, "STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\","+
(const char *)rda->station()->name(), QString().sprintf("MATRIX=%d,",sas_matrix)+
sas_matrix,output); QString().sprintf("NUMBER=%d",output);
} }
delete q; delete q;
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);

View File

@ -21,6 +21,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdescape_string.h>
#include "globals.h" #include "globals.h"
#include "starguide3.h" #include "starguide3.h"
@ -40,11 +41,15 @@ StarGuide3::StarGuide3(RDMatrix *matrix,QObject *parent)
// //
// Load Feed Data // Load Feed Data
// //
sql=QString().sprintf("select NUMBER,ENGINE_NUM,DEVICE_NUM,CHANNEL_MODE\ sql=QString("select ")+
from INPUTS where STATION_NAME=\"%s\" && MATRIX=%d \ "NUMBER,"+ // 00
order by NUMBER", "ENGINE_NUM,"+ // 01
(const char *)rda->station()->name(), "DEVICE_NUM,"+ // 02
matrix->matrix()); "CHANNEL_MODE "+ // 03
"from INPUTS where "+
"STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\" && "+
QString().sprintf("MATRIX=%d ",matrix->matrix())+
"order by NUMBER";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
q->first(); q->first();
for(int i=0;i<sg_inputs;i++) { for(int i=0;i<sg_inputs;i++) {

View File

@ -310,26 +310,24 @@ void SoftwareAuthority::DispatchCommand()
if(f0.size()>=7) { if(f0.size()>=7) {
name=f0[6]+": "+f0[2]; name=f0[6]+": "+f0[2];
} }
sql=QString().sprintf("select NUMBER from INPUTS where \ sql=QString("select NUMBER from INPUTS where ")+
(STATION_NAME=\"%s\")&& \ "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
(MATRIX=%d)&&(NUMBER=%d)", QString().sprintf("(MATRIX=%d)&&",swa_matrix)+
(const char *)rda->station()->name(), QString().sprintf("(NUMBER=%d)",f0[0].toInt());
swa_matrix,f0[0].toInt());
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
if(q->first()) { if(q->first()) {
sql=QString().sprintf("update INPUTS set NAME=\"%s\" where \ sql=QString("update INPUTS set ")+
(STATION_NAME=\"%s\")&&\ "NAME=\""+RDEscapeString(name)+"\" where "+
(MATRIX=%d)&&(NUMBER=%d)", "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
(const char *)name, QString().sprintf("(MATRIX=%d)&&",swa_matrix)+
(const char *)rda->station()->name(), QString().sprintf("(NUMBER=%d)",f0[0].toInt());
swa_matrix,f0[0].toInt());
} }
else { else {
sql=QString().sprintf("insert into INPUTS set NAME=\"%s\",\ sql=QString("insert into INPUTS set ")+
STATION_NAME=\"%s\",MATRIX=%d,NUMBER=%d", "NAME=\""+RDEscapeString(name)+"\","+
(const char *)name, "STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\","+
(const char *)rda->station()->name(), QString().sprintf("MATRIX=%d,",swa_matrix)+
swa_matrix,f0[0].toInt()); QString().sprintf("NUMBER=%d",f0[0].toInt());
} }
delete q; delete q;
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
@ -364,26 +362,24 @@ void SoftwareAuthority::DispatchCommand()
if(f0.size()>=6) { if(f0.size()>=6) {
name=f0[3]+"/"+f0[5]+": "+f0[2]; name=f0[3]+"/"+f0[5]+": "+f0[2];
} }
sql=QString().sprintf("select NUMBER from OUTPUTS where \ sql=QString("select NUMBER from OUTPUTS where ")+
(STATION_NAME=\"%s\")&&\ "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
(MATRIX=%d)&&(NUMBER=%d)", QString().sprintf("(MATRIX=%d)&&",swa_matrix)+
(const char *)rda->station()->name(), QString().sprintf("(NUMBER=%d)",f0[0].toInt());
swa_matrix,f0[0].toInt());
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
if(q->first()) { if(q->first()) {
sql=QString().sprintf("update OUTPUTS set NAME=\"%s\" where \ sql=QString("update OUTPUTS set ")+
(STATION_NAME=\"%s\")&&\ "NAME=\""+RDEscapeString(name)+"\" where "+
(MATRIX=%d)&&(NUMBER=%d)", "(STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\")&&"+
(const char *)name, QString().sprintf("(MATRIX=%d)&&",swa_matrix)+
(const char *)rda->station()->name(), QString().sprintf("(NUMBER=%d)",f0[0].toInt());
swa_matrix,f0[0].toInt());
} }
else { else {
sql=QString().sprintf("insert into OUTPUTS set NAME=\"%s\",\ sql=QString("insert into OUTPUTS set ")+
STATION_NAME=\"%s\",MATRIX=%d,NUMBER=%d", "NAME=\""+RDEscapeString(name)+"\","+
(const char *)name, "STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\","+
(const char *)rda->station()->name(), QString().sprintf("MATRIX=%d,",swa_matrix)+
swa_matrix,f0[0].toInt()); QString().sprintf("NUMBER=%d",f0[0].toInt());
} }
delete q; delete q;
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);

View File

@ -22,6 +22,7 @@
#include <rdapplication.h> #include <rdapplication.h>
#include <rddb.h> #include <rddb.h>
#include <rdescape_string.h>
#include "globals.h" #include "globals.h"
#include "unity4000.h" #include "unity4000.h"
@ -41,11 +42,14 @@ Unity4000::Unity4000(RDMatrix *matrix,QObject *parent)
// //
// Load Feed Data // Load Feed Data
// //
sql=QString().sprintf("select NUMBER,FEED_NAME,CHANNEL_MODE from INPUTS \ sql=QString("select ")+
where STATION_NAME=\"%s\" && MATRIX=%d \ "NUMBER,"+ // 00
order by NUMBER", "FEED_NAME,"+ // 01
(const char *)rda->station()->name(), "CHANNEL_MODE "+ // 02
matrix->matrix()); "from INPUTS where "+
"STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\" && "+
QString().sprintf("MATRIX=%d ",matrix->matrix())+
"order by NUMBER";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
q->first(); q->first();
for(int i=0;i<unity_inputs;i++) { for(int i=0;i<unity_inputs;i++) {

View File

@ -23,6 +23,7 @@
#include <qsignalmapper.h> #include <qsignalmapper.h>
#include <rdapplication.h> #include <rdapplication.h>
#include <rdescape_string.h>
#include "globals.h" #include "globals.h"
#include "vguest.h" #include "vguest.h"
@ -71,9 +72,14 @@ VGuest::VGuest(RDMatrix *matrix,QObject *parent)
// //
// Load Engine Data - Inputs // Load Engine Data - Inputs
// //
sql=QString().sprintf("select NUMBER,ENGINE_NUM,DEVICE_NUM from INPUTS where\ sql=QString("select ")+
(STATION_NAME=\"%s\")&&(MATRIX=%d) order by NUMBER", "NUMBER,"+ // 00
(const char *)matrix->station(),matrix->matrix()); "ENGINE_NUM,"+ // 01
"DEVICE_NUM "+ // 02
"from INPUTS where "+
"(STATION_NAME=\""+RDEscapeString(matrix->station())+"\")&&"+
QString().sprintf("(MATRIX=%d) ",matrix->matrix())+
"order by NUMBER";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
n=1; n=1;
while(q->next()) { while(q->next()) {
@ -92,9 +98,14 @@ VGuest::VGuest(RDMatrix *matrix,QObject *parent)
// Load Engine Data - Outputs // Load Engine Data - Outputs
// //
sql= sql=
QString().sprintf("select NUMBER,ENGINE_NUM,DEVICE_NUM from OUTPUTS where\ QString("select ")+
(STATION_NAME=\"%s\")&&(MATRIX=%d) order by NUMBER", "NUMBER,"+ // 00
(const char *)matrix->station(),matrix->matrix()); "ENGINE_NUM,"+ // 01
"DEVICE_NUM "+ // 02
"from OUTPUTS where "+
"(STATION_NAME=\""+RDEscapeString(matrix->station())+"\")&&"+
QString().sprintf("(MATRIX=%d) ",matrix->matrix())+
"order by NUMBER";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
n=1; n=1;
while(q->next()) { while(q->next()) {
@ -113,12 +124,17 @@ VGuest::VGuest(RDMatrix *matrix,QObject *parent)
// Load Engine Data - Relays // Load Engine Data - Relays
// //
sql= sql=
QString().sprintf("select NUMBER,ENGINE_NUM,DEVICE_NUM,SURFACE_NUM,\ QString("select ")+
RELAY_NUM from VGUEST_RESOURCES where\ "NUMBER,"+ // 00
(STATION_NAME=\"%s\")&&(MATRIX_NUM=%d)&&\ "ENGINE_NUM,"+ // 01
(VGUEST_TYPE=%d) order by NUMBER", "DEVICE_NUM,"+ // 02
(const char *)matrix->station(),matrix->matrix(), "SURFACE_NUM,"+ // 03
RDMatrix::VguestTypeRelay); "RELAY_NUM "+ // 04
"from VGUEST_RESOURCES where "+
"(STATION_NAME=\""+RDEscapeString(matrix->station())+"\")&&"+
QString().sprintf("(MATRIX_NUM=%d)&&",matrix->matrix())+
QString().sprintf("(VGUEST_TYPE=%d) ",RDMatrix::VguestTypeRelay)+
"order by NUMBER";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
n=1; n=1;
while(q->next()) { while(q->next()) {
@ -140,13 +156,16 @@ VGuest::VGuest(RDMatrix *matrix,QObject *parent)
// //
// Load Engine Data - Displays // Load Engine Data - Displays
// //
sql= sql=QString("select ")+
QString().sprintf("select NUMBER,ENGINE_NUM,DEVICE_NUM,SURFACE_NUM\ "NUMBER,"+ // 00
from VGUEST_RESOURCES where\ "ENGINE_NUM,"+ // 01
(STATION_NAME=\"%s\")&&(MATRIX_NUM=%d)&&\ "DEVICE_NUM,"+ // 02
(VGUEST_TYPE=%d) order by NUMBER", "SURFACE_NUM "+ // 03
(const char *)matrix->station(),matrix->matrix(), "from VGUEST_RESOURCES where "+
RDMatrix::VguestTypeDisplay); "(STATION_NAME=\""+RDEscapeString(matrix->station())+"\")&&"+
QString().sprintf("(MATRIX_NUM=%d)&&",matrix->matrix())+
QString().sprintf("(VGUEST_TYPE=%d) ",RDMatrix::VguestTypeDisplay)+
"order by NUMBER";
q=new RDSqlQuery(sql); q=new RDSqlQuery(sql);
n=1; n=1;
while(q->next()) { while(q->next()) {