Author Topic: time logging  (Read 1645 times)

0 Members and 1 Guest are viewing this topic.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
time logging
« on: March 11, 2008, 09:08:01 AM »
has anyone had any luck with a lisp time logger. i've come across a few here:
one that will log when the file was opened, one that will log when you save and one that works with reactors that will display the "actual" time worked in the drawing (taking into account leaving the drawing for meetings, bathroom breaks, etc. - based on a time interval of inactivity.) the last is really what i'm looking for (Jürg Menzi's routine), the only problem is that when i loaded it into my startup and work on a job steady for 3-4 hours, it would tell me that i've only worked on it for 30 min. i'm thinking that if i stepped away for any short amount of time and the 'sleep' reactor kicked in, then when i came back it did not turn off.

Amsterdammed's seems like it would do, but i can't seem to figure out how/where it writes a log.

any thoughts?
any help would be greatly appreciated.
btw, i know that cab suggested spherical time and that would be perfect, but my company won't let us install software on our computers, so it has to be lisp/vba.

link: http://www.theswamp.org/index.php?topic=2489.15
link: http://www.theswamp.org/index.php?topic=5446.0
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: time logging
« Reply #1 on: March 12, 2008, 12:14:08 AM »
here is the one i would like to figure out why the timer isn't working properly...

Code: [Select]
;== AcadDoc.lsp ==============================================================
; Sets Command Reactors to collect the command time.
; Sets a DocManager Reactor to release the Reactor objects at the end
; of an AutoCAD session.
; Copyright:
;   ©2005 MENZI ENGINEERING GmbH, Switzerland
; Notes:
;   - None
; - Initialize ActiveX support
(vl-load-com)
;
; - Initialize session variables
;
(setq Me:DwgNme ""   ;empty drawing name
      Me:CmdTim 0   ;command time
      Me:CmdTmp 0   ;temporary command time
      Me:CmdCnt 0   ;command count
      Me:TimOut 180   ;command timeout
)
;
; - Reactors ------------------------------------------------------------------
;
; - If not set, initialize DocManager-Reactor
(or Me:ReaDma
 (setq Me:ReaDma (VLR-DocManager-Reactor
                  nil
                 '(
                   (:VLR-documentToBeDestroyed . MeDocToBeDestroyedCallbacks)
                  )
                 )
 )
)
; - If not set, initialize DWG-Reactor
(or Me:ReaDwg
 (setq Me:ReaDwg (VLR-DWG-Reactor
                  nil
                 '(
                   (:VLR-SaveComplete . MeDwgSaveCompleteCallbacks)
                  )
                 )
 )
)
; - If not set, initialize Command-Reactor
(or Me:ReaCom
 (setq Me:ReaCom (VLR-Command-Reactor
                  nil
                 '(
                   (:VLR-commandWillStart . MeCommandWillStartCallbacks)
                   (:VLR-commandEnded . MeCommandEndedCallbacks)
                   (:VLR-commandCancelled . MeCommandCancelledCallbacks)
                  )
                 )
 )
)
;
; - Notifications -------------------------------------------------------------
;
; - MeDwgSaveComplete notifications
(defun MeDwgSaveCompleteCallbacks (Rea Arg)
 (MeDoDwgSaveCompleteStuff Arg)
 (princ)
)
; - CommandWillStart notifications
(defun MeCommandWillStartCallbacks (Rea Arg)
 (MeDoCmdWillStartStuff Arg)
 (princ)
)
; - CommandEnded notifications
(defun MeCommandEndedCallbacks (Rea Arg)
 (MeDoCmdEndedStuff Arg)
 (princ)
)
; - CommandCancelled notifications
(defun MeCommandCancelledCallbacks (Rea Arg)
 (MeDoCmdCancelledStuff Arg)
 (princ)
)
; - DocToBeDestroyed notifications
(defun MeDocToBeDestroyedCallbacks (Rea Arg)
 (MeWriteToLog)
 (MeDoCloseStuff)
 (princ)
)
;
; - Subs ----------------------------------------------------------------------
;
; - DWG save complete function
(defun MeDoDwgSaveCompleteStuff (Arg)
 (setq Me:DwgNme (cadr Arg))
 (princ)
)
; - Command will start function
(defun MeDoCmdWillStartStuff (Arg)
 (setq Me:CmdTmp (getvar "MILLISECS")
       Me:CmdCnt (1+ Me:CmdCnt)
 )
 (princ)
)
; - Command ended function
(defun MeDoCmdEndedStuff (Arg / TmpVal)
 (setq TmpVal (- (getvar "MILLISECS") Me:CmdTmp)
       Me:CmdTim (if (> TmpVal (* Me:TimOut 1000)) ;User is sleeping
                  Me:CmdTim
                  (+ TmpVal Me:CmdTim)
                 )
 )
 (princ)
)
; - Command cancelled function
(defun MeDoCmdCancelledStuff (Arg / TmpVal)
 (setq TmpVal (- (getvar "MILLISECS") Me:CmdTmp)
       Me:CmdTim (if (> TmpVal (* Me:TimOut 1000)) ;User was sleeping
                  Me:CmdTim
                  (+ TmpVal Me:CmdTim)
                 )
 )
 (princ)
)
;
; - Write to log function
(defun MeWriteToLog ()
 (alert (strcat
         "Drawing name:\t\t" Me:DwgNme
         "\nTotal command time:\t" (MeCalcTime Me:CmdTim)
         "\nTotal commands called:\t" (itoa Me:CmdCnt)
        )
 )
 (princ)
)
; - Reactor cleanup function
(defun MeDoCloseStuff ( / VarLst)
 (setq VarLst (MeGetReaVars))
 (mapcar 'VLR-remove (mapcar 'eval VarLst))
 (mapcar '(lambda (l) (set l nil)) VarLst)
 (princ)
)
; - Collect global reactor variables
(defun MeGetReaVars ( / RetVal)
 (foreach memb (atoms-family 1)
  (if (wcmatch (strcase memb) "ME:REA*")
   (setq RetVal (cons memb RetVal))
  )
 )
 (mapcar 'read RetVal)
)
; - Calculate time from msecs
(defun MeCalcTime (Val / TimHrs TimMin TimSec TmpVal)
 (setq TmpVal (fix (/ Val 1000.0))
       TimSec (rem TmpVal 60)
       TmpVal (/ (- TmpVal TimSec) 60)
       TimMin (rem TmpVal 60)
       TimHrs (/ (- TmpVal TimMin) 60)
 )
 (strcat (itoa TimHrs) "h " (itoa TimMin) "m " (itoa TimSec) "s")     
)

(princ)
; == End AcadDoc.lsp ==========================================================
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox