Skip to content

support variableFilter to ModelicaSystem #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions OMPython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ def sendExpression(self, command, parsed=True):


class ModelicaSystem(object):
def __init__(self, fileName=None, modelName=None, lmodel=[], useCorba=False, commandLineOptions=None): # 1
def __init__(self, fileName=None, modelName=None, lmodel=[], useCorba=False, commandLineOptions=None, variableFilter=None): # 1
"""
"constructor"
It initializes to load file and build a model, generating object, exe, xml, mat, and json files. etc. It can be called :
Expand Down Expand Up @@ -846,6 +846,8 @@ def __init__(self, fileName=None, modelName=None, lmodel=[], useCorba=False, com
self.outputFlag = False
self.csvFile = '' # for storing inputs condition
self.resultfile="" # for storing result file
self.variableFilter = variableFilter

if not os.path.exists(self.fileName): # if file does not eixt
print("File Error:" + os.path.abspath(self.fileName) + " does not exist!!!")
return
Expand Down Expand Up @@ -920,9 +922,17 @@ def __loadingModel(self):
print(loadmodelError)
self.buildModel()

def buildModel(self):
def buildModel(self, variableFilter=None):
if variableFilter is not None:
self.variableFilter = variableFilter

if self.variableFilter is not None:
varFilter = "variableFilter=" + "\"" + self.variableFilter + "\""
else:
varFilter = "variableFilter=" + "\".*""\""
# print(varFilter)
# buildModelResult=self.getconn.sendExpression("buildModel("+ mName +")")
buildModelResult = self.requestApi("buildModel", self.modelName)
buildModelResult = self.requestApi("buildModel", self.modelName, properties=varFilter)
buildModelError = self.requestApi("getErrorString")
# Issue #145. Always print the getErrorString since it might contains build warnings.
if buildModelError:
Expand Down