Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
54f51f78
Commit
54f51f78
authored
Aug 25, 2016
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(UInterface): небольшой рефакторинг
(попытка удалить лишний код, функции сделать const)
parent
9ff758dc
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
40 deletions
+28
-40
libuniset2.spec
conf/libuniset2.spec
+5
-1
SMInterface.cc
extensions/lib/SMInterface.cc
+1
-1
UInterface.h
include/UInterface.h
+6
-16
UInterface.cc
src/Interfaces/UInterface.cc
+16
-22
No files found.
conf/libuniset2.spec
View file @
54f51f78
...
...
@@ -14,7 +14,7 @@
Name: libuniset2
Version: 2.5
Release: alt1.
1
Release: alt1.
2
Summary: UniSet - library for building distributed industrial control systems
License: LGPL
...
...
@@ -484,6 +484,10 @@ mv -f %buildroot%python_sitelibdir_noarch/* %buildroot%python_sitelibdir/%oname
# ..
%changelog
* Thu Aug 25 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt1.2
- (UNetUDP): add debug information (getInfo)
- minor fixes
* Wed Aug 24 2016 Pavel Vainerman <pv@altlinux.ru> 2.5-alt1.1
- codegen: make readonly in-variables
...
...
extensions/lib/SMInterface.cc
View file @
54f51f78
...
...
@@ -127,7 +127,7 @@ using namespace UniSetTypes;
si
.
node
=
ui
->
getConf
()
->
getLocalNode
();
BEG_FUNC1
(
SMInterface
::
setValue
)
ui
->
fastS
etValue
(
si
,
value
,
myid
);
ui
->
s
etValue
(
si
,
value
,
myid
);
return
;
END_FUNC
(
SMInterface
::
setValue
)
}
...
...
include/UInterface.h
View file @
54f51f78
...
...
@@ -37,23 +37,13 @@
#include "Configuration.h"
// -----------------------------------------------------------------------------------------
/*! \namespace UniversalIO
* Пространство имен содержащее классы, функции и т.п. для работы с вводом/выводом
*/
namespace
UniversalIO
{
/*! Время ожидания ответа */
const
timeout_t
defaultTimeOut
=
3
;
// [сек]
}
// -----------------------------------------------------------------------------------------
#define UI_THROW_EXCEPTIONS UniSetTypes::TimeOut,UniSetTypes::IOBadParam,UniSetTypes::ORepFailed
// -----------------------------------------------------------------------------------------
/*!
* \class UInterface
* Универсальный интерфейс для взаимодействия между объектами (процессами).
* По сути является "фасадом" к реализации механизма взамиодействия
* в libuniset (основанном на CORBA) Хотя до конца скрыть CORBA-у пока не удалось.
* в libuniset (основанном на CORBA) Хотя до конца скрыть CORBA-у пока не удалось.
* Для увеличения производительности в функции встроен cache обращений...
*
* См. также \ref UniversalIOControllerPage
...
...
@@ -70,18 +60,18 @@ class UInterface
// Работа с датчиками
//! Получение состояния датчика
long
getValue
(
const
UniSetTypes
::
ObjectId
id
,
const
UniSetTypes
::
ObjectId
node
)
const
throw
(
UI_THROW_EXCEPTIONS
);
long
getValue
(
const
UniSetTypes
::
ObjectId
id
,
const
UniSetTypes
::
ObjectId
node
)
const
throw
(
UI_THROW_EXCEPTIONS
);
long
getValue
(
const
UniSetTypes
::
ObjectId
id
)
const
;
long
getRawValue
(
const
IOController_i
::
SensorInfo
&
si
);
//! Выставление состояния датчика
void
setValue
(
const
UniSetTypes
::
ObjectId
id
,
long
value
,
const
UniSetTypes
::
ObjectId
node
)
const
throw
(
UI_THROW_EXCEPTIONS
);
void
setValue
(
const
UniSetTypes
::
ObjectId
id
,
long
value
,
const
UniSetTypes
::
ObjectId
node
,
UniSetTypes
::
ObjectId
sup_id
=
UniSetTypes
::
DefaultObjectId
)
const
throw
(
UI_THROW_EXCEPTIONS
);
void
setValue
(
const
UniSetTypes
::
ObjectId
id
,
long
value
)
const
;
void
setValue
(
const
IOController_i
::
SensorInfo
&
si
,
long
value
,
const
UniSetTypes
::
ObjectId
supplier
);
void
setValue
(
const
IOController_i
::
SensorInfo
&
si
,
long
value
,
const
UniSetTypes
::
ObjectId
supplier
)
const
;
// fast - это удалённый вызов "без подтверждения", он быстрее, но менее надёжен
// т.к. вызывающий никогда не узнает об ошибке, если она была (датчик такой не найдён и т.п.)
void
fastSetValue
(
const
IOController_i
::
SensorInfo
&
si
,
long
value
,
UniSetTypes
::
ObjectId
supplier
);
void
fastSetValue
(
const
IOController_i
::
SensorInfo
&
si
,
long
value
,
UniSetTypes
::
ObjectId
supplier
)
const
;
//! Получение состояния для списка указанных датчиков
IOController_i
::
SensorInfoSeq_var
getSensorSeq
(
const
UniSetTypes
::
IDList
&
lst
);
...
...
@@ -178,7 +168,7 @@ class UInterface
return
rep
.
resolve
(
oind
->
getNameById
(
id
)
);
}
UniSetTypes
::
ObjectPtr
resolve
(
const
UniSetTypes
::
ObjectId
id
,
const
UniSetTypes
::
ObjectId
nodeName
,
int
timeoutMS
=
UniversalIO
::
defaultTimeOut
)
const
UniSetTypes
::
ObjectPtr
resolve
(
const
UniSetTypes
::
ObjectId
id
,
const
UniSetTypes
::
ObjectId
nodeName
)
const
throw
(
UniSetTypes
::
ResolveNameError
,
UniSetTypes
::
TimeOut
);
...
...
src/Interfaces/UInterface.cc
View file @
54f51f78
...
...
@@ -282,7 +282,7 @@ void UInterface::setUndefinedState( const IOController_i::SensorInfo& si, bool u
* \return текущее значение датчика
* \exception IOBadParam - генерируется если указано неправильное имя вывода или секции
*/
void
UInterface
::
setValue
(
const
ObjectId
id
,
long
value
,
const
ObjectId
node
)
const
void
UInterface
::
setValue
(
const
ObjectId
id
,
long
value
,
const
ObjectId
node
,
const
UniSetTypes
::
ObjectId
sup_id
)
const
throw
(
UI_THROW_EXCEPTIONS
)
{
if
(
id
==
DefaultObjectId
)
...
...
@@ -291,10 +291,17 @@ throw(UI_THROW_EXCEPTIONS)
if
(
node
==
DefaultObjectId
)
{
ostringstream
err
;
err
<<
"UI(
askRemoteSensor
): id='"
<<
id
<<
"' error: node=UniSetTypes::DefaultObjectId"
;
err
<<
"UI(
setValue
): id='"
<<
id
<<
"' error: node=UniSetTypes::DefaultObjectId"
;
throw
ORepFailed
(
err
.
str
());
}
/*
if ( sup_id == DefaultObjectId )
{
ostringstream err;
err << "UI(setValue): id='" << id << "' error: supplier=UniSetTypes::DefaultObjectId";
throw ORepFailed(err.str());
}
*/
try
{
CORBA
::
Object_var
oref
;
...
...
@@ -313,7 +320,7 @@ throw(UI_THROW_EXCEPTIONS)
oref
=
resolve
(
id
,
node
);
IOController_i_var
iom
=
IOController_i
::
_narrow
(
oref
);
iom
->
setValue
(
id
,
value
,
my
id
);
iom
->
setValue
(
id
,
value
,
sup_
id
);
return
;
}
catch
(
const
CORBA
::
TRANSIENT
&
)
{}
...
...
@@ -365,31 +372,18 @@ throw(UI_THROW_EXCEPTIONS)
void
UInterface
::
setValue
(
const
ObjectId
name
,
long
value
)
const
{
setValue
(
name
,
value
,
uconf
->
getLocalNode
());
setValue
(
name
,
value
,
uconf
->
getLocalNode
()
,
myid
);
}
void
UInterface
::
setValue
(
const
IOController_i
::
SensorInfo
&
si
,
long
value
,
const
UniSetTypes
::
ObjectId
sup
plier
)
void
UInterface
::
setValue
(
const
IOController_i
::
SensorInfo
&
si
,
long
value
,
const
UniSetTypes
::
ObjectId
sup
_id
)
const
{
ObjectId
old
=
myid
;
try
{
myid
=
supplier
;
setValue
(
si
.
id
,
value
,
si
.
node
);
}
catch
(...)
{
myid
=
old
;
throw
;
}
myid
=
old
;
setValue
(
si
.
id
,
value
,
si
.
node
,
sup_id
);
}
// ------------------------------------------------------------------------------------------------------------
// функция не вырабатывает исключий!
void
UInterface
::
fastSetValue
(
const
IOController_i
::
SensorInfo
&
si
,
long
value
,
UniSetTypes
::
ObjectId
sup_id
)
void
UInterface
::
fastSetValue
(
const
IOController_i
::
SensorInfo
&
si
,
long
value
,
UniSetTypes
::
ObjectId
sup_id
)
const
{
if
(
si
.
id
==
DefaultObjectId
)
{
...
...
@@ -805,7 +799,7 @@ void UInterface::unregister( const ObjectId id )throw(ORepFailed)
}
// ------------------------------------------------------------------------------------------------------------
ObjectPtr
UInterface
::
resolve
(
const
ObjectId
rid
,
const
ObjectId
node
,
int
timeoutSec
)
const
ObjectPtr
UInterface
::
resolve
(
const
ObjectId
rid
,
const
ObjectId
node
)
const
throw
(
ResolveNameError
,
UniSetTypes
::
TimeOut
)
{
if
(
rid
==
DefaultObjectId
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment