hdb/tdb archiving with PyTango

Hi all,

I'm currently exploring data archiving with Tango and able to archive the data successfully with HDB and TDB (MySQL).

I would like to start/stop archiving of choosen attributes without using Mambo but with my GUI client !

i already asked question, without success, here :
http://www.tango-controls.org/community/forum/c/general/development/hdbtdb-archiving-without-mambo/?page=1

I resumed my start/stop archiving tests without going through Mambo. I am not expert with Python, but i am now using Pytango with a proxy device to speak directly to the DS. Here are my results and my questions …

STOP:
>>> import PyTango
>>> test_tdbarchiver = PyTango.DeviceProxy ("archiving/tdb/tdbarchiver.01_01")
>>> argin = ["sys/tg_test/1/short_scalar"]
>>> test_tdbarchiver.StopArchiveAtt (argin)
>>> print (test_tdbarchiver.state ())
OFF
>>> print (test_tdbarchiver.status ())
No attributes to archive

The archiving has been stopped :) seen in the table amt of the TDB database.

START:
>>> list = ["true"]
>>> list.append ("12")
>>> list.append ("sys/tg_test/1/short_scalar")
>>> list.append ("5")
>>> list.append ("1")
>>> list.append ("0")
>>> list.append ("archiving/tdb/tdbarchiver.01_01")
>>> list.append ("NULL")
>>> list.append ("5")
>>> list.append ("MODE_P")
>>> list.append ("14000")
>>> list.append ("TDB_SPEC")
>>> list.append ("150000")
>>> list.append ("259200000")
>>> result = test_tdbarchiver.command_inout ('TriggerArchiveConf', list)
>>> print (test_tdbarchiver.state ())
ON
>>> print (test_tdbarchiver.status ())
- KO []
- OK [
sys/tg_test/1/short_scalar]

Here is the problem:
TdbArchiver is in the 'ON' state but no archive, no data, no files;

For archiving resumes, i must:
1- stop and restart the TdbArchiver device !
2- otherelse, send 'init' command with AtkPanel !

Is this normal? Where do i make the mistake?

Is there a way to send the 'init' command directly with the proxy device ? The command_inout() returns following error:

>>> result=test_tdbarchiver.command_inout('init')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/PyTango/connection.py", line 93, in __Connection__command_inout
r = Connection.command_inout_raw(self, name, *args, **kwds)
File "/usr/lib/python2.7/dist-packages/PyTango/connection.py", line 118, in __Connection__command_inout_raw
return self.__command_inout(cmd_name, param)
PyTango.DevFailed: DevFailed[
DevError[
desc = please, restart device
origin = delete_device
reason = not supported
severity = ERR]

DevError[
desc = Init command failed!!
HINT: RESTART device with the Restart command of the device server adm. device
Device server adm. device name = dserver/tdbarchiver/01
origin = InitCmd.execute()
reason = API_InitThrowsException
severity = ERR]

DevError[
desc = Failed to execute command_inout on device archiving/tdb/tdbarchiver.01_01, command init
origin = Connection::command_inout()
reason = API_CommandFailed
severity = ERR]
]


Thanks,
JCM
Hi JCM,

Interacting with the Java archiver devices is not easy, as the actions required for the attribute archiving start are split between the Archiver and the Manager..

The process is automated if you use the PyTangoArchiving api instead, try the following:

# git clone https://github.com/tango-controls/pytangoarchiving pytangoarchiving.git
# cd pytangoarchiving.git
# ipython
import PyTangoArchiving
tdb = PyTangoArchiving.ArchivingAPI('tdb')
tdb.start_archiving('sys/tg_test/1/short_scalar',{'MODE_P':[14000]})

You may find some more documentation and recipes at this URL:
https://github.com/tango-controls/PyTangoArchiving/blob/master/doc/PyTangoArchiving_UserGuide.rst

Hope it helps,

Sergi Rubio
Keep on dancing,

http://www.tango-controls.org/resources/howto/how-fandango/
Hi Sergi,

after the problems with PyTango, I also try with PyTangoArchiving.
See my post and some questions here:
http://www.tango-controls.org/community/forum/c/development/python/hdbtdb-archiving-with-pytangoarchiving/?page=1#post-3117

Thank you.

I resumed my start/stop archiving tests using Pytango with a proxy device to communicate directly to the ArchivingManager DS.
Here are the commands i used in a python console.

How to stop an archiving…
>>> import PyTango
>>> test_archivingmanager = PyTango.DeviceProxy("archiving/hdbtdb/archivingmanager.1")
>>> argin = ["sys/tg_test/1/short_scalar"]
>>> test_archivingmanager.ArchivingStopTdb(argin)

How to start an archiving…
>>> argStartTdb = ["1"]
>>> argStartTdb.append("1")
>>> argStartTdb.append("sys/tg_test/1/short_scalar")
>>> argStartTdb.append("MODE_P")
>>> argStartTdb.append("60000")

>>> test_archivingmanager.command_inout('ArchivingStartTdb',argStartTdb)

Seems ok :)
Regards.
 
Register or login to create to post a reply.