06-08-2010 04:32 PM
Has anyone created an elapsed time (or current time, for that matter) indicator, that shows HH:MM:SS or maybe DD:HH:MM:SS ?
It seems an obvious thing, but I can't find anything built into CVI in the way of a control to do this. Maybe there's an ActiveX control that does it.
Thanks
06-09-2010 12:45 AM
Hi Menchar,
I am not aware of a built-in control, but it is simple to do: I am using the following: GetSystemTime ( &hours,&minutes,&seconds ) and then the Fmt function to format the numbers to a string, something like Fmt ( text_display, "%i%s%i%s%i", hours, ":", minutes, ":", seconds ) and then use a regular text control to display the text/time string.
The only thing: I am afraid that this was too trivial for you and you were looking for something different...
06-09-2010 10:54 AM
Wolfgang -
Well, I suppose I was looking for something all fixed up with some cool time related functionality so I wouldn't have to hack it out. Maybe I'm getting lazy in my old age.
I was looking for something that showed elapsed time after an arbitrary start time, this is a bit different from simply getting the system time and showing it.
Actually, I think I may be able to find this in some old code from ten years ago.
Yes, I'm sure of it - I was being lazy
Menchar
06-09-2010 12:36 PM
Menchar,
For most common time-related operations, you might want to look into the Utility Library>>Date/Time>>CVI Time set of functions. It doesn't include formatting functions, but you can always use a function like CVITimeIntervalToTimeUnit to obtain the individual components, and then use some other function, as Wolfgang suggested, to format them into a single string. As another example, you can use the Programmer's Toolbox CVIAbsoluteTimeToCVIUILTime to convert your timestamp to the format used in the UI Library, and then use the UI Library's FormatDateTimeString function, which allows for more sophisticated formatting.
Luis
06-09-2010 12:57 PM
Luis -
Thanks for the info.
I dunno, it just struck me as something that would make a good standard control for CVI, an elapsed time control, maybe build an async timer into it, and some "methods" for it set, clear, start, get, callback, etc that make it usefull. I found some ActiveX time/date controls on my PC but nothing really that I can use. I just didn't want to create the thing myself. I'm not sure it could be done as a custom control, maybe it could.
Toolslib has a password control, IP control, file browser, progress bar, etc. why not an elapsed time control?
Menchar
06-09-2010 02:21 PM
You're right. It's a good suggestion.
Luis