Up-Time counter

Super simple panel that displays how long Igor has been running:

Menu "Tools"
    "Up-time",/Q,getUpTime()
end
//___________________________________________________________________________________________________  
// update the up-time panel with the current up-time of Igor
Function upTimeTask(s)      // This is the function that will be called periodically
    STRUCT WMBackgroundStruct &s

    SetVariable valdisp0 Win=upTimePanel, value=_STR:Secs2Time(ticks/60,5)

    return 0    // Continue background task
end
//___________________________________________________________________________________________________  
// create a panel displaying the current up-time of Igor
Function getUpTime()
        // get up-time panel if it exists
    if (ItemsInList(WinList("upTimePanel",";","WIN:64")))
        DoWindow/F upTimePanel
    else
        // create up-time task
        Variable numTicks = 1 * 60      // 60 ticks = 1 second
        CtrlNamedBackground upTime, period=numTicks, proc=upTimeTask
        CtrlNamedBackground upTime, start
        // create up-time window
        Newpanel/K=1/NA=2/W=(0,0,120,20)/N=upTimePanel as ""
        SetVariable valdisp0, Win=upTimePanel, size={120,20},font='Nexa Light',frame=0, title="Up-Time:",value=_STR:time(),help={"The current up-time of Igor "+num2str(IgorVersion())}
        ModifyPanel/W=upTimePanel, cbRGB=(65534,65534,65534)
        SetWindow upTimePanel, hook(MyHook) = upTimeWindowHook 
    endif
end
//___________________________________________________________________________________________________  
// Stop the background task
Function StopUpTimeTask()
    CtrlNamedBackground upTime, stop
    dowindow/K upTimePanel
End
//___________________________________________________________________________________________________  
// Stop the background task if the window is killed
Function upTimeWindowHook(s)
    STRUCT WMWinHookStruct &s

    Variable hookResult = 0

    switch(s.eventCode)
        case 2:             // window killed
            StopUpTimeTask()
            break

    endswitch

    return hookResult       // 0 if nothing done, else 1
end
//___________________________________________________________________________________________________  

 

The set variable report uses a font that may not be on everyone's computer. You might simply delete the font selection.

Eventually, someone could add a button to report the up-time to the history (e.g. as a record of some time tracking on an experiment).

Thanks for the snippet!

@jjweimer - I think I have that font on absolutely everything, so much that I forget it's even set. It's part of our facility's identity after rebranding.....

Never-the-less if it isn't available the Igor default is used without error from recollection, though it can be safely deleted or altered. 

I have this start when Igor starts with e.g. this hook:

//___________________________________________________________________________________________________  
// Hook function to call when Igor starts
Function IgorStartOrNewHook(String igorApplicationNameStr)
    getUpTime()
End
//___________________________________________________________________________________________________  

My version seems to have a different help string that includes the full version and build number should anyone like that add the following in getUpTime():

SetVariable valdisp0, help={"The current up-time of Igor Pro"  +StringByKey("IGORFILEVERSION",IgorInfo(3)) + " (Build " +StringByKey("BUILD",IgorInfo(0)) + ")"}

 Edit: Here is a menu item to simply print the current up-time of Igor in the history area as jjweimer suggested:

"Print up-time to history",/Q,Print "Up-Time: "+Secs2Time(ticks/60,5)

 

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More