mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-10 16:43:35 +02:00
2017-08-13 Fred Gleason <fredg@paravelsystems.com>
* Refactored the WheatNet SLIO driver to use event subscription.
This commit is contained in:
@@ -15935,3 +15935,5 @@
|
|||||||
* Implemented a driver for WheatNet LIO devices.
|
* Implemented a driver for WheatNet LIO devices.
|
||||||
2017-08-13 Fred Gleason <fredg@paravelsystems.com>
|
2017-08-13 Fred Gleason <fredg@paravelsystems.com>
|
||||||
* Refactored the WheatNet LIO driver to use event subscription.
|
* Refactored the WheatNet LIO driver to use event subscription.
|
||||||
|
2017-08-13 Fred Gleason <fredg@paravelsystems.com>
|
||||||
|
* Refactored the WheatNet SLIO driver to use event subscription.
|
||||||
|
@@ -41,7 +41,7 @@ WheatnetSlio::WheatnetSlio(RDMatrix *matrix,QObject *parent)
|
|||||||
slio_socket->connectToHost(slio_ip_address.toString(),slio_ip_port);
|
slio_socket->connectToHost(slio_ip_address.toString(),slio_ip_port);
|
||||||
|
|
||||||
slio_poll_timer=new QTimer(this);
|
slio_poll_timer=new QTimer(this);
|
||||||
connect(slio_poll_timer,SIGNAL(timeout()),this,SLOT(pollInputs()));
|
connect(slio_poll_timer,SIGNAL(timeout()),this,SLOT(pollData()));
|
||||||
|
|
||||||
slio_reset_mapper=new QSignalMapper(this);
|
slio_reset_mapper=new QSignalMapper(this);
|
||||||
connect(slio_reset_mapper,SIGNAL(mapped(int)),
|
connect(slio_reset_mapper,SIGNAL(mapped(int)),
|
||||||
@@ -208,14 +208,6 @@ void WheatnetSlio::errorData(int err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WheatnetSlio::pollInputs()
|
|
||||||
{
|
|
||||||
for(int i=0;i<slio_gpios;i++) {
|
|
||||||
SendCommand(QString().sprintf("<SLIO:%d?LVL>",i+1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WheatnetSlio::resetStateData(int line)
|
void WheatnetSlio::resetStateData(int line)
|
||||||
{
|
{
|
||||||
SendCommand(QString().sprintf("<SLIO:%d|LVL:%d>",line+1,
|
SendCommand(QString().sprintf("<SLIO:%d|LVL:%d>",line+1,
|
||||||
@@ -224,6 +216,12 @@ void WheatnetSlio::resetStateData(int line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void WheatnetSlio::pollData()
|
||||||
|
{
|
||||||
|
SendCommand("<SYS?BLID>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void WheatnetSlio::watchdogData()
|
void WheatnetSlio::watchdogData()
|
||||||
{
|
{
|
||||||
if(!slio_watchdog_active) {
|
if(!slio_watchdog_active) {
|
||||||
@@ -300,6 +298,7 @@ void WheatnetSlio::ProcessSys(const QString &cmd)
|
|||||||
slio_reset_states.push_back(false);
|
slio_reset_states.push_back(false);
|
||||||
slio_gpi_states.push_back(false);
|
slio_gpi_states.push_back(false);
|
||||||
CheckLineEntry(i+1);
|
CheckLineEntry(i+1);
|
||||||
|
SendCommand(QString().sprintf("<SLIOSUB:%d|LVL:1>",i+1));
|
||||||
}
|
}
|
||||||
sql=QString("update MATRICES set ")+
|
sql=QString("update MATRICES set ")+
|
||||||
QString().sprintf("GPIS=%d,GPOS=%d where ",slio_gpios,slio_gpios)+
|
QString().sprintf("GPIS=%d,GPOS=%d where ",slio_gpios,slio_gpios)+
|
||||||
@@ -307,13 +306,19 @@ void WheatnetSlio::ProcessSys(const QString &cmd)
|
|||||||
QString().sprintf("(MATRIX=%d)",matrixNumber());
|
QString().sprintf("(MATRIX=%d)",matrixNumber());
|
||||||
q=new RDSqlQuery(sql);
|
q=new RDSqlQuery(sql);
|
||||||
delete q;
|
delete q;
|
||||||
pollInputs();
|
slio_watchdog_timer->start(WHEATNET_SLIO_WATCHDOG_INTERVAL,true);
|
||||||
|
slio_poll_timer->start(WHEATNET_SLIO_POLL_INTERVAL,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if((f0[0]=="BLID")&&(f0.size()==2)) {
|
||||||
|
slio_watchdog_timer->stop();
|
||||||
|
slio_watchdog_timer->start(WHEATNET_SLIO_WATCHDOG_INTERVAL,true);
|
||||||
|
slio_poll_timer->start(WHEATNET_SLIO_POLL_INTERVAL,true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WheatnetSlio::ProcessSlio(int chan,QString &cmd)
|
void WheatnetSlio::ProcessSlioevent(int chan,QString &cmd)
|
||||||
{
|
{
|
||||||
// printf("ProcessSlip(%d,%s)\n",chan,(const char *)cmd);
|
// printf("ProcessSlip(%d,%s)\n",chan,(const char *)cmd);
|
||||||
QStringList f0=f0.split(":",cmd);
|
QStringList f0=f0.split(":",cmd);
|
||||||
@@ -321,14 +326,13 @@ void WheatnetSlio::ProcessSlio(int chan,QString &cmd)
|
|||||||
if(chan<=(int)slio_gpi_states.size()) {
|
if(chan<=(int)slio_gpi_states.size()) {
|
||||||
bool state=f0[1]=="1";
|
bool state=f0[1]=="1";
|
||||||
if(state!=slio_gpi_states[chan-1]) {
|
if(state!=slio_gpi_states[chan-1]) {
|
||||||
printf("change chan: %d state: %d\n",chan,state);
|
|
||||||
slio_gpi_states[chan-1]=state;
|
slio_gpi_states[chan-1]=state;
|
||||||
emit gpiChanged(matrixNumber(),chan-1,state);
|
emit gpiChanged(matrixNumber(),chan-1,state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
syslog(LOG_WARNING,
|
syslog(LOG_WARNING,
|
||||||
"WheatNet device at %s:%d sent invalid SLIO LVL update [%s]",
|
"WheatNet device at %s:%d sent invalid SLIOEVENT LVL update [%s]",
|
||||||
(const char *)slio_ip_address.toString(),
|
(const char *)slio_ip_address.toString(),
|
||||||
slio_ip_port,(const char *)cmd);
|
slio_ip_port,(const char *)cmd);
|
||||||
}
|
}
|
||||||
@@ -353,10 +357,10 @@ void WheatnetSlio::ProcessCommand(const QString &cmd)
|
|||||||
if(f1[0]=="SYS") {
|
if(f1[0]=="SYS") {
|
||||||
ProcessSys(f0[1]);
|
ProcessSys(f0[1]);
|
||||||
}
|
}
|
||||||
if((f1[0]=="SLIO")&&(f1.size()==2)) {
|
if((f1[0]=="SLIOEVENT")&&(f1.size()==2)) {
|
||||||
int chan=f1[1].toUInt(&ok);
|
int chan=f1[1].toUInt(&ok);
|
||||||
if(ok) {
|
if(ok) {
|
||||||
ProcessSlio(chan,f0[1]);
|
ProcessSlioevent(chan,f0[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -33,8 +33,8 @@
|
|||||||
|
|
||||||
#include <switcher.h>
|
#include <switcher.h>
|
||||||
|
|
||||||
#define WHEATNET_SLIO_POLL_INTERVAL 100
|
#define WHEATNET_SLIO_POLL_INTERVAL 1000
|
||||||
#define WHEATNET_SLIO_WATCHDOG_INTERVAL 1000
|
#define WHEATNET_SLIO_WATCHDOG_INTERVAL 5000
|
||||||
|
|
||||||
class WheatnetSlio : public Switcher
|
class WheatnetSlio : public Switcher
|
||||||
{
|
{
|
||||||
@@ -53,18 +53,17 @@ class WheatnetSlio : public Switcher
|
|||||||
void connectedData();
|
void connectedData();
|
||||||
void readyReadData();
|
void readyReadData();
|
||||||
void errorData(int err);
|
void errorData(int err);
|
||||||
void pollInputs();
|
|
||||||
void resetStateData(int line);
|
void resetStateData(int line);
|
||||||
|
void pollData();
|
||||||
void watchdogData();
|
void watchdogData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CheckLineEntry(int line);
|
void CheckLineEntry(int line);
|
||||||
void ProcessSys(const QString &cmd);
|
void ProcessSys(const QString &cmd);
|
||||||
void ProcessSlio(int chan,QString &cmd);
|
void ProcessSlioevent(int chan,QString &cmd);
|
||||||
void ProcessCommand(const QString &cmd);
|
void ProcessCommand(const QString &cmd);
|
||||||
void SendCommand(const QString &cmd);
|
void SendCommand(const QString &cmd);
|
||||||
QSocket *slio_socket;
|
QSocket *slio_socket;
|
||||||
QTimer *slio_poll_timer;
|
|
||||||
QTimer *slio_watchdog_timer;
|
QTimer *slio_watchdog_timer;
|
||||||
bool slio_watchdog_active;
|
bool slio_watchdog_active;
|
||||||
QHostAddress slio_ip_address;
|
QHostAddress slio_ip_address;
|
||||||
@@ -75,6 +74,7 @@ class WheatnetSlio : public Switcher
|
|||||||
QSignalMapper *slio_reset_mapper;
|
QSignalMapper *slio_reset_mapper;
|
||||||
std::vector<QTimer *> slio_reset_timers;
|
std::vector<QTimer *> slio_reset_timers;
|
||||||
std::vector<bool> slio_reset_states;
|
std::vector<bool> slio_reset_states;
|
||||||
|
QTimer *slio_poll_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user