10 #include"schemaparser.h"
12 #include <sdl/syncstorage.hpp>
14 // data type definitions from sdl
15 using Namespace = std::string;
16 using Key = std::string;
17 using Data = std::vector<uint8_t>;
18 using DataMap = std::map<Key, Data>;
19 using Keys = std::set<Key>;
24 unsigned int reserved;
29 unsigned long long int TS;
30 unsigned long long int e_RAB_ID;
31 unsigned long long int UE_ID;
33 double measurement_interval;
34 unsigned long long int active_throughput;
35 unsigned long long int average_throughput;
36 unsigned long long int min_throughput;
37 unsigned long long int max_throughput;
42 using namespace mc_schema;
44 vector<uint8_t> packData(const char *d, int len){
45 const uint8_t *d8 = (const uint8_t *)d;
46 return Data(d8, d8+len+1);
49 int main(int argc, char **argv){
50 Namespace ns("mcnib");
52 string directory = ".";
56 string inflnm = directory + "/" + string("nib.json");
58 ifstream infl(inflnm);
60 cerr << "Error, can't open " << inflnm << endl;
65 while(getline(infl, line)){
71 mc_schemas *mcs = new_mc_schemas(nib_str);
72 if(mcs->has_errors()){
73 fprintf(stderr, "Errors loading the schemas:\n%s\n",mcs->get_errors().c_str());
75 vector<string> streams = mcs->get_streams();
76 printf("Loaded %ld streams:\n", streams.size());
77 for(int i=0;i<streams.size(); ++i){
78 string str_rep = mcs->get_query_rep(streams[i])->to_string();
79 printf("\t%s\n",str_rep.c_str());
82 query_rep *qr = mcs->get_query_rep("throughput_ue");
84 // ---------------------------------------------
85 std::unique_ptr<shareddatalayer::SyncStorage> sdl(shareddatalayer::SyncStorage::create());
88 // --------------------------------------------
91 thpt *t = (thpt *)buf;
92 int t_len = sizeof(thpt)+6;
98 t->GNB_ID.offset = sizeof(thpt);
99 string foobar("foobar");
100 strncpy(buf+sizeof(thpt), foobar.c_str(), 6);
101 t->measurement_interval = 10.1;
102 t->active_throughput = 4;
103 t->average_throughput = 5;
104 t->min_throughput = 6;
105 t->max_throughput = 7;
107 string key = "throughput_ue:"+to_string(t->UE_ID)+":"+foobar+":"+to_string(t->e_RAB_ID);
108 vector<uint8_t> val1 = packData(buf,t_len);
115 t->GNB_ID.length = 6;
116 t->GNB_ID.offset = sizeof(thpt);
117 // string foobar("foobar");
119 strncpy(buf+sizeof(thpt), foobar.c_str(), 6);
120 t->measurement_interval = 110.1;
121 t->active_throughput = 14;
122 t->average_throughput = 15;
123 t->min_throughput = 16;
124 t->max_throughput = 17;
126 key = "throughput_ue:"+to_string(t->UE_ID)+":"+foobar+":"+to_string(t->e_RAB_ID);
127 vector<uint8_t> val2 = packData(buf,t_len);
134 t->GNB_ID.length = 6;
135 t->GNB_ID.offset = sizeof(thpt);
136 // string foobar("foobaz");
138 strncpy(buf+sizeof(thpt), foobar.c_str(), 6);
139 t->measurement_interval = 210.1;
140 t->active_throughput = 24;
141 t->average_throughput = 25;
142 t->min_throughput = 26;
143 t->max_throughput = 27;
145 key = "throughput_ue:"+to_string(t->UE_ID)+":"+foobar+":"+to_string(t->e_RAB_ID);
146 vector<uint8_t> val3 = packData(buf,t_len);
153 t->GNB_ID.length = 6;
154 t->GNB_ID.offset = sizeof(thpt);
155 // string foobar("foobar");
157 strncpy(buf+sizeof(thpt), foobar.c_str(), 6);
158 t->measurement_interval = 310.1;
159 t->active_throughput = 34;
160 t->average_throughput = 35;
161 t->min_throughput = 36;
162 t->max_throughput = 37;
164 key = "throughput_ue:"+to_string(t->UE_ID)+":"+foobar+":"+to_string(t->e_RAB_ID);
165 vector<uint8_t> val4 = packData(buf,t_len);