def getExtendsModifierValue(self, className, extendsName, modifierName): try: # FIXME: OMPython exception UnboundLocalError exception for 'Modelica.Fluid.Machines.ControlledPump' return self.ask( 'getExtendsModifierValue', '{0}, {1}, {2}'.format(className, extendsName, modifierName)) except pyparsing.ParseException as ex: result = self.ask('getExtendsModifierValue', '{0}, {1}, {2}'.format(className, extendsName, modifierName), parsed=False) try: answer = OMParser.check_for_values(result) OMParser.result = {} return answer[2:] except (TypeError, UnboundLocalError) as ex: self.logger.info( 'OMParser error: {0} when calling "OMParser.check_for_values({1})"' .format(ex.message, result)) return result except SystemExit as sys_exit: self.logger.warning( 'sys.exit() called in "getExtendsModifierValue()"') return 'sys.exit()' except SystemExit as sys_exit: self.logger.warning( 'sys.exit() called in "getExtendsModifierValue()"') return 'sys.exit()'
def getComponentModifierNames(self, className, componentName): #print 'getComponentModifierNames' + className + componentName try: return self.ask('getComponentModifierNames', '{0}, "{1}"'.format(className, componentName)) except Exception as e: #print '#####' + str(e.raw_result) #TODO: This is a little hacky return OMParser.check_for_values(e.raw_result)
def execute(self, command): if self._omc is not None: result = self._omc.sendExpression(command) if command == "quit()": self._omc = None return result else: answer = OMParser.check_for_values(result) return answer else: return "No connection with OMC. Create an instance of OMCSession."
def getExtendsModifierValue(self, className, extendsName, modifierName): try: # FIXME: OMPython exception UnboundLocalError exception for 'Modelica.Fluid.Machines.ControlledPump' return self.ask('getExtendsModifierValue', '{0}, {1}, {2}'.format(className, extendsName, modifierName)) except pyparsing.ParseException as ex: self.logger.warning('OMTypedParser error: {0}'.format(ex.message)) result = self.ask('getExtendsModifierValue', '{0}, {1}, {2}'.format(className, extendsName, modifierName), parsed=False) try: answer = OMParser.check_for_values(result) OMParser.result = {} return answer[2:] except (TypeError, UnboundLocalError) as ex: self.logger.warning('OMParser error: {0}'.format(ex.message)) return result
def getExtendsModifierValue(self, className, extendsName, modifierName): try: # FIXME: OMPython exception UnboundLocalError exception for 'Modelica.Fluid.Machines.ControlledPump' return self.ask('getExtendsModifierValue', '{0}, {1}, {2}'.format(className, extendsName, modifierName)) except pyparsing.ParseException as ex: logger.warning('OMTypedParser error: {0}'.format(ex.message)) result = self.ask('getExtendsModifierValue', '{0}, {1}, {2}'.format(className, extendsName, modifierName), parsed=False) try: answer = OMParser.check_for_values(result) OMParser.result = {} return answer[2:] except (TypeError, UnboundLocalError) as ex: logger.warning('OMParser error: {0}'.format(ex.message)) return result
def getComponentModifierValue(self, className, componentName): try: # FIXME: OMPython exception UnboundLocalError exception for 'Modelica.Fluid.Machines.ControlledPump' return self.ask('getComponentModifierValue', '{0}, {1}'.format(className, componentName)) except pyparsing.ParseException as ex: result = self.ask('getComponentModifierValue', '{0}, {1}'.format(className, componentName), parsed=False) try: answer = OMParser.check_for_values(result) OMParser.result = {} return answer[2:] except (TypeError, UnboundLocalError) as ex: self.logger.info('OMParser error: {0} when calling "OMParser.check_for_values({1})"'.format(ex.message, result)) return result except SystemExit as sys_exit: self.logger.warning('sys.exit() called in "getComponentModifierValue()"') return 'sys.exit()' except SystemExit as sys_exit: self.logger.warning('sys.exit() called in "getComponentModifierValue()"') return 'sys.exit()'