summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Shetye2024-06-25 12:48:24 +0530
committerSunil Shetye2024-06-25 12:48:24 +0530
commit1fc79ddfba25debfee9abeb961ec8d03aa3761fb (patch)
tree71ff8e8fa382f421b41f453ff8bb344927f293e8
parent776f60420657506a5b65bb23b9ad0b03b8ca2db0 (diff)
downloadCommon-Interface-Project-1fc79ddfba25debfee9abeb961ec8d03aa3761fb.tar.gz
Common-Interface-Project-1fc79ddfba25debfee9abeb961ec8d03aa3761fb.tar.bz2
Common-Interface-Project-1fc79ddfba25debfee9abeb961ec8d03aa3761fb.zip
add pow function to xsl
-rw-r--r--blocks/.flake85
-rwxr-xr-xblocks/Xcos/MxGraphParser.py6
-rw-r--r--blocks/Xcos/blocks/BARXY.py9
-rw-r--r--blocks/Xcos/blocks/BPLATFORM.py15
-rw-r--r--blocks/Xcos/blocks/CONVERT.py4
-rw-r--r--blocks/Xcos/blocks/CSCOPE.py9
-rw-r--r--blocks/Xcos/blocks/DOLLAR_f.py2
-rw-r--r--blocks/Xcos/blocks/Gyrator.py12
-rw-r--r--blocks/Xcos/blocks/INTEGRAL_m.py2
-rw-r--r--blocks/Xcos/blocks/MAX_f.py2
-rw-r--r--blocks/Xcos/blocks/MIN_f.py2
-rw-r--r--blocks/Xcos/blocks/M_freq.py2
-rw-r--r--blocks/Xcos/blocks/RELAY_f.py2
-rw-r--r--blocks/Xcos/blocks/SELECT_m.py2
-rw-r--r--blocks/Xcos/blocks/STEP_FUNCTION.py2
-rw-r--r--blocks/Xcos/blocks/SampleCLK.py5
-rw-r--r--blocks/Xcos/blocks/TCLSS.py11
-rw-r--r--blocks/Xcos/common/AAAAAA.py26
-rw-r--r--blocks/instructions/views.py2
-rw-r--r--blocks/saveAPI/views.py2
-rw-r--r--blocks/simulationAPI/helpers/ngspice_helper.py4
-rw-r--r--blocks/simulationAPI/helpers/parse.py4
-rw-r--r--blocks/xcos2xml/head.xsl109
23 files changed, 168 insertions, 71 deletions
diff --git a/blocks/.flake8 b/blocks/.flake8
index 9dc33eb7..fadf6518 100644
--- a/blocks/.flake8
+++ b/blocks/.flake8
@@ -1,3 +1,8 @@
[flake8]
+# default pep8 list
+#ignore = E121,E123,E126,E133,E226,E241,E242,E704,W503,W504,W505
+# default flake8 list
+#ignore = E121,E123,E126,E226,E24,E704,W503,W504
+ignore = F40,W504
extend-exclude = docs,env*,migrations,node_modules,Xcos
max-line-length = 100
diff --git a/blocks/Xcos/MxGraphParser.py b/blocks/Xcos/MxGraphParser.py
index 7524f1c7..46bf4945 100755
--- a/blocks/Xcos/MxGraphParser.py
+++ b/blocks/Xcos/MxGraphParser.py
@@ -145,13 +145,11 @@ for root in model:
IDLIST[attribid] = style
globals()[style](outroot, attribid, ParentComponent, ordering, geometry)
elif 'edge' in attrib:
-
sourceVertex = attrib['sourceVertex']
targetVertex = attrib['targetVertex']
sourceType = IDLIST[sourceVertex]
targetType = IDLIST[targetVertex]
-
# switch vertices if required
if sourceType in ['ExplicitInputPort', 'ImplicitInputPort', 'ControlPort'] and targetType in ['ExplicitOutputPort', 'ExplicitLink', 'ImplicitOutputPort', 'ImplicitLink', 'CommandPort', 'CommandControlLink']:
(sourceVertex, targetVertex) = (targetVertex, sourceVertex)
@@ -185,7 +183,7 @@ for root in model:
edgeDict[attribid] = (style, sourceVertex, targetVertex, sourceType, targetType)
edgeDict2[attribid] = (style, sourceVertex, targetVertex, sourceType, targetType)
IDLIST[attribid] = style
-
+
if addSplit:
mxGeometry = cell.find('mxGeometry')
if mxGeometry is not None:
@@ -196,7 +194,7 @@ for root in model:
geometry['height'] = mxPoint.attrib.get('height', '7')
geometry['x'] = mxPoint.attrib.get('x', '0')
geometry['y'] = mxPoint.attrib.get('y', '0')
-
+
splitList.append((attribid, sourceVertex, targetVertex, sourceType, targetType, geometry))
try:
del edgeDict[sourceVertex]
diff --git a/blocks/Xcos/blocks/BARXY.py b/blocks/Xcos/blocks/BARXY.py
index 019e0ea1..d5063675 100644
--- a/blocks/Xcos/blocks/BARXY.py
+++ b/blocks/Xcos/blocks/BARXY.py
@@ -11,11 +11,10 @@ def BARXY(outroot, attribid, ordering, geometry, parameters):
addExprsNode(outnode, TYPE_STRING, 5, parameters)
addScilabDNode(outnode, AS_REAL_PARAM, width=4, realParts=[
- format_real_number(parameters[0]),
- format_real_number(parameters[1]),
- format_real_number(parameters[2]),
- format_real_number(parameters[3])]
- )
+ format_real_number(parameters[0]),
+ format_real_number(parameters[1]),
+ format_real_number(parameters[2]),
+ format_real_number(parameters[3])])
param = [parameters[4]]
addPrecNode(outnode, TYPE_INTEGER, AS_INT_PARAM, 1, param)
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_OBJ_PARAM, parameters)
diff --git a/blocks/Xcos/blocks/BPLATFORM.py b/blocks/Xcos/blocks/BPLATFORM.py
index 1ae1c139..5fc4ca6e 100644
--- a/blocks/Xcos/blocks/BPLATFORM.py
+++ b/blocks/Xcos/blocks/BPLATFORM.py
@@ -10,14 +10,13 @@ def BPLATFORM(outroot, attribid, ordering, geometry, parameters):
addExprsNode(outnode, TYPE_STRING, 7, parameters)
addScilabDNode(outnode, AS_REAL_PARAM, width=7, realParts=[
- format_real_number(parameters[0]),
- format_real_number(parameters[1]),
- format_real_number(parameters[2]),
- format_real_number(parameters[3]),
- format_real_number(parameters[4]),
- format_real_number(parameters[5]),
- format_real_number(parameters[6])]
- )
+ format_real_number(parameters[0]),
+ format_real_number(parameters[1]),
+ format_real_number(parameters[2]),
+ format_real_number(parameters[3]),
+ format_real_number(parameters[4]),
+ format_real_number(parameters[5]),
+ format_real_number(parameters[6])])
addTypeNode(outnode, TYPE_DOUBLE, AS_INT_PARAM, 0, [])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_OBJ_PARAM, parameters)
array = ['0']
diff --git a/blocks/Xcos/blocks/CONVERT.py b/blocks/Xcos/blocks/CONVERT.py
index 32acb47d..643bd669 100644
--- a/blocks/Xcos/blocks/CONVERT.py
+++ b/blocks/Xcos/blocks/CONVERT.py
@@ -36,8 +36,8 @@ def get_from_CONVERT(cell):
input_t = int(float(parameters[0]))
output_t = int(float(parameters[1]))
- input_type = types[input_t-1]
- output_type = types[output_t-1]
+ input_type = types[input_t - 1]
+ output_type = types[output_t - 1]
display_parameter = input_type + ',' + output_type
diff --git a/blocks/Xcos/blocks/CSCOPE.py b/blocks/Xcos/blocks/CSCOPE.py
index 80891349..5c6d7220 100644
--- a/blocks/Xcos/blocks/CSCOPE.py
+++ b/blocks/Xcos/blocks/CSCOPE.py
@@ -11,11 +11,10 @@ def CSCOPE(outroot, attribid, ordering, geometry, parameters):
addExprsNode(outnode, TYPE_STRING, 10, parameters)
addScilabDNode(outnode, AS_REAL_PARAM, width=4, realParts=[
- format_real_number(parameters[8]),
- format_real_number(parameters[4]),
- format_real_number(parameters[5]),
- format_real_number(parameters[6])]
- )
+ format_real_number(parameters[8]),
+ format_real_number(parameters[4]),
+ format_real_number(parameters[5]),
+ format_real_number(parameters[6])])
param = strarray(parameters)
addPrecNode(outnode, TYPE_INTEGER, AS_INT_PARAM, 15, param)
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_OBJ_PARAM, parameters)
diff --git a/blocks/Xcos/blocks/DOLLAR_f.py b/blocks/Xcos/blocks/DOLLAR_f.py
index 2dc132c5..4cdbb1ab 100644
--- a/blocks/Xcos/blocks/DOLLAR_f.py
+++ b/blocks/Xcos/blocks/DOLLAR_f.py
@@ -18,7 +18,7 @@ def DOLLAR_f(outroot, attribid, ordering, geometry, parameters):
addTypeNode(outnode, TYPE_DOUBLE, AS_STATE, 0, [])
# addTypeNode(outnode, TYPE_DOUBLE, AS_DSTATE, 1, parameters[0])
addScilabDNode(outnode, AS_DSTATE, width=4, realParts=[
- format_real_number(parameters[0])])
+ format_real_number(parameters[0])])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, [])
addObjNode(outnode, TYPE_ARRAY,
CLASS_LIST, AS_EQUATIONS, parameters)
diff --git a/blocks/Xcos/blocks/Gyrator.py b/blocks/Xcos/blocks/Gyrator.py
index 6812976a..7f870351 100644
--- a/blocks/Xcos/blocks/Gyrator.py
+++ b/blocks/Xcos/blocks/Gyrator.py
@@ -11,8 +11,8 @@ def Gyrator(outroot, attribid, ordering, geometry, parameters):
addExprsNode(outnode, TYPE_STRING, 2, parameters)
addScilabDNode(outnode, AS_REAL_PARAM, width=2, realParts=[
- format_real_number(parameters[0]),
- format_real_number(parameters[1])])
+ format_real_number(parameters[0]),
+ format_real_number(parameters[1])])
addTypeNode(outnode, TYPE_DOUBLE, AS_INT_PARAM, 0, [])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_OBJ_PARAM, [])
array = ['0']
@@ -61,11 +61,11 @@ def Gyrator(outroot, attribid, ordering, geometry, parameters):
addDataData(additionalStringNode, param)
addNodeScilabDouble(innerArrayNode, height=2, realParts=[
- format_real_number(parameters[0]),
- format_real_number(parameters[1])])
+ format_real_number(parameters[0]),
+ format_real_number(parameters[1])])
addNodeScilabDouble(innerArrayNode, height=2, realParts=[
- format_real_number('0'),
- format_real_number('0')])
+ format_real_number('0'),
+ format_real_number('0')])
addgeometryNode(outnode, GEOMETRY, geometry['height'],
geometry['width'], geometry['x'], geometry['y'])
diff --git a/blocks/Xcos/blocks/INTEGRAL_m.py b/blocks/Xcos/blocks/INTEGRAL_m.py
index 0f5aa0c2..c7fcca13 100644
--- a/blocks/Xcos/blocks/INTEGRAL_m.py
+++ b/blocks/Xcos/blocks/INTEGRAL_m.py
@@ -18,7 +18,7 @@ def INTEGRAL_m(outroot, attribid, ordering, geometry, parameters):
addPrecisionNode(outnode, TYPE_INTEGER, AS_NBZERO, 1, array)
addPrecisionNode(outnode, TYPE_INTEGER, AS_NMODE, 1, array)
addScilabDNode(outnode, AS_STATE, width=1, realParts=[
- format_real_number(parameters[0])])
+ format_real_number(parameters[0])])
addTypeNode(outnode, TYPE_DOUBLE, AS_DSTATE, 0, [])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, parameters)
# Create the outer Array node for equations
diff --git a/blocks/Xcos/blocks/MAX_f.py b/blocks/Xcos/blocks/MAX_f.py
index f7b1c603..926a03bc 100644
--- a/blocks/Xcos/blocks/MAX_f.py
+++ b/blocks/Xcos/blocks/MAX_f.py
@@ -19,7 +19,7 @@ def MAX_f(outroot, attribid, ordering, geometry, parameters):
addPrecisionNode(outnode, TYPE_INTEGER, AS_NMODE, 1, array)
addTypeNode(outnode, TYPE_DOUBLE, AS_STATE, 0, [])
addScilabDNode(outnode, AS_DSTATE, width=2, realParts=[
- 0.0, 0.0])
+ 0.0, 0.0])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, parameters)
addObjNode(outnode, TYPE_ARRAY,
CLASS_LIST, AS_EQUATIONS, parameters)
diff --git a/blocks/Xcos/blocks/MIN_f.py b/blocks/Xcos/blocks/MIN_f.py
index 6af647dd..beed5117 100644
--- a/blocks/Xcos/blocks/MIN_f.py
+++ b/blocks/Xcos/blocks/MIN_f.py
@@ -19,7 +19,7 @@ def MIN_f(outroot, attribid, ordering, geometry, parameters):
addPrecisionNode(outnode, TYPE_INTEGER, AS_NMODE, 1, array)
addTypeNode(outnode, TYPE_DOUBLE, AS_STATE, 0, [])
addScilabDNode(outnode, AS_DSTATE, width=2, realParts=[
- 0.0, 0.0])
+ 0.0, 0.0])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, parameters)
addObjNode(outnode, TYPE_ARRAY,
CLASS_LIST, AS_EQUATIONS, parameters)
diff --git a/blocks/Xcos/blocks/M_freq.py b/blocks/Xcos/blocks/M_freq.py
index c9024abd..7bc914c6 100644
--- a/blocks/Xcos/blocks/M_freq.py
+++ b/blocks/Xcos/blocks/M_freq.py
@@ -39,7 +39,7 @@ def get_from_M_freq(cell):
con = ''
eov = ''
iov = ''
- com = (len(inputs)**2)-1
+ com = (len(inputs)**2) - 1
ports = [eiv, iiv, con, eov, iov, com]
diff --git a/blocks/Xcos/blocks/RELAY_f.py b/blocks/Xcos/blocks/RELAY_f.py
index a1f0d158..26abaa42 100644
--- a/blocks/Xcos/blocks/RELAY_f.py
+++ b/blocks/Xcos/blocks/RELAY_f.py
@@ -19,7 +19,7 @@ def RELAY_f(outroot, attribid, ordering, geometry, parameters):
addPrecisionNode(outnode, TYPE_INTEGER, AS_NMODE, 1, array)
addTypeNode(outnode, TYPE_DOUBLE, AS_STATE, 0, [])
addScilabDNode(outnode, AS_DSTATE, width=1, realParts=[
- 0.0])
+ 0.0])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, [])
addObjNode(outnode, TYPE_ARRAY,
CLASS_LIST, AS_EQUATIONS, [])
diff --git a/blocks/Xcos/blocks/SELECT_m.py b/blocks/Xcos/blocks/SELECT_m.py
index a66a6e79..7236b447 100644
--- a/blocks/Xcos/blocks/SELECT_m.py
+++ b/blocks/Xcos/blocks/SELECT_m.py
@@ -18,7 +18,7 @@ def SELECT_m(outroot, attribid, ordering, geometry, parameters):
addPrecisionNode(outnode, TYPE_INTEGER, AS_NMODE, 1, array)
addTypeNode(outnode, TYPE_DOUBLE, AS_STATE, 0, [])
addScilabDNode(outnode, AS_DSTATE, width=1, realParts=[
- format_real_number(parameters[0])])
+ format_real_number(parameters[0])])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, parameters)
addObjNode(outnode, TYPE_ARRAY,
CLASS_LIST, AS_EQUATIONS, parameters)
diff --git a/blocks/Xcos/blocks/STEP_FUNCTION.py b/blocks/Xcos/blocks/STEP_FUNCTION.py
index 6f640400..abb07f38 100644
--- a/blocks/Xcos/blocks/STEP_FUNCTION.py
+++ b/blocks/Xcos/blocks/STEP_FUNCTION.py
@@ -144,4 +144,4 @@ def get_from_STEP_FUNCTION(cell):
ports = [eiv, iiv, con, eov, iov, com]
- return (parameters, display_parameter, ports) \ No newline at end of file
+ return (parameters, display_parameter, ports)
diff --git a/blocks/Xcos/blocks/SampleCLK.py b/blocks/Xcos/blocks/SampleCLK.py
index bcce936a..c1706990 100644
--- a/blocks/Xcos/blocks/SampleCLK.py
+++ b/blocks/Xcos/blocks/SampleCLK.py
@@ -10,9 +10,8 @@ def SampleCLK(outroot, attribid, ordering, geometry, parameters):
addExprsNode(outnode, TYPE_STRING, 2, parameters)
addScilabDNode(outnode, AS_REAL_PARAM, width=2, realParts=[
- format_real_number(parameters[0]),
- format_real_number(parameters[1])]
- )
+ format_real_number(parameters[0]),
+ format_real_number(parameters[1])])
addTypeNode(outnode, TYPE_DOUBLE, AS_INT_PARAM, 0, [])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_OBJ_PARAM, [])
array = ['0']
diff --git a/blocks/Xcos/blocks/TCLSS.py b/blocks/Xcos/blocks/TCLSS.py
index 92af9d85..7de7c97b 100644
--- a/blocks/Xcos/blocks/TCLSS.py
+++ b/blocks/Xcos/blocks/TCLSS.py
@@ -11,18 +11,17 @@ def TCLSS(outroot, attribid, ordering, geometry, parameters):
addExprsNode(outnode, TYPE_STRING, 5, parameters)
addScilabDNode(outnode, AS_REAL_PARAM, width=4, realParts=[
- format_real_number(parameters[0]),
- format_real_number(parameters[1]),
- format_real_number(parameters[2]),
- format_real_number(parameters[3])]
- )
+ format_real_number(parameters[0]),
+ format_real_number(parameters[1]),
+ format_real_number(parameters[2]),
+ format_real_number(parameters[3])])
addTypeNode(outnode, TYPE_DOUBLE, AS_INT_PARAM, 0, [])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_OBJ_PARAM, parameters)
array = ['0']
addPrecisionNode(outnode, TYPE_INTEGER, AS_NBZERO, 1, array)
addPrecisionNode(outnode, TYPE_INTEGER, AS_NMODE, 1, array)
addScilabDNode(outnode, AS_STATE, width=1, realParts=[
- format_real_number(parameters[0])])
+ format_real_number(parameters[0])])
addTypeNode(outnode, TYPE_DOUBLE, AS_DSTATE, 0, [])
addObjNode(outnode, TYPE_ARRAY, CLASS_LIST, AS_ODSTATE, parameters)
addObjNode(outnode, TYPE_ARRAY,
diff --git a/blocks/Xcos/common/AAAAAA.py b/blocks/Xcos/common/AAAAAA.py
index 0a81c5b4..b0244155 100644
--- a/blocks/Xcos/common/AAAAAA.py
+++ b/blocks/Xcos/common/AAAAAA.py
@@ -542,18 +542,16 @@ def si_format(num):
number = float(num)
si_form = '{:.1e}'.format(number)
neg_prefixes = (
- {SIGN: 'm', LOWER_LIMIT: -2, UPPER_LIMIT: 0, VALUE: 1E-3},
- {SIGN: 'μ', LOWER_LIMIT: -5, UPPER_LIMIT: -3, VALUE: 1E-6},
- {SIGN: 'n', LOWER_LIMIT: -8, UPPER_LIMIT: -6, VALUE: 1E-9},
- {SIGN: 'p', LOWER_LIMIT: -11, UPPER_LIMIT: -9, VALUE: 1E-12}
- )
+ {SIGN: 'm', LOWER_LIMIT: -2, UPPER_LIMIT: 0, VALUE: 1E-3},
+ {SIGN: 'μ', LOWER_LIMIT: -5, UPPER_LIMIT: -3, VALUE: 1E-6},
+ {SIGN: 'n', LOWER_LIMIT: -8, UPPER_LIMIT: -6, VALUE: 1E-9},
+ {SIGN: 'p', LOWER_LIMIT: -11, UPPER_LIMIT: -9, VALUE: 1E-12})
pos_prefixes = (
- {SIGN: '', LOWER_LIMIT: 1, UPPER_LIMIT: 3, VALUE: 1},
- {SIGN: 'k', LOWER_LIMIT: 4, UPPER_LIMIT: 6, VALUE: 1E3},
- {SIGN: 'M', LOWER_LIMIT: 7, UPPER_LIMIT: 9, VALUE: 1E6},
- {SIGN: 'G', LOWER_LIMIT: 10, UPPER_LIMIT: 12, VALUE: 1E9},
- {SIGN: 'T', LOWER_LIMIT: 13, UPPER_LIMIT: 15, VALUE: 1E12}
- )
+ {SIGN: '', LOWER_LIMIT: 1, UPPER_LIMIT: 3, VALUE: 1},
+ {SIGN: 'k', LOWER_LIMIT: 4, UPPER_LIMIT: 6, VALUE: 1E3},
+ {SIGN: 'M', LOWER_LIMIT: 7, UPPER_LIMIT: 9, VALUE: 1E6},
+ {SIGN: 'G', LOWER_LIMIT: 10, UPPER_LIMIT: 12, VALUE: 1E9},
+ {SIGN: 'T', LOWER_LIMIT: 13, UPPER_LIMIT: 15, VALUE: 1E12})
splits = si_form.split('e')
base = float(splits[0])
exp = int(splits[1])
@@ -563,11 +561,11 @@ def si_format(num):
if exp <= 0:
for p in neg_prefixes:
if exp >= p.get(LOWER_LIMIT) and exp <= p.get(UPPER_LIMIT):
- return str(round(number/p.get(VALUE)))+' '+p.get(SIGN)
+ return str(round(number / p.get(VALUE))) + ' ' + p.get(SIGN)
else:
for p in pos_prefixes:
if exp >= p.get(LOWER_LIMIT) and exp <= p.get(UPPER_LIMIT):
- return str(round(number/p.get(VALUE)))+' '+p.get(SIGN)
+ return str(round(number / p.get(VALUE))) + ' ' + p.get(SIGN)
def print_affich_m(rows, columns, prec):
@@ -608,4 +606,4 @@ def format_real_number(parameter):
formatted_number = "{:.1E}".format(real_number)
else:
formatted_number = "{:.1f}".format(float(parameter))
- return formatted_number \ No newline at end of file
+ return formatted_number
diff --git a/blocks/instructions/views.py b/blocks/instructions/views.py
index 46816ecf..c23314e2 100644
--- a/blocks/instructions/views.py
+++ b/blocks/instructions/views.py
@@ -46,7 +46,7 @@ class Instructions(APIView):
allIdDicts[chartId] = idDict
event = 'instruction'
data = 'addChart id=%s type=%s xMin=%s xMax=%s yMin=%s yMax=%s' % (
- chartId, chartType, xMin, xMax, yMin, yMax)
+ chartId, chartType, xMin, xMax, yMin, yMax)
elif number < 100 - 2 * (1 + resets) * len(allChartIds):
chartId = choice(allChartIds)
idDict = allIdDicts[chartId]
diff --git a/blocks/saveAPI/views.py b/blocks/saveAPI/views.py
index 5f28289d..6237b6e2 100644
--- a/blocks/saveAPI/views.py
+++ b/blocks/saveAPI/views.py
@@ -12,7 +12,7 @@ import traceback
import uuid
from .models import Gallery, StateSave
from .serializers import Base64ImageField, GallerySerializer, \
- SaveListSerializer, StateSaveSerializer
+ SaveListSerializer, StateSaveSerializer
logger = logging.getLogger(__name__)
diff --git a/blocks/simulationAPI/helpers/ngspice_helper.py b/blocks/simulationAPI/helpers/ngspice_helper.py
index 4ff1e134..7009896d 100644
--- a/blocks/simulationAPI/helpers/ngspice_helper.py
+++ b/blocks/simulationAPI/helpers/ngspice_helper.py
@@ -41,7 +41,7 @@ class CannotRunParser(Exception):
def CreateXml(file_path, parameters, file_id):
parameters = json.loads(parameters)
- current_dir = settings.MEDIA_ROOT+'/'+str(file_id)
+ current_dir = settings.MEDIA_ROOT + '/' + str(file_id)
# Make Unique Directory for simulation to run
Path(current_dir).mkdir(parents=True, exist_ok=True)
(xcosfilebase, __) = os.path.splitext(file_path)
@@ -87,7 +87,7 @@ def ExecXml(file_obj):
file_obj.parameters,
file_obj.file_id)
(logfilefd, log_name) = mkstemp(prefix=datetime.now().strftime(
- 'scilab-log-%Y%m%d-'), suffix='.txt', dir=current_dir)
+ 'scilab-log-%Y%m%d-'), suffix='.txt', dir=current_dir)
if logfilefd != LOGFILEFD:
os.dup2(logfilefd, LOGFILEFD)
diff --git a/blocks/simulationAPI/helpers/parse.py b/blocks/simulationAPI/helpers/parse.py
index 2695d1d4..52c2aa41 100644
--- a/blocks/simulationAPI/helpers/parse.py
+++ b/blocks/simulationAPI/helpers/parse.py
@@ -54,8 +54,8 @@ def extract_data_from_ngspice_output(pathToFile):
data["x"].append(contents_of_line[1])
for x in range(len(data["y"])):
- data["y"][x].append(contents_of_line[x+2])
- json_data["total_number_of_tables"] = total_number_of_tables -\
+ data["y"][x].append(contents_of_line[x + 2])
+ json_data["total_number_of_tables"] = total_number_of_tables - \
len(json_data["data"])
return json_data
diff --git a/blocks/xcos2xml/head.xsl b/blocks/xcos2xml/head.xsl
index 8c662b76..cb3c3949 100644
--- a/blocks/xcos2xml/head.xsl
+++ b/blocks/xcos2xml/head.xsl
@@ -49,7 +49,7 @@
the iteration stop-condition. Returns 0 or 1
$pFun - a template reference to the function that's to be iterated
$arg1 - an initial argument to the function
-==========================================================================
+==========================================================================
-->
<xsl:template name="iterUntil">
<xsl:param name="pCond" select="/.."/>
@@ -101,6 +101,70 @@
===========================================================================
-->
<!--
+ Template: exp
+ Purpose : Return the value of e^X
+ Parameters:
+ $pX - the real value X, to be used as the "power" in e^X
+ $pEps - [optional] accuracy required
+ increase the number of decimal places for greater accuracy
+ but at the expense of performance.
+==========================================================================
+-->
+ <xsl:template name="exp">
+ <xsl:param name="pX"/>
+ <xsl:param name="pEps" select=".00000001"/>
+
+ <xsl:variable name="vResult">
+ <xsl:call-template name="expIter">
+ <xsl:with-param name="pX" select="$pX"/>
+ <xsl:with-param name="pRslt" select="1 + $pX"/>
+ <xsl:with-param name="pElem" select="$pX"/>
+ <xsl:with-param name="pN" select="1"/>
+ <xsl:with-param name="pEps" select="$pEps"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="$vResult >= 0">
+ <xsl:value-of select="$vResult"/>
+ </xsl:when>
+ <xsl:otherwise>0</xsl:otherwise>
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template name="expIter">
+ <xsl:param name="pX"/>
+ <xsl:param name="pRslt"/>
+ <xsl:param name="pElem"/>
+ <xsl:param name="pN"/>
+ <xsl:param name="pEps"/>
+
+ <xsl:variable name="vnextN" select="$pN+1"/>
+
+ <xsl:variable name="vnewElem"
+ select="$pElem*$pX div $vnextN"/>
+
+ <xsl:variable name="vnewResult" select="$pRslt + $vnewElem"/>
+
+ <xsl:variable name="vdiffResult" select="$vnewResult - $pRslt"/>
+ <xsl:choose>
+ <xsl:when test="$vdiffResult > $pEps or $vdiffResult &lt; -$pEps">
+ <xsl:call-template name="expIter">
+ <xsl:with-param name="pX" select="$pX"/>
+ <xsl:with-param name="pRslt" select="$vnewResult"/>
+ <xsl:with-param name="pElem" select="$vnewElem"/>
+ <xsl:with-param name="pN" select="$vnextN"/>
+ <xsl:with-param name="pEps" select="$pEps"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$vnewResult"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+<!--
Template: ln
Purpose : Return the value of ln(X)
Parameters:
@@ -108,7 +172,7 @@
$pEps - [optional] accuracy required
increase the number of decimal places for greater accuracy
but at the expense of performance.
-==========================================================================
+==========================================================================
-->
<xsl:template name="ln">
<xsl:param name="pX"/>
@@ -170,7 +234,7 @@
$pEps - [optional] accuracy required
increase the number of decimal places for greater accuracy
but at the expense of performance.
-==========================================================================
+==========================================================================
-->
<xsl:template name="log">
<xsl:param name="pX"/>
@@ -211,7 +275,7 @@
$pEps - [optional] accuracy required
increase the number of decimal places for greater accuracy
but at the expense of performance.
-==========================================================================
+==========================================================================
-->
<xsl:template name="log2">
<xsl:param name="pX"/>
@@ -224,6 +288,43 @@
</xsl:call-template>
</xsl:template>
+<!--
+ Template: pow
+ Purpose : Return the value of base^X (base to the power of X)
+ Parameters:
+ $pBase - the value for the base
+ $pPower - the real value X, to be used in calculating base^X
+ $pEps - [optional] accuracy required
+ increase the number of decimal places for greater accuracy
+ but at the expense of performance.
+==========================================================================
+-->
+ <xsl:template name="pow">
+ <xsl:param name="pBase"/>
+ <xsl:param name="pPower"/>
+ <xsl:param name="pEps" select=".00000001"/>
+
+ <xsl:if test="not($pBase > 0)">
+ <xsl:message terminate="yes">
+ <xsl:value-of select="concat('[Error]pow: Non-positive pow base: ',
+ $pBase
+ )"/>
+ </xsl:message>
+ </xsl:if>
+
+ <xsl:variable name="vLogBase">
+ <xsl:call-template name="ln">
+ <xsl:with-param name="pX" select="$pBase"/>
+ <xsl:with-param name="pEps" select="$pEps"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:call-template name="exp">
+ <xsl:with-param name="pX" select="$vLogBase * $pPower"/>
+ <xsl:with-param name="pEps" select="$pEps"/>
+ </xsl:call-template>
+ </xsl:template>
+
<!-- ************************************************************* -->
<!-- ********************* INTERNAL USE ONLY ********************* -->
<!-- ************************************************************* -->