Link to home
Start Free TrialLog in
Avatar of CL050597
CL050597

asked on

C++ Simulation Timer For ATM

I want to run an ATM simulation. I am looking for code which will allow me to time-stamp cells (messages) at a source node and send these cells to a destination node. Ie: I'm looking for simple c++ code which will create a timer object and return time-stamps on invocation of some class method. The code should produce the same results on each run of the program.
Avatar of md041797
md041797

This uses the Win32 time system.  Any other system can be used in a similar way.

class TimeStamp {
public:
  TimeStamp () {StampIt();}
  void StampIt () {GetLocalTime (&TheStamp);}
  SYSTEMTIME &WhenStamped () {return TheStamp;}
private:
  SYSTEMTIME TheStamp;
  };

Good?
Avatar of CL050597

ASKER

If I were to use system time then my implimentation would be dependent on the CPU time of my computer. Ie: If my computer has 200 users vs 2 users then I will obtain different results each time I run my program. I want an implimentation which is  will give me the same results each time I run the program. This means that I have to come-up with a method which is independent of the system clock. Thanks for trying, but your solution is the obvious mistake, try again
Edited text of question
Your problem is still vague.

When you say you want the same results every time you run the program are you saying you need a timer that starts from 0 every time the program starts up?

The routine I gave you uses the local time of day.  How would the time of day vary because you add more users?

When you say you want to send a message from one node to another, do you mean you want the system to communicate from one computer to another?  When you talk about a simulation, it sounds like you intend to run it as a single CPU process.

In short, what do you mean?




Clarification: (1) If I were to have a timer which started at "0" that would be great! (2) If 2 users are using the same computer (cpu) then each would get about half of the cpu time; Thus, their programs would terminate faster than if 200 users were using this same computer (cpu). If 200 users were using the same computer then each would receive about 1/200 th of the cpu time; Thus, their programs would terminate (in real time) a lot slower.
Therefore, the 2 run times of the same program would would give different results. Eg: One run of the program would say this message took 1msec to reach destination, and another run would say the message took 0.5 msec to travel to the same destination.
(3) I want to run a WAN (wide area network) simulation on a single cpu, but "md's" 3rd question is irrelevent to the actual problem. Ie: I only want a timer and the application doesn't affect the timer, really!
ASKER CERTIFIED SOLUTION
Avatar of md041797
md041797

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial