• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

F*S*M T*ime

I want to implement an F*S*M  and when a "job" is at one state for some time ,for example 1 min and then go to other state.The problem is that i don't know how to implement the time(clock) of this  system.
0
Tom211
Asked:
Tom211
  • 2
1 Solution
 
Infinity08Commented:
You want a delay of 1 minute ?

You can use the standard library for that, something like below (note that it's a busy wait, so likely not the preferred way to do it).

Or you can use platform dependent functionality, like sleep or usleep (Linux), Sleep (Windows), ...
What platform are you on ?
time_t tstart = time(0);
time_t tend = time(0);
while (difftime(tend, tstart) < 60.0f) {   // <--- one minute
  // busy wait
}

Open in new window

0
 
Infinity08Commented:
The code sample should have been like this of course (otherwise you'd likely have an infinite loop) :
time_t tstart = time(0);
time_t tend = time(0);
while (difftime(tend, tstart) < 60.0f) {   // <--- one minute
  // busy wait
  tend = time(0);
}

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now