Add port symbols to qeda.

This commit is contained in:
David Craven
2018-01-31 13:23:30 +01:00
parent 309638efca
commit e572099f81
3 changed files with 72 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ Commands:\n\
load COMPONENT Load component definition from global repository\n\
power NET Add power supply symbol to config\n\
ground NET Add ground symbol to config\n\
port Add port symbols to config\n\
sort Sort components and nets in config alphabetically\n\
(use with caution due to possible annotation issues)\n\
config PARAM [VALUE] Set/get config parameter\n\
@@ -136,6 +137,12 @@ function addGround(netName) {
}
}
function addPort() {
var qedaYaml = readYaml();
qedaYaml.port = true;
writeYaml(qedaYaml);
}
function generateLibrary(libraryName) {
var qedaYaml = readYaml();
qedaYaml.library = qedaYaml.library || [];
@@ -161,6 +168,9 @@ function generateLibrary(libraryName) {
for (var i = 0; i < qedaYaml.ground.length; ++i) {
lib.ground(qedaYaml.ground[i]);
}
if (qedaYaml.port === true) {
lib.port()
}
lib.generate(libraryName);
}
@@ -287,6 +297,9 @@ switch (command) {
}
addGround(args.argv.original[1]);
break;
case 'port':
addPort()
break;
case 'config':
if (args.argv.original.length < 2) {
displayError('Missing parameter after "config" command');

View File

@@ -117,9 +117,10 @@ class QedaLibrary
#
# Add symbol
#
addSymbol: (symbol, name) ->
addSymbol: (symbol, name, options="") ->
schematic =
symbol: symbol
options: options
words = name.split('/')
if words.length > 1
for i in [0..(words.length-2)]
@@ -253,6 +254,13 @@ class QedaLibrary
power: (name) ->
@addSymbol 'power', name
#
# Add port symbols
#
port: () ->
input = @addSymbol 'port', 'inputExt', 'input'
output = @addSymbol 'port', 'outputExt', 'output'
#
# Render elements
#

View File

@@ -0,0 +1,50 @@
portSymbol = (symbol, element) ->
settings = symbol.settings
schematic = element.schematic
size = 3 * settings.factor
width = 3 * size
height = 2 * size
symbol
.attribute 'refDes',
x: if schematic.input then 0 else width
y: 0 - settings.space.attribute
halign: if schematic.input then 'left' else 'right'
valign: 'bottom'
.pin
number: 1
name: if schematic.input then 'Y' else 'A'
x: if schematic.input then width else 0
y: height/2
length: 0
orientation: if schematic.input then 'left' else 'right'
.lineWidth settings.lineWidth.thick
if schematic.input
element.description = 'Input Port Symbol'
element.aliases ?= []
element.aliases.push('$_inputExt_')
symbol.polyline(0, 0,
0, height,
width/2, height,
width, height/2,
width/2, 0,
0, 0)
else if schematic.output
element.description = 'Output Port Symbol'
element.aliases ?= []
element.aliases.push('$_outputExt_')
symbol.polyline(width, 0,
width, height,
width/2, height,
0, height/2,
width/2, 0,
width, 0)
module.exports = (symbol, element) ->
element.refDes = '#PORT'
schematic = element.schematic
schematic.showPinNames ?= false
schematic.showPinNumbers ?= false
portSymbol symbol, element