예제 #1
0
def register_server_with_devices(db, server_name, server_instance, devices):
    """Registers a new server with some devices in the Database.
       Devices is a seq<tuple<str, str, str, dict>>> where each item is a
       sequence of 4 elements :
        - device class
        - device name prefix
        - device alias
        - dictionary of properties

       :param db: database where to register devices
       :type db: PyTango.Database
       :param server_name: server name
       :type server_name: str
       :param server_instance: server instance name
       :type server_instance: str
       :param devices: map of devices to create.
       :type devices: dict<str, seq<tuple<str, str, dict>>>
    """
    info = DbDevInfo()
    info.server = server_name + "/" + server_instance
    for dev_info in devices:
        dev_class, prefix, alias, props = dev_info
        if prefix is None:
            prefix = dev_class + "/" + server_instance
        if prefix.count("/") == 1:
            prefix = get_free_device(db, prefix)
        info._class = dev_class
        info.name = prefix
        db.add_device(info)
        if alias is None:
            alias_prefix = dev_class + "_" + server_instance
            alias = get_free_alias(db, alias_prefix)
        db.put_device_alias(info.name, alias)
        if props is not None:
            db.put_device_property(info.name, props)
예제 #2
0
파일: util.py 프로젝트: cmft/sardana
def register_server_with_devices(db, server_name, server_instance, devices):
    """Registers a new server with some devices in the Database.
       Devices is a seq<tuple<str, str, str, dict>>> where each item is a
       sequence of 4 elements :
        - device class
        - device name prefix
        - device alias
        - dictionary of properties

       :param db: database where to register devices
       :type db: PyTango.Database
       :param server_name: server name
       :type server_name: str
       :param server_instance: server instance name
       :type server_instance: str
       :param devices: map of devices to create. 
       :type devices: dict<str, seq<tuple<str, str, dict>>>
    """
    info = DbDevInfo()
    info.server = server_name + "/" + server_instance
    for dev_info in devices:
        dev_class, prefix, alias, props = dev_info
        if prefix is None:
            prefix = dev_class + "/" + server_instance
        if prefix.count("/") == 1:
            prefix = get_free_device(db, prefix)
        info._class = dev_class
        info.name = prefix
        db.add_device(info)
        if alias is None:
            alias_prefix = dev_class + "_" + server_instance
            alias = get_free_alias(db, alias_prefix)
        db.put_device_alias(info.name, alias)
        if props is not None:
            db.put_device_property(info.name, props)
예제 #3
0
def get_dev_info(domain_name, device_server_name, device_ref):
    dev_info = DbDevInfo()
    dev_info._class = device_server_name
    dev_info.server = '%s/%s' % (device_server_name, domain_name)
    # add the device
    dev_info.name = '%s/%s' % (domain_name, device_ref)
    return dev_info
예제 #4
0
def obsconf_device_info(device_id):
    device_name = 'test/obsconf/%s' % device_id
    try:
        dev_info = db.get_device_info(device_name)
    except Exception as ex:
        dev_info = None
    if not dev_info is None:
        print "Device <<%s>> found:" % device_name
        print "Name: %s" % (dev_info.name)
        print "Class Name: %s" % (dev_info.class_name)
        print "Full Name: %s" % (dev_info.ds_full_name)
        print "Exported: %s" % (dev_info.exported)
        print "IOR: %s" % (dev_info.ior)
        print "Version: %s" % (dev_info.version)
        print "PID: %s" % (dev_info.pid)
        print "Started Date: %s" % (dev_info.started_date)
        print "Stopped Date: %s" % (dev_info.stopped_date)
    else:
        # Define device name
        new_device_name = device_name
        # Define the Tango Class served by this DServer
        dev_info = DbDevInfo()
        dev_info._class = "ObservationConfiguration"
        dev_info.server = "ObservationConfiguration/test"
        # add the device
        dev_info.name = new_device_name
        print("Creating device: %s" % new_device_name)
        db.add_device(dev_info)
예제 #5
0
def register(device_name, device_class, device_server):
    new_device_info = DbDevInfo()
    new_device_info.name = device_name
    new_device_info._class = device_class
    new_device_info.server = device_server

    print("Creating device: %s" % device_name)

    db.add_device(new_device_info)
def create_device(ctrl, addr, axis):
    db = Database()
    new_device_info_mcc = DbDevInfo()
    new_device_info_mcc._class = "PhytronMcc2"
    new_device_info_mcc.server = "PhytronMcc2/raspi14"

    new_device = NAME + ctrl + '_' + addr + '_' + axis

    print("Creating device: %s" % new_device)
    new_device_info_mcc.name = new_device
    db.add_device(new_device_info_mcc)
    return (new_device)
예제 #7
0
def setup_tango_config(loaded_config):
    """ Set up tango configuration """
    devices = loaded_config["devices"]
    domain = loaded_config["domain"]
    default_logging_target = loaded_config["default_logging_target"]
    default_logging_level = loaded_config["default_logging_level"]

    for group_name, instances in devices.iteritems():
        for device_id, config in instances.iteritems():

            device_class = config["class"]
            full_device_name = "/".join([domain, group_name, device_id])
            device_server_name = config.get("server", None)
            device_server_id = config.get("server_id", domain)

            db.put_device_property(
                full_device_name, {
                    "logging_level": default_logging_level,
                    "logging_target": default_logging_target
                })

            # Set up all properties, substituting the actual value of domain for {domain}
            for property_name, property_value in config[
                    "properties"].iteritems():
                if type(property_value) is list:
                    formatted_val = map(lambda x: x.format(domain=domain),
                                        property_value)
                else:
                    try:
                        formatted_val = property_value.format(domain=domain)
                    except Exception as e:
                        formatted_val = property_value
                db.put_device_property(full_device_name,
                                       {str(property_name): formatted_val})

            if group_name == "rack" and config.get("components"):
                db.put_device_property(
                    full_device_name,
                    {"rack_components": json.dumps(config["components"])})

            if device_server_name is None:
                print "No device server specified for %s" % device_class
                exit()

            dev_info = DbDevInfo()
            dev_info._class = device_class
            dev_info.server = '%s/%s' % (device_server_name, device_server_id)
            dev_info.name = full_device_name
            db.add_device(dev_info)
for dev in ['lima', 'xspress3']:
    d = None
    try:
        d = DeviceProxy(args[dev])
    except DevFailed:
        pass

    if d:
        print 'Device aleady exist, skipping'
        exit()

db = Database()

print 'Creating LimaCCDs device'
lima = DbDevInfo()
lima._class = 'LimaCCDs'
lima.server = 'LimaCCDs/{instance}'.format(instance=args['name'])
lima.name = args['lima']
db.add_device(lima)

print 'Creating Xspress3 device'
x3 = DbDevInfo()
x3._class = 'Xspress3'
x3.server = 'LimaCCDs/{instance}'.format(instance=args['name'])
x3.name = args['xspress3']
db.add_device(x3)

print 'Setting Properties'
lima = DeviceProxy(args['lima'])
lima.put_property({'LimaCameraType': 'Xspress3'})
from PyTango import Database, DbDevInfo

#  A reference on the DataBase
db = Database()

# The devices name we want to create
new_device_name = "PIStageTango/ktof/pi_stage/test/c413test"

# Define the Tango Class served by this  DServer
new_device_info_stage = DbDevInfo()
new_device_info_stage._class = "linear Stage"
new_device_info_stage.server = "TangoTest"

# add the device
print("Creating device: %s" % new_device_name)
new_device_info_stage.name = new_device_name
db.add_device(new_device_info_stage)
예제 #10
0
from PyTango import Database, DbDevInfo

#  A reference on the DataBase
db = Database()


new_device_name1 = "test/powersupply/1"


# Define the Tango Class served by this  DServer
new_device_info_mouse = DbDevInfo()
new_device_info_mouse._class = "PowerSupply"
new_device_info_mouse.server = "PowerSupplyDS/test" #servername/instance

# add the first device
print("Creating device: %s" % new_device_name1)
new_device_info_mouse.name = new_device_name1
db.add_device(new_device_info_mouse)

예제 #11
0
"""Created Receiving device server class"""
class Receiving(Device):
    __metaclass__ = DeviceMeta

    def init_device(self):
        Device.init_device(self)
        self.set_state(DevState.STANDBY)
        self.debug_stream("Init Receiving Device.")

    @command(dtype_in='DevVarStringArray', dtype_out=None)
    def log(self, details):
        message = details[3]
#        print(message)
        self.debug_stream(message)

"""This part is needed to start device server from command line"""
if '--register' in sys.argv:
    reg_ind = sys.argv.index('--register')
    sys.argv.pop(reg_ind)
    name = sys.argv.pop(reg_ind)
    db = Database()
    dev_info = DbDevInfo()
    dev_info._class = 'Receiving'
    dev_info.server = 'ReceivingDS/logdev'
    dev_info.name = name
    db.add_device(dev_info)
    print("In registration")
else:
    print("Running DS")
    run([Receiving])
예제 #12
0
from PyTango import Database, DbDevInfo

# A reference on the Database
db = Database()

# Define device name
new_device_name = "test/tpm_board/1"
# Define the Tango Class served by this DServer
dev_info = DbDevInfo()
dev_info._class = "TPM_DS"
dev_info.server = "TPM_DS/test"
# add the device
dev_info.name = new_device_name
print("Creating device: %s" % new_device_name)
db.add_device(dev_info)

# Define device name
new_device_name = "test/roach_board/1"
# Define the Tango Class served by this DServer
dev_info = DbDevInfo()
dev_info._class = "ROACH_DS"
dev_info.server = "ROACH_DS/test"
# add the device
dev_info.name = new_device_name
print("Creating device: %s" % new_device_name)
db.add_device(dev_info)

# # Define device name
# new_device_name = "test/tpm_board/2"
# # Define the Tango Class served by this DServer
# dev_info = DbDevInfo()
예제 #13
0
from PyTango import Database, DbDevInfo

# A reference on the Database
db = Database()

# Define device name
new_device_name = "test/tpm_board/1"

# Define the Tango Class served by this DServer
dev_info = DbDevInfo()
dev_info._class = "TPM_DS"
dev_info.server = "TPM_DS/test"

# add the device
dev_info.name = new_device_name
print("Creating device: %s" % new_device_name)
db.add_device(dev_info)



# SECOND DEVICE
# Define device name
new_device_name = "test/tpm_board/2"

# Define the Tango Class served by this DServer
dev_info = DbDevInfo()
dev_info._class = "TPM_DS"
dev_info.server = "TPM_DS/test"

# add the device
dev_info.name = new_device_name
예제 #14
0
from PyTango import Database, DbDevInfo

#  A reference on the DataBase
db = Database()

new_device_name1 = "C3/unity/eras1"

# Define the Tango Class served by this  DServer
new_device_info_mouse = DbDevInfo()
new_device_info_mouse._class = "PyTracker"
new_device_info_mouse.server = "tango_pygame/eras1"  #servername/instance

# add the first device
print("Creating device: %s" % new_device_name1)
new_device_info_mouse.name = new_device_name1
db.add_device(new_device_info_mouse)