mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-09-18 09:10:50 +02:00
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
* Converted sas_shim(8) to use RDApplication.
This commit is contained in:
parent
47a792d0aa
commit
79c0e1d825
@ -16645,3 +16645,5 @@
|
|||||||
* Converted rdpurgecasts(1) to use RDApplication.
|
* Converted rdpurgecasts(1) to use RDApplication.
|
||||||
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
|
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Converted rdrender(1) to use RDApplication.
|
* Converted rdrender(1) to use RDApplication.
|
||||||
|
2018-02-03 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Converted sas_shim(8) to use RDApplication.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// An RDCatch event import shim for the SAS64000
|
// An RDCatch event import shim for the SAS64000
|
||||||
//
|
//
|
||||||
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2004,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
|
||||||
@ -26,13 +26,11 @@
|
|||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
|
|
||||||
#include <rdconf.h>
|
|
||||||
#include <rd.h>
|
#include <rd.h>
|
||||||
#include <rdcmd_switch.h>
|
#include <rdapplication.h>
|
||||||
#include <rddbheartbeat.h>
|
#include <rdconf.h>
|
||||||
|
|
||||||
#include <sas_shim.h>
|
|
||||||
|
|
||||||
|
#include "sas_shim.h"
|
||||||
|
|
||||||
void SigHandler(int signo)
|
void SigHandler(int signo)
|
||||||
{
|
{
|
||||||
@ -48,52 +46,43 @@ void SigHandler(int signo)
|
|||||||
MainObject::MainObject(QObject *parent)
|
MainObject::MainObject(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
|
QString err_msg;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open the Database
|
||||||
|
//
|
||||||
|
rda=new RDApplication("sas_shim","sas_shim",SAS_SHIM_USAGE,this);
|
||||||
|
if(!rda->open(&err_msg)) {
|
||||||
|
fprintf(stderr,"sas_shim: %s\n",(const char *)err_msg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read Command Options
|
// Read Command Options
|
||||||
//
|
//
|
||||||
RDCmdSwitch *cmd=new RDCmdSwitch(qApp->argc(),qApp->argv(),"sas_shim","\n");
|
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
|
||||||
delete cmd;
|
if(!rda->cmdSwitch()->processed(i)) {
|
||||||
|
fprintf(stderr,"sas_shim: unknown command option \"%s\"\n",
|
||||||
rd_config=new RDConfig(RD_CONF_FILE);
|
(const char *)rda->cmdSwitch()->key(i));
|
||||||
rd_config->load();
|
exit(2);
|
||||||
rd_config->setModuleName("sas_shim");
|
|
||||||
|
|
||||||
//
|
|
||||||
// Open Database
|
|
||||||
//
|
|
||||||
shim_db=QSqlDatabase::addDatabase(rd_config->mysqlDriver());
|
|
||||||
if(!shim_db) {
|
|
||||||
fprintf(stderr,"sas_shim: can't open mySQL database\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
shim_db->setDatabaseName(rd_config->mysqlDbname());
|
|
||||||
shim_db->setUserName(rd_config->mysqlUsername());
|
|
||||||
shim_db->setPassword(rd_config->mysqlPassword());
|
|
||||||
shim_db->setHostName(rd_config->mysqlHostname());
|
|
||||||
if(!shim_db->open()) {
|
|
||||||
fprintf(stderr,"sas_shim: unable to connect to mySQL Server");
|
|
||||||
shim_db->removeDatabase(rd_config->mysqlDbname());
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
new RDDbHeartbeat(rd_config->mysqlHeartbeatInterval(),this);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Station Configuration
|
// Station Configuration
|
||||||
//
|
//
|
||||||
shim_rdstation=new RDStation(rd_config->stationName());
|
shim_address=rda->station()->address();
|
||||||
shim_address=shim_rdstation->address();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// RIPCD Connection
|
// RIPCD Connection
|
||||||
//
|
//
|
||||||
shim_ripc=new RDRipc(shim_rdstation,rd_config,this);
|
rda->ripc()->connectHost("localhost",RIPCD_TCP_PORT,rda->config()->password());
|
||||||
shim_ripc->connectHost("localhost",RIPCD_TCP_PORT,rd_config->password());
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// TTY Device
|
// TTY Device
|
||||||
//
|
//
|
||||||
shim_tty=new RDTTYDevice();
|
shim_tty=new RDTTYDevice();
|
||||||
shim_tty->setName(rd_config->sasTtyDevice());
|
shim_tty->setName(rda->config()->sasTtyDevice());
|
||||||
if(!shim_tty->open(IO_ReadOnly)) {
|
if(!shim_tty->open(IO_ReadOnly)) {
|
||||||
fprintf(stderr,"sas_shim: unabled to open tty device\n");
|
fprintf(stderr,"sas_shim: unabled to open tty device\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -112,7 +101,7 @@ MainObject::MainObject(QObject *parent)
|
|||||||
//
|
//
|
||||||
// Detach
|
// Detach
|
||||||
//
|
//
|
||||||
RDDetach(rd_config->logCoreDumpDirectory());
|
RDDetach(rda->config()->logCoreDumpDirectory());
|
||||||
FILE *pidfile=fopen("/var/run/sas_shim.pid","w");
|
FILE *pidfile=fopen("/var/run/sas_shim.pid","w");
|
||||||
fprintf(pidfile,"%d",getpid());
|
fprintf(pidfile,"%d",getpid());
|
||||||
fclose(pidfile);
|
fclose(pidfile);
|
||||||
@ -200,7 +189,6 @@ void MainObject::readTtyData()
|
|||||||
istate=0;
|
istate=0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,10 +204,10 @@ void MainObject::DispatchRml(int input,int output)
|
|||||||
rml.setAddress(shim_address);
|
rml.setAddress(shim_address);
|
||||||
rml.setEchoRequested(false);
|
rml.setEchoRequested(false);
|
||||||
rml.setArgQuantity(3);
|
rml.setArgQuantity(3);
|
||||||
rml.setArg(0,rd_config->sasMatrix());
|
rml.setArg(0,rda->config()->sasMatrix());
|
||||||
rml.setArg(1,input);
|
rml.setArg(1,input);
|
||||||
rml.setArg(2,output);
|
rml.setArg(2,output);
|
||||||
shim_ripc->sendRml(&rml);
|
rda->ripc()->sendRml(&rml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// An RDCatch event import shim for the SAS64000
|
// An RDCatch event import shim for the SAS64000
|
||||||
//
|
//
|
||||||
// (C) Copyright 2002-2004,2016 Fred Gleason <fredg@paravelsystems.com>
|
// (C) Copyright 2002-2004,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
|
||||||
@ -21,16 +21,13 @@
|
|||||||
#ifndef SAS_SHIM_H
|
#ifndef SAS_SHIM_H
|
||||||
#define SAS_SHIM_H
|
#define SAS_SHIM_H
|
||||||
|
|
||||||
#include <qobject.h>
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qsqldatabase.h>
|
#include <qhostaddress.h>
|
||||||
|
#include <qobject.h>
|
||||||
|
|
||||||
#include <rdttydevice.h>
|
#include <rdttydevice.h>
|
||||||
|
|
||||||
#include <rdstation.h>
|
#define SAS_SHIM_USAGE "\n"
|
||||||
#include <rdripc.h>
|
|
||||||
#include <rdconfig.h>
|
|
||||||
|
|
||||||
#define POLL_INTERVAL 100
|
#define POLL_INTERVAL 100
|
||||||
|
|
||||||
class MainObject : public QObject
|
class MainObject : public QObject
|
||||||
@ -45,13 +42,9 @@ class MainObject : public QObject
|
|||||||
private:
|
private:
|
||||||
void DispatchRml(int input,int output);
|
void DispatchRml(int input,int output);
|
||||||
QString shim_station;
|
QString shim_station;
|
||||||
RDStation *shim_rdstation;
|
|
||||||
QHostAddress shim_address;
|
QHostAddress shim_address;
|
||||||
RDRipc *shim_ripc;
|
|
||||||
QSqlDatabase *shim_db;
|
|
||||||
RDTTYDevice *shim_tty;
|
RDTTYDevice *shim_tty;
|
||||||
RDConfig *rd_config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif // SAS_SHIM_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user