Skip to content

Commit

Permalink
made all current and voltage sources work
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitgeddam committed Jun 4, 2020
1 parent 3eb13d9 commit d210f54
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function ComponentProperties () {
}

const setProps = () => {
console.log(val)
dispatch(setCompProperties(id, val))
dispatch(setModel(val.MODEL))
// setVal({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const ComponentParameters = {
NAME: '',
N1: '',
N2: '',
VALUE: '0',

OFFSET: '1.0',
AMPLITUDE: '1.0',
Expand All @@ -48,7 +47,7 @@ const ComponentParameters = {

EXTRA_EXPRESSION: '',
MODEL: '',
VALUE_UNIT: 'A',

OFFSET_UNIT: 'A',
AMPLITUDE_UNIT: 'A',
FREQUENCY_UNIT: 'Hz',
Expand All @@ -62,7 +61,6 @@ const ComponentParameters = {
NAME: '',
N1: '',
N2: '',
VALUE: '0',

INITIAL_VALUE: '0',
PULSED_VALUE: '1',
Expand All @@ -76,7 +74,6 @@ const ComponentParameters = {
EXTRA_EXPRESSION: '',
MODEL: '',

VALUE_UNIT: 'A',
INITIAL_VALUE_UNIT: 'A',
PULSED_VALUE_UNIT: 'A',
DELAY_TIME_UNIT: 'S',
Expand Down Expand Up @@ -105,7 +102,6 @@ const ComponentParameters = {
NAME: '',
N1: '',
N2: '',
VALUE: '0',

INITIAL_VALUE: '0',
PULSED_VALUE: '1',
Expand All @@ -118,7 +114,6 @@ const ComponentParameters = {
EXTRA_EXPRESSION: '',
MODEL: '',

VALUE_UNIT: 'A',
INITIAL_VALUE_UNIT: 'A',
PULSED_VALUE_UNIT: 'A',
RISE_DELAY_TIME_UNIT: 'S',
Expand Down Expand Up @@ -243,7 +238,6 @@ const ComponentParameters = {
NAME: '',
N1: '',
N2: '',
VALUE: '0',

OFFSET: '1.0',
AMPLITUDE: '1.0',
Expand All @@ -254,7 +248,7 @@ const ComponentParameters = {

EXTRA_EXPRESSION: '',
MODEL: '',
VALUE_UNIT: 'V',

OFFSET_UNIT: 'V',
AMPLITUDE_UNIT: 'V',
FREQUENCY_UNIT: 'Hz',
Expand All @@ -268,7 +262,6 @@ const ComponentParameters = {
NAME: '',
N1: '',
N2: '',
VALUE: '0',

INITIAL_VALUE: '0',
PULSED_VALUE: '1',
Expand All @@ -282,7 +275,6 @@ const ComponentParameters = {
EXTRA_EXPRESSION: '',
MODEL: '',

VALUE_UNIT: 'V',
INITIAL_VALUE_UNIT: 'V',
PULSED_VALUE_UNIT: 'V',
DELAY_TIME_UNIT: 'S',
Expand Down Expand Up @@ -311,7 +303,6 @@ const ComponentParameters = {
NAME: '',
N1: '',
N2: '',
VALUE: '0',

INITIAL_VALUE: '0',
PULSED_VALUE: '1',
Expand All @@ -324,7 +315,6 @@ const ComponentParameters = {
EXTRA_EXPRESSION: '',
MODEL: '',

VALUE_UNIT: 'V',
INITIAL_VALUE_UNIT: 'v',
PULSED_VALUE_UNIT: 'v',
RISE_DELAY_TIME_UNIT: 'S',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,22 @@ export function getSvgMetadata (graph, parent, evt, target, x, y, component) {
v1.symbol = component.symbol_prefix.toUpperCase()
v1.CompObject = component

component.name = component.name.toUpperCase()
var props = {}
if (v1.symbol === 'V') {
console.log('voltage')

if (ComponentParameters[v1.symbol][component.name.toUpperCase()] === undefined) {
if (ComponentParameters[v1.symbol][component.name] === undefined) {
props = Object.assign({}, ComponentParameters[v1.symbol].VSOURCE)
} else {
props = Object.assign({}, ComponentParameters[v1.symbol][component.name.toUpperCase()])
props = Object.assign({}, ComponentParameters[v1.symbol][component.name])
}
} else if (v1.symbol === 'I') {
console.log('CURRENT')
if (ComponentParameters[v1.symbol][component.name.toUpperCase()] === undefined) {
if (ComponentParameters[v1.symbol][component.name] === undefined) {
props = Object.assign({}, ComponentParameters[v1.symbol].ISOURCE)
} else {
props = Object.assign({}, ComponentParameters[v1.symbol][component.name.toUpperCase()])
props = Object.assign({}, ComponentParameters[v1.symbol][component.name])
}
} else {
console.log('other')
Expand Down
31 changes: 27 additions & 4 deletions eda-frontend/src/components/SchematicEditor/Helper/ToolbarTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,32 @@ export function GenerateNetList () {

// console.log(compobj)
}
// console.log(component)
if (component.properties.VALUE !== undefined) {
k = k + ' ' + component.properties.VALUE
component.value = component.value + '\n' + component.properties.VALUE
console.log('component properties', component.properties)

if (component.properties.PREFIX.charAt(0) === 'V' || component.properties.PREFIX.charAt(0) === 'v' || component.properties.PREFIX.charAt(0) === 'I' || component.properties.PREFIX.charAt(0) === 'i') {
const comp = component.properties
if (comp.NAME === 'SINE') {
k = k + ` SIN(${comp.OFFSET} ${comp.AMPLITUDE} ${comp.FREQUENCY} ${comp.DELAY} ${comp.DAMPING_FACTOR} ${comp.PHASE} )`
} else if (comp.NAME === 'EXP') {
k = k + ` EXP(${comp.INITIAL_VALUE} ${comp.PULSED_VALUE} ${comp.FREQUENCY} ${comp.RISE_DELAY_TIME} ${comp.RISE_TIME_CONSTANT} ${comp.FALL_DELAY_TIME} ${comp.FALL_TIME_CONSTANT} )`
} else if (comp.NAME === 'DC') {
if (component.properties.VALUE !== undefined) {
k = k + ' ' + 'DC ' + component.properties.VALUE
component.value = component.value + '\n' + component.properties.VALUE
}
} else if (comp.NAME === 'PULSE') {
k = k + ` EXP(${comp.INITIAL_VALUE} ${comp.PULSED_VALUE} ${comp.DELAY_TIME} ${comp.RISE_TIME} ${comp.FALL_TIME} ${comp.PULSE_WIDTH} ${comp.PERIOD} ${comp.PHASE} )`
} else {
if (component.properties.VALUE !== undefined) {
k = k + ' ' + component.properties.VALUE
component.value = component.value + '\n' + component.properties.VALUE
}
}
} else {
if (component.properties.VALUE !== undefined) {
k = k + ' ' + component.properties.VALUE
component.value = component.value + '\n' + component.properties.VALUE
}
}

if (component.properties.EXTRA_EXPRESSION.length > 0) {
Expand All @@ -415,6 +437,7 @@ export function GenerateNetList () {
if (component.properties.MODEL.length > 0) {
k = k + ' ' + component.properties.MODEL.split(' ')[1]
}

// k = k + ' 10'
k = k + ' \n'
// console.log(k)
Expand Down

0 comments on commit d210f54

Please sign in to comment.