diff --git a/scripts/event_header_generator/EventStrings.cpp.template b/scripts/event_header_generator/EventStrings.cpp.template deleted file mode 100644 index d11c60bbcd8c6f9896aa2e36f18cd173e3f4eb31..0000000000000000000000000000000000000000 --- a/scripts/event_header_generator/EventStrings.cpp.template +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (c) 2018 Skyward Experimental Rocketry - * Authors: Luca Erbetta - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/* - ****************************************************************************** - * THIS FILE IS AUTOGENERATED. DO NOT EDIT. * - ****************************************************************************** - */ - -// Generated from: {sheet_link} -// Autogen date: {date} - - -#include "Events.h" -#include "Topics.h" - -#include <map> -using std::map; - -namespace DeathStackBoard -{{ - -string getEventString(uint8_t event) -{{ - static const map<uint8_t, string> event_string_map {{ -{event_map_data} - }}; - auto it = event_string_map.find(event); - return it == event_string_map.end() ? "EV_UNKNOWN" : it->second; -}} - -string getTopicString(uint8_t topic) -{{ - static const map<uint8_t, string> topic_string_map{{ -{topic_map_data} - }}; - auto it = topic_string_map.find(topic); - return it == topic_string_map.end() ? "TOPIC_UNKNOWN" : it->second; -}} - -}} \ No newline at end of file diff --git a/scripts/event_header_generator/Events.h.template b/scripts/event_header_generator/Events.h.template deleted file mode 100644 index 3d79b58591da02b142395484b2d2865983d57a7f..0000000000000000000000000000000000000000 --- a/scripts/event_header_generator/Events.h.template +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (c) 2018 Skyward Experimental Rocketry - * Authors: Luca Erbetta - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/* - ****************************************************************************** - * THIS FILE IS AUTOGENERATED. DO NOT EDIT. * - ****************************************************************************** - */ - -// Generated from: {sheet_link} -// Autogen date: {date} - -#pragma once - -#include <cstdint> -#include <string> -#include <vector> - -#include "events/Event.h" -#include "events/EventBroker.h" -#include "Topics.h" - -using std::string; - -namespace DeathStackBoard -{{ -/** - * Definition of all events in the Homeone Board software - * Refer to section 5.1.1 of the Software Design Document. - */ -enum Events : uint8_t -{{ -{enum_data} -}}; - -const std::vector<uint8_t> EVENT_LIST {{{event_list}}}; - -/** - * @brief Returns the name of the provided event - * - * @param event - * @return string - */ -string getEventString(uint8_t event); - -}} diff --git a/scripts/event_header_generator/README.md b/scripts/event_header_generator/README.md deleted file mode 100644 index f87e46c67ebcec406b02c58e10dbe91b00a0c8d3..0000000000000000000000000000000000000000 --- a/scripts/event_header_generator/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Events Generator Script - -This script generates the Events.h and Topics.h heander file from a GoogleSheets document on Google Drive. - -To execute the script: - -``` -pip install --upgrade google-api-python-client -pip install oauth2client -python scripts/homeone/event_header_generator/event_generator.py -``` - -The first time a browser window should open asking for your credentials (use the Skyward ones). -If it doesn't and only gives you an error, try executing it by clicking on the icon. \ No newline at end of file diff --git a/scripts/event_header_generator/Topics.h.template b/scripts/event_header_generator/Topics.h.template deleted file mode 100644 index 87986edbad2dfd6f72a2377389d43da214e85816..0000000000000000000000000000000000000000 --- a/scripts/event_header_generator/Topics.h.template +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (c) 2018 Skyward Experimental Rocketry - * Authors: Luca Erbetta - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/* - ****************************************************************************** - * THIS FILE IS AUTOGENERATED. DO NOT EDIT. * - ****************************************************************************** - */ - -// Generated from: {sheet_link} -// Autogen date: {date} - -#pragma once - -#include <stdint.h> -#include <string> -#include <vector> - -using std::string; - -namespace DeathStackBoard -{{ -/** - * Definition of various event topics to use in the EventBroker - */ -enum Topics : uint8_t -{{ -{enum_data} -}}; - -const std::vector<uint8_t> TOPIC_LIST {{{topic_list}}}; - -/** - * @brief Returns the name of the provided event - * - * @param event - * @return string - */ -string getTopicString(uint8_t topic); - -}} // namespace DeathStackBoard - diff --git a/scripts/event_header_generator/credentials.json b/scripts/event_header_generator/credentials.json deleted file mode 100644 index dae318afc5661116b82fe75f80f4316e538e670a..0000000000000000000000000000000000000000 --- a/scripts/event_header_generator/credentials.json +++ /dev/null @@ -1 +0,0 @@ -{"installed":{"client_id":"1025168905991-tv31etsgm3lecodc5c798shqciekad40.apps.googleusercontent.com","project_id":"homeone-event-ge-1540834105298","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://www.googleapis.com/oauth2/v3/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"Yhaf67HuHR4DyXZKNXWu2lre","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}} \ No newline at end of file diff --git a/scripts/event_header_generator/event_generator.py b/scripts/event_header_generator/event_generator.py deleted file mode 100644 index 048a2ba7f8fe2725e46533b6877e974bf75e8cfc..0000000000000000000000000000000000000000 --- a/scripts/event_header_generator/event_generator.py +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/python3 - -# Copyright (c) 2018 Skyward Experimental Rocketry -# Authors: Luca Erbetta -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# - -from googleapiclient.discovery import build -from httplib2 import Http -from oauth2client import file, client, tools - -import re -import datetime -import sys -from os.path import join -import os - -OUTPUT_FOLDER = "generated" -SCOPES = 'https://www.googleapis.com/auth/spreadsheets.readonly' - -service = None - -# Spreadsheet file used to generate the events. The can be found in the link -# to the spreadsheet, for example: -# https://docs.google.com/spreadsheets/d/184kR2OAD7yWV0fYJdiGUDmHmy5_prY3nr-XgNA0Uge0/ -# --> -# 184kR2OAD7yWV0fYJdiGUDmHmy5_prY3nr-XgNA0Uge0 -SPREADSHEET_ID = '184kR2OAD7yWV0fYJdiGUDmHmy5_prY3nr-XgNA0Uge0' -EVENTS_RANGE_NAME = 'EventList!A2:A' -TOPICS_RANGE_NAME = 'Topics!B3:B' - - -def auth(): - try: - store = file.Storage('store.json') - creds = store.get() - if not creds or creds.invalid: - flow = client.flow_from_clientsecrets('credentials.json', SCOPES) - creds = tools.run_flow(flow, store) - - global service - service = build('sheets', 'v4', http=creds.authorize(Http())) - return True - except: - print("Authentication error:", sys.exc_info()[0]) - return False - - -def load_events(): - result = service.spreadsheets().values().get(spreadsheetId=SPREADSHEET_ID, - range=EVENTS_RANGE_NAME).execute() - lines = result.get('values', []) - - # Event names start with EV_ and contains only uppercase letters or underscores - re_event = re.compile(r'(?P<ev>^EV_([A-Z_]+)+)') - - # Only return lines with valid events, remove additional data - events = [] - for l in lines: - m = re_event.match(l[0]) - if m is not None: - events.append(m.group('ev')) - else: - print("Skipped line containing invalid event: {}".format(l)) - - return events - - -def load_topics(): - result = service.spreadsheets().values().get(spreadsheetId=SPREADSHEET_ID, - range=TOPICS_RANGE_NAME).execute() - lines = result.get('values', []) - re_topics = re.compile(r'(?P<topic>^TOPIC_([A-Z_]+)+)') - - # Only return lines with valid topics, remove additional data - topics = [] - for l in lines: - m = re_topics.match(l[0]) - if m is not None: - topics.append(m.group('topic')) - else: - print("Skipped line containing invalid topics: {}".format(l)) - - return topics - - -def has_duplicates(lst): - if len(lst) != len(set(lst)): - return True - return False - - - -print("Skyward on-board software event header generator v0.2") -print("Google sheets API auth in progress...") - -if auth(): - print("Auth successfull.") -else: - exit() - -#directory = os.path.dirname(OUTPUT_FOLDER) -if not os.path.exists(OUTPUT_FOLDER): - os.mkdir(OUTPUT_FOLDER) - -print("Reading from: https://docs.google.com/spreadsheets/d/" + SPREADSHEET_ID) - -events = load_events() -topics = load_topics() - -# Check duplicates -if has_duplicates(events): - print("Duplicate events found! Terminating.") - exit() - -if has_duplicates(topics): - print("Duplicate topics found! Terminating.") - exit() - -events.sort() -topics.sort() - -print("{} events loaded.".format(len(events))) -print("{} topics loaded.".format(len(topics))) - -enum_str = "" -event_map_str = "" -event_list_str = "" - -date = datetime.datetime.now() -link = "https://docs.google.com/spreadsheets/d/{id}".format(id=SPREADSHEET_ID) - - -# Events.h generation - -print("Generating Events.h...") - -for e in events: - endl = ",\n" if e != events[-1] else "" - enum_str += " " + e + \ - (" = EV_FIRST_SIGNAL" if e == events[0] else "") + endl - event_map_str += " {{ {event}, {string} }}{endl}".format( - event=e, string='"' + e + '"', endl=endl) - event_list_str += e + (", " if e != events[-1] else "") - -with open('Events.h.template', 'r') as template_file: - template = template_file.read() - -template = template.format(sheet_link=link, date=date, - enum_data=enum_str,event_list=event_list_str) - -with open(join(OUTPUT_FOLDER, 'Events.h'), 'w') as header_file: - header_file.write(template) - -print("Events.h successfully generated.") -# Topics.h generation - -print("Generating Topics.h...") -enum_str = "" -topic_map_str = "" -topic_list_str = "" - -for t in topics: - endl = ",\n" if t != topics[-1] else "" - enum_str += " " + t + endl - topic_map_str += " {{ {topics}, {string} }}{endl}".format( - topics=t, string='"' + t + '"', endl=endl) - topic_list_str += t + (", " if t != topics[-1] else "") - -with open('Topics.h.template', 'r') as template_file: - template = template_file.read() - -template = template.format(sheet_link=link, date=date, - enum_data=enum_str, topic_list=topic_list_str) - -with open(join(OUTPUT_FOLDER, 'Topics.h'), 'w') as header_file: - header_file.write(template) - -with open('EventStrings.cpp.template', 'r') as cpp_template_file: - cpp = cpp_template_file.read() - -cpp = cpp.format(sheet_link=link, date=date, - event_map_data=event_map_str, topic_map_data=topic_map_str) - -with open(join(OUTPUT_FOLDER, 'EventStrings.cpp'), 'w') as cpp_file: - cpp_file.write(cpp) - -print("Topics.h successfully generated.") - -print() -print("All files successfully generated. Please move Events.h, Topics.h, EventStrings.cpp into your project sources.") -print(".... Done.") diff --git a/scripts/event_header_generator/requirements.txt b/scripts/event_header_generator/requirements.txt deleted file mode 100644 index b4e01569861fa5001ba712bfb61688ed45a3f451..0000000000000000000000000000000000000000 --- a/scripts/event_header_generator/requirements.txt +++ /dev/null @@ -1,20 +0,0 @@ -cachetools==3.1.0 -certifi==2019.3.9 -chardet==3.0.4 -google-api-python-client==1.7.8 -google-auth==1.6.3 -google-auth-httplib2==0.0.3 -google-auth-oauthlib==0.3.0 -httplib2==0.12.3 -idna==2.8 -oauth2client==4.1.3 -oauthlib==3.0.1 -pkg-resources==0.0.0 -pyasn1==0.4.5 -pyasn1-modules==0.2.5 -requests==2.21.0 -requests-oauthlib==1.2.0 -rsa==4.0 -six==1.12.0 -uritemplate==3.0.0 -urllib3==1.24.2