1
0
mirror of https://github.com/ElvishArtisan/rivendell.git synced 2025-04-24 01:23:13 +02:00
Fred Gleason 7ce4b2ff10 2018-03-11 Fred Gleason <fredg@paravelsystems.com>
* Converted ripcd(8) to use RDApplication.
	* Documented a 'Notification' message type in
	'docs/apis/notification.xml'.
	* Added an 'RDMulticaster' class.
	* Added an 'mcast_recv_test' program in 'tests/'.
	* Added a 'SYSTEM.NOTIFICATION_ADDRESS' field to the database.
	* Incremented the database version to 276.
	* Added an 'Mcast Address for Notifications' control to the
	'System-Wide Settings' dialog in rdadmin(1).
	* Implemented the 'Process Notification' ['ON'] command in
	ripcd(8).
	* Added an 'RDRipc::sendNotification()' method.
	* Added an 'RDRipc::notificationReceived()' signal.
2018-03-11 20:24:39 -04:00

118 lines
2.4 KiB
C++

// sas64000.cpp
//
// A Rivendell switcher driver for the SAS64000
//
// (C) Copyright 2002-2004,2016-2018 Fred Gleason <fredg@paravelsystems.com>
//
// 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 <stdlib.h>
#include <rdapplication.h>
#include "globals.h"
#include "sas64000.h"
Sas64000::Sas64000(RDMatrix *matrix,QObject *parent)
: Switcher(matrix,parent)
{
//
// Get Matrix Parameters
//
sas_inputs=matrix->inputs();
sas_outputs=matrix->outputs();
//
// Initialize the TTY Port
//
RDTty *tty=new RDTty(rda->station()->name(),matrix->port(RDMatrix::Primary));
sas_device=new RDTTYDevice();
if(tty->active()) {
sas_device->setName(tty->port());
sas_device->setSpeed(tty->baudRate());
sas_device->setWordLength(tty->dataBits());
sas_device->setParity(tty->parity());
sas_device->open(IO_Raw|IO_ReadWrite);
}
delete tty;
}
Sas64000::~Sas64000()
{
delete sas_device;
}
RDMatrix::Type Sas64000::type()
{
return RDMatrix::Sas64000;
}
unsigned Sas64000::gpiQuantity()
{
return 0;
}
unsigned Sas64000::gpoQuantity()
{
return 0;
}
bool Sas64000::primaryTtyActive()
{
return true;
}
bool Sas64000::secondaryTtyActive()
{
return false;
}
void Sas64000::processCommand(RDMacro *cmd)
{
switch(cmd->command()) {
case RDMacro::ST:
SendCommand(cmd,"\x54%03d%03d");
break;
default:
cmd->acknowledge(false);
emit rmlEcho(cmd);
break;
}
}
void Sas64000::SendCommand(RDMacro *cmd,const char *format)
{
char str[8];
if((cmd->arg(1).toInt()<0)||(cmd->arg(1).toInt()>sas_inputs)||
(cmd->arg(2).toInt()<0)||(cmd->arg(2).toInt()>sas_outputs)) {
cmd->acknowledge(false);
emit rmlEcho(cmd);
}
sprintf(str,format,cmd->arg(1).toInt(),cmd->arg(2).toInt());
sas_device->writeBlock(str,7);
cmd->acknowledge(true);
emit rmlEcho(cmd);
}