Пример #1
0
	def test_next_down_signal(self):
		# UP <-----> DN
		#       3   5
		# +---------+---------+
		#       ->  -o
		t = Track("Track1", self.n, up_prefix="A", down_prefix="A", up=0, down=10, joints=[5])
		s = Signal()
		s.attach(t, 5, Direction.DOWN)
		self.assertEqual(t.next_signal(3, Direction.DOWN), s)
Пример #2
0
	def test_next_up_signal(self):
		# UP <-----> DN
		#          o-    <-
		# +---------+---------+
		#           5     8
		t = Track("Track1", self.n, up_prefix="A", down_prefix="A", up=0, down=10, joints=[5])
		s = Signal()
		s.attach(t, 5, Direction.UP)
		self.assertEqual(t.next_signal(8, Direction.UP), s)
Пример #3
0
	def test_next_signal_after_switch(self):
		# UP <-----> DN
		#     o-     5            10
		# +----+-----+-------------+
		# 0    3      \       8
		#              '-+---------+
		#                6   <-   10
		t1 = Track("Track1", self.n, up_prefix="A", down_prefix="A", up=0, down=10, joints=[3])
		t2 = Track("Track2", self.n, up_prefix="B", down_prefix="B", up=6, down=10)
		i = Interlocking("Test", self.n)
		l = Lever(1, i)
		sw = Switch(lever=l, label="A")
		sw.attach(t1, 5, Direction.DOWN)
		sw.attach_turnout(t2, Direction.UP)
		s = Signal()
		s.attach(t1, 3, Direction.UP)
		self.assertEqual(t2.next_signal(8, Direction.UP), s)
Пример #4
0
	def test_next_signal_none(self):
		t = Track("Track1", self.n, up_prefix="A", down_prefix="A", up=0, down=10, joints=[5])
		self.assertEqual(t.next_signal(8, Direction.UP), None)
		self.assertEqual(t.next_signal(3, Direction.DOWN), None)