.. Magnet Information documentation master file, created by
   sphinx-quickstart on Tue Aug  1 10:23:57 2023.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to mgnt_info's documentation!
==============================================

``mgnt_info`` provides a command-line tool for interacting with the magnet information retrieval functions. 
Magnet retrieval works in two modes: single-magnet retrieval and multi-magnet retrieval. 

Single-magnet retrieval will output the following data for one magnet: 

'ELEMENT', 'BARCODE', 'AREA', 'EPICS_CHANNEL_ACCESS_NAME', 'ENGINEERING_NAME', 'LINACZ_M', 'DEVICE', 'OPS_STATUS', 
'PSC_TYPE', 'PSC_DEVICE', 'PSC_LOCN', 'ACSW_NODE', 'TS_NODE', 'MCOR_CRATE_NUM', 'MCOR_CRATE_CHAN', 'BULK_PS', 'IOC', 
'SW_PS_STRING', 'ACSW_NAME', 'ACSW_HOST', 'ACSW_PLUG', 'HW_AREA', 'HW_DISPLAY', 'LIMIT_DISPLAY', 'UNIT_DISPLAY', 
'COOLING_TYPE', 'SAFETY_PPS', 'DEGAUSS_FUNC', 'DEGAUSS_RAMP_RATE', 'DEGAUSS_SETL', 'DEGAUSS_WF', 'DISPLAY_SUBAREA', 
'DISPLAY_AREA', 'PS_STRING', 'PS_CONFIG', 'IMIN_VAL', 'IMAX_VAL', 'BMIN_VAL', 'BMAX_VAL', 'STDZ_FUNC', 'STDZCYCLENUM_VAL', 
'STDZIMIN_VAL', 'STDZIMAX_VAL', 'STDZIFINAL_VAL', 'TRIMRAMPRATE_VAL', 'TRIMSETL_VAL', 'COEFF_0_VAL', 'COEFF_1_VAL', 
'COEFF_2_VAL', 'COEFF_3_VAL', 'COEFF_4_VAL', 'COEFF_5_VAL', 'COEFF_6_VAL', 'COEFF_7_VAL', 'COEFF_8_VAL', 'COEFF_9_VAL', 
'COEFF_10_VAL', 'COEFF_11_VAL', 'COEFF_12_VAL'

Multi-magnet retrieval will output the following data for multiple magnets:

'ELEMENT' and 'EPICS_CHANNEL_ACCESS_NAME'

To get more info about a magnet found using multi-magnet retrieval, use the single-magnet functionality by running ``mgnt_info`` with the device or element name specified.

``mgnt_info`` supports various options to filter the magnet data based on device name, element name, facility, cooling type, and engineering name. 
The retrieved data is printed to the console, and it can be optionally saved as a JSON file. See supported arguments.

``mgnt_info`` currently supports the following arguments:

   * -d, --device_name; Retrieves magnet info by device name
   * -e, --element_name; Retrieves magnet info by element name
   * -f <facility>, --facility; Retrieves magnet info by individual facility, expects <AD_ACCEL> or <FACET2>
   * -s, --string; Retrieves magnet info based on if the magnet is part of a string, expects <INDIVIDUAL> or <STRING>
   * -c, --cooling_type; Retrieves magnet info based on cooling method, expects <AIR> or <HELIUM> or <WATER> or <NONE>
   * -n <ename>, --engineering_name; Retrieves magnet info by engineering name
   * -o <fields>, --output_fields; Select what fields to output, expects a valid field, see above list of outputted data for a list of valid fields
   * -u, --user_friendly_output; Outputs the data in a user friendly manner, expects any argument
   * -j <file_name>, --json; Outputs data to a json file, expects file name as argument

For example (single-magnet retrieval):
::
   sh-3.2$ ./mgnt_info.py -d BEND:CLTS:280

would return
::
   [{'ELEMENT': 'BLRCUS', 'BARCODE': '4584', 'AREA': 'CLTS', 'EPICS_CHANNEL_ACCESS_NAME': 'BEND:CLTS:280', 'ENGINEERING_NAME': '0.625SD38.98', 'LINACZ_M': '3076.79', 'DEVICE': 'SEPT', 'OPS_STATUS': 'Commissioned, Online', 'PSC_TYPE': 'EPSC', 'PSC_DEVICE': 'PSC:CLTS:MG08', 'PSC_LOCN': ' ', 'ACSW_NODE': ' ', 'TS_NODE': ' ', 'MCOR_CRATE_NUM': '0', 'MCOR_CRATE_CHAN': '0', 'BULK_PS': ' ', 'IOC': 'SIOC:SYS0:MG08', 'SW_PS_STRING': ' ', 'ACSW_NAME': ' ', 'ACSW_HOST': ' ', 'ACSW_PLUG': '0', 'HW_AREA': 'CLTS', 'HW_DISPLAY': 'mgnt_epsc', 'LIMIT_DISPLAY': 'mgnt_limits_aux', 'UNIT_DISPLAY': 'mgnt_unit2', 'COOLING_TYPE': 'WATER', 'SAFETY_PPS': '0', 'DEGAUSS_FUNC': 'DISABLED', 'DEGAUSS_RAMP_RATE': '0', 'DEGAUSS_SETL': '0', 'DEGAUSS_WF': ' ', 'DISPLAY_SUBAREA': 'CLTS', 'DISPLAY_AREA': 'bsyCu', 'PS_STRING': ' ', 'PS_CONFIG': 'INDIVIDUAL', 'IMIN_VAL': '0', 'IMAX_VAL': '130', 'BMIN_VAL': '0.1061', 'BMAX_VAL': '15.606', 'STDZ_FUNC': 'ENABLED', 'STDZCYCLENUM_VAL': '3', 'STDZIMIN_VAL': '0', 'STDZIMAX_VAL': '130', 'STDZIFINAL_VAL': '0', 'TRIMRAMPRATE_VAL': '10', 'TRIMSETL_VAL': '10', 'COEFF_0_VAL': '-0.9133', 'COEFF_1_VAL': '8.61424', 'COEFF_2_VAL': '-0.0432501', 'COEFF_3_VAL': '0.0024633', 'COEFF_4_VAL': '-2.00019e-05', 'COEFF_5_VAL': '-1.25678e-06', 'COEFF_6_VAL': '0', 'COEFF_7_VAL': '0', 'COEFF_8_VAL': '0', 'COEFF_9_VAL': '0', 'COEFF_10_VAL': '0', 'COEFF_11_VAL': '0', 'COEFF_12_VAL': '0'}]

Another example (multi-magnet retrieval):
::
   sh-3.2$ ./mgnt_info.py -n 0.625SD38.98 -u True

would return
::
   +-----------+-----------------------------+
   | ELEMENT   | EPICS_CHANNEL_ACCESS_NAME   |
   +===========+=============================+
   | BLXSPH    | BEND:SPH:170                |
   +-----------+-----------------------------+
   | BLXSPS    | BEND:SPS:470                |
   +-----------+-----------------------------+
   | BLRCUS    | BEND:CLTS:280               |
   +-----------+-----------------------------+
   3 results

Note, mgnt_info temporarily only works on lcls-dev3

.. toctree::
   :maxdepth: 2
   :caption: Contents:



=================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
