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
248c4ae4
Commit
248c4ae4
authored
3 years ago
by
Taya Snijder
Browse files
Options
Downloads
Patches
Plain Diff
restored devices/test_device.py
parent
c1851723
No related branches found
Branches containing commit
No related tags found
1 merge request
!26
Resolve #2021 "04 16 branched from master snmp device"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
devices/test_device.py
+34
-55
34 additions, 55 deletions
devices/test_device.py
with
34 additions
and
55 deletions
devices/test_device.py
+
34
−
55
View file @
248c4ae4
...
...
@@ -13,83 +13,63 @@
# PyTango imports
from
tango.server
import
run
from
tango.server
import
device_property
from
tango
import
DevState
# Additional import
<<<<<<<
HEAD
from
clients.SNMP_client
import
SNMP_client
from
src.attribute_wrapper
import
*
from
src.hardware_device
import
*
=======
from
clients.test_client
import
test_client
from
util.attribute_wrapper
import
*
from
util.hardware_device
import
*
>>>>>>>
master
__all__
=
[
"
example_device
"
,
"
main
"
]
class
example_device
(
hardware_device
):
__all__
=
[
"
test_device
"
,
"
main
"
]
class
test_device
(
hardware_device
):
# -----------------
# Device Properties
# -----------------
SNMP_community
=
b
"
public
"
SNMP_host
=
"
127.0.0.1
"
SNMP_timeout
=
5.0
OPC_Server_Name
=
device_property
(
dtype
=
'
DevString
'
,
)
OPC_Server_Port
=
device_property
(
dtype
=
'
DevULong
'
,
)
OPC_Time_Out
=
device_property
(
dtype
=
'
DevDouble
'
,
)
# ----------
# Attributes
# ----------
bool_scalar_R
=
attribute_wrapper
(
comms_annotation
=
"
numpy.bool_ type read scalar
"
,
datatype
=
numpy
.
bool_
)
bool_scalar_RW
=
attribute_wrapper
(
comms_annotation
=
"
numpy.bool_ type read/write scalar
"
,
datatype
=
numpy
.
bool_
,
access
=
AttrWriteType
.
READ_WRITE
)
# simple scalar
attr1
=
attribute_wrapper
(
comms_annotation
=
{
"
oids
"
:
"
1.3.6.1.2.1.1.6.0
"
},
datatype
=
numpy
.
bool_
,
access
=
AttrWriteType
.
READ_WRITE
)
# simple scalar with host
attr2
=
attribute_wrapper
(
comms_annotation
=
{
"
oids
"
:
"
1.3.6.1.2.1.1.5.0
"
},
datatype
=
numpy
.
bool_
,
access
=
AttrWriteType
.
READ_WRITE
)
#spectrum with all elements
attr3
=
attribute_wrapper
(
comms_annotation
=
{
"
oids
"
:
[
"
1.3.6.1.2.1.1.5.1
"
,
"
1.3.6.1.2.1.1.5.2
"
,
"
1.3.6.1.2.1.1.5.3
"
]},
dims
=
(
3
,),
datatype
=
numpy
.
bool_
)
#inferred spectrum
attr4
=
attribute_wrapper
(
comms_annotation
=
{
"
oids
"
:
[
"
1.3.6.1.2.1.1.5.0
"
]},
dims
=
(
3
,),
datatype
=
numpy
.
bool_
)
int32_spectrum_R
=
attribute_wrapper
(
comms_annotation
=
"
numpy.int32 type read spectrum (len = 8)
"
,
datatype
=
numpy
.
int32
,
dims
=
(
8
,))
int32_spectrum_RW
=
attribute_wrapper
(
comms_annotation
=
"
numpy.int32 type read spectrum (len = 8)
"
,
datatype
=
numpy
.
int32
,
dims
=
(
8
,),
access
=
AttrWriteType
.
READ_WRITE
)
d
ef
always_executed_hook
(
self
):
"""
Method always executed before any TANGO command is executed.
"""
pass
d
ouble_image_R
=
attribute_wrapper
(
comms_annotation
=
"
numpy.double type read image (dims = 2x8)
"
,
datatype
=
numpy
.
double
,
dims
=
(
2
,
8
))
double_image_RW
=
attribute_wrapper
(
comms_annotation
=
"
numpy.double type read/write image (dims = 8x2)
"
,
datatype
=
numpy
.
double
,
dims
=
(
8
,
2
),
access
=
AttrWriteType
.
READ_WRITE
)
def
delete_device
(
self
):
"""
Hook to delete resources allocated in init_device.
This method allows for any memory or other resources allocated in the
init_device method to be released. This method is called by the device
destructor and by the device Init command (a Tango built-in).
"""
self
.
debug_stream
(
"
Shutting down...
"
)
self
.
Off
()
self
.
debug_stream
(
"
Shut down. Good bye.
"
)
int32_scalar_R
=
attribute_wrapper
(
comms_annotation
=
"
numpy.int32 type read scalar
"
,
datatype
=
numpy
.
int32
)
uint16_spectrum_RW
=
attribute_wrapper
(
comms_annotation
=
"
numpy.uint16 type read/write spectrum (len = 8)
"
,
datatype
=
numpy
.
uint16
,
dims
=
(
8
,),
access
=
AttrWriteType
.
READ_WRITE
)
float32_image_R
=
attribute_wrapper
(
comms_annotation
=
"
numpy.float32 type read image (dims = 8x2)
"
,
datatype
=
numpy
.
float32
,
dims
=
(
8
,
2
))
uint8_image_RW
=
attribute_wrapper
(
comms_annotation
=
"
numpy.uint8 type read/write image (dims = 2x8)
"
,
datatype
=
numpy
.
uint8
,
dims
=
(
2
,
8
),
access
=
AttrWriteType
.
READ_WRITE
)
# --------
# overloaded functions
# --------
def
initialise
(
self
):
"""
user code here. is called when the state is set to STANDBY
"""
# set up the SNMP ua client
self
.
snmp_manager
=
SNMP_client
(
self
.
SNMP_community
,
self
.
SNMP_host
,
self
.
SNMP_timeout
,
self
.
Fault
,
self
)
<<<<<<<
HEAD
# map the attributes to the OPC ua comm client
for
i
in
self
.
attr_list
():
i
.
set_comm_client
(
self
.
snmp_manager
)
def
configure_for_initialise
(
self
):
"""
user code here. is called when the sate is set to INIT
"""
"""
Initialises the attributes and properties of the PCC.
"""
self
.
s
nmp_manager
.
start
(
)
self
.
s
et_state
(
DevState
.
INIT
)
# --------
# Commands
# --------
=======
# set up the test client
self
.
test_client
=
test_client
(
self
.
Fault
,
self
)
...
...
@@ -98,15 +78,14 @@ class example_device(hardware_device):
i
.
set_comm_client
(
self
.
test_client
)
self
.
test_client
.
start
()
>>>>>>>
master
# ----------
# Run server
# ----------
def
main
(
args
=
None
,
**
kwargs
):
"""
Main function of the
PCC
module.
"""
return
run
((
example
_device
,),
args
=
args
,
**
kwargs
)
"""
Main function of the
example
module.
"""
return
run
((
test
_device
,),
args
=
args
,
**
kwargs
)
if
__name__
==
'
__main__
'
:
...
...
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