Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
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
LOFAR2.0
tango
Commits
ca680788
Commit
ca680788
authored
4 years ago
by
Thomas Juerges
Browse files
Options
Downloads
Patches
Plain Diff
Finish (again) the crossecho client for Tango API
parent
630821cb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
crossechoTangoDev/Crossecho.py
+27
-17
27 additions, 17 deletions
crossechoTangoDev/Crossecho.py
with
27 additions
and
17 deletions
crossechoTangoDev/Crossecho.py
+
27
−
17
View file @
ca680788
...
...
@@ -23,7 +23,7 @@ from PyTango import AttrQuality, DispLevel, DevState
from
PyTango
import
AttrWriteType
,
PipeWriteType
# Additional import
# PROTECTED REGION ID(Crossecho.additionnal_import) ENABLED START #
from
lib.opc_interface
import
connect_to_server
,
DEFAULT_URI
from
opcua
import
Client
import
numpy
# PROTECTED REGION END # // Crossecho.additionnal_import
...
...
@@ -50,6 +50,10 @@ class Crossecho(Device):
dtype
=
'
str
'
,
default_value
=
"
55555
"
)
OPC_time_out
=
device_property
(
dtype
=
,
default_value
=
1000
)
# ----------
# Attributes
# ----------
...
...
@@ -79,20 +83,26 @@ class Crossecho(Device):
def
init_device
(
self
):
Device
.
init_device
(
self
)
# PROTECTED REGION ID(Crossecho.init_device) ENABLED START #
self
.
client
=
connect_to_server
(
self
.
OPC_Server_Name
,
self
.
OPC_Server_Port
)
self
.
objects
=
self
.
client
.
get_objects_node
()
self
.
idx
=
self
.
client
.
get_namespace_index
(
DEFAULT_URI
)
# Now getting a variable node using its browse path
self
.
opc_obj
=
self
.
client
.
get_root_node
().
get_child
([
"
0:Objects
"
,
"
{}:StationMetrics
"
.
format
(
idx
),
"
{}:RCU
"
.
format
(
idx
)])
try
:
self
.
client
=
Client
(
"
opc.tcp://{}:{}/
"
.
format
(
self
.
OPC_Server_Name
,
self
.
OPC_Server_Port
),
self
.
OPC_time_out
)
self
.
client
.
connect
()
self
.
client
.
load_type_definitions
()
objects
=
self
.
client
.
get_objects_node
()
idx
=
self
.
client
.
get_namespace_index
(
DEFAULT_URI
)
# Now getting a variable node using its browse path
self
.
opc_obj
=
self
.
client
.
get_root_node
().
get_child
([
"
0:Objects
"
,
"
{}:StationMetrics
"
.
format
(
idx
),
"
{}:RCU
"
.
format
(
idx
)])
self
.
logger
.
info
(
"
Connected to the OPC-UA server %s
"
,
self
.
OPC_Server_Name
)
except
:
self
.
logger
.
error
(
"
Failed to connect to the OPC-UA server %s. Traceback: %s
"
,
self
.
OPC_Server_Name
,
traceback
.
format_exc
())
# PROTECTED REGION END # // Crossecho.init_device
def
always_executed_hook
(
self
):
# PROTECTED REGION ID(Crossecho.always_executed_hook) ENABLED START #
pass
# PROTECTED REGION END # // Crossecho.always_executed_hook
# PROTECTED REGION E
logg
ND # // Crossecho.always_executed_hook
def
delete_device
(
self
):
# PROTECTED REGION ID(Crossecho.delete_device) ENABLED START #
...
...
@@ -106,12 +116,12 @@ class Crossecho(Device):
def
read_RCU_modes
(
self
):
# PROTECTED REGION ID(Crossecho.RCU_modes_read) ENABLED START #
return
[
''
]
return
self
.
RCU_modes
# PROTECTED REGION END # // Crossecho.RCU_modes_read
def
read_crosslet_stat
(
self
):
# PROTECTED REGION ID(Crossecho.crosslet_stat_read) ENABLED START #
return
[
0.0
]
return
crosslet_stat
# PROTECTED REGION END # // Crossecho.crosslet_stat_read
...
...
@@ -121,7 +131,7 @@ class Crossecho(Device):
def
read_xlt_stat
(
self
):
# PROTECTED REGION ID(Crossecho.xlt_stat_read) ENABLED START #
return
dict
(
x
=
0
,
y
=
0
)
return
dict
(
x
=
self
.
crosslet_stat
,
y
=
self
.
RCU_modes
)
# PROTECTED REGION END # // Crossecho.xlt_stat_read
# --------
...
...
@@ -134,10 +144,10 @@ class Crossecho(Device):
def
record_cross
(
self
):
# PROTECTED REGION ID(Crossecho.record_cross) ENABLED START #
if
self
.
is_record_cross_allowed
()
is
True
:
timeStamp
,
crosslet
S
tat
s
,
rcuM
odes
=
self
.
opc_obj
.
call_method
(
"
{}:record_cross
"
.
format
(
idx
),
self
.
subBand
,
self
.
integrationTime
)
print
(
"
Timestamp is
"
,
result
[
0
]
)
print
(
"
Crosscorrelations are
"
,
numpy
.
array
(
result
[
1
])
)
print
(
"
RCU modes are
"
,
numpy
.
array
(
result
[
2
])
)
timeStamp
,
self
.
crosslet
_s
tat
,
self
.
RCU_m
odes
=
self
.
opc_obj
.
call_method
(
"
{}:record_cross
"
.
format
(
idx
),
self
.
subBand
,
self
.
integrationTime
)
print
(
"
Timestamp is
"
,
timeStamp
)
print
(
"
Crosscorrelations are
"
,
self
.
crosslet_stat
)
print
(
"
RCU modes are
"
,
self
.
RCU_modes
)
# PROTECTED REGION END # // Crossecho.record_cross
...
...
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