예제 #1
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_attach_down(self):
		s = Signal()
		t = Track("Track1", self.t, up_prefix="A", down_prefix="A", up=0, down=1)
		s.attach(t, 0.5, Direction.DOWN)
		self.assertEqual(s.track, t)
		self.assertEqual(s.position, 0.5)
		self.assertEqual(s.direction, Direction.DOWN)
		self.assertIn(0.5, t.down_signals)
		self.assertEqual(t.down_signals[0.5], s)
예제 #2
0
파일: test_track.py 프로젝트: sammdot/S3
	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)
예제 #3
0
파일: test_track.py 프로젝트: sammdot/S3
	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)
예제 #4
0
파일: test_track.py 프로젝트: sammdot/S3
	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)
예제 #5
0
파일: test_track.py 프로젝트: sammdot/S3
	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)
예제 #6
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_next_prev_signal(self):
		# UP <-----> DN
		#       o-          o-
		# 5 ----------------------- 0
		t = Track("Track1", self.t, up_prefix="A", down_prefix="A", up=5, down=0)
		s1 = Signal()
		s2 = Signal()
		s1.attach(t, 4, Direction.UP)
		s2.attach(t, 1, Direction.UP)
		self.assertEqual(s1.prev_signal, s2)
		self.assertEqual(s2.next_signal, s1)
예제 #7
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_new_york_a_multilever_number(self):
		# UP <-----> DN
		# 81-B 15LaX o-         o- 41-B 15LbX
		# 5 ---------------------> 0
		t = Track("Track1", self.t, line="B", number="1", up=5, down=0,
			down_parity=Parity.ODD, style=NumberingStyle.NEW_YORK_A)
		x15 = Lever(15, self.i)
		s1 = Signal(lever=x15, label="A")
		s2 = Signal(lever=x15, label="B")
		s1.attach(t, 3.6, Direction.UP)
		s2.attach(t, 0, Direction.UP)
		self.assertEqual(s1.number, "81-B 15LaX")
		self.assertEqual(s2.number, "41-B 15LbX")
예제 #8
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_new_york_b_center_track(self):
		# UP <-----> DN
		#     D3-4 o-
		# 5 ----------------------- 0
		#                    -o D4-1
		t = Track("Track1", self.t, line="D", up_number="3", down_number="4", up=5, down=0,
			style=NumberingStyle.NEW_YORK_B)
		s1 = Signal()
		s2 = Signal()
		s1.attach(t, 3.6, Direction.UP)
		s2.attach(t, 0.8, Direction.DOWN)
		self.assertEqual(s1.number, "D3-4")
		self.assertEqual(s2.number, "D4-1")
예제 #9
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_new_york_a_center_track(self):
		# UP <-----> DN
		#     43-D o-
		# 5 <---------------------- 0
		#                    -o 54-D
		t = Track("Track1", self.t, line="D", up_number="3", down_number="4", up=5, down=0,
			up_parity=Parity.ODD, style=NumberingStyle.NEW_YORK_A)
		s1 = Signal()
		s2 = Signal()
		s1.attach(t, 3.6, Direction.UP)
		s2.attach(t, 0.8, Direction.DOWN)
		self.assertEqual(s1.number, "43-D")
		self.assertEqual(s2.number, "54-D")
예제 #10
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_new_york_b_multilever_number(self):
		# UP <-----> DN
		# B1-4 XA17 o-          o- B1-0 XB17
		# 5 ---------------------- 0
		t = Track("Track1", self.t, line="B", number="1", up=5, down=0,
			style=NumberingStyle.NEW_YORK_B)
		x17 = Lever(17, self.i)
		s1 = Signal(lever=x17, label="A")
		s2 = Signal(lever=x17, label="B")
		s1.attach(t, 3.6, Direction.UP)
		s2.attach(t, 0, Direction.UP)
		self.assertEqual(s1.number, "B1-4 XA17")
		self.assertEqual(s2.number, "B1-0 XB17")
예제 #11
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_toronto_multilever_number(self):
		# UP <-----> DN
		#  BA4 XA13 o-          o- BA0 XB13
		# 5 ---------------------- 0
		t = Track("Track1", self.t, up_prefix="BA", down_prefix="B", up=5, down=0,
			up_parity=Parity.EVEN, down_parity=Parity.ODD)
		x13 = Lever(13, self.i)
		s1 = Signal(lever=x13, label="A")
		s2 = Signal(lever=x13, label="B")
		s1.attach(t, 3.6, Direction.UP)
		s2.attach(t, 0, Direction.UP)
		self.assertEqual(s1.number, "BA4 XA13")
		self.assertEqual(s2.number, "BA0 XB13")
예제 #12
0
파일: test_track.py 프로젝트: sammdot/S3
	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)
예제 #13
0
파일: test_route.py 프로젝트: sammdot/S3
	def test_linear_route_ending_in_automatic(self):
		# UP <-----> DN
		#        4            12         16
		# -------+-------------+----------+----
		#        -o 2          -o 4       -o
		n = TrackNetwork("Test")
		i = Interlocking("Test", n)
		l2 = Lever(2, i)
		l4 = Lever(4, i)

		t1 = Track("Track1", n, up_prefix="B", down_prefix="B", up=0, down=18, joints=[4, 12, 16])

		s2 = Signal(lever=l2, control_length = ControlLength([
			(True, [SWO(t1, 8), SWO(t1, 14)])
		]))
		s4 = Signal(lever=l4, control_length = ControlLength([
			(True, [SWO(t1, 14)])
		]))
		s6 = Signal()

		s2.attach(t1, 4, Direction.DOWN)
		s4.attach(t1, 12, Direction.DOWN)
		s6.attach(t1, 16, Direction.DOWN)

		routes = i.routes_from(l2)
		self.assertIn(([l2], s4), routes)
		self.assertIn(([l2, l4], s6), routes)
		self.assertEqual(len(routes), 2)
예제 #14
0
파일: test_route.py 프로젝트: sammdot/S3
	def test_fork_route(self):
		# UP <-----> DN
		#
		#   2          7    10           16  18
		# --+----------+-----+------------+---- t1
		#   -o 2       -o 4   \ 5         -o 6
		#                      '----------+---- t2
		#                                 -o 8
		n = TrackNetwork("Test")
		i = Interlocking("Test", n)
		l2, l4, l5, l6, l8 = [Lever(j, i) for j in [2, 4, 5, 6, 8]]

		t1 = Track("Track1", n, up_prefix="B", down_prefix="B", up=0, down=18, joints=[2, 7, 16])
		t2 = Track("Track2", n, up_prefix="B", down_prefix="B", up=12, down=18)
		sw = Switch(lever=l5, label="A")
		sw.attach(t1, 10, Direction.DOWN)
		sw.attach_turnout(t2, Direction.UP)

		s2 = Signal(lever=l2, control_length = ControlLength([
			(l5.normal, [SWO(t1, 3), SWO(t1, 8)]),
			(l5.reverse, [SWO(t1, 3), SWO(t1, 8), SWO(t2, 15)])
		]))
		s4 = Signal(lever=l4, control_length = ControlLength([
			(l5.normal, [SWO(t1, 8)]),
			(l5.reverse, [SWO(t1, 8), SWO(t2, 15)])
		]))
		s6 = Signal(lever=l6)
		s8 = Signal(lever=l8)

		s2.attach(t1, 2, Direction.DOWN)
		s4.attach(t1, 7, Direction.DOWN)
		s6.attach(t1, 16, Direction.DOWN)
		s8.attach(t2, 16, Direction.DOWN)

		routes = i.routes_from(l2)
		self.assertIn(([l2], s4), routes)
		self.assertIn(([l2, l4], s6), routes)
		self.assertIn(([l2, l4, l5], s8), routes)
		self.assertEquals(len(routes), 3)
예제 #15
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_new_york_b_number(self):
		# UP <-----> DN
		#             B1-1 o-
		# 5 ---------------------- 0
		#         -o B1-4 X16   -o B1-0
		t = Track("Track1", self.t, line="B", number="1", up=5, down=0,
			style=NumberingStyle.NEW_YORK_B)
		x16 = Lever(16, self.i)
		s1 = Signal()
		s2 = Signal(lever=x16)
		s3 = Signal()
		s1.attach(t, 1.25, Direction.UP)
		s2.attach(t, 3.6, Direction.DOWN)
		s3.attach(t, 0.2, Direction.DOWN)
		self.assertEqual(s1.number, "B1-1")
		self.assertEqual(s2.number, "B1-4 X16")
		self.assertEqual(s3.number, "B1-0")
예제 #16
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_new_york_a_number(self):
		# UP <-----> DN
		#             51-B o-
		# 5 ---------------------> 0
		#         -o 41-B 14LX  -o 01-B
		t = Track("Track1", self.t, line="B", number="1", up=5, down=0,
			down_parity=Parity.ODD, style=NumberingStyle.NEW_YORK_A)
		x14 = Lever(14, self.i)
		s1 = Signal()
		s2 = Signal(lever=x14)
		s3 = Signal()
		s1.attach(t, 1.25, Direction.UP)
		s2.attach(t, 3.6, Direction.DOWN)
		s3.attach(t, 0.2, Direction.DOWN)
		self.assertEqual(s1.number, "51-B")
		self.assertEqual(s2.number, "41-B 14LX")
		self.assertEqual(s3.number, "01-B")
예제 #17
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_toronto_number(self):
		# UP <-----> DN
		#              BA2 o-
		# 5 ---------------------- 0
		#         -o B3 X12     -o B1
		t = Track("Track1", self.t, up_prefix="BA", down_prefix="B", up=5, down=0,
			up_parity=Parity.EVEN, down_parity=Parity.ODD)
		x12 = Lever(12, self.i)
		s1 = Signal()
		s2 = Signal(lever=x12)
		s3 = Signal()
		s1.attach(t, 1.25, Direction.UP)
		s2.attach(t, 3.6, Direction.DOWN)
		s3.attach(t, 0.2, Direction.DOWN)
		self.assertEqual(s1.number, "BA2")
		self.assertEqual(s2.number, "B3 X12")
		self.assertEqual(s3.number, "B1")
예제 #18
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_out_of_range(self):
		s = Signal()
		t = Track("Track1", self.t, up_prefix="A", down_prefix="A", up=0, down=1)
		with self.assertRaises(SignalError):
			s.attach(t, 3, Direction.UP)
예제 #19
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_attach_wrong_network(self):
		s = Signal(lever=self.l, label="D")
		n = TrackNetwork("Test")
		t = Track("Track1", n, up_prefix="A", down_prefix="A", up=0, down=1)
		with self.assertRaises(SignalError):
			s.attach(t, 0.5, Direction.UP)
예제 #20
0
파일: test_signal.py 프로젝트: sammdot/S3
	def test_attach_with_lever_without_network(self):
		s = Signal(lever=self.l, label="C")
		t = Track("Track1", self.t, up_prefix="A", down_prefix="A", up=0, down=1)
		s.attach(t, 0.5, Direction.UP)
		self.assertEqual(s.network, self.t)