-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_generate_code.py
More file actions
31 lines (22 loc) · 956 Bytes
/
example_generate_code.py
File metadata and controls
31 lines (22 loc) · 956 Bytes
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
# Copyright 2019 Joan Puig
# See LICENSE for details
from FIT.codegen import TypeCodeGenerator, MessageCodeGenerator
from FIT.profile import Profile
def main():
# This sample code shows how to read the Profile object from the SDK zip file and generate the FIT.types file
# Modify to fit your directory setup
generate_files = True
sdk_file = './data/SDK/FitSDKRelease_Latest.zip'
types_file = './FIT/types.py'
messages_file = './FIT/messages.py'
profile = Profile.from_sdk_zip(sdk_file)
if generate_files:
# Generates the code and writes the file to disk
TypeCodeGenerator.generate(profile, types_file)
MessageCodeGenerator.generate(profile, messages_file)
else:
# This will not generate the code but only print it to the screen
print(TypeCodeGenerator.generate(profile))
print(MessageCodeGenerator.generate(profile))
if __name__ == "__main__":
main()