예제 #1
0
 public void TestVariableNameParser()
 {
     VariableNameParser p = new VariableNameParser();
     //p.Parse("am2");
     //p.Parse("am2.Ta");
     string name;
     int[] dim = p.Parse("am2.Ta[2][0]", out name);
 }
예제 #2
0
        // map block variables to output tags
        private void MapOutBlockVariables()
        {
            VariableNameParser vnp = new VariableNameParser();
            foreach (OutputBlockMap map in outputBlockMaps)
            {
                // parse block variable name
                string parsedName;
                int[] dim = vnp.Parse(map.BlockVariableName, out parsedName);

                // get value from block variable name
                object v;
                this.flowsheet.GetBlockVariable(parsedName, out v);

                // map block variable value to plant tag
                // array variable: am2.Ta[1] <-> FIX.TA1.F_CV
                if (dim != null)
                {
                    this.outputValues[map.TagName] = (v != null) ? ((double[])v)[dim[0]] : 0.0;
                }
                // no dimension
                else
                {
                    this.outputValues[map.TagName] =  (v != null) ? (double)v : 0.0;
                }
            }
        }