diff --git a/README.md b/README.md index d5dd0b5..b6e4161 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,13 @@ Found 2247 frames, step time of 20 ms for a total duration of 0:00:44.940000. Used 16.45% of the available memory ``` +Errors in the sequence will be highlighted & prepended with a Validation Error message: +``` +> python3 validator.py invalidlightshow.fseq +WARNING: FSEQ file should be renamed to 'lightshow.fseq' before playing in a Tesla +VALIDATION ERROR: Expected file format to be V2 Uncompressed +``` + ## Boolean Light Channels Most lights available on the vehicle can only turn on or off instantly, which corresponds to 0% or 100% brightness of an 'Effect' in xLights. - For off, use blank space in the xLights timeline @@ -292,4 +299,4 @@ To command a closure to move in a particular manner, add an 'On' effect and adju - Vehicles without rear fog lights will not use any other light in place of rear fog lights. #### Tail lights and License Plate Lights -- On Model 3 built before October 2020: left tail, right tail, and license plate lights operate together. They will activate during ```(Left tail || Right tail)``` requests from xLights - note that the license plate lights xLights channel will have no effect on these vehicles. \ No newline at end of file +- On Model 3 built before October 2020: left tail, right tail, and license plate lights operate together. They will activate during ```(Left tail || Right tail)``` requests from xLights - note that the license plate lights xLights channel will have no effect on these vehicles. diff --git a/validator.py b/validator.py index 2a8b374..385c3bd 100644 --- a/validator.py +++ b/validator.py @@ -4,11 +4,15 @@ import sys import argparse import datetime +from pathlib import Path MEMORY_LIMIT = 681 + class ValidationError(Exception): - pass + def __init__(self, message): + super(ValidationError, self).__init__(f"VALIDATION ERROR: {message}") + @dataclasses.dataclass class ValidationResults: @@ -16,8 +20,13 @@ class ValidationResults: step_time: int duration_s: int memory_usage: float + command_count: int def validate(file): + file_name = Path(file.name).name + if file_name != "lightshow.fseq": + print(f"WARNING: FSEQ file should be renamed to 'lightshow.fseq' before playing in a Tesla.") + """Calculates the memory usage of the provided .fseq file""" magic = file.read(4) start, minor, major = struct.unpack(" 1: + raise ValidationError(f"Sequence uses {count} commands. The maximum allowed is {MEMORY_LIMIT}.") + + return ValidationResults(frame_count, step_time, duration_s, memory_usage, count) + if __name__ == "__main__": # Expected usage: python3 validator.py lightshow.fseq @@ -81,7 +96,5 @@ def validate(file): print(e) sys.exit(1) - print(f"Found {results.frame_count} frames, step time of {results.step_time} ms for a total duration of {datetime.timedelta(seconds=results.duration_s)}.") + print(f"Found {results.frame_count} frames and {results.command_count} commands, step time of {results.step_time} ms for a total duration of {datetime.timedelta(seconds=results.duration_s)}.") print(f"Used {results.memory_usage*100:.2f}% of the available memory") - if results.memory_usage > 1: - sys.exit(1)