Commit f9d1ed46 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos

Merge branch 'issue_24' into 'master'

It fixes #24

Closes #24

See merge request !12
parents 49278315 11471bf9
......@@ -8,7 +8,7 @@
</parent>
<artifactId>MetadataManager</artifactId>
<version>3.1</version>
<version>3.3</version>
<packaging>pom</packaging>
<name>Tango MetadataManager</name>
......
......@@ -116,13 +116,12 @@ class StompClient():
if self.client.session.state == StompSession.CONNECTED:
# if the heartbeat changed, we disconnect
if self.heartbeat == self.heartbeat_set:
try:
self.LOG.debug("Beating. metadataManagerId=%s queueName=%s" % self._getManagerId(), self.queueName)
try:
self.client.beat()
except Exception as e:
# if the heartbeat failed we close the connection
# this put the client in the correct DISCONNECTED state
self.LOG.warn("Missed a heartBeat: %s" %e)
self.LOG.warn("Missed a heartBeat: %s" % str(e.message))
try:
self.client.close(True)
except:
......
......@@ -260,8 +260,7 @@ class MetadataManager (PyTango.Device_4Impl):
return state_ok
def read_scanName(self, attr):
attr.set_value(self.attr_scanName_read)
self.logger.info("read_scanName. scanName=%s metadatamanager=%s" % (self.attr_scanName_read, self.get_name()))
attr.set_value(self.attr_scanName_read)
def write_scanName(self, attr):
scanName = attr.get_write_value()
......@@ -616,7 +615,7 @@ class MetadataManager (PyTango.Device_4Impl):
return state_ok
# This sends a notification to the electronic logbook (ICAT+)
def sendNotification(self, category, message):
def sendNotification(self, eventType, category, message):
try:
if requests:
# The content of the message
......@@ -627,7 +626,7 @@ class MetadataManager (PyTango.Device_4Impl):
params = dict(
{
"type" : "notification",
"type" : eventType,
"datasetName" : datasetName,
"category" : category,
"content" : content,
......@@ -635,8 +634,8 @@ class MetadataManager (PyTango.Device_4Impl):
}
)
requests.adapters.DEFAULT_RETRIES = 1
# Some versions of requests have not got this configuration
#requests.adapters.DEFAULT_RETRIES = 1
headers = {'Content-Type': 'application/json', 'Accept':'application/json'}
requests.post(self.icatplus_server + "/investigations/" + str(self.get_proposal()) + "/instrument/" + self.beamlineID.lower() +"/events/notification?sessionId=" + self.API_KEY,
data=(json.dumps(params)),
......@@ -646,16 +645,19 @@ class MetadataManager (PyTango.Device_4Impl):
pass
def notifyInfo(self, message):
self.sendNotification("info", message)
self.sendNotification("notification", "info", message)
def notifyDebug(self, message):
self.sendNotification("debug", message)
self.sendNotification("notification", "debug", message)
def notifyCommand(self, message):
self.sendNotification("commandLine", message)
self.sendNotification("notification", "commandLine", message)
def notifyError(self, message):
self.sendNotification("error", message)
self.sendNotification("notification", "error", message)
def userComment(self, message):
self.sendNotification("annotation", "comment", message)
def InterruptScan(self):
self.debug("In InterruptScan()")
......@@ -1093,6 +1095,9 @@ class MetadataManagerClass(PyTango.DeviceClass):
'notifyCommand':
[[PyTango.DevString, "Message"],
[PyTango.DevVoid, "none"]],
'userComment':
[[PyTango.DevString, "Message"],
[PyTango.DevVoid, "none"]]
}
......
......@@ -123,11 +123,8 @@ class ParameterDefinition():
else:
s = str(json.loads(value)[p[1]])
except Exception as e:
print "============="
print p
traceback.print_exc(file=sys.stdout)
#self.LOG.error("Error reading attribute %s: %s" %(p[0], e))
except Exception as e:
traceback.print_exc(file=sys.stdout)
strrep.append(s)
return ' '.join(strrep)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment