fermi-ad / acsys-python

Python module to access the Fermilab Control System
MIT License
8 stars 4 forks source link

Clock Event Hardware and Software type not working #79

Closed gopikaops closed 4 months ago

gopikaops commented 4 months ago

Hi Team I am trying to get Hardware and Software type event data. This is my DRF request - B:VIMIN@E,10,S,0 and B:VIMIN@E,10,H,0

I am referring the DRF - https://www-bd.fnal.gov/controls/public/drf2/#event


The Clock event uses signals provided by the global timing system.

clock-evt         = "E," evt-number [ "," type [ "," delay ] ]

evt-number        = hex-number                             ; evt-number < 216

type              = "H"                                    ; hardware 
                  | "S"                                    ; software
                  | "E"                                    ; either one (default)

delay             = time-freq                              ; default is 0

This is the error I am getting -

AD142074-MLT:gmps-ml gopikab$ python3 collect.py 
B:VIMIN@E,10,H,0
Feb 26, 2024 21:25
Traceback (most recent call last):
  File "/Users/gopikab/Documents/vimin-ml/gmps-ml/collect.py", line 54, in <module>
    general_getter(parameter, "")
  File "/Users/gopikab/Documents/vimin-ml/gmps-ml/collect.py", line 42, in general_getter
    return acsys.run_client(wrapper)
  File "/Users/gopikab/Library/Python/3.9/lib/python/site-packages/acsys/__init__.py", line 831, in run_client
    return loop.run_until_complete(client_fut)
  File "/Users/gopikab/Library/Python/3.9/lib/python/site-packages/nest_asyncio.py", line 90, in run_until_complete
    return f.result()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 256, in __step
    result = coro.send(None)
  File "/Users/gopikab/Library/Python/3.9/lib/python/site-packages/acsys/__init__.py", line 807, in __client_main
    result = (await main(con, **kwargs))
  File "/Users/gopikab/Documents/vimin-ml/gmps-ml/collect.py", line 30, in wrapper
    for index, data in enumerate(evt_res.data):
AttributeError: 'ItemStatus' object has no attribute 'data'
AD142074-MLT:gmps-ml gopikab$ python3 collect.py 
B:VIMIN@E,10,S,0
Feb 26, 2024 21:25
Traceback (most recent call last):
  File "/Users/gopikab/Documents/vimin-ml/gmps-ml/collect.py", line 54, in <module>
    general_getter(parameter, "")
  File "/Users/gopikab/Documents/vimin-ml/gmps-ml/collect.py", line 42, in general_getter
    return acsys.run_client(wrapper)
  File "/Users/gopikab/Library/Python/3.9/lib/python/site-packages/acsys/__init__.py", line 831, in run_client
    return loop.run_until_complete(client_fut)
  File "/Users/gopikab/Library/Python/3.9/lib/python/site-packages/nest_asyncio.py", line 90, in run_until_complete
    return f.result()
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/asyncio/tasks.py", line 256, in __step
    result = coro.send(None)
  File "/Users/gopikab/Library/Python/3.9/lib/python/site-packages/acsys/__init__.py", line 807, in __client_main
    result = (await main(con, **kwargs))
  File "/Users/gopikab/Documents/vimin-ml/gmps-ml/collect.py", line 30, in wrapper
    for index, data in enumerate(evt_res.data):
AttributeError: 'ItemStatus' object has no attribute 'data'
AD142074-MLT:gmps-ml gopikab$ 

Here is my code - https://github.com/fermi-ad/gmps-ml/blob/main/collection_gmps_ml_project_parameters.py Additionally, I am able to get all the data with default type : B:VIMIN@E,10,E,0

beauremus commented 4 months ago

When you get a response, it can be data ItemData or a status ItemStatus. The status is an error that communicates why you didn't get data. These stack traces tell you that you didn't account for ItemStatus coming back because the ItemStatus class doesn't have a data attribute; only ItemData has a data attribute.

If you're using an .is_reading check or .is_reading_for like below, the else condition will be an ItemStatus. You can print that status to get more information.

        # Process incoming data
        async for evt_res in dpm:
            if evt_res.is_reading_for(0):
                # This 0 argument matches the tag in `add_entry`
                if evt_res.is_reading_for(0):
                    print(evt_res)
                else:
                    # This is responses to tags that aren't 0
                    pass
            else:
                # This is likely a status response
                pass
                # You could print the status
                #print(f'Status: {evt_res}')

You are getting an error because what you are requesting doesn't exist. Data Logger config event 14 Data Logger config event 10 Here are the two event configurations I found for B:VIMIN. e,14,e,0 and e,10,e,0 So, when you request

B:VIMIN@E,10,S,0 and B:VIMIN@E,10,H,0

The logger can't find a match to your request. It's probably returning a "node not found" error, which tells you that no configuration matches your request.

If you want data with these configurations, you must create entries in D43 for them.

Let me know if I missed the mark on this. Let's figure out what you need!