• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X PCB Editor
  3. Calling scripts within the desired time intervals

Stats

  • State Suggested Answer
  • Replies 1
  • Answers 1
  • Subscribers 160
  • Views 4580
  • Members are here 0
More Content

Calling scripts within the desired time intervals

DPGDA
DPGDA over 1 year ago

Hi,

I would like to prepare either script or skill function that would perform some tasks within the desired amount of time.

I've seen the hiRegTimer() function as a SKILL process, but it does not work in Allegro products (or I cannot use it properly).

Ideally, I would like to open the PCB design, then the popup window appears asking for the interval value and then the script executes predefimed commands within the set intervals.

  • Sign in to reply
  • Cancel
  • JuanCR
    0 JuanCR over 1 year ago

    Hello DPGDA,

    You are aware of the hiRegTimer() function - this can be used to schedule functions to be called at a number of tenths of seconds in the future, provided that the top level user interface is not blocked. This works well, but it is only a single-shot execution. If you want repeated execution, you need to get the function to submit another hiRegTimer call, and so on.

    I understand you would like a convenient way of setting up and managing repeating jobs.

    The following SKILL code provides such a solution. The comments in the code give examples of its use - when you submit a job, it returns an identifier - that identifier can be used to terminate a repeating job. As a result, multiple concurrent scheduled jobs can be easily managed with the package.

    You should however take care not to schedule anything that is too lengthy to run, since this will appear to occasionally freeze the user interface as the scheduled task runs.

    You should avoid loading the CCStimer.ils code more than once within the same Virtuoso session. Doing so will lose information about any currently scheduled jobs and will also cause the same job ids to be re-used. This can have the effect of causing recently terminated jobs to run multiple times. If you are loading the code from a SKILL script which may get loaded again later, you should consider using this snippet of code to avoid the file being loaded twice:

    unless(boundp('CCStimer)
      load("/path/to/CCStimer.ils")
    )

    The SKILL code is given below:

    /* CCStimer.ils

    Language   SKILL
    Date       Sep 17, 2007 

    A package for scheduling timer jobs, either one off or
    repeated. The scheduler returns an id, and this id can
    also be used to terminate the scheduled job.

    ; schedule a one-off job
    job1=CCStimer->schedule("println('hello)" 50)
    ; schedule a repeated job
    job2=CCStimer->schedule("println('goodbye)" 50 ?repeat t)
    ; terminate the repeated job:
    CCStimer->terminate(job2)

    Can also schedule functions of one argument (the id):

    CCStimer->schedule(lambda((id) printf("Job id is %d\n" id)) 30)

    This example works in SKILL++. It uses a lambda function and
    a lexically scoped counter to terminate the repeating job after
    a specified number of times.

    (defun CCSrunNTimes (command time ntimes)
      (CCStimer->schedule
       (lambda (id) (if (greaterp ntimes 0) 
                        (errsetstring command t)
                        (CCStimer->terminate id))
               (predecrement ntimes))
       time
       ?repeat t
       )
      )

    ; print out a message 10 times, every 2 seconds.
    CCSrunNTimes("println(\"hello\")" 20 10)

    Note - this code uses SKILL++ semantics, and so should keep the
    ils suffix.

    ***************************************************

    SCCS Info: @(#) CCStimer.ils 10/10/07.13:01:45 1.2

    */
    /*******************************************************************************
    *  DISCLAIMER: The following code is provided for Cadence customers to use at  *
    *   their own risk. The code may require modification to satisfy the           *
    *   requirements of any user. The code and any modifications to the code may   *
    *   not be compatible with current or future versions of Cadence products.     *
    *   THE CODE IS PROVIDED "AS IS" AND WITH NO WARRANTIES, INCLUDING WITHOUT     *
    *   LIMITATION ANY EXPRESS WARRANTIES OR IMPLIED WARRANTIES OF MERCHANTABILITY *
    *   OR FITNESS FOR A PARTICULAR USE.                                           *
    *******************************************************************************/

    (importSkillVar CCStimer)
    (setq CCStimer
          (let (
                (timerIdTable (makeTable 'timerIds nil))
                (nextId 1)
                )

            /***************************************************************
            *                                                              *
            *      (schedule callback tenthsSeconds @key repeat "txg")     *
            *                                                              *
            *      Exported function to schedule a job. The job is a       *
            * specified callback string, and it will be executed at least  *
            * the specified tenths of seconds in the future. If ?repeat t  *
            *    is passed, the job will be rescheduled once executed -    *
            *          otherwise it will only be scheduled once.           *
            *         Returns an identifier (integer) for the job.         *
            *                                                              *
            ***************************************************************/
            (defun schedule (callback tenthsSeconds @key repeat "gxg")
              (let (newId)
                (unless (or (stringp callback) (symbolp callback) (procedurep callback))
                  (error "schedule: callback must be a string, symbol, or function object: %L\n"
                         callback)
                  )
                (setq newId (postincrement nextId))
                (setarray timerIdTable newId 
                          list(callback tenthsSeconds repeat))
                (hiRegTimer 
                  (sprintf nil "CCStimer->execute(%d)" newId)
                  tenthsSeconds
                  )
                newId
                )
              )

            /***************************************************************
            *                                                              *
            *                      (terminate id "x")                      *
            *                                                              *
            *  Exported function to terminate a job, given an id. Returns  *
            * t if the id was terminated, nil if the id didn't correspond  *
            *              to a job that is still scheduled.               *
            *                                                              *
            ***************************************************************/
            (defun terminate (id "x")
              (remove id timerIdTable)!=nil
              )

            /***************************************************************
            *                                                              *
            *                       (execute id "x")                       *
            *                                                              *
            *     Exported function - only expected to be invoked from     *
            *     inside the timer scheduled by the function schedule.     *
            *                                                              *
            ***************************************************************/
            (defun execute (id "x")
              (let (jobDetails)
                (setq jobDetails (arrayref timerIdTable id))
                (when jobDetails
                  (if (stringp (car jobDetails))
                      (errsetstring (car jobDetails) t)
                      (errset (funcall (car jobDetails) id) t)
                      )
                  ;----------------------------------------------------------
                  ; If the repeat flag was set, schedule it again. Otherwise
                  ; delete the job details
                  ;----------------------------------------------------------
                  (if (caddr jobDetails)
                    (hiRegTimer 
                      (sprintf nil "CCStimer->execute(%d)" id)
                      (cadr jobDetails)
                      )
                    (terminate id)
                    )
                  ) ; when jobDetails
                ) ; let
              ) ; defun

            ;----------------------------------------------------------------
            ; Return DPL with exported functions
            ;----------------------------------------------------------------
            (list nil
                  'schedule schedule
                  'terminate terminate
                  'execute execute
                  )
            ) ; let
          ) ; setq

    This was taken from an article on COS, which you can find here: 

    Article (11381132) Title: How to schedule a repeating function with a timer in SKILL
    URL: https://support.cadence.com/apex/ArticleAttachmentPortal?id=a1Od0000000nZocEAE

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information