Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
FofbTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DG
FOFB
FofbTool
Commits
a83b2bf4
Commit
a83b2bf4
authored
1 year ago
by
BRONES Romain
Browse files
Options
Downloads
Patches
Plain Diff
feat(config): Put tango paths in configuration file
parent
2ddedadc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
FofbTool/Configuration.py
+9
-9
9 additions, 9 deletions
FofbTool/Configuration.py
FofbTool/Utils.py
+35
-76
35 additions, 76 deletions
FofbTool/Utils.py
FofbTool/default.cfg
+13
-0
13 additions, 0 deletions
FofbTool/default.cfg
with
57 additions
and
85 deletions
FofbTool/Configuration.py
+
9
−
9
View file @
a83b2bf4
...
...
@@ -131,9 +131,9 @@ def cellnode_configure_combpm(cellnodename, bpmallowed=None):
# Get device proxy
try
:
p
=
FofbTool
.
Utils
.
tangopath
_cell
nodes
[
cellnodename
.
lower
()]
p
=
config
[
"
tangopath
.fofb
nodes
"
]
[
cellnodename
.
lower
()]
except
KeyError
:
logger
.
error
(
"
Wrong cellnodename. Possibilities are {}
"
.
format
(
FofbTool
.
Utils
.
tangopath
_cell
nodes
.
keys
()))
logger
.
error
(
"
Wrong cellnodename. Possibilities are {}
"
.
format
(
list
(
config
[
'
tangopath
.fofb
nodes
'
]
.
keys
()))
)
return
False
try
:
...
...
@@ -188,9 +188,9 @@ def cellnode_configure_ccn(cellnodename, nbpm=None, npsc=None):
# Get device proxy
try
:
p
=
FofbTool
.
Utils
.
tangopath
_cell
nodes
[
cellnodename
.
lower
()]
p
=
config
[
"
tangopath
.fofb
nodes
"
]
[
cellnodename
.
lower
()]
except
KeyError
:
logger
.
error
(
"
Wrong cellnodename. Possibilities are {}
"
.
format
(
FofbTool
.
Utils
.
tangopath
_cell
nodes
.
keys
()))
logger
.
error
(
"
Wrong cellnodename. Possibilities are {}
"
.
format
(
list
(
config
[
'
tangopath
.fofb
nodes
'
]
.
keys
()))
)
return
False
try
:
...
...
@@ -242,7 +242,7 @@ def centralnode_configure_ccn(nbpm=None, npsc=None):
success: boolean
True if configuration is a success
"""
p
=
FofbTool
.
Utils
.
tangopath
_
nodes
[
"
centralnode
"
]
p
=
config
[
"
tangopath
.fofb
nodes
"
]
[
"
centralnode
"
]
try
:
prx
=
tango
.
DeviceProxy
(
p
)
except
tango
.
DevFailed
as
e
:
...
...
@@ -252,7 +252,7 @@ def centralnode_configure_ccn(nbpm=None, npsc=None):
if
nbpm
is
None
:
logger
.
debug
(
"
Use default value for nbpm
"
)
nbpm
=
[
getconf
(
"
nbpm
"
,
"
ccn
"
,
n
,
'
i
'
)
for
n
in
FofbTool
.
Utils
.
tangopath
_cell
nodes
.
keys
()]
nbpm
=
[
getconf
(
"
nbpm
"
,
"
ccn
"
,
n
,
'
i
'
)
for
n
in
config
[
'
tangopath
.fofb
nodes
'
]
.
keys
()
if
'
cellnode
'
in
n
]
logger
.
debug
(
"
{} bpm expected in the ethernet frame on {}
"
.
format
(
nbpm
,
p
))
if
npsc
is
None
:
...
...
@@ -304,9 +304,9 @@ def cellnode_configure_comcorr(cellnodename, pscid=None, enable=True):
# Get device proxy
try
:
p
=
FofbTool
.
Utils
.
tangopath
_cell
nodes
[
cellnodename
.
lower
()]
p
=
config
[
"
tangopath
.fofb
nodes
"
]
[
cellnodename
.
lower
()]
except
KeyError
:
logger
.
error
(
"
Wrong cellnodename. Possibilities are {}
"
.
format
(
FofbTool
.
Utils
.
tangopath
_cell
nodes
.
keys
()))
logger
.
error
(
"
Wrong cellnodename. Possibilities are {}
"
.
format
(
list
(
config
[
'
tangopath
.fofb
nodes
'
]
.
keys
()))
)
return
False
try
:
...
...
@@ -343,7 +343,7 @@ def centralnode_configure_corr():
"""
Configure the correction algorithm on the centralnode.
"""
p
=
FofbTool
.
Utils
.
tangopath
_
nodes
[
"
centralnode
"
]
p
=
config
[
"
tangopath
.fofb
nodes
"
]
[
"
centralnode
"
]
try
:
prx
=
tango
.
DeviceProxy
(
p
)
except
tango
.
DevFailed
as
e
:
...
...
This diff is collapsed.
Click to expand it.
FofbTool/Utils.py
+
35
−
76
View file @
a83b2bf4
...
...
@@ -15,26 +15,6 @@ import FofbTool.Operation
# Get the module logger
logger
=
logging
.
getLogger
(
"
FofbTool
"
)
tangopath_cellnodes
=
{
"
cellnode-c01
"
:
"
ans/dg/fofb-cellnode-c01
"
,
"
cellnode-c06
"
:
"
ans/dg/fofb-cellnode-c06
"
,
"
cellnode-c09
"
:
"
ans/dg/fofb-cellnode-c09
"
,
"
cellnode-c14
"
:
"
ans/dg/fofb-cellnode-c14
"
,
}
tangopath_nodes
=
{
"
centralnode
"
:
"
ans/dg/fofb-centralnode
"
,
}
tangopath_nodes
.
update
(
tangopath_cellnodes
)
tangopath
=
{
"
fofb-watcher
"
:
"
ans/dg/fofb-watcher
"
,
"
fofb-command
"
:
"
ans/dg/fofb-command
"
,
"
fofb-manager
"
:
"
ans/dg/fofb-manager
"
,
"
bpm-manager
"
:
"
ans/dg/bpm-manager
"
,
}
tangopath
.
update
(
tangopath_nodes
)
def
init_opcua
():
"""
Run init on all OPCUA devices. Catch DevFailed and inform via log.
...
...
@@ -45,7 +25,7 @@ def init_opcua():
logger
.
warning
(
"
Not running configuration of combpm because FOFB seems to be running.
"
)
return
for
i
,(
n
,
p
)
in
enumerate
(
tangopath
_
nodes
.
items
()
)
:
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath
.fofb
nodes
"
]
.
items
():
logger
.
info
(
"
Perform init() on {}
'
{}
'"
.
format
(
n
,
p
))
try
:
tango
.
DeviceProxy
(
p
).
init
()
...
...
@@ -63,11 +43,12 @@ def init_watcher():
logger
.
warning
(
"
Not running configuration of combpm because FOFB seems to be running.
"
)
return
p
=
FofbTool
.
Configuration
.
config
[
"
tangopath
"
][
"
fofb-watcher
"
]
try
:
wprx
=
tango
.
DeviceProxy
(
tangopath
[
"
fofb-watcher
"
]
)
wprx
=
tango
.
DeviceProxy
(
p
)
wprx
.
set_timeout_millis
(
60000
)
except
tango
.
DevFailed
as
e
:
logger
.
error
(
"
Could not get DeviceProxy on {}
"
.
format
(
tangopath
[
"
fofb-watcher
"
]
))
logger
.
error
(
"
Could not get DeviceProxy on {}
"
.
format
(
p
))
logger
.
debug
(
str
(
e
))
return
...
...
@@ -79,17 +60,18 @@ def init_watcher():
logger
.
debug
(
str
(
e
))
logger
.
info
(
"
Perform init() on Fofb-Command.
"
)
p
=
FofbTool
.
Configuration
.
config
[
"
tangopath
"
][
"
fofb-command
"
]
try
:
tango
.
DeviceProxy
(
tangopath
[
"
fofb-command
"
]
).
init
()
tango
.
DeviceProxy
(
p
).
init
()
except
tango
.
DevFailed
as
e
:
logger
.
error
(
"
Could not perform init() on
'
{}
'
, got DevFailed.
"
.
format
(
tangopath
[
'
fofb-command
'
]
))
logger
.
error
(
"
Could not perform init() on
'
{}
'
, got DevFailed.
"
.
format
(
p
))
logger
.
debug
(
str
(
e
))
def
confds_opcua
():
"""
Apply attribute configuration on all OPCUA devices. Catch DevFailed and inform via log.
"""
for
i
,(
n
,
p
)
in
enumerate
(
tangopath
_
nodes
.
items
()
)
:
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath
.fofb
nodes
"
]
.
items
():
try
:
prx
=
tango
.
DeviceProxy
(
p
)
except
tango
.
DevFailed
as
e
:
...
...
@@ -118,10 +100,11 @@ def check_fofbnotrunning():
True if FOFB is not running
"""
p
=
FofbTool
.
Configuration
.
config
[
"
tangopath
"
][
"
fofb-watcher
"
]
try
:
prx
=
tango
.
DeviceProxy
(
tangopath
[
"
fofb-watcher
"
]
)
prx
=
tango
.
DeviceProxy
(
p
)
except
tango
.
DevFailed
as
e
:
logger
.
error
(
"
Failed to get the Device proxy to
'
{}
'"
.
format
(
tangopath
[
"
fofb-watcher
"
]
))
logger
.
error
(
"
Failed to get the Device proxy to
'
{}
'"
.
format
(
p
))
logger
.
debug
(
str
(
e
))
return
False
...
...
@@ -148,9 +131,10 @@ def conf_all_combpm():
return
False
success
=
True
for
i
,(
n
,
p
)
in
enumerate
(
tangopath_cellnodes
.
items
()):
s
=
FofbTool
.
Configuration
.
cellnode_configure_combpm
(
n
)
success
=
success
and
s
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath.fofbnodes
"
].
items
():
if
'
cellnode
'
in
n
:
s
=
FofbTool
.
Configuration
.
cellnode_configure_combpm
(
n
)
success
=
success
and
s
return
success
...
...
@@ -176,9 +160,10 @@ def conf_all_comcorr(enable=True):
return
False
success
=
True
for
i
,(
n
,
p
)
in
enumerate
(
tangopath_cellnodes
.
items
()):
s
=
FofbTool
.
Configuration
.
cellnode_configure_comcorr
(
n
,
enable
=
enable
)
success
=
success
and
s
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath.fofbnodes
"
].
items
():
if
'
cellnode
'
in
n
:
s
=
FofbTool
.
Configuration
.
cellnode_configure_comcorr
(
n
,
enable
=
enable
)
success
=
success
and
s
return
success
...
...
@@ -199,9 +184,10 @@ def conf_all_ccn():
return
False
success
=
True
for
i
,(
n
,
p
)
in
enumerate
(
tangopath_cellnodes
.
items
()):
s
=
FofbTool
.
Configuration
.
cellnode_configure_ccn
(
n
)
success
=
success
and
s
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath.fofbnodes
"
].
items
():
if
'
cellnode
'
in
n
:
s
=
FofbTool
.
Configuration
.
cellnode_configure_ccn
(
n
)
success
=
success
and
s
s
=
FofbTool
.
Configuration
.
centralnode_configure_ccn
()
success
=
success
and
s
...
...
@@ -224,9 +210,9 @@ def get_prx_from_nodename(nodename):
"""
# Get device proxy
try
:
p
=
FofbTool
.
Utils
.
tangopath
_
nodes
[
nodename
.
lower
()]
p
=
FofbTool
.
Configuration
.
config
[
"
tangopath
.fofb
nodes
"
]
[
nodename
.
lower
()]
except
KeyError
:
logger
.
error
(
"
Wrong nodename. Possibilities are {}
"
.
format
(
FofbTool
.
Utils
.
tangopath
_
nodes
.
keys
()))
logger
.
error
(
"
Wrong nodename. Possibilities are {}
"
.
format
(
FofbTool
.
Configuration
.
config
[
"
tangopath
.fofb
nodes
"
]
.
keys
()))
return
None
try
:
...
...
@@ -238,37 +224,8 @@ def get_prx_from_nodename(nodename):
return
prx
def
get_prx_from_cellnodename
(
cellnodename
):
"""
Return a tango.DeviceProxy from a cellnode name.
On failure, log error and return None.
PARAMETERS
----------
nodename: str
The target fofbnode, ie
'
cellnode-c09
'
RETURN
------
prx: tango.DeviceProxy or None
"""
# Get device proxy
try
:
p
=
FofbTool
.
Utils
.
tangopath_cellnodes
[
cellnodename
.
lower
()]
except
KeyError
:
logger
.
error
(
"
Wrong nodename. Possibilities are {}
"
.
format
(
FofbTool
.
Utils
.
tangopath_cellnodes
.
keys
()))
return
None
try
:
prx
=
tango
.
DeviceProxy
(
p
)
except
tango
.
DevFailed
as
e
:
logger
.
error
(
"
Failed to get the Device proxy to
'
{}
'"
.
format
(
p
))
logger
.
debug
(
str
(
e
))
return
None
return
prx
# No more difference
get_prx_from_cellnodename
=
get_prx_from_nodename
def
stop_all_combpm
():
"""
...
...
@@ -280,8 +237,9 @@ def stop_all_combpm():
if
not
check_fofbnotrunning
():
logger
.
warning
(
"
Not running stop combpm because FOFB seems to be running.
"
)
for
i
,(
n
,
p
)
in
enumerate
(
tangopath_cellnodes
.
items
()):
FofbTool
.
Operation
.
stop_combpm
(
n
)
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath.fofbnodes
"
].
items
():
if
'
cellnode
'
in
n
:
FofbTool
.
Operation
.
stop_combpm
(
n
)
def
stop_all_ccn
():
...
...
@@ -294,7 +252,7 @@ def stop_all_ccn():
if
not
check_fofbnotrunning
():
logger
.
warning
(
"
Not running stop combpm because FOFB seems to be running.
"
)
for
i
,(
n
,
p
)
in
enumerate
(
tangopath
_
nodes
.
items
()
)
:
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath
.fofb
nodes
"
]
.
items
():
FofbTool
.
Operation
.
stop_ccn
(
n
)
FofbTool
.
Operation
.
reset_ccn
(
n
)
...
...
@@ -306,8 +264,9 @@ def start_all_combpm():
"""
for
i
,(
n
,
p
)
in
enumerate
(
tangopath_cellnodes
.
items
()):
FofbTool
.
Operation
.
start_combpm
(
n
)
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath.fofbnodes
"
].
items
():
if
'
cellnode
'
in
n
:
FofbTool
.
Operation
.
start_combpm
(
n
)
def
start_all_ccn
():
...
...
@@ -316,7 +275,7 @@ def start_all_ccn():
"""
for
i
,(
n
,
p
)
in
enumerate
(
tangopath
_
nodes
.
items
()
)
:
for
n
,
p
in
FofbTool
.
Configuration
.
config
[
"
tangopath
.fofb
nodes
"
]
.
items
():
FofbTool
.
Operation
.
start_ccn
(
n
)
This diff is collapsed.
Click to expand it.
FofbTool/default.cfg
+
13
−
0
View file @
a83b2bf4
...
...
@@ -90,3 +90,16 @@ pscid = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
numbpm
=
122
[tangopath]
fofb-watcher
=
ans/dg/fofb-watcher
fofb-command
=
ans/dg/fofb-command
fofb-manager
=
ans/dg/fofb-manager
bpm-manager
=
ans/dg/bpm-manager
[tangopath.fofbnodes]
centralnode
=
ans/dg/fofb-centralnode
cellnode-c01
=
ans/dg/fofb-cellnode-c01
cellnode-c06
=
ans/dg/fofb-cellnode-c06
cellnode-c09
=
ans/dg/fofb-cellnode-c09
cellnode-c14
=
ans/dg/fofb-cellnode-c14
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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