RecoSim  1.0
 All Classes Files Functions Variables Enumerations
qos_management.h
Go to the documentation of this file.
1 
22 #ifndef QOS_MANAGEMENT_H
23 #define QOS_MANAGEMENT_H
24 
25 #include <systemc.h>
26 #include "utils.h"
27 #include "monitoring.h"
28 #include "qos_interface.h"
29 
30 #define FOUT if(generate_logfile()) (*fout)
31 
32 class QoS_management : public sc_module {
33 
34 protected:
35 
36  // Log file stream
37  ofstream* fout;
38 
39 public:
40 
41  QoS_interface& services;
42 
43  // Trace Signal
44  TRACE_VAR_SC_BIGINT_PTR(QoS_var, TRACE_LV_SIZE);
45 
46  QoS_management(sc_module_name nm, QoS_interface& _qos_if, ofstream* _fout) : sc_module(nm), services(_qos_if), fout(_fout) {
47 
48  // Create Common Thread
49  sc_spawn_options method_options;
50  sc_spawn(sc_bind(&QoS_management::QoS_common_thread, this, services.getApplications().size(), Monitoring::thread_number++), "Dynamic_process_QoS_common", &method_options);
51 
52  // Create Thread for each Application
53  for(int i = 0; i < (int) services.getApplications().size(); i++) {
54  sc_spawn_options method_options;
55  string process_name("Dynamic_process_QoS_");
56  ostringstream out;
57  out << i;
58  process_name.append(out.str());
59 
60  sc_spawn(sc_bind(&QoS_management::QoS_application_thread, this, i, services.getApplications().at(i), Monitoring::thread_number++), process_name.c_str(), &method_options);
61  }
62 
63  // Activate Trace
64  activate_common_trace(services.getApplications().size());
65  for(int i = 0; i < (int) services.getApplications().size(); i++)
66  activate_application_trace(i, services.getApplications().at(i));
67  }
68 
69  QOS_COMMON_ACTIVATE {
70 
71  TRACE_VAR_SC_BIGINT_ALLOCATE(QoS_var, TRACE_LV_SIZE, ApplicationNumber);
72 
73  }
74 
75  QOS_APPLICATION_ACTIVATE {
76 
77  // Init
78  QoS_var[applicationID] = 0;
79 
80  // Trace
81  QOS_TRACE(QoS_var[applicationID], application.getName() + ".QoS_var", unsigned);
82 
83  }
84 
85 
86  // !! Ajouter une application interface
87 
88 
89  QOS_COMMON_THREAD {
90 
91  cout << "Start common application " << endl;
92 
93  while(true) {
94 
95  wait();
96 
97  cout << "NEVER common application " << endl;
98 
99  }
100 
101  }
102 
103  // Resultat true, false
104  // Top/Bottom
105  // Typage événement
106 
107  // Fermer le flux log solution après ...
108 
109  QOS_APPLICATION_THREAD {
110 
111  vector<Application> appList = services.getApplications();
112 
113  // TEST
114  int current_hyperperiod = 0;
115 
116  cout << "Start application " << application.getName() << endl;
117 
118  wait(application.getGlobalOffset());
119  while(true) {
120 
121  // New hyperperiod -> update VCD trace
122  //set_hyperperiod_status(++current_hyperperiod);
123 
124  string hpid_str(Utils::itoa(++current_hyperperiod));
125  QoS_var[applicationID] = ((sc_bigint<TRACE_LV_SIZE>) Utils::string_to_ascii("Hyperperiod ") << (hpid_str.size() * 8))
126  + Utils::string_to_ascii(hpid_str);
127 
128  wait(application.getGlobalHypeperiod());
129 
130  cout << "QoS check ME for application " << application.getName() << endl;
131 
132  FOUT << sc_time_stamp() << ": " << name() << ": QoS check ME for application " << application.getName() << endl;
133  application.checkQoSOnHyperperiod();
134  }
135 
136  }
137 
138 };
139 
140 
141 #endif
Definition: qos_management.h:32
Definition: qos_interface.h:40
virtual vector< Application > & getApplications()=0
Get the list of application(s)