# -*- coding: utf-8 -*- # # This file is part of the Simulatede2BbaSwitch project # # Elettra - Sincrotrone Trieste S.C.p.A. # # Distributed under the terms of the GPL license. # See LICENSE.txt for more info. """ Simulatede2BbaSwitch Simple boolen r/w variable. The real thing will be a boolen attribute expoter by the Tango MPS interface """ # PROTECTED REGION ID(Simulatede2BbaSwitch.system_imports) ENABLED START # # PROTECTED REGION END # // Simulatede2BbaSwitch.system_imports # PyTango imports import tango from tango import DebugIt from tango.server import run from tango.server import Device from tango.server import attribute, command from tango import AttrQuality, DispLevel, DevState from tango import AttrWriteType, PipeWriteType # Additional import # PROTECTED REGION ID(Simulatede2BbaSwitch.additionnal_import) ENABLED START # # PROTECTED REGION END # // Simulatede2BbaSwitch.additionnal_import __all__ = ["Simulatede2BbaSwitch", "main"] class Simulatede2BbaSwitch(Device): """ Simple boolen r/w variable. The real thing will be a boolen attribute expoter by the Tango MPS interface """ # PROTECTED REGION ID(Simulatede2BbaSwitch.class_variable) ENABLED START # # PROTECTED REGION END # // Simulatede2BbaSwitch.class_variable # ---------- # Attributes # ---------- enable = attribute( dtype='DevBoolean', access=AttrWriteType.READ_WRITE, label="bba enable", doc="true if enabled", ) # --------------- # General methods # --------------- def init_device(self): """Initializes the attributes and properties of the Simulatede2BbaSwitch.""" Device.init_device(self) self._enable = False # PROTECTED REGION ID(Simulatede2BbaSwitch.init_device) ENABLED START # dev_m_attr = self.get_device_attr() wattr = dev_m_attr.get_w_attr_by_name("enable") wattr.set_write_value(False) self.set_state(tango.DevState.ON) self.set_status("MPS BBA switches ready") # PROTECTED REGION END # // Simulatede2BbaSwitch.init_device def always_executed_hook(self): """Method always executed before any TANGO command is executed.""" # PROTECTED REGION ID(Simulatede2BbaSwitch.always_executed_hook) ENABLED START # # PROTECTED REGION END # // Simulatede2BbaSwitch.always_executed_hook 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. """ # PROTECTED REGION ID(Simulatede2BbaSwitch.delete_device) ENABLED START # # PROTECTED REGION END # // Simulatede2BbaSwitch.delete_device # ------------------ # Attributes methods # ------------------ def read_enable(self): # PROTECTED REGION ID(Simulatede2BbaSwitch.enable_read) ENABLED START # """Return the enable attribute.""" return self._enable # PROTECTED REGION END # // Simulatede2BbaSwitch.enable_read def write_enable(self, value): # PROTECTED REGION ID(Simulatede2BbaSwitch.enable_write) ENABLED START # """Set the enable attribute.""" self._enable = value # PROTECTED REGION END # // Simulatede2BbaSwitch.enable_write # -------- # Commands # -------- # ---------- # Run server # ---------- # PROTECTED REGION ID(Simulatede2BbaSwitch.custom_code) ENABLED START # # PROTECTED REGION END # // Simulatede2BbaSwitch.custom_code def main(args=None, **kwargs): """Main function of the Simulatede2BbaSwitch module.""" # PROTECTED REGION ID(Simulatede2BbaSwitch.main) ENABLED START # return run((Simulatede2BbaSwitch,), args=args, **kwargs) # PROTECTED REGION END # // Simulatede2BbaSwitch.main # PROTECTED REGION ID(Simulatede2BbaSwitch.custom_functions) ENABLED START # # PROTECTED REGION END # // Simulatede2BbaSwitch.custom_functions if __name__ == '__main__': main()