Skip to content
Snippets Groups Projects
Commit 3300fac9 authored by Luca Erbetta's avatar Luca Erbetta :rocket:
Browse files

[EventGen] Add event & topic list

parent 7ac89907
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "Topics.h" #include "Topics.h"
#include <map> #include <map>
using std::map;
namespace DeathStackBoard namespace DeathStackBoard
{{ {{
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include <vector>
#include "events/Event.h" #include "events/Event.h"
#include "events/EventBroker.h" #include "events/EventBroker.h"
...@@ -41,7 +42,6 @@ ...@@ -41,7 +42,6 @@
#include "Topics.h" #include "Topics.h"
using std::string; using std::string;
using std::map;
namespace DeathStackBoard namespace DeathStackBoard
{{ {{
...@@ -54,6 +54,8 @@ enum Events : uint8_t ...@@ -54,6 +54,8 @@ enum Events : uint8_t
{enum_data} {enum_data}
}}; }};
const std::vector<uint8_t> EVENT_LIST {{{event_list}}};
/** /**
* @brief Returns the name of the provided event * @brief Returns the name of the provided event
* *
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
#include <stdint.h> #include <stdint.h>
#include <string> #include <string>
#include <vector>
using std::map;
using std::string; using std::string;
namespace DeathStackBoard namespace DeathStackBoard
...@@ -48,6 +48,8 @@ enum Topics : uint8_t ...@@ -48,6 +48,8 @@ enum Topics : uint8_t
{enum_data} {enum_data}
}}; }};
const std::vector<uint8_t> TOPIC_LIST {{{topic_list}}};
/** /**
* @brief Returns the name of the provided event * @brief Returns the name of the provided event
* *
......
...@@ -139,6 +139,7 @@ print("{} topics loaded.".format(len(topics))) ...@@ -139,6 +139,7 @@ print("{} topics loaded.".format(len(topics)))
enum_str = "" enum_str = ""
event_map_str = "" event_map_str = ""
event_list_str = ""
date = datetime.datetime.now() date = datetime.datetime.now()
link = "https://docs.google.com/spreadsheets/d/{id}".format(id=SPREADSHEET_ID) link = "https://docs.google.com/spreadsheets/d/{id}".format(id=SPREADSHEET_ID)
...@@ -154,12 +155,13 @@ for e in events: ...@@ -154,12 +155,13 @@ for e in events:
(" = EV_FIRST_SIGNAL" if e == events[0] else "") + endl (" = EV_FIRST_SIGNAL" if e == events[0] else "") + endl
event_map_str += " {{ {event}, {string} }}{endl}".format( event_map_str += " {{ {event}, {string} }}{endl}".format(
event=e, string='"' + e + '"', endl=endl) event=e, string='"' + e + '"', endl=endl)
event_list_str += e + (", " if e != events[-1] else "")
with open('Events.h.template', 'r') as template_file: with open('Events.h.template', 'r') as template_file:
template = template_file.read() template = template_file.read()
template = template.format(sheet_link=link, date=date, template = template.format(sheet_link=link, date=date,
enum_data=enum_str) enum_data=enum_str,event_list=event_list_str)
with open(join(OUTPUT_FOLDER, 'Events.h'), 'w') as header_file: with open(join(OUTPUT_FOLDER, 'Events.h'), 'w') as header_file:
header_file.write(template) header_file.write(template)
...@@ -170,18 +172,20 @@ print("Events.h successfully generated.") ...@@ -170,18 +172,20 @@ print("Events.h successfully generated.")
print("Generating Topics.h...") print("Generating Topics.h...")
enum_str = "" enum_str = ""
topic_map_str = "" topic_map_str = ""
topic_list_str = ""
for t in topics: for t in topics:
endl = ",\n" if t != topics[-1] else "" endl = ",\n" if t != topics[-1] else ""
enum_str += " " + t + endl enum_str += " " + t + endl
topic_map_str += " {{ {topics}, {string} }}{endl}".format( topic_map_str += " {{ {topics}, {string} }}{endl}".format(
topics=t, string='"' + t + '"', endl=endl) topics=t, string='"' + t + '"', endl=endl)
topic_list_str += t + (", " if t != topics[-1] else "")
with open('Topics.h.template', 'r') as template_file: with open('Topics.h.template', 'r') as template_file:
template = template_file.read() template = template_file.read()
template = template.format(sheet_link=link, date=date, template = template.format(sheet_link=link, date=date,
enum_data=enum_str) enum_data=enum_str, topic_list=topic_list_str)
with open(join(OUTPUT_FOLDER, 'Topics.h'), 'w') as header_file: with open(join(OUTPUT_FOLDER, 'Topics.h'), 'w') as header_file:
header_file.write(template) header_file.write(template)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment