Commit fb440e2e authored by Pavel Vainerman's avatar Pavel Vainerman

(2.0): удалил неиспользуемые классы IOs (AnalogCard,DigitalCard).

parent 9d1305ea
......@@ -36,7 +36,5 @@ Version 2.0
- (DBServer): сделать возможность задать для датчика в configure.xml dbignore="1". Видимо надо встроить это поле в SensorMessgage
- удалить AlarmMessage,InfoMessage,InfoServer,TimerServer(подумать),ISRestorer,MessageInteface_xxx,SystemGuard
т.к. активного распространения не получили (пока-что).
- убрать неиспользуемые нынче классы include/IOs/DigitalCard..
- удалить SandClock.h т.к. он deperecated (вместо него HourGlass.h)
- перейти где нужно на rw-mutex-ы..
- написать документацию по ModbusSlave
......@@ -217,7 +217,6 @@ AC_CONFIG_FILES([Makefile
src/Makefile
include/Makefile
include/modbus/Makefile
include/IOs/Makefile
tests/Makefile
tests/JrnTests/Makefile
tests/UniXmlTest/Makefile
......
/* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Vitaly Lipatov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
/*! \file
* \brief Заголовочный файл для организации низкоуровневого ввода-вывода.
* \author Vitaly Lipatov
*/
// --------------------------------------------------------------------------
#ifndef DIGITALCARD_H__
#define DIGITALCARD_H__
/*! Абстрактный класс работы с цифровым вводом/выводом */
class DigitalCard
{
public:
virtual ~DigitalCard(){};
// virtual bool getCurrentState(int module)=0;
virtual bool get(int module) = 0;
virtual void set(int module, bool state) = 0;
};
#endif
/* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Vitaly Lipatov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
/*! \file
* \brief Заголовочный файл для дискретной карты DIO5600
* \author Vitaly Lipatov
*/
// --------------------------------------------------------------------------
#ifndef __DIO5600_H_
#define __DIO5600_H_
// --------------------------------------------------------------------------
#include "DigitalCard.h"
#include "IOs/IOAccessOld.h"
// портов для функций ввода/вывода
const int DIO5600_A = 0x10;
const int DIO5600_B = 0x02;
const int DIO5600_C_LO = 0x01;
const int DIO5600_C_HI = 0x08;
const int DIO5600_C = (DIO5600_C_LO | DIO5600_C_HI);
class DigitalCard_O5600: public DigitalCard, IOAccess
{
public:
//inline DIO5600() { }
inline DigitalCard_O5600(int ba, char mode)
{
init(1, 0, ba, mode);
}
bool get(int module);
// bool getCurrentState(int module);
void set(int module, bool state);
protected:
// void reinit();
char getMask(int module);
char getPrevious(int module);
int getPort(int module);
void putByte(int port, char val);
int getByte(int ba);
bool init(bool flagInit, int numOfCard, int base_address,char mode);
int baseadr; //
char iomode; //
char portmap[4];
};
#endif
/* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Vitaly Lipatov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
/*! \file
* \brief Заголовочный файл для организации низкоуровневого ввода-вывода.
* \author Vitaly Lipatov
* \par
* Этот файл предназначен для внутреннего использования в классах
* ввода-вывода
*/
// --------------------------------------------------------------------------
#ifndef _IOACCESS_H_
#define _IOACCESS_H_
// --------------------------------------------------------------------------
#include <unistd.h>
#include <fcntl.h>
#include <iostream>
#include "Exceptions.h"
/*! \class IOAccess
* \brief Предоставление операций для низкоуровневого ввода-вывода.
* \author Vitaly Lipatov
* \par
* Этот класс предназначен для внутреннего использования в классах
* ввода-вывода
*/
class IOAccess
{
public:
/// При создании объекта открываются все порты на запись/чтение
IOAccess()
{
fd_port = open("/dev/port", O_RDWR | O_NDELAY);
if ( fd_port == -1 )
throw UniSetTypes::IOBadParam();
}
~IOAccess()
{
close(fd_port);
}
/*! Получение значений из диапазона портов от port до port+size байт.
Записываются по адресу buf.
*/
void get(int port, void* buf, int size) const
{
if ( lseek(fd_port, port, SEEK_SET) == -1 )
throw UniSetTypes::IOBadParam();
ssize_t s = read(fd_port, buf, size);
if ( s != size )
throw UniSetTypes::IOBadParam();
}
/// Получение байта из указанного порта
int in(int port) const
{
char input;
get(port, &input, 1);
return input;
}
/*! Запись значений в диапазон портов от port до port+size байт.
Значения берутся начиная с адреса buf.
*/
void put(int port, const void* buf, int size) const
{
if ( lseek(fd_port, port, SEEK_SET) == -1 )
throw UniSetTypes::IOBadParam();
ssize_t s = write(fd_port, buf, size);
if ( s != size )
throw UniSetTypes::IOBadParam();
}
/// Вывод байта value в порт port
void out(int port, int value) const
{
char output = value;
put(port,&output,1);
}
private:
/// Дескриптор открытого файла, соотнесённого с портами
int fd_port;
};
#endif
/* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Vitaly Lipatov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
/*! \file
* \brief Предоставление операций для низкоуровневого ввода-вывода.
* \author Vitaly Lipatov
*/
// --------------------------------------------------------------------------
#include <unistd.h>
#ifdef __GLIBC__
#include <sys/io.h> // для glibc
#else
#include <asm/io.h>
#endif
#ifndef _IOACCESS_H_
#define _IOACCESS_H_
#include <fcntl.h>
#include <iostream>
#include <iomanip>
#include "Exceptions.h"
/*! \class IOAccess
* \par
* Этот класс предназначен для внутреннего использования в классах
* ввода-вывода
*/
class IOAccess
{
public:
/// При создании объекта открываются все порты на запись/чтение
IOAccess()
{
std::cout << "IOAccess!!" << std::endl;
if (ioperm( 0x100, 0x50, 0666 ) == -1 )
throw UniSetTypes::IOBadParam();
}
~IOAccess()
{
}
/*! Получение значений из диапазона портов от port до port+size байт.
Записываются по адресу buf.
*/
/*
void get(int port, void* buf, int size) const
{
if ( lseek(fd_port, port, SEEK_SET) == -1 )
throw IOBadParam();
ssize_t s = read(fd_port, buf, size);
if ( s != size )
throw IOBadParam();
}
*/
/// Получение байта из указанного порта
int in(int port) const
{
char input;
//get(port, &input, 1);
input = inb( port );
return input;
}
/*! Запись значений в диапазон портов от port до port+size байт.
Значения берутся начиная с адреса buf.
*/
/*
void put(int port, const void* buf, int size) const
{
if ( lseek(fd_port, port, SEEK_SET) == -1 )
throw IOBadParam();
ssize_t s = write(fd_port, buf, size);
if ( s != size )
throw IOBadParam();
}
*/
/// Вывод байта value в порт port
void out(int port, int value) const
{
// char output = value;
//put(port,&output,1);
outb( value, port );
}
private:
/// Дескриптор открытого файла, соотнесённого с портами
int fd_port;
};
#endif
############################################################################
# This file is part of the UniSet library #
############################################################################
# install
ios_include_HEADERS = *.h
#$(shell ls $(top_srcdir)/$(subdir) | grep .h )
ios_includedir = $(includedir)/uniset/IOs
......@@ -2,7 +2,7 @@
# This file is part of the UniSet library #
############################################################################
SUBDIRS=IOs modbus
SUBDIRS=modbus
include $(top_builddir)/conf/common.mk
......
/* This file is part of the UniSet project
* Copyright (c) 2002 Free Software Foundation, Inc.
* Copyright (c) 2002 Pavel Vainerman
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// --------------------------------------------------------------------------
// idea: lav@etersoft.ru
// realisation: pv@etersoft.ru, lav@etersoft.ru
// --------------------------------------------------------------------------
#ifndef SandClock_H_
#define SandClock_H_
// --------------------------------------------------------------------------
/*! WARNING! This class is DEPRECATED! Use HourGlass.. */
// --------------------------------------------------------------------------
#include "PassiveTimer.h"
// --------------------------------------------------------------------------
/*! WARNING! This class is DEPRECATED! Use HourGlass.. */
class SandClock
{
public:
SandClock(): _state(false),_sand(0),_size(0){}
~SandClock(){}
// запустить часы (заново)
inline void run( int msec )
{
t.setTiming(msec);
_state = true;
_sand = msec;
_size = msec;
}
inline void reset ()
{
run(_size);
}
inline int duration()
{
return _size;
}
// перевернуть часы
// true - засечь время
// false - перевернуть часы (обратный ход)
// возвращает аргумент (т.е. идёт ли отсчёт времени)
inline bool rotate( bool st )
{
if( st == _state )
return st;
_state = st;
if( !_state )
{
int cur = t.getCurrent();
_sand -= cur;
if( _sand < 0 )
_sand = 0;
// std::cout << "перевернули: прошло " << cur
// << " осталось " << sand
// << " засекаем " << cur << endl;
t.setTiming(cur);
}
else
{
_sand += t.getCurrent();
if( _sand > _size )
_sand = _size;
// std::cout << "вернули: прошло " << t.getCurrent()
// << " осталось " << sand
// << " засекам " << sand << endl;
t.setTiming(_sand);
}
return st;
}
// получить прошедшее время
// для положения st
inline int current( bool st )
{
return t.getCurrent();
}
// получить заданное время
// для положения st
inline int interval( bool st )
{
return t.getInterval();
}
// проверить наступление
inline bool check()
{
// пока часы не "стоят"
// всегда false
if( !_state )
return false;
return t.checkTime();
}
inline bool state(){ return _state; }
protected:
PassiveTimer t;
bool _state;
int _sand;
int _size;
};
// --------------------------------------------------------------------------
#endif
// --------------------------------------------------------------------------
......@@ -15,7 +15,6 @@ libUniSet_la_LDFLAGS = -version-info @LIBVER@
libUniSet_la_LIBADD = \
$(top_builddir)/src/Communications/libCommunications.la \
$(top_builddir)/src/Communications/Modbus/libModbus.la \
$(top_builddir)/src/IOs/libIOs.la \
$(top_builddir)/src/Interfaces/libInterfaces.la \
$(top_builddir)/src/ObjectRepository/libObjectsRepository.la \
$(top_builddir)/src/Processes/libProcesses.la \
......
// This file is part of the NCS project. (c) 1999-2000 All rights reserved.
// 14-ти битная аналоговая карта 16 входов (8 дифф), 2 выхода (12-ти битные)
/*
#include <assert.h>
#include "conf.h"
#include "IOPort.h"
#include "IOs/AnalogCardAI165A.h"
#include "SysTimer.h"
#include "Exceptions.h"
//-----------------------------------------------------------------------------
AnalogCardAI165A::AnalogCardAI165A( void )
{
if( ioperm( base_io_adr, 0x10, PORT_PERMISSION ) == -1 )
throw GlobalError("Невозможно открыть порты");
if (!((inb(base_io_adr+14)=='A')&&(inb(base_io_adr+15)==17)))
throw GlobalError("Модуль AI16-5a-STB с FIFO не найден !");
outw(0x0000,base_io_adr+0);
// Умножение входного сигнала
int u=0x0000;
// u=0x5555;
// case 2 : n=0xAAAA; break;
// case 3 : n=0xFFFF; break;
outw(u,base_io_adr+6);
outw(u,base_io_adr+8);
maxInputChannel=16;
}
//-----------------------------------------------------------------------------
AnalogCardAI165A::~AnalogCardAI165A( void )
{
}
//-----------------------------------------------------------------------------
int AnalogCardAI165A::getValue( int io_channel )
{
assert(io_channel>=0);
assert(io_channel<16);
// if(io_channel>=16)
// printf("%d\n",io_channel);
// io_channel&=0x0F;
outb(0x00, base_io_adr+0);
io_channel|=0x20; // Однопроводное подключение
outb(io_channel, base_io_adr+2);
msleep(10); // можно поставить for (int i=0;i<90;i++);
//int o=inb(base_io_adr+0);
//outb((o&240)|0x80, base_io_adr+0);
outb(0x80, base_io_adr+0); // ST_RDY Старт АЦП
//for (int i=0; i<60; i++); // pause
//while(!(inb(base_io_adr+0)&0x80)); // ST_RDY
while(!(inb(base_io_adr+0)&0x20));
int r=inw(base_io_adr+2);
if (r<0) r=-1;
//if (r>8191) r=8191;
return r;
}
void AnalogCardAI165A::getChainValue( long * data, const int NumChannel )
{
assert(NumChannel>=0);
assert(NumChannel<16);
outw(0x00, base_io_adr+0);
int io_channel=0;
io_channel|=0x20; // Однопроводное подключение
outb(io_channel, base_io_adr+2);
msleep(1);
for(int n=0; n< NumChannel; n++)
{
outb(0x80|0x01, base_io_adr+0); // ST_RDY | n++
while(!(inb(base_io_adr+0)&0x80)); // ST_RDY // Опрос бита готовности
data[n]=inw(base_io_adr+2);
// может быть здесь все же нужна пауза?
}
outw(0x00, base_io_adr+0);
}
//-----------------------------------------------------------------------------
// !!! Не устанавливается номер канала
void AnalogCardAI165A::setValue( int io_channel, int value )
// io_channel -- 0 or 1
{
assert(io_channel==0 || io_channel==1 );
if (value<0)
value=0;
else if (value>4095)
value=4095;
io_channel&=1;
io_channel<<=12;
value&=0x0FFF;
outw(value,base_io_adr+14);
outb(value,base_io_adr+14);
}
*/
/***************************************************************************
* This file is part of the UniSet* library *
* Copyright (C) 1999-2002 SET Research Institute. All rights reserved. *
***************************************************************************/
/*! \file
* \brief Класс для дискретной карты O5600
* \author Vitaly Lipatov
*/
/**************************************************************************/
#include <assert.h>
#include "IOs/DigitalCard_O5600.h"
#include "Exceptions.h"
using namespace std;
// Получить маску для модуля module
char DigitalCard_O5600::getMask( int module )
{
assert ( module >= 0 && module < 24 );
return 1 << ( module & 0x07 );
}
// Получить адрес порта для указанного модуля
int DigitalCard_O5600::getPort( int module )
{
//assert( baseadr + 2 < SIZE_OF_PORTMAP );
if ( ( module >= 0 ) && ( module < 8 ) )
{
return baseadr + 2; // C
}
else if ( module > 7 && module < 16 )
{
return baseadr + 0; // A
}
else if ( module > 15 && module < 24 )
{
return baseadr + 1; // B
}
// Чего за ерунду передаете?!!
//logErr.Save( "Неправильный номер модуля для функции GetPort, module=%d", module );
//throw Exceptions::OutOfRange();
return baseadr;
}
bool DigitalCard_O5600::get( int module )
{
char tmp = ~in( getPort( module ) );
return tmp & getMask( module );
}
char DigitalCard_O5600::getPrevious( int module )
{
assert ( getPort( module ) - baseadr >= 0 );
assert ( getPort( module ) - baseadr < 4 );
return portmap[ getPort( module ) - baseadr ];
}
/*
bool DigitalCard_O5600::getCurrentState( int module )
{
return getPrevious( module ) & getMask( module );
}
*/
void DigitalCard_O5600::putByte( int ba, char val )
{
portmap[ba - baseadr] = val;
out( ba, ~val );
}
int DigitalCard_O5600::getByte( int ba )
{
char tmp = ~in( ba );
return tmp;
}
void DigitalCard_O5600::set( int module, bool state )
{
char val = getPrevious( module );
char mask = getMask( module );
if ( state )
val |= mask;
else
val &= ~mask;
putByte( getPort( module ), val );
}
bool DigitalCard_O5600::init( bool flagInit, int numOfCard, int base_address, char mode )
{
//if ( !Card.portmap )
// logIO.Save( "DigitalCard_O5600: Вызвана Init без предварительного получения памяти" );
//this->numOfCard = numOfCard;
baseadr = base_address;
cout << "baseadr=" << baseadr << endl;
iomode = mode;
//logReg.Save( "DigitalCard_O5600: Начали" );
out( baseadr + 0x03, iomode | 0x80 ); // Настройка режима карты
for ( int k = 0;k < 3;k++ )
{
putByte( baseadr + k, 0 );
}
if ( in( baseadr + 0x03 ) == 0xff ) // Нет карты
return false;
//logReg.Save( "DigitalCard_O5600: Установлен" );
return true;
}
############################################################################
# This file is part of the UniSet library #
############################################################################
noinst_LTLIBRARIES = libIOs.la
libIOs_la_SOURCES = AnalogCard_AI165A.cc DigitalCard_O5600.cc
include $(top_builddir)/conf/setting.mk
......@@ -2,7 +2,7 @@
# This file is part of the UniSet library #
############################################################################
SUBDIRS=ObjectRepository Processes Interfaces Timers IOs Services Various Communications
SUBDIRS=ObjectRepository Processes Interfaces Timers Services Various Communications
include $(top_builddir)/conf/common.mk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment