#!/usr/bin/env python3 import json import datetime from simulation import SimulationThread def main(): periods = json.load(open("periods.json")) print("Period listing:") for period in periods: period_start_time = datetime.time.fromisoformat(period["timestart"]) print("Name: {}\t\tTime start: {}".format(period["name"], period_start_time)) print(" Number of states: {}".format(len(period["states"]))) test_times = [ "00:00:00", "07:59:59", "08:00:00", "09:59:59", "10:00:00", "16:59:59", "17:00:00", "18:59:59", "19:00:00", "23:59:59", ] SimulationThread.initialize(periods, datetime.time.fromisoformat("07:59"), 60, 4.0, True) for test_time in test_times: test_time_obj = datetime.time.fromisoformat(test_time) print("Period matching time {} is '{}'".format(test_time, periods[SimulationThread.get_instance()._get_period_index(test_time_obj)]["verbose-name"])) print("Starting thread...") SimulationThread.get_instance().start() SimulationThread.get_instance().join() print("Thread finished") print(SimulationThread.get_instance().get_snapshot()) if __name__ == '__main__': main()