Changeset 1017


Ignore:
Timestamp:
Jul 15, 2012 8:45:39 AM (11 years ago)
Author:
jemian
Message:

fixes #11, always require whitespace after "def" or "rdef" when not a macro function

Location:
specdomain/trunk/src/specdomain
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • specdomain/trunk/src/specdomain/comparison/auto.mac

    r1014 r1017  
    6262----------------------------------------
    6363The filter adjustment assures a high incident photon rate within a band
    64 just below the rate limit of the detector. The width of the band is defined
    65 by the step size in transmission, defined in AUTO_FILTER_FACTOR,
     64just below the rate limit of the detector. The width of the band is
     65defined by the step size in transmission, defined in AUTO_FILTER_FACTOR,
    6666which is used for each correction. If the count rate is higher than
    6767AUTO_RATE_LIMIT, the transmission is immediately reduced by
     
    132132
    133133No special configuration is needed to run these macros. Simply load the macro
    134 file and run :spec:def:`auto_setup`::
    135 
    136   > qdo auto.mac
    137   > auto_setup
     134file and run ``auto_setup``::
     135
     136> qdo auto.mac
     137> auto_setup
    138138
    139139Dependencies
     
    142142Dependencies on other macros:
    143143
    144 * :spec:macrofile:`filter.mac` (used to control the attenuators):
    145 
    146   - :spec:def:`filter_trans`
    147   - :spec:def:`filter_get_trans()`
    148   - :spec:def:`filter_get_trans_up()`
    149   - :spec:def:`filter_get_mask()`
    150   - :spec:def:`filter_max()`
    151 
    152 * :spec:def:`recount` (modified count command used to retake an exposure)
     144* filter.mac (used to control the attenuators):
     145
     146  - filter_trans
     147  - filter_get_trans()
     148  - filter_get_trans_up()
     149  - filter_get_mask()
     150  - filter_max()
     151
     152* recount (modified count command used to retake an exposure)
    153153
    154154Impact
     
    156156The following chained macro definitions are affected by this macro:
    157157
    158 * :spec:def:`user_prescan_head`
    159 * :spec:def:`user_chk_counts` (from our modified :spec:def:`count` command)
    160 * :spec:def:`user_precount`
     158* user_prescan_head
     159* user_chk_counts (provided in our modified ``count`` command)
     160* user_precount
    161161
    162162File information
     
    252252  SPHINX code documentation suite.
    253253
    254 2012/07/13 (CS):
    255 
    256 - renamed some private macros to start with underscores::
    257 
    258     auto_precount        --> _auto_precount
    259     auto_prescan_head    --> _auto_prescan_head
    260     auto_user_chk_counts --> _auto_user_chk_counts
    261 
    262 - moved the macro definitions for the above macros out of the
    263   :spec:def:`auto_set_level` macro to avoid unnecessary nested definitions.
    264 
    265 
    266254TO DO
    267255-----
     
    270258- complete documentation
    271259- insert hyperlinks into documentation
    272 
    273260"""
    274261
    275 ###############################################################################
     262#==============================================================================
     263
     264#==============================================================================
    276265# Global variable definitions
    277 ###############################################################################
    278 
    279   global AUTO_MAC                 #: Save the name of this macro file
    280   global AUTO_LEVEL               #: Type of adjustments {0,1,2}
    281   global AUTO_MODE                #: Adjustment mode (pilot vs. post-exp) {0,1}
    282   global AUTO_COUNTER             #: Counter to monitor
    283   global AUTO_COUNT_RBV           #: Counter read back value (measured counts)
    284   global AUTO_RETRY_MAX           #: Maximum number of retries
    285   global AUTO_EXP_LOW             #: Low exposure time limit
    286   global AUTO_EXP_HIGH            #: High exposure time limit
    287   global AUTO_PILOT_EXPTIME       #: Exposure time for pilot exposures
    288   global AUTO_RATE_LIMIT          #: High rate limit
    289   global AUTO_COUNT_HIGH          #: High count limit
    290   global AUTO_COUNT_TARGET        #: Target count level
    291   global AUTO_COUNT_LOW           #: Low count limit
    292   global AUTO_FILTER_FACTOR       #: Filter transmission factor for adjustments
    293   global AUTO_COUNT_PREC          #: Count time precision (rounding)
    294   global AUTO_FILTER_LOCK         #: Lock if rate-limited
    295   global AUTO_SET_PILOT           #: Set pilot exposure time in user_precount
    296   global AUTO_ORIG_EXPTIME        #: Save the original requested count time
    297   global AUTO_DEBUG               #: Debug flag
     266#==============================================================================
     267
     268  # Save the name of this macro file (Used for the help function).
     269  global AUTO_MAC
     270         AUTO_MAC = DOFILE
     271
     272  global AUTO_LEVEL                # Type of adjustments {0,1,2}
     273  global AUTO_MODE                 # Adjustment mode (pilot/post-exp){0,1}
     274  global AUTO_COUNTER              # Counter to monitor
     275  global AUTO_COUNT_RBV            # Counter read back value (measured counts)
     276  global AUTO_RETRY_MAX            # Maximum number of retries
     277  global AUTO_EXP_LOW              # low exposure time limit
     278  global AUTO_EXP_HIGH             # highexposure time limit
     279  global AUTO_PILOT_EXPTIME        # exposure time for pilot exposures
     280  global AUTO_RATE_LIMIT           # High rate limit
     281  global AUTO_COUNT_HIGH           # High count limit
     282  global AUTO_COUNT_TARGET         # Target count level
     283  global AUTO_COUNT_LOW            # Low count limit
     284  global AUTO_FILTER_FACTOR        # Filter transmission factor for adjustments
     285  global AUTO_COUNT_PREC           # Count time precision (rounding)
     286
     287  global AUTO_FILTER_LOCK          # Lock if rate-limited
     288  global AUTO_SET_PILOT            # Set pilot exposure time in user_precount
     289  global AUTO_ORIG_EXPTIME         # save the original requested count time
     290  global AUTO_DEBUG                # debug flag
    298291
    299292  # set default values for global variables
    300   AUTO_MAC = DOFILE
    301293  AUTO_COUNTER = det
    302294  AUTO_LEVEL = 0
     
    317309  AUTO_DEBUG = 0
    318310
    319 
    320 ###############################################################################
     311#==============================================================================
    321312# Macro command definitions
    322 ###############################################################################
     313#==============================================================================
    323314
    324315#------------------------------------------------------------------------------
    325316# allow for misspelled help commands
    326 #def autohelp '{auto_help}'
     317def autohelp 'auto_help'
    327318
    328319def auto_help '{
     
    506497  Turn off any automatic filter and exposure adjustments.
    507498
    508   USAGE::
     499  Usage::
    509500
    510501    > auto_off
    511502
    512   NOTE:
    513     This command is equivalent to ``auto_set_level 0``
    514 
    515   SEE ALSO:
     503  .. note:: This command is equivalent to ``auto_set_level 0``
     504
     505  .. seealso::
    516506     :spec:def:`auto_set_level`,
    517507     :spec:def:`auto_on`
     
    527517def auto_on '{
    528518  """
    529   Turn on automatic filter and exposure adjustments.
    530 
    531   This macro is identical to :spec:def:`auto_set_level`. Please refer to the
    532   :spec:def:`auto_set_level` documentation for more details.
    533   """
    534 
     519  See :spec:def:`auto_set_level`
     520  """
    535521auto_set_level $*
    536522
     
    542528  Set the level of automatic filter and exposure adjustments.
    543529
    544   USAGE::
     530  Usage::
    545531
    546532    > auto_set_level [<level>]
    547533    > auto_on [<level>]
    548 
    549   If now arguement is given, the user is prompted for input. The argument
    550   ``<level>`` can be one of the following:
    551 
    552       =====  =================================================================
    553       Level  Description
    554       =====  =================================================================
    555       ``0``  No automatic adjustments are made
    556       ``1``  Only filters are adjusted, no exposure time adjustments
    557       ``2``  Both filters and exposure times are automatically adjusted
    558       =====  =================================================================
    559 
    560   EXAMPLES::
     534        where <level> can be one of the following:
     535          0 - automatic filter and exposure OFF
     536          1 - automatic filter ON, automatic exposure OFF
     537          2 - automatic filter and exposure ON
     538        if <level> is ommitted, the users is asked for input
     539
     540
     541        ===== =================================================================
     542        Level Description
     543        ===== =================================================================
     544        0     No automatic adjustments are made
     545        1     Only filters are adjusted, no exposure time adjustments
     546        2     Both filters and exposure times are automatically adjusted
     547        ===== =================================================================
     548
     549
     550  Examples::
    561551
    562552    > auto_set_level
     
    566556        turns on automatic filter adjustments (level 1)
    567557
    568   NOTE:
    569      :spec:def:`auto_set_level` and :spec:def:`auto_on` are equivalent to
    570      each other.
    571 
    572   SEE ALSO:
     558  .. note::
     559     ``auto_set_level`` and ``auto_on`` are equivalent to each other
     560
     561  .. seealso::
    573562     :spec:def:`auto_off`
    574563
     
    606595  }
    607596
     597  #-------------------------------------------
     598  # define necessary chained macro definitions
     599
     600  #--------------------
     601  def auto_prescan_head \'
     602  #   =================
     603    # if automatic filter setting is active start scan with very low
     604    # filter transmission
     605    if(AUTO_LEVEL > 0){
     606      AUTO_ORIG_EXPTIME = COUNT_TIME
     607      filter_trans 1e-8
     608      if(AUTO_LEVEL > 1){
     609        # start with low exposure times
     610        COUNT_TIME = AUTO_EXP_LOW
     611        _ctime = COUNT_TIME
     612      }
     613    }
     614    # add auto_cleanup to cleanup_once
     615    cdef("cleanup_once","auto_cleanup; ", "auto_cleanup_once_key",0x20)
     616  \'
     617
     618  #-----------------------
     619  def auto_user_chk_counts \'
     620  #   ====================
     621    if(AUTO_LEVEL > 0){
     622      # automatic filter and exposure setting (if activated)
     623      success = _auto_adjust_redo()
     624    }
     625  \'
     626
     627  #----------------
     628  def auto_precount \'
     629  #   =============
     630    if(AUTO_LEVEL > 0){
     631      if(AUTO_MODE == 1 & AUTO_SET_PILOT == 1){
     632        # remember the original exposure time
     633        AUTO_ORIG_EXPTIME = COUNT_TIME
     634        # set the pilot exposure time
     635        COUNT_TIME = AUTO_PILOT_EXPTIME
     636        _ctime = COUNT_TIME
     637        AUTO_SET_PILOT = 0
     638      }
     639    }
     640  \'
     641
     642  #---------------
     643  def auto_cleanup \'
     644  #   ============
     645    # drop in filters after finishing, since we do not know where we end up
     646    # (center of a peak for dscan?)
     647    AUTO_SET_PILOT = 1
     648    AUTO_FILTER_LOCK = 0
     649    if(AUTO_LEVEL > 0){
     650      filter_trans 1e-8
     651    }
     652    cdef("cleanup_once", "", "auto_cleanup_once_key", "delete")
     653  \'
     654
     655
    608656  #--------------------------------------------
    609657  # include necessary chained macro definitions
     
    612660  if (AUTO_LEVEL > 0){
    613661
    614     #: add _auto_prescan_head to user_prescan_head
    615     cdef("user_prescan_head", "{_auto_prescan_head}; ", \
    616          "auto_prescan_head_key", 0x10)
    617 
    618     #: add _auto_user_chk_counts to user_chk_counts
    619     cdef("user_chk_counts", "{_auto_user_chk_counts}; ", \
     662    # add auto_prescan_head to user_prescan_head
     663    cdef("user_prescan_head", "auto_prescan_head; ", "auto_prescan_head_key",\
     664         0x10)
     665
     666    # add auto_user_chk_counts to user_chk_counts
     667    cdef("user_chk_counts", "auto_user_chk_counts; ", \
    620668         "auto_user_chk_counts_key")
    621669
    622     #: add _auto_precount to user_precount
    623     cdef("user_precount", "{_auto_precount}; ", "auto_precount_key", 0x10)
    624 
    625     #: add _auto_cleanup to the end of user_scan_tail
    626     cdef("user_scan_tail","{_auto_cleanup}; ", \
     670    # add auto_precount to user_precount
     671    cdef("user_precount", "auto_precount; ", "auto_precount_key", 0x10)
     672
     673    # add auto_cleanup to the end of user_scan_tail
     674    cdef("user_scan_tail","auto_cleanup; ", \
    627675         "auto_user_scan_tail_key",0x20)
     676
    628677  }
    629678
     
    637686  if (AUTO_LEVEL < 1) {
    638687
    639     #: remove _auto_prescan_head from user_prescan_head
     688    # remove auto_prescan_head from user_prescan_head
    640689    cdef("user_prescan_head", "", "auto_prescan_head_key", "delete")
    641690
    642     #: remove _auto_user_chk_counts from user_chk_counts
     691    # remove auto_user_chk_counts from user_chk_counts
    643692    cdef("user_chk_counts", "", "auto_user_chk_counts_key", "delete")
    644693
    645     #: remove _auto_precount from user_precount
     694    # remove auto_precount from user_precount
    646695    cdef("user_precount", "", "auto_precount_key", "delete")
    647696
    648     #: remove _auto_cleanup from user_scan_tail
     697    # remove auto_cleanup from user_scan_tail and cleanup_once
    649698    cdef("user_scan_tail", "", "auto_user_scan_tail_key", "delete")
    650     #: remove _auto_cleanup from cleanup_once
    651699    cdef("cleanup_once", "", "auto_cleanup_once_key", "delete")
    652700  }
     
    662710  exposure time adjustments.
    663711
    664   DESCRIPTION:
     712  Description:
     713
    665714    Need some more details here...
    666715
    667   USAGE::
     716
     717  Usage::
    668718
    669719    > auto_set_mode [<mode>]
     
    673723        when called with no arguments, the user is prompted
    674724
    675   EXAMPLE::
     725  Example::
    676726
    677727    > auto_set_mode 1
    678728        use the pilot exposure mode for automatic adjustments.
    679729
    680   SEE ALSO:
     730  .. seealso::
     731
    681732    :spec:def:`auto_setup`
    682733
     
    716767  adjustments.
    717768
    718   USAGE::
     769  Usage::
    719770
    720771    > auto_set_exposure [<min> <max>]
     
    722773        when called with no arguments, the user is prompted
    723774
    724   EXAMPLE::
     775  Arguments:
     776
     777  :param float min_exptime: minimum exposure time [s]
     778  :param float max_exptime: maximum exposure time [s]
     779
     780  Example:
     781
     782    * set the minimum exposure time to 1 sec and the maximum to 10 sec::
    725783
    726784      > auto_set_exposure 1 10
    727           set the minimum exposure time to 1 sec and the maximum to 10 sec
    728785
    729786  """
     
    754811  Display the current auto settings.
    755812
    756   USAGE::
     813  Usage::
    757814
    758815    > auto_show
     
    800857  Display the current auto-level exposure settings.
    801858
    802   USAGE::
     859  Usage::
    803860
    804861    > auto_show_exposure
     
    812869
    813870
    814 ###############################################################################
     871#==============================================================================
    815872# Internal macros
    816 ###############################################################################
    817 
    818 #------------------------------------------------------------------------------
    819 def _auto_cleanup '{
    820   """
    821   Cleanup routine for automatic filter/exposure control
    822   """
    823 
    824   # drop in filters after finishing, since we do not know where we end up
    825   # (center of a peak for dscan?)
    826   AUTO_SET_PILOT = 1
    827   AUTO_FILTER_LOCK = 0
    828   if(AUTO_LEVEL > 0){
    829     filter_trans 1e-10
    830   }
    831   #: remove _auto_cleanup_once from cleanup_once
    832   cdef("cleanup_once", "", "auto_cleanup_once_key", "delete")
    833 }'
    834 
    835 
    836 #------------------------------------------------------------------------------
    837 def _auto_prescan_head '{
    838   """
    839   Prepare for automatic filter/exposure control before the start of a scan
    840 
    841   This inserts filters with a transmission of 1e-10, sets some values in
    842   the global variables and adds a cleanup routine to ``cleanup_once``.
    843   """
    844 
    845   # if automatic filter setting is active start scan with very low
    846   # filter transmission
    847   if(AUTO_LEVEL > 0){
    848     AUTO_ORIG_EXPTIME = COUNT_TIME
    849     filter_trans 1e-10
    850     if(AUTO_LEVEL > 1){
    851       # start with low exposure times
    852       COUNT_TIME = AUTO_EXP_LOW
    853       _ctime = COUNT_TIME
    854     }
    855   }
    856   #: add _auto_cleanup to cleanup_once
    857   cdef("cleanup_once","{_auto_cleanup}; ", "auto_cleanup_once_key",0x20)
    858 }'
    859 
    860 
    861 #------------------------------------------------------------------------------
    862 def _auto_user_chk_counts '{
    863   """
    864   Check if counts are valid and retake exposure if necessary.
    865   """
    866 
    867   if(AUTO_LEVEL > 0){
    868     # automatic filter and exposure setting (if activated)
    869     success = _auto_adjust_redo()
    870   }
    871 }'
    872 
    873 
    874 #------------------------------------------------------------------------------
    875 def _auto_precount '{
    876   """
    877   Prepare for automatic filter/exposure control at beginning of count command.
    878   """
    879 
    880   if(AUTO_LEVEL > 0){
    881     if(AUTO_MODE == 1 & AUTO_SET_PILOT == 1){
    882       # remember the original exposure time
    883       AUTO_ORIG_EXPTIME = COUNT_TIME
    884       # set the pilot exposure time
    885       COUNT_TIME = AUTO_PILOT_EXPTIME
    886       _ctime = COUNT_TIME
    887       AUTO_SET_PILOT = 0
    888     }
    889   }
    890 }'
    891 
     873#==============================================================================
    892874
    893875#------------------------------------------------------------------------------
    894876def _auto_print_setup '{
    895877  """
    896   Print the configuration options and current values to screen
    897 
    898   NOTE:
     878  Summary
     879  -------
     880  Prints the configuration options and current values to screen
     881
     882  .. note::
    899883     The option numbers must be kept in sync between
    900884     :spec:def:`_auto_set_option` and
     
    935919def _auto_set_option '{
    936920  """
    937   Sets a new value for a given option.
    938 
    939   DESCRIPTION:
     921  Sets a new value for a given option
     922
     923  Description:
     924
    940925    Sets a new value for a given option from the options menu that was created
    941926    with the :spec:def:`_auto_print_setup` command.
    942927
    943   NOTE:
    944     The option numbers must be kept in sync between
    945     :spec:def:`_auto_set_option` and
    946     :spec:def:`_auto_print_setup`.
     928  .. note::
     929     The option numbers must be kept in sync between
     930     :spec:def:`_auto_set_option` and
     931     :spec:def:`_auto_print_setup`.
    947932
    948933  """
     
    11781163  Analyze the previous exposure
    11791164
    1180   DESCRIPTION:
     1165  Description:
     1166
    11811167    This macro retrieves the necessary information to analyze the last exposure
    11821168    and to initiate adjustments, if necessary. Usually, this step consists only
     
    11861172    etc.
    11871173
    1188   USAGE::
     1174  Usage::
    11891175
    11901176    > _auto_analyze_exposure
     
    12021188  Calculate and apply necessary exposure time and filter adjustments.
    12031189
    1204   DESCRIPTION:
    1205 
    1206     The function returns 1 if transmission or exposure time have been changed,
    1207     0 otherwise.
    1208 
    1209   USAGE::
    1210     > changed = _auto_adjust()
     1190  Description:
     1191
     1192    The function returns 1 if transmission or exposure time are changed, 0
     1193    otherwise.
    12111194
    12121195  """
     
    14241407  Make sure the user-entered exposure times are consistent
    14251408
    1426   USAGE::
     1409  Usage::
    14271410
    14281411    > _auto_check_exposure
     
    14461429  Make sure the user-entered count levels are consistent
    14471430
    1448   USAGE::
     1431  Usage::
    14491432
    14501433    > _auto_check_levels
     
    14761459  round it to the given count time precision.
    14771460
    1478   USAGE::
     1461  Usage::
    14791462
    14801463    > adjusted_time = _auto_calc_exposure(requested_time)
     
    15031486  Determines whether the auto-adjusting has been successful.
    15041487
    1505   DESCRIPTION:
     1488  Description:
    15061489
    15071490    If the current exposure does not meet the required criteria, counting
     
    15101493    The function returns 1 in case of success, 0 otherwise.
    15111494
    1512   USAGE::
     1495  Usage::
    15131496
    15141497    > success = _auto_adjust_redo()
    15151498
    1516   NOTE:
    1517     This macro makes use of the :spec:def:`recount` macro, which has to be
    1518     added to SPEC during the startup procedure.
     1499  .. note::
     1500     This macro makes use of the :spec:def:`recount` macro, which has to be
     1501     added to SPEC during the startup procedure.
    15191502
    15201503  """
     
    15631546    Clears the terminal screen
    15641547
    1565     DESCRIPTION:
     1548    Description:
     1549
    15661550      Clears the screen without losing the screen history or messing up the
    15671551      scrolling capabilities (this has been a problem for certain terminals)
     
    15691553      returning the cursor to the top left corner.
    15701554
    1571     USAGE::
     1555    Usage::
    15721556
    15731557      > _clear_screen
     
    15921576}
    15931577
    1594 ###############################################################################
     1578#==============================================================================
    15951579# End of $Id: $
    1596 ###############################################################################
     1580#==============================================================================
  • specdomain/trunk/src/specdomain/doc/bugs.rst

    r1016 r1017  
    99* fix the signature recognition for roles
    1010* fix the signature handling for roles and directives
    11 * grep detection of macros fails for def declarations in extended comments (TRAC ticket #11)::
    12 
    13         > I found the cause of the processing error. It must have something to do
    14         > the the regex you use to identify definitions. Line 65 in the header
    15         > docstring started with the word "defined". Somehow that triggered the
    16         > regexp, which collected everything up to the next "(", which happens to be
    17         > on line 69 "(2*AUTO_FILTER_FACTOR)".
    18         > I temporarily fixed the problem by moving the word "defined" to the end of
    19         > the previous line, but this fluke could potentially arise again. Is there
    20         > a way of not searching for any of the function declarations (def, cdef,
    21         > rdef, global, ...) inside a docstring? Otherwise, you may have to improve
    22         > the regex.
  • specdomain/trunk/src/specdomain/sphinxcontrib/specmacrofileparser.py

    r1007 r1017  
    8787                        string_start
    8888                        + r'\s*?'                           # optional blank space
    89                         + r'(r?def)                      # 1: def_type (rdef | def)
     89                        + r'(r?def)\s'                      # 1: def_type (rdef | def)
    9090                        + non_greedy_whitespace
    9191                        + macro_name_match                  # 2: macro_name
Note: See TracChangeset for help on using the changeset viewer.