summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRahul P2020-04-29 18:45:25 +0530
committerGitHub2020-04-29 18:45:25 +0530
commit175208c2553bde875968a9bc53176b6039ba9360 (patch)
treec1ccaabdddf0a6801167934650676ec00d2a867d
parenta35d497b81023950a6e675536f9cd4bf895983c2 (diff)
parentb0c203a3ec7bc85ebad08e76fade3c31d1291459 (diff)
downloadeSim-175208c2553bde875968a9bc53176b6039ba9360.tar.gz
eSim-175208c2553bde875968a9bc53176b6039ba9360.tar.bz2
eSim-175208c2553bde875968a9bc53176b6039ba9360.zip
Merge pull request #153 from rahulp13/master
updates related to OM converter
-rw-r--r--Examples/7805VoltageRegulator/D.lib2
-rw-r--r--Examples/7812VoltageRegulator/D.lib2
-rw-r--r--src/ngspicetoModelica/ModelicaUI.py30
-rw-r--r--src/ngspicetoModelica/NgspicetoModelica.py118
-rw-r--r--src/projManagement/Worker.py2
5 files changed, 80 insertions, 74 deletions
diff --git a/Examples/7805VoltageRegulator/D.lib b/Examples/7805VoltageRegulator/D.lib
index 8a7fb4da..f53bf3e0 100644
--- a/Examples/7805VoltageRegulator/D.lib
+++ b/Examples/7805VoltageRegulator/D.lib
@@ -1,2 +1,2 @@
-.model 1n4148 D(is=2.495E-09 rs=4.755E-01 n=1.679E+00 tt=3.030E-09 cjo=1.700E-12 vj=1 m=1.959E-01 bv=1.000E+02 ibv=1.000E-04)
+.model 1N4148 D(is=2.495E-09 rs=4.755E-01 n=1.679E+00 tt=3.030E-09 cjo=1.700E-12 vj=1 m=1.959E-01 bv=1.000E+02 ibv=1.000E-04)
diff --git a/Examples/7812VoltageRegulator/D.lib b/Examples/7812VoltageRegulator/D.lib
index 8a7fb4da..f53bf3e0 100644
--- a/Examples/7812VoltageRegulator/D.lib
+++ b/Examples/7812VoltageRegulator/D.lib
@@ -1,2 +1,2 @@
-.model 1n4148 D(is=2.495E-09 rs=4.755E-01 n=1.679E+00 tt=3.030E-09 cjo=1.700E-12 vj=1 m=1.959E-01 bv=1.000E+02 ibv=1.000E-04)
+.model 1N4148 D(is=2.495E-09 rs=4.755E-01 n=1.679E+00 tt=3.030E-09 cjo=1.700E-12 vj=1 m=1.959E-01 bv=1.000E+02 ibv=1.000E-04)
diff --git a/src/ngspicetoModelica/ModelicaUI.py b/src/ngspicetoModelica/ModelicaUI.py
index cd5cf03b..428bcab6 100644
--- a/src/ngspicetoModelica/ModelicaUI.py
+++ b/src/ngspicetoModelica/ModelicaUI.py
@@ -1,4 +1,5 @@
import os
+import glob
import traceback
from PyQt4 import QtGui, QtCore
from configuration.Appconfig import Appconfig
@@ -19,8 +20,7 @@ class OpenModelicaEditor(QtGui.QWidget):
self.projName = os.path.basename(self.projDir)
self.ngspiceNetlist = os.path.join(
self.projDir, self.projName + ".cir.out")
- self.modelicaNetlist = os.path.join(
- self.projDir, self.projName + ".mo")
+ self.modelicaNetlist = os.path.join(self.projDir, "*.mo")
self.map_json = Appconfig.modelica_map_json
self.grid = QtGui.QGridLayout()
@@ -96,28 +96,6 @@ class OpenModelicaEditor(QtGui.QWidget):
IfMOS = '1'
break
- subOptionInfo = []
- subSchemInfo = []
- if len(subcktName) > 0:
- # subOptionInfo = []
- # subSchemInfo = []
- for eachsub in subcktName:
- filename_temp = eachsub + '.sub'
- data = obj_NgMoConverter.readNetlist(filename_temp)
- # print "Data---------->",data
- subOptionInfo, subSchemInfo = (
- obj_NgMoConverter.separateNetlistInfo(data)
- )
- for eachline in subSchemInfo:
- # words = eachline.split()
- if eachline[0] == 'm':
- IfMOS = '1'
- break
- # print("Subcircuit OptionInfo :" +
- # "subOptionInfo------------------->", subOptionInfo)
- # print("Subcircuit Schematic Info :" +
- # "subSchemInfo-------------------->", subSchemInfo)
-
node, nodeDic, pinInit, pinProtectedInit = \
obj_NgMoConverter.nodeSeparate(
compInfo, '0', [], subcktName, []
@@ -233,7 +211,9 @@ class OpenModelicaEditor(QtGui.QWidget):
def callOMEdit(self):
if self.obj_validation.validateTool("OMEdit"):
- self.cmd2 = "OMEdit " + self.modelicaNetlist
+ modelFiles = glob.glob(self.modelicaNetlist)
+ modelFiles = ' '.join(file for file in modelFiles)
+ self.cmd2 = "OMEdit " + modelFiles
self.obj_workThread2 = Worker.WorkerThread(self.cmd2)
self.obj_workThread2.start()
print("OMEdit called")
diff --git a/src/ngspicetoModelica/NgspicetoModelica.py b/src/ngspicetoModelica/NgspicetoModelica.py
index 83df42a4..09e28981 100644
--- a/src/ngspicetoModelica/NgspicetoModelica.py
+++ b/src/ngspicetoModelica/NgspicetoModelica.py
@@ -57,6 +57,7 @@ class NgMoConverter:
"""
optionInfo = []
schematicInfo = []
+ self.deviceDetail = []
for eachline in netlist:
@@ -284,7 +285,7 @@ class NgMoConverter:
For each component in the netlist initialize it
according to Modelica format
"""
- # print "CompInfo inside compInit function : compInit------->",compInfo
+ # print ("CompInfo inside compInit function : compInit----->",compInfo)
# initial processing to check if MOs is present. If so, library to be
# used is BondLib
modelicaCompInit = []
@@ -292,25 +293,25 @@ class NgMoConverter:
mosInfo = {}
# IfMOS = '0'
- for eachline in compInfo:
- # words = eachline.split()
- if eachline[0] == 'm':
- # IfMOS = '1'
- break
- if len(subcktName) > 0:
- subOptionInfo = []
- subSchemInfo = []
- for eachsub in subcktName:
- filename_tem = eachsub + '.sub'
- filename_tem = os.path.join(dir_name, filename_tem)
- data = self.readNetlist(filename_tem)
- subOptionInfo, subSchemInfo = self.separateNetlistInfo(data)
-
- for eachline in subSchemInfo:
- # words = eachline.split()
- if eachline[0] == 'm':
- # IfMOS = '1'
- break
+ # for eachline in compInfo:
+ # # words = eachline.split()
+ # if eachline[0] == 'm':
+ # # IfMOS = '1'
+ # break
+ # if len(subcktName) > 0:
+ # subOptionInfo = []
+ # subSchemInfo = []
+ # for eachsub in subcktName:
+ # filename_tem = eachsub + '.sub'
+ # filename_tem = os.path.join(dir_name, filename_tem)
+ # data = self.readNetlist(filename_tem)
+ # subOptionInfo, subSchemInfo = self.separateNetlistInfo(data)
+
+ # for eachline in subSchemInfo:
+ # # words = eachline.split()
+ # if eachline[0] == 'm':
+ # # IfMOS = '1'
+ # break
# Lets Start with Source details
for eachline in self.sourceDetail:
@@ -398,7 +399,7 @@ class NgMoConverter:
# Now empty the source list as it may be used by subcircuit
self.sourceDetail[:] = []
- # print "Source Detail after processing-------->",self.sourceDetail
+ # print ("Source Detail after processing-------->",self.sourceDetail)
# Lets start for device
for eachline in self.deviceDetail:
@@ -471,7 +472,8 @@ class NgMoConverter:
self.mappingData["Devices"][deviceName]["import"]
) + ".NPN"
elif trans == 'pnp':
- start = self.mappingData(
+ start = (
+ self.mappingData
["Devices"]
[deviceName]
["import"]
@@ -863,7 +865,15 @@ class NgMoConverter:
newline = newline.split('.subckt ' + subname)
intLine = newline[1].split()
newindex = numNodesSub[subname]
- nodesInfoLine = intLine[0:newindex]
+ nodeTemp = intLine[0:newindex]
+
+ nodesInfoLine = []
+ # Replace hyphen '-' from node
+ for i in nodeTemp:
+ i = i.replace("-", "")
+ if i not in nodesInfoLine:
+ nodesInfoLine.append(i)
+
return nodesInfoLine
def getSubParamLine(self, subname, numNodesSub, subParamInfo, dir_name):
@@ -903,7 +913,7 @@ class NgMoConverter:
pinInit = 'Modelica.Electrical.Analog.Interfaces.Pin '
pinProtectedInit = 'Modelica.Electrical.Analog.Interfaces.Pin '
protectedNode = []
- # print "CompInfo coming to nodeSeparate function: compInfo",compInfo
+ # print ("CompInfo coming to nodeSeparate function: compInfo",compInfo)
# Removing '[' and ']' from compInfo for Digital node
for i in range(0, len(compInfo), 1):
@@ -926,7 +936,7 @@ class NgMoConverter:
for i in range(0, len(templine), 1):
if templine[i] in subcktName:
point = i
- # print "Added in node----->",words[1:point]
+ # print ("Added in node----->",words[1:point])
nodeTemp.extend(words[1:point])
else:
nodeTemp.append(words[1])
@@ -951,6 +961,7 @@ class NgMoConverter:
continue
else:
protectedNode.append(node[i])
+
if ifSub == '1':
if len(nonprotectedNode) > 0:
for i in range(0, len(nonprotectedNode), 1):
@@ -1000,7 +1011,9 @@ class NgMoConverter:
eachline[0] == 'v' or
eachline[0] == 'V' or
eachline[0] == 'i' or
- eachline[0] == 'I'
+ eachline[0] == 'I' or
+ eachline[0] == 'a' or
+ eachline[0] == 'A'
):
conn = 'connect(' + words[0] + '.p,' + nodeDic[words[1]] + ');'
connInfo.append(conn)
@@ -1107,10 +1120,10 @@ class NgMoConverter:
basename = filename
filename = os.path.join(dir_name, filename)
data = self.readNetlist(filename)
- # print "Data-------------------->",data
+ # print ("Data-------------------->",data)
subOptionInfo, subSchemInfo = self.separateNetlistInfo(data)
- # print "SubOptionInfo------------------->",subOptionInfo
- # print "SubSchemInfo-------------------->",subSchemInfo
+ # print ("SubOptionInfo------------------->",subOptionInfo)
+ # print ("SubSchemInfo-------------------->",subSchemInfo)
if len(subOptionInfo) > 0:
newline = subOptionInfo[0]
# subInitLine = newline
@@ -1124,12 +1137,12 @@ class NgMoConverter:
subtransInfo, subInbuiltModelDict = (
self.addModel(subOptionInfo)
)
- # print "Sub Model------------------------------->",subModel
- # print "SubModelInfo------------------------>",subModelInfo
- # print "subsubName---------------------------->",subsubName
- # print "subParamInfo------------------------>",subParamInfo
- # print "subtransInfo------------------------>",subtransInfo
- # print "subInbuiltModel-------------->",subInbuiltModelDict
+ # print ("Sub Model------------------------------->",subModel)
+ # print ("SubModelInfo------------------------>",subModelInfo)
+ # print ("subsubName---------------------------->",subsubName)
+ # print ("subParamInfo------------------------>",subParamInfo)
+ # print ("subtransInfo------------------------>",subtransInfo)
+ # print ("subInbuiltModel-------------->",subInbuiltModelDict)
IfMOSsub = '0'
for eachline in subSchemInfo:
@@ -1154,18 +1167,18 @@ class NgMoConverter:
if eachline[0] == 'm':
IfMOSsub = '1'
break
- # print "subsubOptionInfo------------------>",subsubOptionInfo
- # print "subsubSchemInfo-------------------->",subsubSchemInfo
+ # print ("subsubOptionInfo----------------->",subsubOptionInfo)
+ # print ("subsubSchemInfo------------------->",subsubSchemInfo)
modelicaSubParam = self.processParam(subParamInfo)
- # print "modelicaSubParam------------------>",modelicaSubParam
+ # print ("modelicaSubParam----------------->",modelicaSubParam)
nodeSub, nodeDicSub, pinInitSub,\
pinProtectedInitSub = self.nodeSeparate(
subSchemInfo, '1', eachsub, subsubName, numNodesSub)
- # print "NodeSub------------------------->",nodeSub
- # print "NodeDicSub-------------------------->",nodeDicSub
- # print "PinInitSub-------------------------->",pinInitSub
- # print "PinProtectedInitSub----------->",pinProtectedInitSub
+ # print ("NodeSub------------------------->",nodeSub)
+ # print ("NodeDicSub-------------------------->",nodeDicSub)
+ # print ("PinInitSub-------------------------->",pinInitSub)
+ # print ("PinProtectedInitSub----------->",pinProtectedInitSub)
modelicaSubCompInit, numNodesSubsub = self.compInit(
subSchemInfo,
nodeSub,
@@ -1175,14 +1188,14 @@ class NgMoConverter:
subtransInfo,
subInbuiltModelDict
)
- # print "modelicaSubCompInit------------>",modelicaSubCompInit
- # print "numNodesSubsub---------------------->",numNodesSubsub
+ # print ("modelicaSubCompInit---------->",modelicaSubCompInit)
+ # print ("numNodesSubsub-------------------->",numNodesSubsub)
modelicaSubParamNew = self.getSubParamLine(
eachsub,
numNodesSub,
modelicaSubParam,
dir_name) # Ask Manas
- # print "modelicaSubParamNew------------>",modelicaSubParamNew
+ # print ("modelicaSubParamNew---------->",modelicaSubParamNew)
connSubInfo = self.connectInfo(
subSchemInfo,
nodeSub,
@@ -1190,7 +1203,20 @@ class NgMoConverter:
numNodesSubsub,
subcktName
)
- # print "connSubInfo----------------->",connSubInfo
+ # print ("connSubInfo----------------->",connSubInfo)
+
+ # Recursively process Subcircuit
+ if len(subsubName) > 0:
+ data, subOptionInfo, subSchemInfo, subModel, subModelInfo,\
+ subsubName, subParamInfo, modelicaSubCompInit,\
+ modelicaSubParam, nodeSubInterface, nodeSub,\
+ nodeDicSub, pinInitSub, connSubInfo = (
+ self.procesSubckt(
+ subsubName, numNodesSubsub, dir_name
+ )
+ )
+
+ # After Sub Ckt Func
newname = basename.split('.')
newfilename = newname[0]
outfilename = newfilename + ".mo"
diff --git a/src/projManagement/Worker.py b/src/projManagement/Worker.py
index 8ced35a7..8ce605f0 100644
--- a/src/projManagement/Worker.py
+++ b/src/projManagement/Worker.py
@@ -90,7 +90,7 @@ class WorkerThread(QtCore.QThread):
@params
:command => (self.args) takes space separated string of\
comamnds to be executed in different child processes
- (see subproces.Popen())
+ (see subprocess.Popen())
"""
procThread = Appconfig()