1. Anchor routing added with mutiport
This commit is contained in:
@@ -142,22 +142,22 @@ assert.strictEqual(
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
{
|
||||
left: helpers.buildElementPorts('anchor').left.a,
|
||||
right: helpers.buildElementPorts('anchor').right.a,
|
||||
a1: helpers.buildElementPorts('anchor').a1.a,
|
||||
b1: helpers.buildElementPorts('anchor').b1.a,
|
||||
},
|
||||
{ left: 180, right: 0 },
|
||||
'Anchor objects should default to 180 degree left port and 0 degree right port'
|
||||
{ a1: 180, b1: 0 },
|
||||
'Anchor objects should default to a1 for the left port and b1 for the right port'
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
{
|
||||
left: helpers.buildElementPorts('anchor').left,
|
||||
right: helpers.buildElementPorts('anchor').right,
|
||||
a1: helpers.buildElementPorts('anchor').a1,
|
||||
b1: helpers.buildElementPorts('anchor').b1,
|
||||
},
|
||||
{
|
||||
left: { x: 0, y: -15, a: 180, width: 0.5 },
|
||||
right: { x: 30, y: -15, a: 0, width: 0.5 }
|
||||
a1: { x: 0, y: -15, a: 180, width: 0.5 },
|
||||
b1: { x: 0, y: -15, a: 0, width: 0.5 }
|
||||
},
|
||||
'Anchor ports should sit on the left and right edges of a port-sized circle'
|
||||
'Anchor a/b port pairs should share coordinates and keep opposite directions'
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
helpers.buildBasicComponentPorts('waveguide', { length: 120, width: 0.6 }).b1,
|
||||
@@ -300,7 +300,46 @@ const elementNodes = [
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('port', { angle: 90, width: 0.8 }), {
|
||||
port: { x: 0, y: 0, a: 90, width: 0.8 }
|
||||
});
|
||||
assert.deepStrictEqual(Object.keys(helpers.buildElementPorts('anchor')), ['left', 'right']);
|
||||
assert.deepStrictEqual(Object.keys(helpers.buildElementPorts('anchor')), ['a1', 'b1']);
|
||||
assert.deepStrictEqual(Object.keys(helpers.buildElementPorts('port', { portNumber: 3, pitch: 10 })), ['port_1', 'port_2', 'port_3']);
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('port', { portNumber: 3, pitch: 10 }).port_1, { x: 0, y: 10, a: 0, width: 0.5 });
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('port', { portNumber: 3 }).port_1, { x: 0, y: 10, a: 0, width: 0.5 });
|
||||
assert.deepStrictEqual(Object.keys(helpers.buildElementPorts('anchor', { portNumber: 2, pitch: 12 })), ['a1', 'b1', 'a2', 'b2']);
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('anchor', { portNumber: 2, pitch: 12 }).b2, { x: 0, y: -21, a: 0, width: 0.5 });
|
||||
assert.deepStrictEqual(helpers.buildElementPorts('anchor', { portNumber: 2, pitch: 12 }).a2, { x: 0, y: -21, a: 180, width: 0.5 });
|
||||
assert.deepStrictEqual(
|
||||
helpers.getNodePortCanvasPoint({
|
||||
id: 'anchor-rotated',
|
||||
type: 'anchorNode',
|
||||
position: { x: 100, y: 200 },
|
||||
data: {
|
||||
elementType: 'anchor',
|
||||
rotation: 90,
|
||||
portNumber: 1,
|
||||
pitch: 10,
|
||||
ports: helpers.buildElementPorts('anchor', { portNumber: 1, pitch: 10 })
|
||||
}
|
||||
}, 'a1'),
|
||||
{ x: 115, y: 200 },
|
||||
'Anchor port endpoint coordinates should rotate with the anchor body'
|
||||
);
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ portNumber: 1 }), { width: 30, height: 30 });
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ elementType: 'anchor', portNumber: 1 }), { width: 8, height: 30 });
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ elementType: 'anchor', portNumber: 4, pitch: 10 }), { width: 8, height: 72 });
|
||||
assert.deepStrictEqual(helpers.buildElementBoxSize({ portNumber: 4, pitch: 10 }), { width: 30, height: 72 });
|
||||
assert.deepStrictEqual(
|
||||
helpers.buildPageComponentPorts(null, [{
|
||||
id: 'port-array',
|
||||
type: 'portNode',
|
||||
position: { x: 100, y: 200 },
|
||||
data: { componentDisplayName: 'array', elementType: 'port', portNumber: 3, pitch: 10, width: 0.6 }
|
||||
}]),
|
||||
{
|
||||
array_1: { x: 100, y: 190, a: 0, width: 0.6 },
|
||||
array_2: { x: 100, y: 200, a: 0, width: 0.6 },
|
||||
array_3: { x: 100, y: 210, a: 0, width: 0.6 }
|
||||
}
|
||||
);
|
||||
|
||||
const canvasPortsYaml = helpers.buildCanvasPortsYaml(elementNodes);
|
||||
assert(canvasPortsYaml.includes('name: in0'));
|
||||
@@ -314,6 +353,8 @@ assert(elementsYaml.includes('type: port'));
|
||||
assert(elementsYaml.includes('anchor_1:'));
|
||||
assert(elementsYaml.includes('type: anchor'));
|
||||
assert(elementsYaml.includes('y: -20.0'));
|
||||
assert(elementsYaml.includes('port_number: 1'));
|
||||
assert(elementsYaml.includes('pitch: 10'));
|
||||
|
||||
const instancesWithoutElements = helpers.buildInstancesYaml({
|
||||
nodes: elementNodes,
|
||||
@@ -484,7 +525,20 @@ const edgeD = {
|
||||
target: 'f',
|
||||
data: { route: { xsection: 'rib_low', family: 'optical' } }
|
||||
};
|
||||
const edgeE = {
|
||||
id: 'edge-metal-alias',
|
||||
source: 'e',
|
||||
target: 'f',
|
||||
data: { route: { xsection: 'metal1', family: 'electrical' } }
|
||||
};
|
||||
const edgeF = {
|
||||
id: 'edge-metal-underscore',
|
||||
source: 'a',
|
||||
target: 'b',
|
||||
data: { route: { xsection: 'metal_1', family: 'electrical' } }
|
||||
};
|
||||
assert.strictEqual(helpers.findSameTypeRouteCrossing(edgeB, [edgeA], crossingNodes).conflictEdge.id, 'edge-a-b');
|
||||
assert.strictEqual(helpers.findSameTypeRouteCrossing(edgeC, [edgeA], crossingNodes), null);
|
||||
assert.strictEqual(helpers.findSameTypeRouteCrossing(edgeD, [edgeA], crossingNodes), null);
|
||||
assert.strictEqual(helpers.findSameTypeRouteCrossing(edgeE, [edgeF], crossingNodes).conflictEdge.id, 'edge-metal-underscore');
|
||||
assert.strictEqual(helpers.findSameFamilyRouteCrossing(edgeB, [edgeA], crossingNodes).conflictEdge.id, 'edge-a-b');
|
||||
|
||||
Reference in New Issue
Block a user