コード例 #1
0
#!/usr/bin/env python

import sys
sys.path.append("/home/jonathan/Programing/Python/SpiNNer")

import diagram

from model import board
from model import coordinates
from model import transforms
from model import topology

d = diagram.Diagram()

# Create a small system of boards on a hexagonal coordinate system
boards = board.create_torus(4,4)
boards = transforms.hex_to_cartesian(boards)
boards = transforms.rhombus_to_rect(boards)
boards = transforms.compress(boards)
#boards = transforms.space_folds(boards, (4,2), (0.7,1))
boards = transforms.fold(boards, (4,2))

# Create a dictionary which maps boards to coordinates to use for labelling
# boards in the diagram.
board2coord = dict(boards)

# Draw the boards on the diagram as a hexagons
for b, coords in boards:
	d.add_board_square(b, coords)
	
	for direction, colour in ( (topology.NORTH,      "red")
コード例 #2
0
ファイル: diagram.py プロジェクト: imclab/SpiNNer
         "board %d %s" %
         (board.follow_wire(direction).id,
          Diagram.DIRECTION_POSTFIX[topology.opposite(direction)])) + "\n"

    def add_packet_path(self, board, in_direction, out_direction, styles=None):
        self._add_path([
            "board %d %s" %
            (board.id, Diagram.DIRECTION_POSTFIX[in_direction]),
            "board %d %s" %
            (board.id, Diagram.DIRECTION_POSTFIX[out_direction])
        ], styles)


if __name__ == "__main__":
    d = Diagram()
    boards = board.create_torus(20)
    boards = transforms.hex_to_cartesian(boards)
    b2c = dict(boards)
    boards = transforms.compress(boards)
    boards = transforms.rhombus_to_rect(boards)
    boards = transforms.fold(boards, (4, 2))

    boards = transforms.cabinetise(boards, 5, 10, 24)

    d.set_cabinet_system(cabinet.System(), 0.1)

    for board, coords in boards:
        d.add_board_cabinet(board, coords)
        d.add_label(board, r"\tiny %s" % (str(tuple(b2c[board]))),
                    ["rotate=90"])
        d.add_wire(board, topology.NORTH, ["red"])
コード例 #3
0
#!/usr/bin/env python

import sys
sys.path.append("/home/jonathan/Programing/Python/SpiNNer")

import diagram

from model import board
from model import transforms
from model import topology

d = diagram.Diagram()

# Create a small system of boards on a hexagonal coordinate system
boards = board.create_torus(4,4)

# Create a dictionary which maps boards to coordinates to use for labelling
# boards in the diagram.
board2coord = dict(boards)

# Draw the boards on the diagram as a hexagons
for board, coords in boards:
	d.add_board_hexagon(board, coords)
	
	# Draw only long wires
	for direction, colour in ( (topology.NORTH,      "red")
	                         , (topology.NORTH_EAST, "green")
	                         , (topology.EAST,       "blue")):
		if sum(map(abs, board2coord[board.follow_wire(direction)] - board2coord[board])) > 2:
			d.add_wire(board, direction, [colour])
コード例 #4
0
			dimensions   = (rack_width, rack_height, rack_depth),
			num_slots    = num_slots_per_rack,
			slot_spacing = slot_spacing,
			slot_offset  = slot_offset,
		),
		dimensions   = (cabinet_width, cabinet_height, cabinet_depth),
		num_racks    = num_racks_per_cabinet,
		rack_spacing = rack_spacing,
		rack_offset  = rack_offset,
	),
	num_cabinets    = num_cabinets,
	cabinet_spacing = cabinet_spacing,
)

# Create an inter-linked torus
torus = board.create_torus(width, height)

# Convert to Cartesian coordinates as the coming manipulations use/abuse this
cart_torus = transforms.hex_to_cartesian(torus)

# Cut the left-hand side of the torus off and move it to the right to form a
# rectangle
rect_torus = transforms.rhombus_to_rect(cart_torus)

# Compress the coordinates to eliminate the "wavy" pattern on the y-axis turning
# the board coordinates into a continuous mesh.
comp_torus = transforms.compress(rect_torus, 1 if compress_rows else 2
                                           , 2 if compress_rows else 1
                                           )

# Show where the folds will occur