def sendExpression(self, command, parsed=True): """ Sends an expression to the OpenModelica. The return type is parsed as if the expression was part of the typed OpenModelica API (see ModelicaBuiltin.mo). * Integer and Real are returned as Python numbers * Strings, enumerations, and typenames are returned as Python strings * Arrays, tuples, and MetaModelica lists are returned as tuples * Records are returned as dicts (the name of the record is lost) * Booleans are returned as True or False * NONE() is returned as None * SOME(value) is returned as value """ if self._omc is not None: result = self._omc.sendExpression(str(command)) if command == "quit()": self._omc = None return result else: if (parsed==True): answer = OMTypedParser.parseString(result) return answer else: return result else: return "No connection with OMC. Create an instance of OMCSession."
def execute(self, command): result = self._omc.sendExpression(command) #print result try: return OMTypedParser.parseString(result) except Exception as e: e.raw_result = result raise e
def getParameterValue(self, className, parameterName): try: raw_text = self.ask('getParameterValue', '{0}, {1}'.format(className, parameterName), parsed=False) return OMTypedParser.parseString(raw_text) except pyparsing.ParseException as ex: regex_findall = self._REGEX_checkParameterArrayValue.findall( raw_text) if regex_findall and (len(regex_findall) == 1): return regex_findall[0] else: return ""
def sendExpression(self, command): """ Sends an expression to the OpenModelica. The return type is parsed as if the expression was part of the typed OpenModelica API (see ModelicaBuiltin.mo). * Integer and Real are returned as Python numbers * Strings, enumerations, and typenames are returned as Python strings * Arrays, tuples, and MetaModelica lists are returned as tuples * Records are returned as dicts (the name of the record is lost) * Booleans are returned as True or False * NONE() is returned as None * SOME(value) is returned as value """ if self._omc is not None: result = self._omc.sendExpression(str(command)) if command == "quit()": self._omc = None return result else: answer = OMTypedParser.parseString(result) return answer else: return "No connection with OMC. Create an instance of OMCSession."
def execute(self, command): result = self.sendExpression(command) return OMTypedParser.parseString(result)
def execute(self, command): result = self._omc.sendExpression(command) answer = OMTypedParser.parseString(result) return answer