Snap integration through Snap devices
Is it possible that PyAlarm devices interact with the Snap system through Tango instead of a MySQL connection? Soleil is indeed using a Oracle snapshot database.
Sample code ( tested with Snap version of https://www2.synchrotron-soleil.fr/controle/packages/ArchivingRoot-22.1.0.zip):
- Create a context
import PyTango
import sys
try:
manager = PyTango.DeviceProxy("archiving/snapmanager/1")
result = manager.CreateNewContext(["ga","testica", "0", "2020-09-26", "test", "description", "ans/ca/machinestatus/current"])
print "Context created = ", result
except PyTango.DevFailed:
exctype , value = sys.exc_info()[:2]
print "Failed with exception !", exctype
for err in value :
print "---ERROR ELEMENT-------"
print err
- Create a snapshot from a context
import PyTango
import sys
import time
try:
archiver = PyTango.DeviceProxy("archiving/snaparchiver/1")
context_id = 77
archiver.TriggerLaunchSnapShot(context_id)
# wait for snapshot termination
while (archiver.state() == PyTango.DevState.RUNNING):
time.sleep(0.05)
# get its id
snap_id = archiver.GetSnapShotResult(context_id)
print "LaunchSnapShot finished, snaphot id =", snap_id
# if an error has occured, state of archiver is FAULT with error message in status
print archiver.state(), archiver.status()
# update comment, only available on manager device
manager = PyTango.DeviceProxy("archiving/snapmanager/1")
manager.UpdateSnapComment(([snap_id], ["updated comment"]))
except PyTango.DevFailed:
exctype , value = sys.exc_info()[:2]
print "Failed with exception !", exctype
for err in value :
print "---ERROR ELEMENT-------"
print err
- Get a snapshot data
import PyTango
import sys
import time
try:
extractor = PyTango.DeviceProxy("archiving/snapextractor/1")
attributes = extractor.GetAttributeListForContext(77)
for i in range(len(attributes)):
value = extractor.GetSnapValue(["99057", attributes[i]])
print attributes[i] , " = " , value
except PyTango.DevFailed:
exctype , value = sys.exc_info()[:2]
print "Failed with exception !", exctype
for err in value :
print "---ERROR ELEMENT-------"
print err
Edited by Raphaël GIRARDOT