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
dd1958d6
Commit
dd1958d6
authored
4 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Touchups.
parent
057d3a82
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
RCUSCC/RCUSCC/RCUSCC.py
+21
-22
21 additions, 22 deletions
RCUSCC/RCUSCC/RCUSCC.py
with
21 additions
and
22 deletions
RCUSCC/RCUSCC/RCUSCC.py
+
21
−
22
View file @
dd1958d6
...
@@ -49,11 +49,9 @@ def only_when_on(func):
...
@@ -49,11 +49,9 @@ def only_when_on(func):
return
when_on_wrapper
return
when_on_wrapper
def
fault_on_
opcua_
error
(
func
):
def
fault_on_error
(
func
):
"""
"""
Wrapper to catch exceptions generated by the OPC-UA connection.
Wrapper to catch exceptions. Sets the device in a FAULT state if any occurs.
Sets the device in a FAULT state if that occurs.
"""
"""
@wraps
(
func
)
@wraps
(
func
)
...
@@ -69,7 +67,8 @@ def fault_on_opcua_error(func):
...
@@ -69,7 +67,8 @@ def fault_on_opcua_error(func):
class
OPCUAConnection
(
Thread
):
class
OPCUAConnection
(
Thread
):
"""
"""
Run a connector function in the background, until it succeeds.
Connects to OPC-UA in the foreground or background, and sends HELLO
messages to keep a check on the connection. On connection failure, reconnects once.
"""
"""
def
__init__
(
self
,
client
,
on_func
,
fault_func
,
streams
,
try_interval
=
2
):
def
__init__
(
self
,
client
,
on_func
,
fault_func
,
streams
,
try_interval
=
2
):
...
@@ -410,21 +409,21 @@ class RCUSCC(Device):
...
@@ -410,21 +409,21 @@ class RCUSCC(Device):
# ------------------
# ------------------
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_Attenuator_R
(
self
):
def
read_Attenuator_R
(
self
):
"""
Return the Attenuator_R attribute.
"""
"""
Return the Attenuator_R attribute.
"""
self
.
_Attenuator_R
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Attenuator_R
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Attenuator_R
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
Attenuator_R
"
][
2
].
get_value
()])
self
.
_Attenuator_R
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Attenuator_R
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Attenuator_R
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
Attenuator_R
"
][
2
].
get_value
()])
return
self
.
_Attenuator_R
return
self
.
_Attenuator_R
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_Attenuator_RW
(
self
):
def
read_Attenuator_RW
(
self
):
"""
Return the Attenuator_R attribute.
"""
"""
Return the Attenuator_R attribute.
"""
self
.
_Attenuator_RW
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Attenuator_RW
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Attenuator_RW
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
Attenuator_RW
"
][
2
].
get_value
()])
self
.
_Attenuator_RW
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Attenuator_RW
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Attenuator_RW
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
Attenuator_RW
"
][
2
].
get_value
()])
return
self
.
_Attenuator_RW
return
self
.
_Attenuator_RW
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
write_Attenuator_RW
(
self
,
value
):
def
write_Attenuator_RW
(
self
,
value
):
"""
Set the Attenuator_RW attribute.
"""
"""
Set the Attenuator_RW attribute.
"""
self
.
attribute_mapping
[
"
Attenuator_RW
"
][
0
].
set_value
(
value
[
0
].
tolist
())
self
.
attribute_mapping
[
"
Attenuator_RW
"
][
0
].
set_value
(
value
[
0
].
tolist
())
...
@@ -433,21 +432,21 @@ class RCUSCC(Device):
...
@@ -433,21 +432,21 @@ class RCUSCC(Device):
self
.
_Attenuator_RW
=
value
self
.
_Attenuator_RW
=
value
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_Band_R
(
self
):
def
read_Band_R
(
self
):
"""
Return the Band_R attribute.
"""
"""
Return the Band_R attribute.
"""
self
.
_Band_R
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Band_R
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Band_R
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
Band_R
"
][
2
].
get_value
()])
self
.
_Band_R
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Band_R
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Band_R
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
Band_R
"
][
2
].
get_value
()])
return
self
.
_Band_R
return
self
.
_Band_R
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_Band_RW
(
self
):
def
read_Band_RW
(
self
):
"""
Return the Band_R attribute.
"""
"""
Return the Band_R attribute.
"""
self
.
_Band_RW
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Band_RW
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Band_RW
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
Band_RW
"
][
2
].
get_value
()])
self
.
_Band_RW
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Band_RW
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Band_RW
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
Band_RW
"
][
2
].
get_value
()])
return
self
.
_Band_RW
return
self
.
_Band_RW
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
write_Band_RW
(
self
,
value
):
def
write_Band_RW
(
self
,
value
):
"""
Set the Band_RW attribute.
"""
"""
Set the Band_RW attribute.
"""
self
.
attribute_mapping
[
"
Band_RW
"
][
0
].
set_value
(
value
[
0
].
tolist
())
self
.
attribute_mapping
[
"
Band_RW
"
][
0
].
set_value
(
value
[
0
].
tolist
())
...
@@ -456,28 +455,28 @@ class RCUSCC(Device):
...
@@ -456,28 +455,28 @@ class RCUSCC(Device):
self
.
_Band_RW
=
value
self
.
_Band_RW
=
value
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_ADC_JESD_R
(
self
):
def
read_ADC_JESD_R
(
self
):
"""
Return the
Band
_R attribute.
"""
"""
Return the
ADC_JESD
_R attribute.
"""
self
.
_ADC_JESD_R
=
numpy
.
array
([
self
.
attribute_mapping
[
"
ADC_JESD_R
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
ADC_JESD_R
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
ADC_JESD_R
"
][
2
].
get_value
()])
self
.
_ADC_JESD_R
=
numpy
.
array
([
self
.
attribute_mapping
[
"
ADC_JESD_R
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
ADC_JESD_R
"
][
1
].
get_value
(),
self
.
attribute_mapping
[
"
ADC_JESD_R
"
][
2
].
get_value
()])
return
self
.
_ADC_JESD_R
return
self
.
_ADC_JESD_R
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_Dither_Frequency_R
(
self
):
def
read_Dither_Frequency_R
(
self
):
"""
Return the Dither_Frequency_R attribute.
"""
"""
Return the Dither_Frequency_R attribute.
"""
self
.
_Dither_Frequency_R
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Dither_Frequency_R
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Dither_Frequency_R
"
][
1
].
get_value
()])
self
.
_Dither_Frequency_R
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Dither_Frequency_R
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Dither_Frequency_R
"
][
1
].
get_value
()])
return
self
.
_Dither_Frequency_R
return
self
.
_Dither_Frequency_R
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_Dither_Frequency_RW
(
self
):
def
read_Dither_Frequency_RW
(
self
):
"""
Return the Dither_Frequency_R attribute.
"""
"""
Return the Dither_Frequency_R attribute.
"""
self
.
_Dither_Frequency_RW
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Dither_Frequency_RW
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Dither_Frequency_RW
"
][
1
].
get_value
()])
self
.
_Dither_Frequency_RW
=
numpy
.
array
([
self
.
attribute_mapping
[
"
Dither_Frequency_RW
"
][
0
].
get_value
(),
self
.
attribute_mapping
[
"
Dither_Frequency_RW
"
][
1
].
get_value
()])
return
self
.
_Dither_Frequency_RW
return
self
.
_Dither_Frequency_RW
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
write_Dither_Frequency_RW
(
self
,
value
):
def
write_Dither_Frequency_RW
(
self
,
value
):
"""
Set the Dither_Frequency_RW attribute.
"""
"""
Set the Dither_Frequency_RW attribute.
"""
self
.
attribute_mapping
[
"
Dither_Frequency_RW
"
][
0
].
set_value
(
value
[
0
].
tolist
())
self
.
attribute_mapping
[
"
Dither_Frequency_RW
"
][
0
].
set_value
(
value
[
0
].
tolist
())
...
@@ -485,42 +484,42 @@ class RCUSCC(Device):
...
@@ -485,42 +484,42 @@ class RCUSCC(Device):
self
.
_Dither_Frequency_RW
=
value
self
.
_Dither_Frequency_RW
=
value
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_LED_R
(
self
):
def
read_LED_R
(
self
):
"""
Return the LED_R attribute.
"""
"""
Return the LED_R attribute.
"""
self
.
_LED_R
=
self
.
attribute_mapping
[
"
LED_R
"
].
get_value
()
self
.
_LED_R
=
self
.
attribute_mapping
[
"
LED_R
"
].
get_value
()
return
self
.
_LED_R
return
self
.
_LED_R
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_LED_RW
(
self
):
def
read_LED_RW
(
self
):
"""
Return the LED_RW attribute.
"""
"""
Return the LED_RW attribute.
"""
self
.
_LED_RW
=
self
.
attribute_mapping
[
"
LED_RW
"
].
get_value
()
self
.
_LED_RW
=
self
.
attribute_mapping
[
"
LED_RW
"
].
get_value
()
return
self
.
_LED_RW
return
self
.
_LED_RW
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
write_LED_RW
(
self
,
value
):
def
write_LED_RW
(
self
,
value
):
"""
Set the LED_RW attribute.
"""
"""
Set the LED_RW attribute.
"""
self
.
attribute_mapping
[
"
LED_RW
"
].
set_value
(
value
.
tolist
())
self
.
attribute_mapping
[
"
LED_RW
"
].
set_value
(
value
.
tolist
())
self
.
_LED_RW
=
value
self
.
_LED_RW
=
value
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_Pwr_dig_R
(
self
):
def
read_Pwr_dig_R
(
self
):
"""
Return the Pwr_dig_R attribute.
"""
"""
Return the Pwr_dig_R attribute.
"""
self
.
_Pwr_dig_R
=
self
.
attribute_mapping
[
"
Pwr_dig_R
"
].
get_value
()
self
.
_Pwr_dig_R
=
self
.
attribute_mapping
[
"
Pwr_dig_R
"
].
get_value
()
return
self
.
_Pwr_dig_R
return
self
.
_Pwr_dig_R
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_Temperature_R
(
self
):
def
read_Temperature_R
(
self
):
"""
Return the Temperature_R attribute.
"""
"""
Return the Temperature_R attribute.
"""
self
.
_Temperature_R
=
self
.
attribute_mapping
[
"
Temperature_R
"
].
get_value
()
self
.
_Temperature_R
=
self
.
attribute_mapping
[
"
Temperature_R
"
].
get_value
()
return
self
.
_Temperature_R
return
self
.
_Temperature_R
@only_when_on
@only_when_on
@fault_on_
opcua_
error
@fault_on_error
def
read_CLK_PLL_locked_R
(
self
):
def
read_CLK_PLL_locked_R
(
self
):
"""
Return the CLK_PLL_locked_R attribute.
"""
"""
Return the CLK_PLL_locked_R attribute.
"""
self
.
_CLK_PLL_locked_R
=
self
.
attribute_mapping
[
"
CLK_PLL_locked_R
"
].
get_value
()
self
.
_CLK_PLL_locked_R
=
self
.
attribute_mapping
[
"
CLK_PLL_locked_R
"
].
get_value
()
...
...
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