diff --git a/docker/Makefile b/docker/Makefile index 9c47079..737c814 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -15,10 +15,12 @@ define print_message @printf "\033[$(1)m$(2)\033[0m\n" endef -.PHONY: all clean yamcs-up yamcs-down yamcs-simulator yamcs-shell help +.PHONY: all all-10hz clean yamcs-up yamcs-down yamcs-simulator yamcs-simulator-10hz yamcs-shell help all: clean yamcs-simulator ## run all: clean, yamcs-up (yamcs-down) and yamcs-simulator +all-10hz: clean yamcs-simulator-10hz ## run all: clean, yamcs-up (yamcs-down) and yamcs-simulator + yamcs-up: | yamcs-down ## bring up yamcs system docker compose up -d @@ -30,6 +32,10 @@ yamcs-simulator: yamcs-up ## run yamcs simulator $(call print_message,36,Connect via http://localhost:8090/ system may take about 50 seconds to startup) cd .. && $(PYTHON) ./simulator.py +yamcs-simulator-10hz: yamcs-up ## run yamcs simulator at 10hz + $(call print_message,36,Connect via http://localhost:8090/ system may take about 50 seconds to startup) + cd .. && $(PYTHON) ./simulator.py --rate=10 + yamcs-shell: ## shell into yamcs container docker compose up -d && docker compose exec yamcs bash diff --git a/simulator.py b/simulator.py index 3d30440..cf0cc0a 100755 --- a/simulator.py +++ b/simulator.py @@ -7,7 +7,7 @@ from struct import unpack_from from threading import Thread from time import sleep - +from argparse import ArgumentParser def send_tm(simulator): tm_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -25,7 +25,7 @@ def send_tm(simulator): tm_socket.sendto(packet, ('127.0.0.1', 10015)) simulator.tm_counter += 1 - sleep(1) + sleep(1 / simulator.rate) def receive_tc(simulator): @@ -39,12 +39,13 @@ def receive_tc(simulator): class Simulator(): - def __init__(self): + def __init__(self, rate): self.tm_counter = 0 self.tc_counter = 0 self.tm_thread = None self.tc_thread = None self.last_tc = None + self.rate = rate def start(self): self.tm_thread = Thread(target=send_tm, args=(self,)) @@ -63,9 +64,16 @@ def print_status(self): if __name__ == '__main__': - simulator = Simulator() + parser = ArgumentParser() + parser.add_argument("-r", "--rate", + dest="rate", + default=1, + type=int, + help="Playback rate. 1 = 1Hz, 10 = 10Hz, etc.") + args = parser.parse_args() + simulator = Simulator(args.rate) simulator.start() - + sys.stdout.write('Using playback rate of ' + str(args.rate) + 'Hz \r\n'); try: prev_status = None while True: