From 0d3c1d092834581a9cf28f0c81120f4b866d1a6c Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Mon, 22 Dec 2014 13:41:57 +0200 Subject: [PATCH] added a command to calculate the current average wait time --- src/dev.cc | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/dev.cc b/src/dev.cc index 463be30..44a263a 100644 --- a/src/dev.cc +++ b/src/dev.cc @@ -20,7 +20,9 @@ along with this program. If not, see . #include #include #include +#include #include +#include #include #include #include @@ -30,12 +32,22 @@ along with this program. If not, see . #include "dev.h" #include "timer.h" +struct CustStat { + int id; + time_t start, end; +}; + +#define TMHIST_SIZE 16 + void post_redisplay(); // defined in main.cc int customer, ticket; static int report_inputs, cmd_echo; static long last_ticket_msec = LONG_MIN; +static std::vector cstat; + +time_t calc_avg_wait(); static void runcmd(const char *cmd); static int fd = -1; @@ -123,6 +135,14 @@ void issue_ticket() { ticket++; last_ticket_msec = get_msec(); + + CustStat st; + st.id = ticket; + st.start = time(0); + st.end = (time_t)-1; + cstat.push_back(st); + + if(report_inputs) { fprintf(fp, "ticket: %d\n", ticket); } @@ -135,6 +155,16 @@ void next_customer() if(customer < ticket) { customer++; last_ticket_msec = LONG_MIN; + + for(size_t i=0; i