Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rpc2tango-bridge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs
ds
rpc2tango-bridge
Commits
8803fa2e
Commit
8803fa2e
authored
4 years ago
by
Claudio Scafuri
Browse files
Options
Downloads
Patches
Plain Diff
removed lots of print sattemets, handle failures of lpc_resolve
parent
96d740ef
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/RPC2TangoBridge.cpp
+19
-3
19 additions, 3 deletions
src/RPC2TangoBridge.cpp
src/RPC2TangoBridge.h
+4
-0
4 additions, 0 deletions
src/RPC2TangoBridge.h
src/RpcHandle.cpp
+17
-11
17 additions, 11 deletions
src/RpcHandle.cpp
src/attribute_converter.cpp
+12
-12
12 additions, 12 deletions
src/attribute_converter.cpp
with
52 additions
and
26 deletions
src/RPC2TangoBridge.cpp
+
19
−
3
View file @
8803fa2e
...
@@ -188,10 +188,21 @@ void RPC2TangoBridge::init_device()
...
@@ -188,10 +188,21 @@ void RPC2TangoBridge::init_device()
* is taken from the configuration file.
* is taken from the configuration file.
*/
*/
set_status
(
"Allocating dynamic attributes"
);
set_status
(
"Allocating dynamic attributes"
);
inserted
=
0
;
failed
=
0
;
AllocateAttributes
();
AllocateAttributes
();
if
(
inserted
==
0
){
set_state
(
Tango
::
FAULT
);
set_status
(
"failed to create all dynamic attributes"
);
}
else
{
set_state
(
Tango
::
ON
);
set_state
(
Tango
::
ON
);
set_status
(
"ON"
);
char
mesg
[
90
];
sprintf
(
mesg
,
"created attributes : %d , failed: %d
\n
"
,
inserted
,
failed
);
string
sts
(
mesg
);
set_status
(
sts
);
}
}
}
...
@@ -298,7 +309,9 @@ void RPC2TangoBridge::AllocateAttributes()
...
@@ -298,7 +309,9 @@ void RPC2TangoBridge::AllocateAttributes()
DEBUG_STREAM
<<
"Aggiunto alla mappa con nome "
<<
name
<<
" e "
<<
spattr
->
get_name
()
<<
" 0x"
<<
spattr
<<
endl
;
DEBUG_STREAM
<<
"Aggiunto alla mappa con nome "
<<
name
<<
" e "
<<
spattr
->
get_name
()
<<
" 0x"
<<
spattr
<<
endl
;
spectrumNamesMap
[
name
]
=
spattr
;
spectrumNamesMap
[
name
]
=
spattr
;
add_attribute
(
spattr
);
add_attribute
(
spattr
);
inserted
++
;
}
}
else
failed
++
;
}
}
else
else
...
@@ -310,17 +323,20 @@ void RPC2TangoBridge::AllocateAttributes()
...
@@ -310,17 +323,20 @@ void RPC2TangoBridge::AllocateAttributes()
/* insert the couple attribute name/BridgeAttr* into the names map */
/* insert the couple attribute name/BridgeAttr* into the names map */
namesMap
[
name
]
=
att
;
namesMap
[
name
]
=
att
;
add_attribute
(
att
);
add_attribute
(
att
);
inserted
++
;
}
}
else
{
ERROR_STREAM
<<
"failed: "
<<
name
<<
endl
;
failed
++
;}
}
}
}
}
catch
(
Tango
::
DevFailed
&
e
)
catch
(
Tango
::
DevFailed
&
e
)
{
{
printException
(
"Error creating attribute"
,
e
);
failed
++
;
printException
(
"Error creating attribute"
,
e
);
}
}
}
/* else: element not already present in the map */
}
/* else: element not already present in the map */
}
}
RPCHandleSet
::
instance
()
->
handleCount
();
RPCHandleSet
::
instance
()
->
handleCount
();
}
}
//+----------------------------------------------------------------------------
//+----------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
src/RPC2TangoBridge.h
+
4
−
0
View file @
8803fa2e
...
@@ -262,6 +262,10 @@ private:
...
@@ -262,6 +262,10 @@ private:
bool
write_dynamic_attribute
(
Tango
::
WAttribute
&
w
);
bool
write_dynamic_attribute
(
Tango
::
WAttribute
&
w
);
void
printException
(
const
char
*
msg
,
Tango
::
DevFailed
&
e
);
void
printException
(
const
char
*
msg
,
Tango
::
DevFailed
&
e
);
bool
force_spectrum
(
char
*
device_property
);
bool
force_spectrum
(
char
*
device_property
);
//coutrer of ok/failed
unsigned
int
inserted
;
unsigned
int
failed
;
// Tango::DevShort *attr_AlarmAttribute_read;
// Tango::DevShort *attr_AlarmAttribute_read;
};
};
...
...
This diff is collapsed.
Click to expand it.
src/RpcHandle.cpp
+
17
−
11
View file @
8803fa2e
...
@@ -43,22 +43,28 @@ RPCHandle::RPCHandle(string rpccall)
...
@@ -43,22 +43,28 @@ RPCHandle::RPCHandle(string rpccall)
}
}
else
/* do not connect(): this will leave _sid to -1 */
else
/* do not connect(): this will leave _sid to -1 */
_lastRpcErr
=
"failed resolving call "
+
rpccall
;
_lastRpcErr
=
"failed resolving call "
+
rpccall
;
}
}
bool
RPCHandle
::
resolve_rpc
(
const
char
*
call
,
char
**
host
,
short
int
*
port
)
bool
RPCHandle
::
resolve_rpc
(
const
char
*
call
,
char
**
host
,
short
int
*
port
)
{
{
int
res
;
int
res
;
char
fam
[
RPCSPLITLEN
],
mem
[
RPCSPLITLEN
],
act
[
RPCSPLITLEN
],
mode
[
RPCSPLITLEN
];
char
fam
[
RPCSPLITLEN
],
mem
[
RPCSPLITLEN
],
act
[
RPCSPLITLEN
],
mode
[
RPCSPLITLEN
];
RpcResolver
resolver
;
if
(
split_rpccall
(
call
,
fam
,
mem
,
act
,
mode
)
>=
0
)
try
{
{
RpcResolver
resolver
;
res
=
resolver
.
resolve
(
fam
,
mem
,
act
,
mode
,
host
,
port
);
if
(
split_rpccall
(
call
,
fam
,
mem
,
act
,
mode
)
>=
0
)
if
(
res
>=
0
&&
host
!=
NULL
)
{
return
true
;
res
=
resolver
.
resolve
(
fam
,
mem
,
act
,
mode
,
host
,
port
);
}
if
(
res
>=
0
&&
host
!=
NULL
)
return
true
;
return
false
;
else
return
false
;
}
}
catch
(...){
return
false
;
}
}
}
RPCHandle
::~
RPCHandle
()
RPCHandle
::~
RPCHandle
()
...
...
This diff is collapsed.
Click to expand it.
src/attribute_converter.cpp
+
12
−
12
View file @
8803fa2e
...
@@ -41,7 +41,7 @@ AttributeConverter::AttributeConverter(char *propertyName, bool force_spectrum)
...
@@ -41,7 +41,7 @@ AttributeConverter::AttributeConverter(char *propertyName, bool force_spectrum)
* returns false and strlen(writeCall) is 0.
* returns false and strlen(writeCall) is 0.
*/
*/
readWrite
=
isReadWrite
(
propertyName
,
readCall
,
writeCall
);
readWrite
=
isReadWrite
(
propertyName
,
readCall
,
writeCall
);
printf
(
"AttributeConverter %s readWrite: %d
\n
"
,
propertyName
,
readWrite
);
//
printf ("AttributeConverter %s readWrite: %d\n",propertyName,readWrite);
/* used to determine data_type below. We refer to read name, we are not
/* used to determine data_type below. We refer to read name, we are not
* interested in write_name. The configuration of the device properties must
* interested in write_name. The configuration of the device properties must
* be consistent, but we do not check it.
* be consistent, but we do not check it.
...
@@ -53,7 +53,7 @@ AttributeConverter::AttributeConverter(char *propertyName, bool force_spectrum)
...
@@ -53,7 +53,7 @@ AttributeConverter::AttributeConverter(char *propertyName, bool force_spectrum)
}
}
data_type
=
data_type_for_mode
(
mode
);
data_type
=
data_type_for_mode
(
mode
);
printf
(
"creating in converter attribute for
\"
%s
\"
: data type:
\"
%s
\"\n
"
,
propertyName
,
dataType
(
data_type
).
c_str
());
//
printf("creating in converter attribute for \"%s\": data type: \"%s\"\n", propertyName, dataType(data_type).c_str());
if
(
data_type
>=
0
&&
(
is_spectrum
(
mode
)
||
force_spectrum
))
if
(
data_type
>=
0
&&
(
is_spectrum
(
mode
)
||
force_spectrum
))
{
{
spectrum
=
true
;
spectrum
=
true
;
...
@@ -181,10 +181,10 @@ SpectrumBridgeAttr* AttributeConverter::createSpectrumAttribute(const char* name
...
@@ -181,10 +181,10 @@ SpectrumBridgeAttr* AttributeConverter::createSpectrumAttribute(const char* name
"READ ONLY spectrum attribute with the same name"
,
name
);
"READ ONLY spectrum attribute with the same name"
,
name
);
if
(
RPCHandle
::
split_rpccall
(
name
,
fam
,
mem
,
act
,
mode
)
<
0
)
if
(
RPCHandle
::
split_rpccall
(
name
,
fam
,
mem
,
act
,
mode
)
<
0
)
{
{
//printf("\e[1;31m*\e[0m Error in RPC data_type: \"%s\"\n", name);
//printf("\e[1;31m*\e[0m Error in RPC data_type: \"%s\"\n", name);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
/* particular case in which we know that the RF is long 32 */
/* particular case in which we know that the RF is long 32 */
if
(
strcmp
(
mode
,
"RF"
)
==
0
)
if
(
strcmp
(
mode
,
"RF"
)
==
0
)
max_x
=
32
;
max_x
=
32
;
...
@@ -208,8 +208,8 @@ SpectrumBridgeAttr* AttributeConverter::createSpectrumAttribute(const char* name
...
@@ -208,8 +208,8 @@ SpectrumBridgeAttr* AttributeConverter::createSpectrumAttribute(const char* name
BridgeAttr
*
AttributeConverter
::
createScalarAttribute
(
const
char
*
name
,
long
int
data_type
)
BridgeAttr
*
AttributeConverter
::
createScalarAttribute
(
const
char
*
name
,
long
int
data_type
)
{
{
printf
(
"createScalarAttribute
%s
\n
"
,
name
)
;
//DEBUG_STREAM <<
"createScalarAttribute
"<<
name;
char
desc
[
256
];
char
desc
[
256
];
char
res
[
256
];
char
res
[
256
];
UserDefaultAttrProp
default_att_prop
;
UserDefaultAttrProp
default_att_prop
;
BridgeAttr
*
attr
;
BridgeAttr
*
attr
;
...
@@ -234,16 +234,16 @@ BridgeAttr* AttributeConverter::createScalarAttribute(const char* name, long int
...
@@ -234,16 +234,16 @@ BridgeAttr* AttributeConverter::createScalarAttribute(const char* name, long int
BridgeAttr
*
AttributeConverter
::
createScalarAttribute
(
const
char
*
name
,
const
char
*
writeName
,
long
int
data_type
)
BridgeAttr
*
AttributeConverter
::
createScalarAttribute
(
const
char
*
name
,
const
char
*
writeName
,
long
int
data_type
)
{
{
printf
(
"createScalarAttribute_write
%s
\n
"
,
name
)
;
//DEBUG_STREAM <<
"create
ScalarAttribute_write
" <<
name;
char
desc
[
256
];
char
desc
[
256
];
char
res
[
256
];
char
res
[
256
];
UserDefaultAttrProp
default_att_prop
;
UserDefaultAttrProp
default_att_prop
;
BridgeAttr
*
attr
;
BridgeAttr
*
attr
;
snprintf
(
desc
,
255
,
"This attribute maps the RPC call
\"
%s
\"
in a tango "
snprintf
(
desc
,
255
,
"This attribute maps the RPC call
\"
%s
\"
in a tango "
"READ WRITE scalar attribute. RPC read call:
\"
%s
\"
write call:
\"
%s
\"
"
,
name
,
name
,
writeName
);
"READ WRITE scalar attribute. RPC read call:
\"
%s
\"
write call:
\"
%s
\"
"
,
name
,
name
,
writeName
);
printf
(
"createScalarAttribute_write %s %s...
\n
"
,
name
,
writeName
);
//
printf("createScalarAttribute_write %s %s...\n",name,writeName);
attr
=
new
BridgeAttr
(
name
,
writeName
,
data_type
,
Tango
::
READ_WRITE
);
attr
=
new
BridgeAttr
(
name
,
writeName
,
data_type
,
Tango
::
READ_WRITE
);
printf
(
".....createScalarAttribute_write %s %s
\n
"
,
name
,
writeName
);
//
printf(".....createScalarAttribute_write %s %s\n",name,writeName);
if
(
attr
!=
NULL
)
if
(
attr
!=
NULL
)
{
{
// snprintf(res, 256, "\e[1;32m* \e[0mcreated \"%s\"\t\e[0;37m[\e[0;32mscalar"
// snprintf(res, 256, "\e[1;32m* \e[0mcreated \"%s\"\t\e[0;37m[\e[0;32mscalar"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment