aboutsummaryrefslogtreecommitdiff
path: root/trunk-recorder/formatter.cc
blob: 38d6b41d49f108e75537cd815223ee4bfe9aa3d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "formatter.h"
#include <boost/lexical_cast.hpp>

int frequency_format = 0;
bool statusAsString = true;

boost::format format_freq(double f) {
  if (frequency_format == 1)
    return boost::format("%10.6f MHz") % (f / 1000000.0);
  else if (frequency_format == 2)
    return boost::format("%.0f Hz") % f;
  else
    return boost::format("%e") % f;
}

std::string get_frequency_format() {
  if (frequency_format == 1)
    return "mhz";
  else if (frequency_format == 2)
    return "hz";
  else
    return "exp";
}

boost::format FormatSamplingRate(float f) {
  return boost::format("%.0f") % f;
}

std::string format_state(State state) {
  if (statusAsString) {
    if (state == MONITORING)
      return "monitoring";
    else if (state == RECORDING)
      return "recording";
    else if (state == INACTIVE)
      return "inactive";
    else if (state == ACTIVE)
      return "active";
    else if (state == IDLE)
      return "idle";
    else if (state == COMPLETED)
      return "completed";
    else if (state == STOPPED)
      return "stopped";
    else if (state == AVAILABLE)
      return "available";
    return "Unknown";
  }
  return boost::lexical_cast<std::string>(state);
}

std::string format_state(State state, MonitoringState monitoringState) {
  if (statusAsString) {
    if (state == MONITORING){
      if(monitoringState == UNSPECIFIED)
        return "monitoring";
      else if(monitoringState == UNKNOWN_TG)
        return "monitoring : UNKNOWN TG";
      else if(monitoringState == IGNORED_TG)
        return "monitoring : IGNORED TG";
      else if(monitoringState == NO_SOURCE)
        return "monitoring : NO SOURCE COVERING FREQ";
      else if(monitoringState == NO_RECORDER)
        return "monitoring : NO RECORDER AVAILABLE";
      else if(monitoringState == ENCRYPTED)
        return "monitoring : ENCRYPTED";
      else if(monitoringState == DUPLICATE)
        return "monitoring : DUPLICATE";
      else if(monitoringState == SUPERSEDED)
        return "monitoring : SUPERSEDED";
      else
        return "monitoring";
    }
    else if (state == RECORDING)
      return "recording";
    else if (state == INACTIVE)
      return "inactive";
    else if (state == ACTIVE)
      return "active";
    else if (state == IDLE)
      return "idle";
    else if (state == COMPLETED)
      return "completed";
    else if (state == STOPPED)
      return "stopped";
    else if (state == AVAILABLE)
      return "available";
    return "Unknown";
  }
  return boost::lexical_cast<std::string>(state);
}