summaryrefslogtreecommitdiff
path: root/src/ngspicetoModelica/NgspicetoModelica.py
diff options
context:
space:
mode:
authorfahim-oscad2016-03-31 14:00:58 +0530
committerfahim-oscad2016-03-31 14:00:58 +0530
commit9ff48b10ff4c184aa605003df48ccf463ccecf2b (patch)
tree8ba4042dc62a142e4c5f0f2f127306f89a01daf1 /src/ngspicetoModelica/NgspicetoModelica.py
parent8ac1b2874949f65dda3d940de77cc315a3babd69 (diff)
downloadeSim-9ff48b10ff4c184aa605003df48ccf463ccecf2b.tar.gz
eSim-9ff48b10ff4c184aa605003df48ccf463ccecf2b.tar.bz2
eSim-9ff48b10ff4c184aa605003df48ccf463ccecf2b.zip
Modified getUnitVal function to accomodate decimal values
Diffstat (limited to 'src/ngspicetoModelica/NgspicetoModelica.py')
-rw-r--r--src/ngspicetoModelica/NgspicetoModelica.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/ngspicetoModelica/NgspicetoModelica.py b/src/ngspicetoModelica/NgspicetoModelica.py
index c89c742b..6fe75516 100644
--- a/src/ngspicetoModelica/NgspicetoModelica.py
+++ b/src/ngspicetoModelica/NgspicetoModelica.py
@@ -214,12 +214,17 @@ class NgMoConverter:
def getUnitVal(self,compValue):
print "Received compValue--------> ",compValue
- regExp = re.compile("([0-9]+)([a-zA-Z]+)")
+ #regExp = re.compile("([0-9]+)([a-zA-Z]+)")
+ regExp = re.compile("([0-9]+)\.?([0-9]+)?([a-zA-Z])?")
matchString = regExp.match(str(compValue)) #separating number and string
try:
- numValue = matchString.group(1)
- unitValue = matchString.group(2)
- modifiedcompValue = numValue+self.mappingData["Units"][unitValue]
+ valBeforeDecimal = matchString.group(1)
+ valAfterDecimal = matchString.group(2)
+ unitValue = matchString.group(3)
+ if str(valAfterDecimal)=='None':
+ modifiedcompValue = valBeforeDecimal+self.mappingData["Units"][unitValue]
+ else:
+ modifiedcompValue = valBeforeDecimal+'.'+valAfterDecimal+self.mappingData["Units"][unitValue]
return modifiedcompValue
except:
return compValue