diff --git a/tangostationcontrol/tangostationcontrol/toolkit/archiver_base_mysql.py b/tangostationcontrol/tangostationcontrol/toolkit/archiver_base_mysql.py deleted file mode 100644 index e770cbb42820804ada57dcc3790afd04e2ded842..0000000000000000000000000000000000000000 --- a/tangostationcontrol/tangostationcontrol/toolkit/archiver_base_mysql.py +++ /dev/null @@ -1,926 +0,0 @@ -#! /usr/bin/env python3 - -from sqlalchemy.dialects.mysql.types import INTEGER -from sqlalchemy.orm import declarative_base -from sqlalchemy import Column, Integer, String -from sqlalchemy.dialects.mysql import DOUBLE,TIMESTAMP,BLOB, FLOAT, BIGINT -from typing import List -import numpy - -#Declarative system used to define classes mapped to relational DB tables -Base = declarative_base() - -class Attribute(Base): - """ - Class that represents a Tango Attribute mapped to table 'att_conf' - """ - __tablename__ = 'att_conf' - __table_args__ = {'extend_existing': True} - - att_conf_id = Column(Integer, primary_key=True) - att_name = Column(String) - att_conf_data_type_id = Column(Integer) - att_ttl = Column(Integer) - facility = Column(String) - domain = Column(String) - family = Column(String) - member = Column(String) - name = Column(String) - - def __repr__(self): - return f"<Attribute(fullname='{self.att_name}',data_type ='{self.att_conf_data_type_id}',ttl='{self.att_ttl}',facility ='{self.facility}',domain ='{self.domain}',family ='{self.family}',member ='{self.member}',name ='{self.name}')>" - -class DataType(Base): - """ - Class that represents a Tango Data Type mapped to table 'att_conf_data_type' - """ - __tablename__ = 'att_conf_data_type' - __table_args__ = {'extend_existing': True} - - att_conf_data_type_id = Column(Integer, primary_key=True) - data_type = Column(String) - - def __repr__(self): - return f"<DataType(type='{self.data_type}')>" - -class Scalar(Base): - """ - Abstract class that represents Super-class of Scalar mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - - # Primary key is not defined for tables which store values, but SQLAlchemy requires a mandatory - # primary key definition. Anyway, this definition is on Python-side and does not compromise - # DBMS architecture - att_conf_id = Column(Integer, primary_key=True) - data_time = Column(TIMESTAMP) - recv_time = Column(TIMESTAMP) - insert_time = Column(TIMESTAMP, primary_key=True) - quality = Column(Integer) - att_error_desc_id = Column(Integer) - -class Scalar_Boolean(Scalar): - """ - Abstract class that represents Parent class of Scalar Boolean mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Scalar_Boolean_RO(Scalar_Boolean): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devboolean_ro' - """ - __tablename__ = 'att_scalar_devboolean_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_Boolean_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Boolean_RW(Scalar_Boolean): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devboolean_rw' - """ - __tablename__ = 'att_scalar_devboolean_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(Integer) - - def __repr__(self): - return f"<Scalar_Boolean_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_UChar(Scalar): - """ - Abstract class that represents Parent class of Scalar Uchar mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Scalar_UChar_RO(Scalar_UChar): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devuchar_ro' - """ - __tablename__ = 'att_scalar_devuchar_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_UChar_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_UChar_RW(Scalar_UChar): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devuchar_rw' - """ - __tablename__ = 'att_scalar_devuchar_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(Integer) - - def __repr__(self): - return f"<Scalar_UChar_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Double(Scalar): - """ - Abstract class that represents Parent class of Scalar Double mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(DOUBLE) - -class Scalar_Double_RO(Scalar_Double): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devdouble_ro' - """ - __tablename__ = 'att_scalar_devdouble_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_Double_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Double_RW(Scalar_Double): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devdouble_rw' - """ - __tablename__ = 'att_scalar_devdouble_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(DOUBLE) - - def __repr__(self): - return f"<Scalar_Double_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Encoded(Scalar): - """ - Abstract class that represents Parent class of Scalar Encoded mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(BLOB) - -class Scalar_Encoded_RO(Scalar_Encoded): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devencoded_ro' - """ - __tablename__ = 'att_scalar_devencoded_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_Encoded_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Encoded_RW(Scalar_Encoded): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devencoded_rw' - """ - __tablename__ = 'att_scalar_devencoded_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(BLOB) - - def __repr__(self): - return f"<Scalar_Encoded_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Enum(Scalar): - """ - Abstract class that represents Parent class of Scalar Enum mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Scalar_Enum_RO(Scalar_Enum): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devenum_ro' - """ - __tablename__ = 'att_scalar_devenum_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_Enum_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Enum_RW(Scalar_Enum): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devenum_rw' - """ - __tablename__ = 'att_scalar_devenum_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(Integer) - - def __repr__(self): - return f"<Scalar_Enum_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Float(Scalar): - """ - Abstract class that represents Parent class of Scalar Float mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(FLOAT) - -class Scalar_Float_RO(Scalar_Float): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devfloat_ro' - """ - __tablename__ = 'att_scalar_devfloat_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_Float_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Float_RW(Scalar_Float): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devfloat_rw' - """ - __tablename__ = 'att_scalar_devfloat_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(FLOAT) - - def __repr__(self): - return f"<Scalar_Float_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Long64(Scalar): - """ - Abstract class that represents Parent class of Scalar Long64 mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(BIGINT) - -class Scalar_Long64_RO(Scalar_Long64): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devlong64_ro' - """ - __tablename__ = 'att_scalar_devlong64_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_Long64_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Long64_RW(Scalar_Long64): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devlong64_rw' - """ - __tablename__ = 'att_scalar_devlong64_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(BIGINT) - - def __repr__(self): - return f"<Scalar_Long64_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_ULong64(Scalar): - """ - Abstract class that represents Parent class of Scalar ULong64 mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(INTEGER) - -class Scalar_ULong64_RO(Scalar_ULong64): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devulong64_ro' - """ - __tablename__ = 'att_scalar_devulong64_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_ULong64_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_ULong64_RW(Scalar_ULong64): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devulong64_rw' - """ - __tablename__ = 'att_scalar_devulong64_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(INTEGER) - - def __repr__(self): - return f"<Scalar_ULong64_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - - -class Scalar_Long(Scalar): - """ - Abstract class that represents Parent class of Scalar Long mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(INTEGER) - -class Scalar_Long_RO(Scalar_Long): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devlong_ro' - """ - __tablename__ = 'att_scalar_devlong_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_Long_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Long_RW(Scalar_Long): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devlong_rw' - """ - __tablename__ = 'att_scalar_devlong_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(INTEGER) - - def __repr__(self): - return f"<Scalar_Long_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_ULong(Scalar): - """ - Abstract class that represents Parent class of Scalar ULong mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(INTEGER) - -class Scalar_ULong_RO(Scalar_ULong): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devulong_ro' - """ - __tablename__ = 'att_scalar_devulong_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_ULong_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_ULong_RW(Scalar_ULong): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devulong_rw' - """ - __tablename__ = 'att_scalar_devulong_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(INTEGER) - - def __repr__(self): - return f"<Scalar_ULong_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Short(Scalar): - """ - Abstract class that represents Parent class of Scalar Short mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Scalar_Short_RO(Scalar_Short): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devshort_ro' - """ - __tablename__ = 'att_scalar_devshort_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_Short_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_Short_RW(Scalar_Short): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devshort_rw' - """ - __tablename__ = 'att_scalar_devshort_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(Integer) - - def __repr__(self): - return f"<Scalar_Short_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_State(Scalar): - """ - Abstract class that represents Parent class of Scalar State mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Scalar_State_RO(Scalar_State): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devstate_ro' - """ - __tablename__ = 'att_scalar_devstate_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_State_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_State_RW(Scalar_State): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devstate_rw' - """ - __tablename__ = 'att_scalar_devstate_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(Integer) - - def __repr__(self): - return f"<Scalar_State_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_String(Scalar): - """ - Abstract class that represents Parent class of Scalar String mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(String) - -class Scalar_String_RO(Scalar_String): - """ - Class that represents a Tango Scalar Read-Only Value mapped to table 'att_scalar_devstring_ro' - """ - __tablename__ = 'att_scalar_devstring_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Scalar_String_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Scalar_String_RW(Scalar_String): - """ - Class that represents a Tango Scalar Read-Write Value mapped to table 'att_scalar_devstring_rw' - """ - __tablename__ = 'att_scalar_devstring_rw' - __table_args__ = {'extend_existing': True} - value_w = Column(String) - - def __repr__(self): - return f"<Scalar_String_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',value_r='{self.value_r}',value_w='{self.value_w}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array(Base): - """ - Abstract class that represents Super-class of Array mapper classes - """ - __abstract__ = True - # Primary key is not defined for tables which store values, but SQLAlchemy requires a mandatory - # primary key definition. Anyway, this definition is on Python-side and does not compromise - # DBMS architecture - att_conf_id = Column(Integer, primary_key=True) - data_time = Column(TIMESTAMP) - recv_time = Column(TIMESTAMP) - insert_time = Column(TIMESTAMP, primary_key=True) - idx = Column(Integer, primary_key=True) - dim_x_r = Column(Integer) - dim_y_r = Column(Integer) - quality = Column(Integer) - att_error_desc_id = Column(Integer) - -class Array_Boolean(Array): - """ - Abstract class that represents Parent class of Array Boolean mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Array_Boolean_RO(Array_Boolean): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devboolean_ro' - """ - __tablename__ = 'att_array_devboolean_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_Boolean_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Boolean_RW(Array_Boolean): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devboolean_rw' - """ - __tablename__ = 'att_array_devboolean_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(Integer) - - def __repr__(self): - return f"<Array_Boolean_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_UChar(Array): - """ - Abstract class that represents Parent class of Array UChar mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Array_UChar_RO(Array_UChar): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devuchar_ro' - """ - __tablename__ = 'att_array_devuchar_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_UChar_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_UChar_RW(Array_Boolean): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devuchar_rw' - """ - __tablename__ = 'att_array_devuchar_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(Integer) - - def __repr__(self): - return f"<Array_UChar_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Double(Array): - """ - Abstract class that represents Parent class of Array Double mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(DOUBLE) - -class Array_Double_RO(Array_Double): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devdouble_ro' - """ - __tablename__ = 'att_array_devdouble_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_Double_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Double_RW(Array_Double): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devdouble_rw' - """ - __tablename__ = 'att_array_devdouble_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(DOUBLE) - - def __repr__(self): - return f"<Array_Double_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Encoded(Array): - """ - Abstract class that represents Parent class of Array Encoded mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(BLOB) - -class Array_Encoded_RO(Array_Encoded): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devencoded_ro' - """ - __tablename__ = 'att_array_devencoded_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_Encoded_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Encoded_RW(Array_Encoded): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devencoded_rw' - """ - __tablename__ = 'att_array_devencoded_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(BLOB) - - def __repr__(self): - return f"<Array_Encoded_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Enum(Array): - """ - Abstract class that represents Parent class of Array Enum mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Array_Enum_RO(Array_Enum): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devenum_ro' - """ - __tablename__ = 'att_array_devenum_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_Enum_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Enum_RW(Array_Enum): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devenum_rw' - """ - __tablename__ = 'att_array_devenum_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(Integer) - - def __repr__(self): - return f"<Array_Enum_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Float(Array): - """ - Abstract class that represents Parent class of Array Float mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(FLOAT) - -class Array_Float_RO(Array_Float): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devfloat_ro' - """ - __tablename__ = 'att_array_devfloat_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_Float_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Float_RW(Array_Float): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devfloat_rw' - """ - __tablename__ = 'att_array_devfloat_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(FLOAT) - - def __repr__(self): - return f"<Array_Float_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Long64(Array): - """ - Abstract class that represents Parent class of Array Long64 mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(BIGINT) - -class Array_Long64_RO(Array_Long64): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devlong64_ro' - """ - __tablename__ = 'att_array_devlong64_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_Long64_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Long64_RW(Array_Long64): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devlong64_rw' - """ - __tablename__ = 'att_array_devlong64_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(BIGINT) - - def __repr__(self): - return f"<Array_Long64_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_ULong64(Array): - """ - Abstract class that represents Parent class of Array ULong64 mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(INTEGER) - -class Array_ULong64_RO(Array_ULong64): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devulong64_ro' - """ - __tablename__ = 'att_array_devulong64_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_ULong64_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_ULong64_RW(Array_ULong64): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devulong64_rw' - """ - __tablename__ = 'att_array_devulong64_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(INTEGER) - - def __repr__(self): - return f"<Array_ULong64_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - - -class Array_Long(Array): - """ - Abstract class that represents Parent class of Array Long mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(INTEGER) - -class Array_Long_RO(Array_Long): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devlong_ro' - """ - __tablename__ = 'att_array_devlong_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_Long_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Long_RW(Array_Long): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devlong_rw' - """ - __tablename__ = 'att_array_devlong_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(INTEGER) - - def __repr__(self): - return f"<Array_Long_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_ULong(Array): - """ - Abstract class that represents Parent class of Array ULong mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(INTEGER) - -class Array_ULong_RO(Array_ULong): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devulong_ro' - """ - __tablename__ = 'att_array_devulong_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_ULong_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_ULong_RW(Array_ULong): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devulong_rw' - """ - __tablename__ = 'att_array_devulong_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(INTEGER) - - def __repr__(self): - return f"<Array_ULong_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Short(Array): - """ - Abstract class that represents Parent class of Array Short mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Array_Short_RO(Array_Short): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devshort_ro' - """ - __tablename__ = 'att_array_devshort_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_Short_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_Short_RW(Array_Short): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devshort_rw' - """ - __tablename__ = 'att_array_devshort_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(Integer) - - def __repr__(self): - return f"<Array_Short_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_State(Array): - """ - Abstract class that represents Parent class of Array State mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(Integer) - -class Array_State_RO(Array_State): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devstate_ro' - """ - __tablename__ = 'att_array_devstate_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_State_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_State_RW(Array_State): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devstate_rw' - """ - __tablename__ = 'att_array_devstate_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(Integer) - - def __repr__(self): - return f"<Array_State_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_String(Array): - """ - Abstract class that represents Parent class of Array String mapper classes - """ - # In the concrete inheritance use case, it is common that the base class is not represented - # within the database, only the subclasses. In other words, the base class is abstract. - __abstract__ = True - value_r = Column(String) - -class Array_String_RO(Array_String): - """ - Class that represents a Tango Array Read-Only Value mapped to table 'att_array_devstring_ro' - """ - __tablename__ = 'att_array_devstring_ro' - __table_args__ = {'extend_existing': True} - - def __repr__(self): - return f"<Array_String_RO(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -class Array_String_RW(Array_String): - """ - Class that represents a Tango Array Read-Write Value mapped to table 'att_array_devstring_rw' - """ - __tablename__ = 'att_array_devstring_rw' - __table_args__ = {'extend_existing': True} - dim_x_w = Column(Integer) - dim_y_w = Column(Integer) - value_w = Column(String) - - def __repr__(self): - return f"<Array_String_RW(att_conf_id='{self.att_conf_id}',data_time='{self.data_time}',recv_time='{self.recv_time}',insert_time='{self.insert_time}',idx='{self.idx}',dim_x_r='{self.dim_x_r}',dim_y_r='{self.dim_y_r}',value_r='{self.value_r}',dim_x_w='{self.dim_x_w}',dim_y_w='{self.dim_y_w}',value_w='%{self.value_w},quality='{self.quality}',att_error_desc_id='{self.att_error_desc_id}')>" - -def get_class_by_tablename(tablename: str): - """ - Returns class reference mapped to a table. - """ - for mapper in Base.registry.mappers: - c = mapper.class_ - classname = c.__name__ - if not classname.startswith('_'): - if hasattr(c, '__tablename__') and c.__tablename__ == tablename: - return c - return None - -def build_array_from_record(rows: List[Array], dim_x: int): - """ - Converts Array database items in Python lists - """ - matrix = numpy.array([]) - for i in range(0,dim_x): - x = numpy.array([item for item in rows if item.idx==i]) #group records by array index - if i==0: - matrix = numpy.append(matrix,x) #append first row - else: - matrix = numpy.vstack([matrix,x]) #stack vertically - result = numpy.transpose(matrix) #transpose -> each row is a distinct array of value - list_result = result.tolist() - return list_result - -def get_values_from_record(data_matrix: List[Array]): - """ - Returns a matrix of values from a matrix of Array records - """ - array_matrix = numpy.matrix(data_matrix) - value_matrix = numpy.empty(array_matrix.shape) - for index in range(array_matrix.size): # for each object element - value_matrix.itemset(index,array_matrix.item(index).value_r) # extract the value from object and put in the matrix - return value_matrix - diff --git a/tangostationcontrol/tangostationcontrol/toolkit/retriever.py b/tangostationcontrol/tangostationcontrol/toolkit/retriever.py index 5c7426dbe41faf4ecd6d2498c809097335d107d5..f9b996480ca4372aa4d7da3e74b3b045b718623f 100644 --- a/tangostationcontrol/tangostationcontrol/toolkit/retriever.py +++ b/tangostationcontrol/tangostationcontrol/toolkit/retriever.py @@ -119,102 +119,6 @@ class Retriever(ABC): raise ValueError(f"Attribute {attribute_fqname} not found!") from e return result -class RetrieverMySQL(Retriever): - - def __init__(self, cm_name: str = 'archiving/hdbpp/confmanager01'): - self.cm_name = cm_name - - super().__init__() - - def connect_to_archiving_db(self): - """ - Returns a session to a MySQL DBMS using default credentials. - """ - creds = get_db_config(self.cm_name) - - # Set sqlalchemy library connection - if creds["host"] == 'archiver-maria-db': - creds["libname"] = 'mysql+pymysql' - else: - raise ValueError(f"Invalid hostname: {creds['host']}, we only support 'archiver-maria-db'") - - Session = self.create_session(creds) - return Session() - - def set_archiver_base(self): - """ - Sets the right mapper class following the DBMS connection - """ - return importlib.import_module('.archiver_base_mysql', package=__package__) - - def get_attribute_datatype(self,attribute_fqname: str): - """ - Takes as input the fully-qualified name of an attribute and returns its Data-Type. - Data Type name indicates the type (e.g. string, int, ...) and the read/write property. The name is used - as DB table name suffix in which values are stored. - """ - domain, family, member, name = split_tango_name(attribute_fqname,"attribute") - try: - result = self.session.query(self.ab.DataType.data_type).join(self.ab.Attribute,self.ab.Attribute.att_conf_data_type_id==self.ab.DataType.att_conf_data_type_id).\ - filter(and_(self.ab.Attribute.domain == domain, self.ab.Attribute.family == family, self.ab.Attribute.member == member, self.ab.Attribute.name == name)).one() - return result[0] - except (AttributeError, TypeError, NoResultFound) as e: - raise ValueError(f"Attribute {attribute_fqname} not found!") from e - - def get_attribute_value_by_hours(self,attribute_fqname: str, hours: float = 1.0): - """ - Takes as input the attribute fully-qualified name and the number of past hours since the actual time - (e.g. hours=1 retrieves values in the last hour, hours=8.5 retrieves values in the last eight hours and half). - Returns a list of timestamps and a list of values - """ - attr_datatype = self.get_attribute_datatype(attribute_fqname) - # Retrieves the class that maps the DB table given the tablename - tablename = f"att_{attr_datatype}" - return super().get_attribute_value_by_hours(attribute_fqname,hours,tablename) - - - def get_attribute_value_by_interval(self,attribute_fqname: str, start_time: datetime, stop_time: datetime): - """ - Takes as input the attribute name and a certain starting and ending point-time. - The datetime format is pretty flexible (e.g. "YYYY-MM-dd hh:mm:ss"). - Returns a list of timestamps and a list of values - """ - attr_datatype = self.get_attribute_datatype(attribute_fqname) - # Retrieves the class that maps the DB table given the tablename - tablename = f"att_{attr_datatype}" - return super().get_attribute_value_by_interval(attribute_fqname,start_time,stop_time,tablename) - - # DRAFT # - def get_masked_fpga_temp(self,start_time: datetime, stop_time: datetime,temp_attr_name:str='stat/sdp/1/fpga_temp_r', - mask_attr_name:str='stat/sdp/1/tr_fpga_mask_r'): - """ - Returns a list of SDP/fpga_temp_r values, but only if SDP/tr_fpga_mask_r values are TRUE - """ - mask_values = self.get_attribute_value_by_interval(mask_attr_name,start_time,stop_time) - temp_values = self.get_attribute_value_by_interval(temp_attr_name,start_time,stop_time) - # Since timestamps can be not syncrhonized, remove first or last element from arrays - if len(mask_values)==len(temp_values): - first_mask_datatime = mask_values[0].data_time - first_temp_datatime = temp_values[0].data_time - if (first_mask_datatime>first_temp_datatime): - mask_values = mask_values[:-int(mask_values[0].dim_x_r)] - temp_values = temp_values[int(temp_values[0].dim_x_r):] - elif (first_mask_datatime<first_temp_datatime): - mask_values = mask_values[int(mask_values[0].dim_x_r)] - temp_values = temp_values[:-int(temp_values[0].dim_x_r):] - else: - raise Exception - # Convert DB Array records into Python lists - mask_data = self.ab.build_array_from_record(mask_values,mask_values[0].dim_x_r) - temp_data = self.ab.build_array_from_record(temp_values,temp_values[0].dim_x_r) - # Extract only the value from the array - mask_array_values = self.ab.get_values_from_record(mask_data) - temp_array_values = self.ab.get_values_from_record(temp_data) - # Multiply the matrix - #masked_values = np.multiply(temp_array_values,mask_array_values) - masked_values = numpy.ma.masked_array(temp_array_values,mask=numpy.invert(mask_array_values.astype(bool))) - return masked_values, mask_values, temp_values - class RetrieverTimescale(Retriever): def __init__(self, cm_name: str = 'archiving/hdbppts/confmanager01'):