Skip to content
Snippets Groups Projects

Resolve "Add the proposal session name"

Merged Wout De Nolf requested to merge 52-add-the-proposal-session-name into master
Files
3
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# -*- coding:utf-8 -*-
##############################################################################
@@ -7,24 +7,24 @@
##============================================================================
##
## File : MetaExperiment.py
##
##
## Project : Metadata for high level experiment
##
## This file is part of Tango device class.
##
##
## Tango is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
##
## Tango is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
##
## You should have received a copy of the GNU General Public License
## along with Tango. If not, see <http://www.gnu.org/licenses/>.
##
##
##
## $Author : andy.gotz$
##
@@ -64,19 +64,19 @@ class MetaExperiment (tango.LatestDeviceImpl):
tango.LatestDeviceImpl.__init__(self,cl,name)
self.debug_stream("In __init__()")
MetaExperiment.init_device(self)
def delete_device(self):
self.debug_stream("In delete_device()")
self.debug_stream("In delete_device()")
self.client.disconnect()
def init_device(self):
self.debug_stream("In init_device()")
self.get_device_properties(self.get_device_class())
self.attr_proposalName_read = ''
self.attr_proposal_read = ''
self.attr_proposalSession_read = ''
self.attr_sample_read = ''
self.attr_dataRoot_read = ''
self.attr_proposalName_read = 'please enter'
self.attr_dataRoot_read = ''
self.attr_proposal_read = 'please enter'
self.attr_proposalSession_read = 'please enter'
self.attr_sample_read = 'please enter'
self.attr_dataRoot_read = '/data/visitor/'
@@ -99,7 +99,7 @@ class MetaExperiment (tango.LatestDeviceImpl):
self.logger.addHandler(graypy.GELFUDPHandler(self.graylogServer, self.graylogPort))
except:
traceback.print_exc(file=sys.stdout)
# JMS client
self.client = StompClient(self.queueURLs, self.queueName, self.beamlineID, jolokia_port=self.jolokiaPort)
self.info_stream("Configuration URL=%s" %self.client.getConfigURL())
@@ -109,66 +109,66 @@ class MetaExperiment (tango.LatestDeviceImpl):
self.proxy = tango.DeviceProxy(self.get_name())
# mimic write_hardware without side effects
db = tango.Util.instance().get_database()
attr_map = db.get_device_attribute_property(self.get_name(),['proposalName','proposalSession','sample','dataRoot'])
self.attr_proposalName_read = attr_map['proposalName'].get('__value',[''])[0]
self.attr_proposalSession_read = attr_map['proposalSession'].get('__value',[''])[0]
attr_map = db.get_device_attribute_property(self.get_name(),['proposal','proposalSession','sample','dataRoot'])
self.attr_proposal_read = attr_map['proposal'].get('__value',[''])[0]
self.attr_proposalSession_read = attr_map['proposalSession'].get('__value',[''])[0]
self.attr_sample_read = attr_map['sample'].get('__value',[''])[0]
self.attr_dataRoot_read = attr_map['dataRoot'].get('__value',[''])[0]
if self.attr_proposalName_read:
self.info_stream("Recovered proposal name %s" %self.attr_proposalName_read)
if self.attr_proposalSession_read:
if self.attr_proposal_read:
self.info_stream("Recovered proposal name %s" %self.attr_proposal_read)
if self.attr_proposalSession_read:
self.info_stream("Recovered proposal session %s" %self.attr_proposalSession_read)
if self.attr_sample_read:
self.info_stream("Recovered sample name %s" %self.attr_sample_read)
if self.attr_dataRoot_read:
self.info_stream("Recovered data root %s" %self.attr_dataRoot_read)
# we need to push them in this order
self.push_change_event("ProposalName", self.attr_proposalName_read)
self.push_change_event("ProposalName", self.attr_proposal_read)
self.push_change_event("ProposalSession", self.attr_proposalSession_read)
self.push_change_event("Sample", self.attr_sample_read)
self.push_change_event("DataRoot", self.attr_dataRoot_read)
self.UpdateState()
#----- PROTECTED REGION END -----# // MetaExperiment.init_device
#----- PROTECTED REGION END -----# // MetaExperiment.init_device
def always_executed_hook(self):
self.debug_stream("In always_executed_hook()")
#----- PROTECTED REGION ID(MetaExperiment.always_executed_hook) ENABLED START -----#
#----- PROTECTED REGION END -----# // MetaExperiment.always_executed_hook
#----- PROTECTED REGION END -----# // MetaExperiment.always_executed_hook
#--------------------------------------------------------------------------
# MetaExperiment read/write attribute methods
#--------------------------------------------------------------------------
def read_proposalName(self, attr):
self.debug_stream("In read_proposalName()")
def read_proposal(self, attr):
self.debug_stream("In read_proposal()")
#----- PROTECTED REGION ID(MetaExperiment.proposal_read) ENABLED START -----#
attr.set_value(self.attr_proposalName_read)
#----- PROTECTED REGION END -----# // MetaExperiment.proposal_read
def write_proposalName(self, attr):
self.debug_stream("In write_proposalName()")
attr.set_value(self.attr_proposal_read)
#----- PROTECTED REGION END -----# // MetaExperiment.proposal_read
def write_proposal(self, attr):
self.debug_stream("In write_proposal()")
data = attr.get_write_value()
#----- PROTECTED REGION ID(MetaExperiment.proposal_write) ENABLED START -----#
# new proposal (investigation) registration, if not empty
if data and (data != self.attr_proposalName_read):
if data and (data != self.attr_proposal_read):
self.CreateInvestigation(data)
self.attr_proposalName_read = data
self.push_change_event("ProposalName", self.attr_proposalName_read)
self.attr_proposal_read = data
self.push_change_event("ProposalName", self.attr_proposal_read)
self.proxy.write_attribute("sample", "please enter")
self.proxy.write_attribute("dataRoot", "/data/visitor/")
self.UpdateState()
#----- PROTECTED REGION END -----# // MetaExperiment.proposal_write
#----- PROTECTED REGION END -----# // MetaExperiment.proposal_write
def read_proposalSession(self, attr):
self.debug_stream("In read_proposalSession()")
#----- PROTECTED REGION ID(MetaExperiment.read_proposalSession) ENABLED START -----#
attr.set_value(self.attr_proposalSession_read)
#----- PROTECTED REGION END -----# // MetaExperiment.session_read
#----- PROTECTED REGION END -----# // MetaExperiment.session_read
def write_proposalSession(self, attr):
self.debug_stream("In write_proposalSession()")
data = attr.get_write_value()
@@ -178,15 +178,15 @@ class MetaExperiment (tango.LatestDeviceImpl):
self.proxy.write_attribute("sample", "please enter")
self.proxy.write_attribute("dataRoot", "/data/visitor/")
self.UpdateState()
#----- PROTECTED REGION END -----# // MetaExperiment.session_write
#----- PROTECTED REGION END -----# // MetaExperiment.session_write
def read_sample(self, attr):
self.debug_stream("In read_sample()")
#----- PROTECTED REGION ID(MetaExperiment.sample_read) ENABLED START -----#
attr.set_value(self.attr_sample_read)
#----- PROTECTED REGION END -----# // MetaExperiment.sample_read
#----- PROTECTED REGION END -----# // MetaExperiment.sample_read
def write_sample(self, attr):
self.debug_stream("In write_sample()")
data = attr.get_write_value()
@@ -194,14 +194,14 @@ class MetaExperiment (tango.LatestDeviceImpl):
self.attr_sample_read = data
self.push_change_event("Sample", self.attr_sample_read)
self.UpdateState()
#----- PROTECTED REGION END -----# // MetaExperiment.sample_write
#----- PROTECTED REGION END -----# // MetaExperiment.sample_write
def read_dataRoot(self, attr):
self.debug_stream("In read_dataRoot()")
#----- PROTECTED REGION ID(MetaExperiment.dataRoot_read) ENABLED START -----#
attr.set_value(self.attr_dataRoot_read)
#----- PROTECTED REGION END -----# // MetaExperiment.dataRoot_read
#----- PROTECTED REGION END -----# // MetaExperiment.dataRoot_read
def write_dataRoot(self, attr):
self.debug_stream("In write_dataRoot()")
data = attr.get_write_value()
@@ -209,22 +209,22 @@ class MetaExperiment (tango.LatestDeviceImpl):
self.attr_dataRoot_read = data
self.push_change_event("DataRoot", self.attr_dataRoot_read)
self.UpdateState()
#----- PROTECTED REGION END -----# // MetaExperiment.dataRoot_write
#----- PROTECTED REGION END -----# // MetaExperiment.dataRoot_write
def read_attr_hardware(self, data):
self.debug_stream("In read_attr_hardware()")
#----- PROTECTED REGION ID(MetaExperiment.read_attr_hardware) ENABLED START -----#
#----- PROTECTED REGION END -----# // MetaExperiment.read_attr_hardware
#----- PROTECTED REGION END -----# // MetaExperiment.read_attr_hardware
#--------------------------------------------------------------------------
# MetaExperiment command methods
#--------------------------------------------------------------------------
def dev_state(self):
""" This command gets the device state (stored in its device_state data member) and returns it to the caller.
:return: Device state
@@ -234,11 +234,11 @@ class MetaExperiment (tango.LatestDeviceImpl):
argout = tango.DevState.UNKNOWN
#----- PROTECTED REGION ID(MetaExperiment.State) ENABLED START -----#
self.Connect()
#----- PROTECTED REGION END -----# // MetaExperiment.State
#----- PROTECTED REGION END -----# // MetaExperiment.State
if argout != tango.DevState.ALARM:
tango.LatestDeviceImpl.dev_state(self)
return self.get_state()
def dev_status(self):
""" This command gets the device status (stored in its device_status data member) and returns it to the caller.
:return: Device status
@@ -271,44 +271,44 @@ class MetaExperiment (tango.LatestDeviceImpl):
self.client.sendObject(inv)
def UpdateState(self):
if not self.attr_proposalName_read or (self.attr_proposalName_read == "please enter"):
if not self.attr_proposal_read or (self.attr_proposal_read == "please enter"):
self.set_status("No experiment started")
elif not self.attr_proposalSession_read or (self.attr_proposalSession_read == "please enter"):
self.set_status("No experiment started")
elif self.attr_sample_read and (self.attr_sample_read != "please enter"):
self.set_status("Ready to start dataset for experiment %r and session %r" % (self.attr_proposalName_read, self.attr_proposalSession_read))
self.set_status("Ready to start dataset for experiment %r and session %r" % (self.attr_proposal_read, self.attr_proposalSession_read))
else:
self.set_status("Experiment %r session %r started" % (self.attr_proposalName_read, self.attr_proposalSession_read))
self.set_status("Experiment %r session %r started" % (self.attr_proposal_read, self.attr_proposalSession_read))
try:
self.append_status(self.client.getStatus(),True)
except Exception:
self.debug_stream("Error appending status")
#----- PROTECTED REGION END -----# // MetaExperiment.programmer_methods
#----- PROTECTED REGION END -----# // MetaExperiment.programmer_methods
class MetaExperimentClass(tango.DeviceClass):
#--------- Add you global class variables here --------------------------
#----- PROTECTED REGION ID(MetaExperiment.global_class_variables) ENABLED START -----#
#----- PROTECTED REGION END -----# // MetaExperiment.global_class_variables
#----- PROTECTED REGION END -----# // MetaExperiment.global_class_variables
# Class Properties
class_property_list = {
'graylogServer':
[tango.DevString,
[tango.DevString,
"Graylog Server",
["graylog-dau.esrf.fr"] ],
'graylogPort':
[tango.DevInt,
[tango.DevInt,
"Graylog port",
[12203] ],
'queueURLs':
[tango.DevVarStringArray,
[tango.DevVarStringArray,
"URLs of the queues (including port)",
["bcu-mq-01.esrf.fr:61613"]],
'queueName':
[tango.DevString,
[tango.DevString,
"Name of the stomp queue for sending ingestion requests",
["/queue/icatIngest"] ],
'jolokiaPort':
@@ -321,7 +321,7 @@ class MetaExperimentClass(tango.DeviceClass):
# Device Properties
device_property_list = {
'beamlineID':
[tango.DevString,
[tango.DevString,
"Beamline ID for reporting metadata",
[] ],
}
@@ -334,7 +334,7 @@ class MetaExperimentClass(tango.DeviceClass):
# Attribute definitions
attr_list = {
'proposalName':
'proposal':
[[tango.DevString,
tango.SCALAR,
tango.READ_WRITE],
@@ -371,8 +371,8 @@ def main():
py = tango.Util(sys.argv)
py.add_class(MetaExperimentClass, MetaExperiment, 'MetaExperiment')
#----- PROTECTED REGION ID(MetaExperiment.add_classes) ENABLED START -----#
#----- PROTECTED REGION END -----# // MetaExperiment.add_classes
#----- PROTECTED REGION END -----# // MetaExperiment.add_classes
U = tango.Util.instance()
U.server_init()
Loading