EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
<== Date ==> <== Thread ==>

Subject: Re: How to: IOC reading information from file?
From: "Cobb, Tom \(DLSLtd,RAL,LSCI\) via Tech-talk" <tech-talk at aps.anl.gov>
To: "Marco A. Barra Montevechi Filho" <marco.filho at lnls.br>, Michael Davidsaver <mdavidsaver at gmail.com>
Cc: "Nariyoshi, Pedro" <nariyosh at frib.msu.edu>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Tue, 29 Nov 2022 14:05:51 +0000
An alternative approach if going down the Python route is to write the whole IOC in Python using pythonSoftIOC. Something like this:

import json

# Import the basic framework components.
from softioc import asyncio_dispatcher, builder, softioc

# Set the record prefix
builder.SetDeviceName("MY-DEVICE-PREFIX")

# Make some dummy data
with open("/tmp/mydata.json", "w") as f:
    f.write('{"my_var": 1.0}')

# Create some records
value = builder.aIn("VALUE", initial_value=0.0)


def set_value_from_json(path: str):
    with open(path) as f:
        text = f.read()
    value.set(json.loads(text)["my_var"])


path = builder.stringOut("PATH", always_update=True, on_update=set_value_from_json)

# Boilerplate get the IOC started
builder.LoadDatabase()
softioc.iocInit(asyncio_dispatcher.AsyncioDispatcher())

# Finally leave the IOC running with an interactive shell.
softioc.interactive_ioc(globals())

# On commandline:
# $ caget MY-DEVICE-PREFIX:VALUE
# MY-DEVICE-PREFIX:VALUE 0.0
# $ caput MY-DEVICE-PREFIX:PATH /tmp/mydata.json
# $ caget MY-DEVICE-PREFIX:VALUE
# MY-DEVICE-PREFIX:VALUE 1.0

Thanks,
Tom

From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Michael Davidsaver via Tech-talk <tech-talk at aps.anl.gov>
Sent: 28 November 2022 20:55
To: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>
Cc: Nariyoshi, Pedro <nariyosh at frib.msu.edu>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: How to: IOC reading information from file?
 
On 11/28/22 12:37, Michael Davidsaver wrote:
> On 11/28/22 12:05, Marco A. Barra Montevechi Filho via Tech-talk wrote:
>> Thanks for the suggestion, Pedro!
>>
>> At the end of the day, i figured that maybe autosave fdbrestore function would do what i wanted. Unfortunately, the function was resulting in segmentation fault. Looking in tech-talk i found this thread: https://epics.anl.gov/tech-talk/2014/msg01851.php <https://epics.anl.gov/tech-talk/2014/msg01851.php> which suggested that for autosave versions before 5.4.1 it is a known bug which is fixed after that. Since im using autosave 5-10-2 and the PVs are not very long, i gave up using autosave for this.
>
> Could you provide any details which might go into a ticket?
> Specific arguments used?  ideally a stack trace?  etc...
>
> https://github.com/epics-modules/autosave/issues

I haven't tried fdbrestore() previously, so I'm not certain about the
caput() errors.  It certainly didn't crash on me.

Did you do full cleanup and rebuild when switching between autosave versions?
(eg. "make distclean", or just deleting and re-downloading the source)

Linking in old object code files is great way to experience some bizarre crashes.


> epics> var save_restoreDebug 5
> epics> fdbrestore "ioc_settings.sav"
> save_restore:fdbrestore:entry
> save_restore:request_manual_restore: entry
> save_restore task: calling do_manual_restore('ioc_settings.sav')
> save_restore:do_manual_restore: entry for file 'ioc_settings.sav'
> epics> do_manual_restore:ca_put() to 'TST:Speed-SP.VAL'failed.
> do_manual_restore:ca_put() to 'TST:DM-Sel.VAL'failed.
> do_manual_restore:ca_put() to 'TST:SampT-Sel.VAL'failed.
> do_manual_restore:ca_put() to 'TST:SampT:N-Sel.VAL'failed.
> do_manual_restore:ca_put() to 'TST:SampDet-Sel.VAL'failed.
> do_manual_restore:ca_put() to 'TST:Plt-SP.VAL'failed.
> do_manual_restore:ca_put() to 'TST:Samp-SP.VAL'failed.
> do_manual_restore:ca_put() to 'TST:Plt:N-SP.VAL'failed.
> do_manual_restore:ca_put() to 'TST:Samp:N-SP.VAL'failed.
> do_manual_restore:ca_put() to 'TST:Gn:X-SP.VAL'failed.
> do_manual_restore:ca_put() to 'TST:Gn:Y-SP.VAL'failed.
> do_manual_restore:ca_put() to 'TST:Gn:Z-SP.VAL'failed.
> do_manual_restore:ca_put() to 'TST:Tl-Sel.VAL'failed.
> save_restore: manual restore status=1 (0==success)


 

-- 

This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
 


References:
How to: IOC reading information from file? Marco A. Barra Montevechi Filho via Tech-talk
Re: How to: IOC reading information from file? Nariyoshi, Pedro via Tech-talk
Re: How to: IOC reading information from file? Marco A. Barra Montevechi Filho via Tech-talk
Re: How to: IOC reading information from file? Michael Davidsaver via Tech-talk
Re: How to: IOC reading information from file? Michael Davidsaver via Tech-talk

Navigate by Date:
Prev: Re: Problem downloading from sequenzer repo Birke, Thomas via Tech-talk
Next: Re: Problem downloading from sequenzer repo Andrew Johnson via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
Navigate by Thread:
Prev: Re: How to: IOC reading information from file? Michael Davidsaver via Tech-talk
Next: Re: How to: IOC reading information from file? Marco A. Barra Montevechi Filho via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
ANJ, 29 Nov 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·