DaviD_H Posted September 16, 2008 Share Posted September 16, 2008 HI i am developing an application that show a discharge graph of a battery and shows the percent of charge remaining in the battery. I also want to display the time (in days and hours) the battery is giving voltage to a device. Obviously the application must be run all this time. Anyone can gives me the code or help? Thanks Link to comment Share on other sites More sharing options...
AzeoTech Posted September 17, 2008 Share Posted September 17, 2008 Well, I'm unsure when you actually want to start the clock, but basically you want to create a variable, and then store systime() to that variable at the instant you want to start the clock. To create the variable, create a sequence marked Auto-Start and declare the variable. For example: global starttime Then, to set the starttime, in sequence script put: starttime = systime() This could be in a channel event, in a button Quick Sequence, or anywhere else that takes sequence script. To display the elapsed time, just subtract this value from systime(). For example, put this: systime() - starttime in a variable value component's expression. You can use the FormatTime() function to display it in hours, minutes and seconds instead of straight seconds: FormatTime(systime() - starttime) Link to comment Share on other sites More sharing options...
DaviD_H Posted September 17, 2008 Author Share Posted September 17, 2008 Thanks. Another doubt: I have created variables: global totaltime global tiempo and put this code lines in main program: tiempo = systime() while (1) totaltime=FormatTime(systime() - tiempo) ..... endwhile and in the display page I have created a Variable value display related to "totaltime", but I only gets Tiempo=0.000 Does I need an especial configuration? Thanks again Link to comment Share on other sites More sharing options...
AzeoTech Posted September 17, 2008 Share Posted September 17, 2008 The formattime() function returns a string, not a number. You declared totaltime as a number, and when DAQFactory tries to convert 00:00:01 to a number it just does the first 00. It gets to the : and says, I can't convert any more so I'll stop. Just change your totaltime declaration to: global string totaltime Note also, that you don't need to store it in a variable. The way you have it written would be more appropriate if tiempo was a private variable. However, since its a global, you can just put the formattime() expression in the variable value expression directly. Link to comment Share on other sites More sharing options...
DaviD_H Posted September 17, 2008 Author Share Posted September 17, 2008 ok done and working! Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.