Opened 11 years ago

Closed 11 years ago

#2462 closed defect (fixed)

filterOutput isn't working

Reported by: tshort.rlists@… Owned by: somebody
Priority: normal Milestone: 1.9.1
Component: Run-time Version: trunk
Keywords: filterOutput Cc:

Description

Steps to reproduce in OMEdit:

  1. Open Modelica.Electrical.Analog.Examples.Rectifier.
  1. Ctrl-B (simulation tab).
  1. Under the Output tab, enter "iAC.*" in the Variable Filter tab.
  1. Hit simulate.

The simulation runs successfully, but all variables are returned. None are filtered.

In simulation_runtime.cpp, I got filtering to work (I think) with the following changes.

  /* new imple */
  for(long i=0; i<modelData->nVariablesReal; i++) { 
    if(!modelData->realVarsData[i].filterOutput) {
        modelData->realVarsData[i].filterOutput = regexec(&myregex, modelData->realVarsData[i].info.name, 0, NULL, 0);
      }}
  for(long i=0; i<modelData->nAliasReal; i++)
  {
    if(modelData->realAlias[i].aliasType == 0)  /* variable */
    {
        if(!modelData->realAlias[i].filterOutput // && !modelData->realVarsData[modelData->realAlias[i].nameID].filterOutput
            ) {
        modelData->realAlias[i].filterOutput = regexec(&myregex, modelData->realAlias[i].info.name, 0, NULL, 0);
      }
      // else
      // {
      //   modelData->realAlias[i].filterOutput = 1;
      //   modelData->realVarsData[modelData->realAlias[i].nameID].filterOutput = 1;
      // }
    }
    else if(modelData->realAlias[i].aliasType == 1)  /* parameter */
    {
      if(!modelData->realAlias[i].filterOutput // && !modelData->realParameterData[modelData->realAlias[i].nameID].filterOutput
          ){
        modelData->realAlias[i].filterOutput = regexec(&myregex, modelData->realAlias[i].info.name, 0, NULL, 0);
      }
      // else
      // {
      //   modelData->realAlias[i].filterOutput = 1;
      //   modelData->realParameterData[modelData->realAlias[i].nameID].filterOutput = 1;
      // }
    }
  }

Change History (4)

comment:1 by Martin Sjölund, 11 years ago

What are the changes? Post any changes in diff format

comment:2 by tshort.rlists@…, 11 years ago

Here are changes in svn diff format. I tried cleaning it up a bit because I had some debugging stuff in there. As you're looking at this, note that I'm bad at C/C++. I only changed the Real variables part.

===================================================================
--- SimulationRuntime/c/simulation/simulation_runtime.cpp	(revision 17647)
+++ SimulationRuntime/c/simulation/simulation_runtime.cpp	(working copy)
@@ -363,38 +363,29 @@
 
   /* new imple */
   for(long i=0; i<modelData->nVariablesReal; i++) if(!modelData->realVarsData[i].filterOutput)
-    modelData->realVarsData[i].filterOutput = regexec(&myregex, modelData->realVarsData[i].info.name, 0, NULL, 0) != 0;
+    modelData->realVarsData[i].filterOutput = regexec(&myregex, modelData->realVarsData[i].info.name, 0, NULL, 0);
   for(long i=0; i<modelData->nAliasReal; i++)
   {
+    // The following two cases look like they can be collapsed.
     if(modelData->realAlias[i].aliasType == 0)  /* variable */
     {
-      if(!modelData->realAlias[i].filterOutput && !modelData->realVarsData[modelData->realAlias[i].nameID].filterOutput)
-        modelData->realAlias[i].filterOutput = regexec(&myregex, modelData->realAlias[i].info.name, 0, NULL, 0) != 0;
-      else
-      {
-        modelData->realAlias[i].filterOutput = 0;
-        modelData->realVarsData[modelData->realAlias[i].nameID].filterOutput = 0;
-      }
+      if(!modelData->realAlias[i].filterOutput)
+        modelData->realAlias[i].filterOutput = regexec(&myregex, modelData->realAlias[i].info.name, 0, NULL, 0);
     }
     else if(modelData->realAlias[i].aliasType == 1)  /* parameter */
     {
-      if(!modelData->realAlias[i].filterOutput && !modelData->realParameterData[modelData->realAlias[i].nameID].filterOutput)
-        modelData->realAlias[i].filterOutput = regexec(&myregex, modelData->realAlias[i].info.name, 0, NULL, 0) != 0;
-      else
-      {
-        modelData->realAlias[i].filterOutput = 0;
-        modelData->realParameterData[modelData->realAlias[i].nameID].filterOutput = 0;
-      }
+      if(!modelData->realAlias[i].filterOutput)
+        modelData->realAlias[i].filterOutput = regexec(&myregex, modelData->realAlias[i].info.name, 0, NULL, 0);
     }
   }
Version 0, edited 11 years ago by tshort.rlists@… (next)

comment:3 by Martin Sjölund, 11 years ago

Did r18466 fix the problem? I think it does, and #2508 is the same issue.

comment:4 by Martin Sjölund, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.