Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Scripting alternative to core.wait()

Feedback
Kajaji
2013-02-06
2013-02-06
  • Kajaji
    Kajaji
    2013-02-06

    Since core.waitfor() does not work properly because of (I think wrong implementation) after 0.10.4, here is an alternative script function that can have the same effect (but not precisely).

    // Name: WaitUntil
    // License: Public Domain
    // Author: Khalid AlAjaji
    // Description: alternative to core.waitfor function which does not work after 0.10.4

    function WaitUntil(datestring,spec)
    {
    //example format of datestring "2010:04:30T20:35:00", spec is ""utc" or "local"

    tr = core.getTimeRate();
    JD = core.jdFromDateString(datestring,spec);
    if ( tr != 0 )
    {
    td = (JD-core.getJDay())*86400/tr; //td will be positive if both time differnece and time rate are negative or positive
    }
    core.debug("time rate is " + tr + " time difference is " + td);

    if ((tr != 0) && (td > 0))
    {
    core.wait(td);
    }
    } // end of WaitUntil()

    // Sample usage

    core.moveToAltAzi(25,0,2);
    core.setTimeRate(50);
    core.setDate("2010:04:30T20:30:00","local");
    WaitUntil("2010:04:30T20:25:00","local");
    core.setTimeRate(0);
    // Now move view direction south and up
    core.moveToAltAzi(25,180,2);

     
    Last edit: Kajaji 2013-02-06


Anonymous


Cancel   Add attachments