예제 #1
0
        private void AssertConnected(ISIS.GME.Dsml.CyPhyML.Interfaces.Component comp, IMgaObject obj1, IMgaObject obj2)
        {
            var conns1 = comp.Children.PortCompositionCollection.Where(pc => pc.SrcEnd.ID == obj1.ID && pc.DstEnd.ID == obj2.ID);
            var conns2 = comp.Children.PortCompositionCollection.Where(pc => pc.SrcEnd.ID == obj2.ID && pc.DstEnd.ID == obj1.ID);

            Assert.Equal(1, conns1.Count() + conns2.Count());
        }
예제 #2
0
        public void SetUnit()
        {
            File.Copy(orgXmePathInputModel, xmePathInputModel, true);

            String connString;

            MgaUtils.ImportXMEForTest(xmePathInputModel, out connString);
            var mgaPath = connString.Substring("MGA=".Length);

            Assert.True(File.Exists(mgaPath), "Input model not found; import may have failed.");

            var project = GetProject(mgaPath);

            var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();

            importer.Initialize(project);

            project.BeginTransactionInNewTerr();
            try
            {
                var fco = importer.ImportFile(project, testPath, acmPath);
                ISIS.GME.Dsml.CyPhyML.Interfaces.Component comp = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(fco);

                var millimeter = comp.Children.PropertyCollection
                                 .First(p => p.Name.Equals("mm"))
                                 .Referred.unit;
                Assert.NotNull(millimeter);
                Assert.Equal("Millimeter", millimeter.Name);

                var henry = comp.Children.PropertyCollection
                            .First(p => p.Name.Equals("Henry"))
                            .Referred.unit;
                Assert.NotNull(henry);
                Assert.Equal("Henry", henry.Name);

                var acre = comp.Children.PropertyCollection
                           .First(p => p.Name.Equals("acre"))
                           .Referred.unit;
                Assert.NotNull(acre);
                Assert.Equal("Acre", acre.Name);
            }
            finally
            {
                project.CommitTransaction();
            }

            project.Save();
            project.Close();
        }
예제 #3
0
        public static void RunFormulaEvaluator(this ISIS.GME.Dsml.CyPhyML.Interfaces.Component component)
        {
            var project    = component.Impl.Project;
            var currentobj = component.Impl as MgaFCO;

            // create formula evaluator type
            // FIXME: calling the elaborator is faster than calling the formula evaluator
            Type            typeFormulaEval = Type.GetTypeFromProgID("MGA.Interpreter.CyPhyFormulaEvaluator");
            IMgaComponentEx formulaEval     = Activator.CreateInstance(typeFormulaEval) as IMgaComponentEx;

            // empty selected object set
            Type    typeMgaFCOs  = Type.GetTypeFromProgID("Mga.MgaFCOs");
            MgaFCOs selectedObjs = Activator.CreateInstance(typeMgaFCOs) as MgaFCOs;

            // initialize formula evauator
            formulaEval.Initialize(project);

            // automation means no UI element shall be shown by the interpreter
            formulaEval.ComponentParameter["automation"] = "true";

            // do not write to the console
            formulaEval.ComponentParameter["console_messages"] = "off";

            // do not expand nor collapse the model
            formulaEval.ComponentParameter["expanded"] = "true";

            // do not generate the post processing python scripts
            // FIXME: Why should we generate them ???
            formulaEval.ComponentParameter["do_not_generate_post_processing"] = "true";

            // call the formula evaluator and update all parameters starting from the current object
            try
            {
                formulaEval.InvokeEx(project, currentobj, selectedObjs, 128);
            }
            catch (COMException)
            {
                // FIXME: handle this exception properly
                // success = false;
                // this.Logger.WriteError(exceptionMessage);
                // this.Logger.WriteError("CyPhyFormulaEvaluator 1.0 finished with errors");
            }
        }