Beispiel #1
0
	def test_previous_down_signal(self):
		# UP <-----> DN
		#           5     8
		# +---------+---------+
		#           -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.prev_signal(8, Direction.DOWN), s)
Beispiel #2
0
	def test_previous_up_signal(self):
		# UP <-----> DN
		#      <-  o-
		# +---------+---------+
		#       3   5
		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.prev_signal(3, Direction.UP), s)
Beispiel #3
0
	def test_prev_signal_after_switch(self):
		# UP <-----> DN
		# 0    3     5            10
		# +----+-----+-------------+
		#      -o    \       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.DOWN)
		self.assertEqual(t2.prev_signal(8, Direction.DOWN), s)
Beispiel #4
0
	def test_prev_signal_none(self):
		t = Track("Track1", self.n, up_prefix="A", down_prefix="A", up=0, down=10, joints=[5])
		self.assertEqual(t.prev_signal(8, Direction.UP), None)
		self.assertEqual(t.prev_signal(3, Direction.DOWN), None)