Skip to content
Snippets Groups Projects
Commit a0b9016c authored by Thomas Juerges's avatar Thomas Juerges
Browse files

Merge branch 'master' into 2021-03-22T14.42.30-branched_from_master-Makefile_refactoring

parents 15d430b0 363bba72
No related branches found
No related tags found
1 merge request!21Small refactoring of the Makefile
Showing
with 610 additions and 5 deletions
...@@ -37,3 +37,4 @@ services: ...@@ -37,3 +37,4 @@ services:
- --strict - --strict
- -- - --
- /venv/bin/itango3 - /venv/bin/itango3
restart: on-failure
ARG VERSION=latest ARG VERSION=latest
FROM nexus.engageska-portugal.pt/ska-docker/tango-itango:${VERSION} ARG DOCKER_REGISTRY_HOST=nexus.engageska-portugal.pt
ARG DOCKER_REGISTRY_USER=ska-docker
FROM $DOCKER_REGISTRY_HOST/$DOCKER_REGISTRY_USER/tango-itango:${VERSION}
RUN sudo apt-get -y update && \ RUN sudo apt-get -y update && \
sudo apt-get -y upgrade && \ sudo apt-get -y upgrade && \
...@@ -7,5 +9,7 @@ RUN sudo apt-get -y update && \ ...@@ -7,5 +9,7 @@ RUN sudo apt-get -y update && \
sudo aptitude -y install htop iftop iproute2 mc most net-tools tcpdump telnet tmux traceroute vim xterm && \ sudo aptitude -y install htop iftop iproute2 mc most net-tools tcpdump telnet tmux traceroute vim xterm && \
sudo aptitude clean && \ sudo aptitude clean && \
sudo aptitude autoclean && \ sudo aptitude autoclean && \
pip3 install "opcua >= 0.98.9" asyncua astropy sudo pip3 install "opcua >= 0.98.9" asyncua astropy && \
sudo pip3 uninstall -y jedi parso && \
sudo pip3 install "parso == 0.7.1" "jedi == 0.17.2" && \
sudo pip3 cache purge
...@@ -18,6 +18,7 @@ services: ...@@ -18,6 +18,7 @@ services:
volumes: volumes:
- ${TANGO_SKA_CONTAINER_MOUNT} - ${TANGO_SKA_CONTAINER_MOUNT}
- ${TANGO_LOFAR_CONTAINER_MOUNT} - ${TANGO_LOFAR_CONTAINER_MOUNT}
- ${TANGO_LOFAR_LOCAL_DIR}/jupyter-notebooks:/jupyter-notebooks:rw
- ${HOME}:/hosthome - ${HOME}:/hosthome
environment: environment:
- TANGO_HOST=${TANGO_HOST} - TANGO_HOST=${TANGO_HOST}
...@@ -25,7 +26,7 @@ services: ...@@ -25,7 +26,7 @@ services:
- DISPLAY=${DISPLAY} - DISPLAY=${DISPLAY}
ports: ports:
- "8888:8888" - "8888:8888"
working_dir: ${TANGO_LOFAR_CONTAINER_DIR}/jupyter-notebooks working_dir: /jupyter-notebooks
entrypoint: entrypoint:
- /usr/local/bin/wait-for-it.sh - /usr/local/bin/wait-for-it.sh
- ${TANGO_HOST} - ${TANGO_HOST}
...@@ -33,3 +34,4 @@ services: ...@@ -33,3 +34,4 @@ services:
- --strict - --strict
- -- - --
- /usr/bin/tini -- jupyter notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token= --NotebookApp.password= - /usr/bin/tini -- jupyter notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token= --NotebookApp.password=
restart: on-failure
# Create shortcuts for our devices
pcc = DeviceProxy("LTS/PCC/1")
sdp = DeviceProxy("LTS/SDP/1")
# Put them in a list in case one wants to iterate
devices = [pcc, sdp]
#
# Docker compose file that forms the basis for LOFAR tango devices
#
# This is an abstract image that does not need to be spinned up, but
# might be out of consistency with other images.
#
# Defines:
# - device-base: Base configuration for devices.
#
# Requires:
# - tango.yml
#
version: '2'
services:
lofar-device-base:
image: lofar-device-base
build:
context: lofar-device-base
container_name: ${CONTAINER_NAME_PREFIX}lofar-device-base
network_mode: ${NETWORK_MODE}
FROM nexus.engageska-portugal.pt/ska-docker/tango-itango:latest
COPY lofar-requirements.txt /lofar-requirements.txt
RUN pip3 install -r /lofar-requirements.txt
opcua >= 0.98.9
astropy
...@@ -16,3 +16,4 @@ services: ...@@ -16,3 +16,4 @@ services:
- ${HOME}:/hosthome - ${HOME}:/hosthome
ports: ports:
- "4842:4842" - "4842:4842"
restart: on-failure
%% Cell type:code id:funded-deputy tags:
``` python
import time
```
%% Cell type:code id:bridal-mumbai tags:
``` python
d=DeviceProxy("LTS/PCC/1")
```
%% Cell type:code id:subjective-conference tags:
``` python
state = str(d.state())
if state == "OFF":
d.initialise()
time.sleep(1)
state = str(d.state())
if state == "STANDBY":
d.on()
state = str(d.state())
if state == "ON":
print("Device is now in on state")
```
%% Cell type:code id:liable-thesaurus tags:
``` python
values = [[d.RCU_mask_RW, "RCU_mask_RW"],
[d.Ant_mask_RW,"Ant_mask_RW"],
[d.RCU_attenuator_R,"RCU_attenuator_R"],
[d.RCU_attenuator_RW,"RCU_attenuator_RW"],
[d.RCU_band_R,"RCU_band_R"],
[d.RCU_band_RW,"RCU_band_RW"],
[d.RCU_temperature_R,"RCU_temperature_R"],
[d.RCU_Pwr_dig_R,"RCU_Pwr_dig_R"],
[d.RCU_LED0_R,"RCU_LED0_R"],
[d.RCU_LED0_RW,"RCU_LED0_RW"],
[d.RCU_ADC_lock_R,"RCU_ADC_lock_R"],
[d.RCU_ADC_SYNC_R,"RCU_ADC_SYNC_R"],
[d.RCU_ADC_JESD_R,"RCU_ADC_JESD_R"],
[d.RCU_ADC_CML_R,"RCU_ADC_CML_R"],
[d.RCU_OUT1_R,"RCU_OUT1_R"],
[d.RCU_OUT2_R,"RCU_OUT2_R"],
[d.RCU_ID_R,"RCU_ID_R"],
[d.RCU_version_R,"RCU_version_R"],
[d.HBA_element_beamformer_delays_R,"HBA_element_beamformer_delays_R"],
[d.HBA_element_beamformer_delays_RW,"HBA_element_beamformer_delays_RW"],
[d.HBA_element_pwr_R,"HBA_element_pwr_R"],
[d.HBA_element_pwr_RW,"HBA_element_pwr_RW"],
[d.RCU_monitor_rate_RW,"RCU_monitor_rate_RW"]]
for i in values:
print("🟦🟦🟦", i[1], ": ", i[0])
```
%% Output
---------------------------------------------------------------------------
DevFailed Traceback (most recent call last)
<ipython-input-4-aafae2adcd98> in <module>
----> 1 values = [[d.RCU_mask_RW, "RCU_mask_RW"],
2 [d.Ant_mask_RW,"Ant_mask_RW"],
3 [d.RCU_attenuator_R,"RCU_attenuator_R"],
4 [d.RCU_attenuator_RW,"RCU_attenuator_RW"],
5 [d.RCU_band_R,"RCU_band_R"],
/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py in __DeviceProxy__getattr(self, name)
342 attr_info = self.__get_attr_cache().get(name_l)
343 if attr_info:
--> 344 return __get_attribute_value(self, attr_info, name)
345
346 try:
/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py in __get_attribute_value(self, attr_info, name)
281 def __get_attribute_value(self, attr_info, name):
282 _, enum_class = attr_info
--> 283 attr_value = self.read_attribute(name).value
284 if enum_class:
285 return enum_class(attr_value)
/usr/local/lib/python3.7/dist-packages/tango/green.py in greener(obj, *args, **kwargs)
193 green_mode = access('green_mode', None)
194 executor = get_object_executor(obj, green_mode)
--> 195 return executor.run(fn, args, kwargs, wait=wait, timeout=timeout)
196
197 return greener
/usr/local/lib/python3.7/dist-packages/tango/green.py in run(self, fn, args, kwargs, wait, timeout)
107 # Sychronous (no delegation)
108 if not self.asynchronous or not self.in_executor_context():
--> 109 return fn(*args, **kwargs)
110 # Asynchronous delegation
111 accessor = self.delegate(fn, *args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py in __DeviceProxy__read_attribute(self, value, extract_as)
439
440 def __DeviceProxy__read_attribute(self, value, extract_as=ExtractAs.Numpy):
--> 441 return __check_read_attribute(self._read_attribute(value, extract_as))
442
443
/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py in __check_read_attribute(dev_attr)
155 def __check_read_attribute(dev_attr):
156 if dev_attr.has_failed:
--> 157 raise DevFailed(*dev_attr.get_err_stack())
158 return dev_attr
159
DevFailed: DevFailed[
DevError[
desc = Read value for attribute RCU_mask_RW has not been updated
origin = Device_3Impl::read_attributes_no_except
reason = API_AttrValueNotSet
severity = ERR]
DevError[
desc = Failed to read_attribute on device lts/pcc/1, attribute RCU_mask_RW
origin = DeviceProxy::read_attribute()
reason = API_AttributeFailed
severity = ERR]
]
%% Cell type:code id:charitable-subject tags:
``` python
d.RCU_mask_RW = [False, False, False, False, False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,]
time.sleep(1)
print(d.RCU_mask_RW)
monitor_rate = d.RCU_monitor_rate_RW
print("current monitoring rate: {}, setting to {}".format(monitor_rate, monitor_rate + 1))
d.RCU_monitor_rate_RW = monitor_rate + 1
time.sleep(2)
print("new monitoring rate is: {}".format(d.RCU_monitor_rate_RW))
```
%% Output
[False False False False False False False False False False False False
False False False False False False False False False False False False
False False False False False False False False]
current monitoring rate: 0.0, setting to 1.0
new monitoring rate is: 1.0
%% Cell type:code id:impressive-request tags:
``` python
attr_names = d.get_attribute_list()
for i in attr_names:
exec("value = print(i, d.{})".format(i))
```
%% Cell type:code id:conditional-scale tags:
``` python
```
%% Cell type:code id:waiting-chance tags:
``` python
import time
```
%% Cell type:code id:moving-alexandria tags:
``` python
d=DeviceProxy("LTS/SDP/1")
```
%% Cell type:code id:ranking-aluminum tags:
``` python
state = str(d.state())
if state == "OFF":
d.initialise()
time.sleep(1)
state = str(d.state())
if state == "STANDBY":
d.on()
state = str(d.state())
if state == "ON":
print("Device is now in on state")
else:
print("warning, expected device to be in on state, is: ", state)
```
%% Output
warning, expected device to be in on state, is: FAULT
%% Cell type:code id:transsexual-battle tags:
``` python
values = [
[d.fpga_mask_RW, "fpga_mask_RW"],
[d.fpga_scrap_R, "fpga_scrap_R"],
[d.fpga_scrap_RW, "fpga_scrap_RW"],
[d.fpga_status_R, "fpga_status_R"],
[d.fpga_temp_R, "fpga_temp_R"],
[d.fpga_version_R, "fpga_version_R"],
[d.fpga_weights_R, "fpga_weights_R"],
[d.fpga_weights_RW, "fpga_weights_RW"],
[d.tr_busy_R, "tr_busy_R"],
[d.tr_reload_RW, "tr_reload_RW"],
# [d.tr_tod_R, "tr_tod_R"],
# [d.tr_uptime_R, "tr_uptime_R"]
]
for i in values:
print("🟦🟦🟦", i[1], ": ", i[0])
```
%% Cell type:code id:eligible-times tags:
``` python
attr_names = d.get_attribute_list()
for i in attr_names:
exec("value = print(i, d.{})".format(i))
```
%% Output
---------------------------------------------------------------------------
DevFailed Traceback (most recent call last)
<ipython-input-5-e44d5c52394a> in <module>
----> 1 d.tr_tod_R
/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py in __DeviceProxy__getattr(self, name)
319 attr_info = self.__get_attr_cache().get(name_l)
320 if attr_info:
--> 321 return __get_attribute_value(self, attr_info, name)
322
323 if name_l in self.__get_pipe_cache():
/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py in __get_attribute_value(self, attr_info, name)
281 def __get_attribute_value(self, attr_info, name):
282 _, enum_class = attr_info
--> 283 attr_value = self.read_attribute(name).value
284 if enum_class:
285 return enum_class(attr_value)
/usr/local/lib/python3.7/dist-packages/tango/green.py in greener(obj, *args, **kwargs)
193 green_mode = access('green_mode', None)
194 executor = get_object_executor(obj, green_mode)
--> 195 return executor.run(fn, args, kwargs, wait=wait, timeout=timeout)
196
197 return greener
/usr/local/lib/python3.7/dist-packages/tango/green.py in run(self, fn, args, kwargs, wait, timeout)
107 # Sychronous (no delegation)
108 if not self.asynchronous or not self.in_executor_context():
--> 109 return fn(*args, **kwargs)
110 # Asynchronous delegation
111 accessor = self.delegate(fn, *args, **kwargs)
/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py in __DeviceProxy__read_attribute(self, value, extract_as)
439
440 def __DeviceProxy__read_attribute(self, value, extract_as=ExtractAs.Numpy):
--> 441 return __check_read_attribute(self._read_attribute(value, extract_as))
442
443
/usr/local/lib/python3.7/dist-packages/tango/device_proxy.py in __check_read_attribute(dev_attr)
155 def __check_read_attribute(dev_attr):
156 if dev_attr.has_failed:
--> 157 raise DevFailed(*dev_attr.get_err_stack())
158 return dev_attr
159
DevFailed: DevFailed[
DevError[
desc = TypeError: Expecting a numeric type, but it is not. If you use a numpy type instead of python core types, then it must exactly match (ex: numpy.int32 for PyTango.DevLong)
origin = Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/tango/server.py", line 138, in read_attr
set_complex_value(attr, ret)
File "/usr/local/lib/python3.7/dist-packages/tango/server.py", line 115, in set_complex_value
attr.set_value(value)
TypeError: Expecting a numeric type, but it is not. If you use a numpy type instead of python core types, then it must exactly match (ex: numpy.int32 for PyTango.DevLong)
reason = PyDs_PythonError
severity = ERR]
DevError[
desc = Failed to read_attribute on device lts/sdp/1, attribute tr_tod_R
origin = DeviceProxy::read_attribute()
reason = API_AttributeFailed
severity = ERR]
]
%% Cell type:code id:social-massachusetts tags:
``` python
def force_start(device):
if device.state() == DevState.FAULT:
device.Off()
if device.state() == DevState.OFF:
device.initialise()
if device.state() == DevState.INIT:
device.Standby()
if device.state() == DevState.STANDBY:
device.On()
return device.state()
```
%% Cell type:code id:defined-apache tags:
``` python
for d in devices:
print("Device %s is now in state %s" % (d, force_start(d)))
```
%% Output
Device PCC(lts/pcc/1) is now in state FAULT
Device SDP(lts/sdp/1) is now in state ON
%% Cell type:code id:superior-wheel tags:
``` python
```
test
\ No newline at end of file
%% Cell type:code id:waiting-chance tags:
``` python
import time
import numpy
```
%% Cell type:code id:moving-alexandria tags:
``` python
d=DeviceProxy("LTS/test_device/1")
```
%% Cell type:code id:ranking-aluminum tags:
``` python
state = str(d.state())
if state == "OFF":
d.initialise()
time.sleep(1)
state = str(d.state())
if state == "STANDBY":
d.on()
state = str(d.state())
if state == "ON":
print("Device is now in on state")
```
%% Output
Device is now in on state
%% Cell type:code id:beneficial-evidence tags:
``` python
attr_names = d.get_attribute_list()
for i in attr_names:
exec("value = print(i, d.{})".format(i))
```
%% Output
bool_scalar_R [False]
bool_scalar_RW [False]
int64_spectrum_R [0 0 0 0 0 0 0 0]
str_spectrum_RW ('', '', '', '', '', '', '', '')
double_image_R [[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]
[0. 0.]]
double_image_RW [[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]]
int32_scalar_R [0]
uint16_spectrum_RW [0 0 0 0 0 0 0 0]
float32_image_R [[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]]
uint8_image_RW [[0 0]
[0 0]
[0 0]
[0 0]
[0 0]
[0 0]
[0 0]
[0 0]]
tr_tod_R [0]
tr_uptime_R [0]
State <function __get_command_func.<locals>.f at 0x7f1c88a29e18>
Status <function __get_command_func.<locals>.f at 0x7f1c88a5abf8>
%% Cell type:code id:sporting-current tags:
``` python
d.RCU_mask_RW = [False, False, False, False, False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,]
time.sleep(1)
print(d.RCU_mask_RW)
monitor_rate = d.RCU_monitor_rate_RW
print("current monitoring rate: {}, setting to {}".format(monitor_rate, monitor_rate + 1))
monitor_rate = monitor_rate + 1
time.sleep(1)
```
%% Output
3.0
%% Cell type:code id:sharing-mechanics tags:
``` python
```
%% Cell type:code id:ruled-tracy tags:
``` python
```
#! /usr/bin/env python3
from tango import DeviceProxy
from numpy import array, transpose
def get_internal_attribute_history(device: DeviceProxy, attribute_name: str, depth: int = 10):
try:
history = array(device.attribute_history(attr_name = attribute_name, depth = depth))
except Exception as e:
raise ValueError("Cannot access the internal history of the attribute '{}/{}'.".format(device.name(), attribute_name)) from e
history_values = array([entry.value for entry in history])
values = history_values.transpose()
return values
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment