473,804 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display time since start

Hi,

I have a C++ data acquisition program, running under Linux. The basic
stucture is:

Setup devices
Acquire data for x seconds.
Cleanup.

The problem is that I don't have a way to determine how long the data
acquisition has been running. What I'd like is to print out (using
printf or cout) a small clock that gives the elapsed time since data
acquisition began.

I'd appreciate any help anyone may have.

Apr 25 '07 #1
3 2925
Hi,

From the top of my head

#include <time.h>

Lookup
time
localtime
strftime

time_t Time = time( 0 );

const int Size = 400;
char Buffer[ Size ];
strftime( Buffer, Size - 1, "%T", localtime( &Time ) );
cout << Buffer << string( 400, ' ' ) << '\r'; // Keep on one line
Regards, Ron

--
Regards, Ron AF Greve

http://www.InformationSuperHighway.eu

<ti*********@gm ail.comwrote in message
news:11******** *************@r 35g2000prh.goog legroups.com...
Hi,

I have a C++ data acquisition program, running under Linux. The basic
stucture is:

Setup devices
Acquire data for x seconds.
Cleanup.

The problem is that I don't have a way to determine how long the data
acquisition has been running. What I'd like is to print out (using
printf or cout) a small clock that gives the elapsed time since data
acquisition began.

I'd appreciate any help anyone may have.

Apr 25 '07 #2
On Apr 25, 9:00 pm, timhoagl...@gma il.com wrote:
I have a C++ data acquisition program, running under Linux. The basic
stucture is:
Setup devices
Acquire data for x seconds.
Cleanup.
The problem is that I don't have a way to determine how long the data
acquisition has been running. What I'd like is to print out (using
printf or cout) a small clock that gives the elapsed time since data
acquisition began.
You can use time() to get the current time, and difftime to get
the difference in seconds between two times. (If you limit
yourself to Posix, Linux, and possibly Windows, you can just
subtract between two time_t to get the difference in seconds.
This isn't portable, however.)

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Apr 26 '07 #3
ti*********@gma il.com a écrit :
Hi,

I have a C++ data acquisition program, running under Linux. The basic
stucture is:

Setup devices
Acquire data for x seconds.
Cleanup.

The problem is that I don't have a way to determine how long the data
acquisition has been running. What I'd like is to print out (using
printf or cout) a small clock that gives the elapsed time since data
acquisition began.
Well, as others said, you can use time.h.
Another solution is to use boost::date_tim e:

#include "boost/date_time/posix_time/posix_time.hpp"

using namespace boost::posix_ti me;

// stores date of data acquisition start
ptime start(second_cl ock::universal_ time());
//use microsec_clock: :universal_time () for sub second precision

// to printout elapsed time
time_duration elapsed=second_ clock::universa l_time()-start;
std::cout<<"Ela psed: "<<to_simple_st ring(elapsed)<< std::endl;

There is also boost/timer.hpp that would be of interest to you but I
have never used it.
http://boost.org/libs/timer/timer.htm

Michael
Apr 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1949
by: Follower | last post by:
Hi, I am working on a function to return extracts from a text document with a specific phrase highlighted (i.e. display the context of the matched phrase). The requirements are: * Match should be case-insensitive, but extract should have case preserved.
8
9263
by: Monty | last post by:
Let's say you provide an online service from 7:00AM to 6:00PM Eastern Time (daylight time in the summer). Is there way of showing these hours of availability on a web page in the user's local time? Thanks in advance for any advice.
0
382
by: pembed2003 | last post by:
"news.hku.hk" <billychu@hkusua.hku.hk> wrote in message news:<408e8476$2@newsgate.hku.hk>... > thanks for all of your's help > but i still can't grasp the idea of the algorithm > maybe could anyone explain in words(preferably with c++ codes) that how the > algorithm works ?? > Thanks My solution is very simple so I will try to explain it to you. > >
6
1688
by: Michael | last post by:
I would like to display the time counting down on a webpage when I use this script.... Is it possible? <script language="JavaScript"> <!-- var tID = 0; var startTime = null; var timeout=20*(60*1000) + 0*1000; // 20:00 minutes, as milliseconds
6
1910
by: Aspiring .NET Programmer | last post by:
Happy Friday everyone!!! I am working on a windows service and a C# application and needed some help with certain functionality. Please read through my issue below. Thanks! I have a windows service which writes into a log file periodically (text file). I want to create a windows form application, which, upon invocation should continuously display the contents of the log file.
14
23175
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So, we're looking for a way to display the page with a "please wait..." message while the process is running, and then, when the process is done, update the page with the actual results/page content. We have a page that opens another browser/page...
0
2472
by: adubra | last post by:
Hi there, I am using a device context (DC) and a buffer to successfully draw to screen. However, when I update the DC at very high frame rate and drag the frame containing the image very quickly over the screen or I drag another window on top of the fast display, I get errors (Pyassertion ....). I believe those are related to a conflict between the thread that is updating the buffer (over which I have control) and the thread that is doing the...
11
7656
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I know I sound like a one-note Johnny on this but I'm still looking for a solution. I need to display characters coming in from a serial port or a socket. I also need to be able to type characters into the display myself - but that's not the main issue at this time. I've tried a scrolling multiline text box but once the original viewable area fills up and it starts scrolling the flashing of the entire area drives me nuts. The...
1
1668
adelemb
by: adelemb | last post by:
Hi all, I want an image to display in a table if another table cell shows an updated date of less than 24hours. The date displayed in the cell is already working and display fine, but I have no idea where to start with calling the image! This is to be used on a forum that displays a list of posted messages in a table. If a new message is posted under a topic, then I want an image to display for that topic indicating that there is something...
9
2077
by: tomhawkins1 | last post by:
Hi I currently have a site where users can upload files. These files can be doc, wmv, jpeg, xls, dwf, dwf and dwg. These files are uploaded to /home/**user**/uploads and not /home/ **user**/public_html/uploads to prevent any old user from browsing them. I then use a general showDoc page with the following function (from
0
10562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10319
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.