Parsing of an element line to the active circuit object. The name of the active circuit object is the last name in the global CIRCUITNAMES: CIRCUITNAMES[-1]. The circuit object itself is stored in the dictionary CIRCUITS under this name: circuitDict[CIRCUITNAMES[-1]]. :param li
(line, name, cirType)
| 393 | |
| 394 | |
| 395 | def _parseElement(line, name, cirType): |
| 396 | """ |
| 397 | Parsing of an element line to the active circuit object. |
| 398 | The name of the active circuit object is the last name in the global |
| 399 | CIRCUITNAMES: CIRCUITNAMES[-1]. The circuit object itself is stored in the |
| 400 | dictionary CIRCUITS under this name: circuitDict[CIRCUITNAMES[-1]]. |
| 401 | |
| 402 | :param line: list with tokens from a netlist line |
| 403 | :type line: list with tokens |
| 404 | |
| 405 | :param circuitDict: Dictionary to which the definition will be written |
| 406 | :type circuitDict: dictionary |
| 407 | |
| 408 | :return: Errors: number of errors found in this line. |
| 409 | |
| 410 | :rtype: Integer |
| 411 | """ |
| 412 | global _CIRCUITNAMES |
| 413 | newElement = element() |
| 414 | deviceType = line[0].value[0].upper() |
| 415 | errors = 0 |
| 416 | if deviceType in _DEVICETYPES: |
| 417 | newElement.type = deviceType |
| 418 | newElement.refDes = line[0].value |
| 419 | nNodes = _DEVICES[deviceType].nNodes |
| 420 | nRefs = _DEVICES[deviceType].nRefs |
| 421 | nFields = 1 + nNodes + nRefs |
| 422 | if _DEVICES[deviceType].value == True: |
| 423 | nFields += 1 |
| 424 | if len(line) < nFields: |
| 425 | _printError("Error: incomplete element specification.", line[-1]) |
| 426 | errors += 1 |
| 427 | else: |
| 428 | for i in range(nNodes): |
| 429 | pos = 1 + i |
| 430 | if line[pos].type in _NODES: |
| 431 | newElement.nodes.append(line[pos].value) |
| 432 | else: |
| 433 | _printError("Error: syntax error in node ID", line[pos]) |
| 434 | errors += 1 |
| 435 | for i in range(_DEVICES[deviceType].nRefs): |
| 436 | pos = 1 + nNodes + i |
| 437 | if line[pos].type == "ID": |
| 438 | newElement.refs.append(line[pos].value) |
| 439 | else: |
| 440 | _printError("Error: syntax error in device ID", line[pos]) |
| 441 | errors += 1 |
| 442 | pos = 1 + nNodes + nRefs |
| 443 | if _DEVICES[deviceType].value: |
| 444 | if line[pos].type == "ID": |
| 445 | newElement.model = line[pos].value |
| 446 | elif line[pos].type in _VALEXPR: |
| 447 | newElement.model = _DEVICES[deviceType].models[0] |
| 448 | if line[pos].type == 'EXPR': |
| 449 | newElement.params['value'] = line[pos].value |
| 450 | if newElement.model in _MODELS.keys(): |
| 451 | if not _MODELS[newElement.model].params['value'] and ini.laplace in newElement.params['value'].atoms(sp.Symbol): |
| 452 | _printError("Error: Laplace variable not allowed in this expression.", line[pos]) |
no test coverage detected