Example #1
0
 public Checker(CyPhyGUIs.IInterpreterMainParameters parameters, CyPhyGUIs.GMELogger logger, IMgaTraceability traceability, CyPhyTypeFactory factory)
 {
     this.mainParameters = parameters;
     this.Logger = logger;
     this.Traceability = traceability;
     this.Factory = factory;
 }
 public CodeGenerator(CyPhyGUIs.IInterpreterMainParameters parameters, Mode mode, GMELogger Logger)
 {
     this.Logger = Logger;
     this.mainParameters = parameters;
     CodeGenerator.verbose = ((CyPhy2RF.CyPhy2RF_Settings)parameters.config).Verbose;
     this.mode = mode;
 }
        public PCCPropertyInputDistributionEditor(CyPhyGUIs.IInterpreterMainParameters mainParameters, CyPhyGUIs.GMELogger logger)
        {
            this.Logger = logger;
            this.MainParameters = mainParameters;
            InitializeComponent();
            this.cbDist.SelectedIndex = 0;
            this.DirtyProperties = new List<PCC.PCCProperty>();
            this.PropertyData = ((System.Windows.Forms.BindingSource)dataGridView1.DataSource).List;
            bool hadProperty = false;
            foreach (var property in this.GetPCCPropertiesFromComponent(true).OrderBy(p => p.Name))
            {
                this.PropertyData.Add(property);
                hadProperty = true;
            }

            if (hadProperty == false)
            {
                this.Logger.WriteWarning("No properties can be used as PCC Property Input distributions!");
                this.Logger.WriteWarning("A property can only be used if:");
                this.Logger.WriteWarning(" [1] It maps to a Modelica Parameter of a Modelica Model.");
                this.Logger.WriteWarning(" [2] It does NOT have any incoming value flows.");
                this.Logger.WriteWarning(" [3] It has a real value.");
                this.Close();
            }
        }
        public CodeGenerator(CyPhyGUIs.IInterpreterMainParameters parameters, Mode mode)
        {
            this.mainParameters = parameters;
            CodeGenerator.verbose = ((CyPhy2Schematic.CyPhy2Schematic_Settings)parameters.config).Verbose;
            partNames = new Dictionary<string, int>();
            partComponentMap = new Dictionary<Eagle.part, Component>();
            componentPartMap = new Dictionary<Component, Eagle.part>();
            preRouted = new Dictionary<ComponentAssembly, Layout.LayoutParser>();

            this.mode = mode;
        }
        public void Initialize(MgaProject project, CyPhyGUIs.GMELogger logger = null)
        {
            this.IsCancelled = false;

            if (logger == null)
            {
                // dispose our responsibliity
                this.LoggerDisposeRequired = true;
                this.Logger = new CyPhyGUIs.GMELogger(project, this.GetType().Assembly.GetName().Name);
            }
            else
            {
                // dispose caller's responsibility
                this.LoggerDisposeRequired = false;
                this.Logger = logger;
            }

            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            this.Project = project;
        }
Example #6
0
 public PET(CyPhyGUIs.IInterpreterMainParameters parameters, CyPhyGUIs.GMELogger logger)
 {
     this.Logger = logger;
     this.pet = CyPhyClasses.ParametricExploration.Cast(parameters.CurrentFCO);
     this.outputDirectory = parameters.OutputDirectory;
     this.testBench = pet.Children.TestBenchRefCollection.FirstOrDefault().Referred.TestBenchType;
     this.PCCPropertyInputDistributions = new Dictionary<string, string>();
     // Determine type of driver of the Parametric Exploration
     if (this.pet.Children.PCCDriverCollection.Count() == 1)
     {
         this.theDriver = DriverType.PCC;
         this.driverName = "PCCDriver";
     }
     else if (this.pet.Children.OptimizerCollection.Count() == 1)
     {
         this.theDriver = DriverType.Optimizer;
         this.driverName = "Optimizer";
     }
     else if (this.pet.Children.ParameterStudyCollection.Count() == 1)
     {
         this.theDriver = DriverType.ParameterStudy;
         this.driverName = "ParameterStudy";
     }
 }
        public Checker(MgaFCO model, MgaProject project, IMgaTraceability traceability = null, CyPhyGUIs.GMELogger logger = null)
        {
            Model = model;
            Project = project;
            if (logger != null)
            {
                this.Logger = logger;
            }
            else
            {
                GMEConsole = GMEConsole.CreateFromProject(project);
            }

            registeredRules = new ConcurrentDictionary<string, List<RuleDescriptor>>();

            if (traceability == null)
            {
                this.Traceability = new META.MgaTraceability();
            }
            else
            {
                this.Traceability = traceability;
            }
        }
 /// <summary>
 /// Initializes a new instance of <see cref="CyPhyMasterInterpreterAPI"/>.
 /// </summary>
 /// <param name="project">Master interpreter runs on part of this project.</param>
 /// <param name="logger">If logger is give it will be used.</param>
 public CyPhyMasterInterpreterAPI(MgaProject project, CyPhyGUIs.GMELogger logger)
 {
     this.Initialize(project, logger);
 }
        public ModelicaModelPicker(
            bool createMultipleComponents, 
            MgaProject thisProject, 
            CyPhyGUIs.GMELogger logger, 
            CyPhy.ComponentType cyphyComponent=null)
        {
            this.InitializeComponent();

            this.componentDetails = new List<ComponentDetail>();
            this.externalPackagePaths = new List<string>();
            this.externalPackageNames = new List<string>();
            this.UpdateModelPickerDataSource_detailed();

            this.m_Logger = logger;
            this.m_Project = thisProject;
            this.m_createMultipleComponents = createMultipleComponents;
            this.dgvModelPicker.MultiSelect = true;

            //string testFilePath = "";

            //if (File.Exists(testFilePath))
            //{
            //    this.ReadFileAndImportComponents_Flat(testFilePath);
            //    return;
            //}
            
            if (this.m_createMultipleComponents)
            {
                this.gbComponentType.Visible = true;
                this.btnImportSelected.Text = "Import Selected Component(s)";
            }

            if (!this.m_createMultipleComponents && 
                cyphyComponent != null)
            {
                this.m_CyPhyComponent = cyphyComponent;
            }

            this.pictureBoxLoader.Visible = false;
            this.btnImportSelected.Enabled = false;
            this.btnViewWebDoc.Enabled = false;
            this.cbIncludeMSL.Checked = true;
            this.cbIncludeMSL.Enabled = false;

            lbExternalLibList.Items.Add("ModelicaStandardLibrary");

            this.rootFolder = CyPhyClasses.RootFolder.GetRootFolder(this.m_Project);

            if (this.rootFolder != null)
            {
                this.localConnectorLibrary =
                    this.rootFolder.Children.ConnectorsCollection.FirstOrDefault(x => x.Name == "ImportedConnectors");

                if (this.localConnectorLibrary != null)
                {
                    this.localPortLibrary =
                        this.localConnectorLibrary.Children.PortsCollection.FirstOrDefault(x =>
                        x.Name == "ImportedPortTypes");

                    if (this.localPortLibrary != null)
                    {
                        this.localPortMap =
                            this.localPortLibrary.Children.ModelicaConnectorCollection.ToDictionary(mc => mc.Attributes.Class);
                    }
                    else
                    {
                        this.localPortLibrary = CyPhyClasses.Ports.Create(this.localConnectorLibrary);
                        this.localPortLibrary.Name = "ImportedPortTypes";
                        this.localPortMap = new Dictionary<string, CyPhy.ModelicaConnector>();
                    }
                }
                else
                {
                    this.localConnectorLibrary = CyPhyClasses.Connectors.Create(this.rootFolder);
                    this.localConnectorLibrary.Name = "ImportedConnectors";
                    this.localPortLibrary = CyPhyClasses.Ports.Create(this.localConnectorLibrary);
                    this.localPortLibrary.Name = "ImportedPortTypes";
                    this.localPortMap = new Dictionary<string, CyPhy.ModelicaConnector>();
                }
            }
            else
            {
                this.m_Logger.WriteError("Could not get the root folder!");
                return;
            }

            this.backgroundWorkerTreeImport.DoWork += backgroundWorkerTreeImport_DoWork;
            this.backgroundWorkerTreeImport.RunWorkerCompleted += backgroundWorkerTreeImport_RunWorkerCompleted;

            this.backgroundWorkerComponentImport.DoWork += backgroundWorkerComponentImport_DoWork;
            this.backgroundWorkerComponentImport.RunWorkerCompleted += backgroundWorkerComponentImport_RunWorkerCompleted;

            this.numModelicaModels = 0;

            this.numComponentParams = 0;
            this.numModelicaParams = 0;

            this.numComponentPorts = 0;
            this.numModelicaPorts = 0;
        }
Example #10
0
 public Checker(CyPhyGUIs.IInterpreterMainParameters parameters, CyPhyGUIs.GMELogger logger)
 {
     this.Logger = logger;
     this.mainParameters = parameters;
     this.Results = new Dictionary<RuleDescriptor, List<RuleFeedbackBase>>();
 }
Example #11
0
        /// <summary>
        /// Intializes a new instance of the <see cref="CodeGenerator"/> class.
        /// </summary>
        /// <param name="parameters">Passed through the Main function in CyPhyGUIs API.</param>
        /// <param name="logger">Instance of logger to log to.</param>
        /// <param name="traceability">Traceability map from CyPhyElborate (and if called by it, the MasterInterpreter too).</param>
        public CodeGenerator(CyPhyGUIs.IInterpreterMainParameters parameters, CyPhyGUIs.GMELogger logger, CyPhyCOMInterfaces.IMgaTraceability traceability)
        {
            this.Logger = logger;
            this.MainParameters = parameters;
            this.modelicaSettings = this.MainParameters.config as CyPhy2Modelica_v2Settings;
            this.traceability = traceability;
            this.LimitDefintion = new LimitDefinition();
            this.reservedPackageNames = new List<string>() { "Modelica", MainPackage };
            this.instanceURIMap = new Dictionary<string, ComponentInfo>();
            this.modelURIMap = new Dictionary<string, ComponentInfo>();
            this.extendsURIMap = new Dictionary<string, ComponentInfo>();
            this.pccInputs = new List<PCCInputDistribution>();
            this.ModelicaURIMap = new ComponentMap()
            {
                InstanceMapping = this.instanceURIMap,
                ModelMapping = this.modelURIMap,
                ExtendsMapping = this.extendsURIMap
            };
            var externalPackages = (this.MainParameters.config as CyPhy2Modelica_v2Settings).IncludeDirectoryPath;
            foreach (var packagePath in externalPackages)
            {
                this.reservedPackageNames.Add(ModelicaLibrary.GetLibraryFromPath(packagePath).Name);
            }

            this.requirementMetrics = new List<RequirementMetric>();
        }
 public Generator(CyPhyGUIs.IInterpreterMainParameters parameters, CyPhyGUIs.GMELogger logger)
 {
     this.Logger = logger;
     this.mainParameters = parameters;
     this.RunCommand = "";
 }
 public CodeGenerator(CyPhyGUIs.IInterpreterMainParameters parameters)
 {
     this.mainParameters = parameters;
     CodeGenerator.verbose = ((CyPhy2SystemC.CyPhy2SystemC_Settings)parameters.config).Verbose;
 }
Example #14
0
        public PET(CyPhyGUIs.IInterpreterMainParameters parameters, CyPhyGUIs.GMELogger logger)
        {
            this.Logger = logger;
            this.pet = CyPhyClasses.ParametricExploration.Cast(parameters.CurrentFCO);
            this.outputDirectory = parameters.OutputDirectory;
            config.MgaFilename = parameters.CurrentFCO.Project.ProjectConnStr.Substring("MGA=".Length);
            if (parameters.SelectedConfig != null)
            {
                config.SelectedConfigurations = new string[] { parameters.SelectedConfig }.ToList();
            }
            else
            {
                config.SelectedConfigurations = new string[] { parameters.OriginalCurrentFCOName }.ToList();
            }
            config.GeneratedConfigurationModel = parameters.GeneratedConfigurationModel;
            config.PETName = "/" + string.Join("/", getAncestors(parameters.CurrentFCO, stopAt: parameters.CurrentFCO.Project.RootFolder).Skip(1) // HACK: MI inserts a "Temporary" folder
                .getTracedObjectOrSelf(parameters.GetTraceability()).Select(obj => obj.Name).Reverse()) + "/" + parameters.OriginalCurrentFCOName;
            this.PCCPropertyInputDistributions = new Dictionary<string, string>();
            // Determine type of driver of the Parametric Exploration
            if (this.pet.Children.PCCDriverCollection.Count() == 1)
            {
                this.theDriver = DriverType.PCC;
                this.driverName = "PCCDriver";
            }
            else if (this.pet.Children.OptimizerCollection.Count() == 1)
            {
                this.theDriver = DriverType.Optimizer;
                this.driverName = "Optimizer";

                var optimizer = this.pet.Children.OptimizerCollection.FirstOrDefault();
                var config = AddConfigurationForMDAODriver(optimizer);
                config.type = "optimizer";

                foreach (var intermediateVar in optimizer.Children.IntermediateVariableCollection)
                {
                    var sourcePath = GetSourcePath(null, (MgaFCO)intermediateVar.Impl);
                    if (sourcePath != null)
                    {
                        var intermVar = new PETConfig.Parameter();
                        intermVar.source = sourcePath;

                        config.intermediateVariables.Add(intermediateVar.Name, intermVar);
                    }
                }

                foreach (var constraint in optimizer.Children.OptimizerConstraintCollection)
                {
                    var sourcePath = GetSourcePath(null, (MgaFCO)constraint.Impl);
                    if (sourcePath != null)
                    {
                        var cons = new PETConfig.Constraint();
                        cons.source = sourcePath;

                        if (!string.IsNullOrWhiteSpace(constraint.Attributes.MinValue))
                        {
                            double minValue;
                            if (double.TryParse(constraint.Attributes.MinValue,
                                NumberStyles.Float | NumberStyles.AllowThousands,
                                CultureInfo.InvariantCulture, out minValue))
                            {
                                cons.RangeMin = minValue;
                            }
                            else
                            {
                                throw new ApplicationException(String.Format("Cannot parse Constraint MinValue '{0}'",
                                    constraint.Attributes.MinValue));
                            }
                        }
                        else
                        {
                            cons.RangeMin = null;
                        }

                        if (!string.IsNullOrWhiteSpace(constraint.Attributes.MaxValue))
                        {
                            double maxValue;
                            if (double.TryParse(constraint.Attributes.MaxValue,
                                NumberStyles.Float | NumberStyles.AllowThousands,
                                CultureInfo.InvariantCulture, out maxValue))
                            {
                                cons.RangeMax = maxValue;
                            }
                            else
                            {
                                throw new ApplicationException(String.Format("Cannot parse Constraint MaxValue '{0}'",
                                    constraint.Attributes.MaxValue));
                            }
                        }
                        else
                        {
                            cons.RangeMax = null;
                        }
                        config.constraints.Add(constraint.Name, cons);
                    }
                }

            }
            else if (this.pet.Children.ParameterStudyCollection.Count() == 1)
            {
                this.theDriver = DriverType.ParameterStudy;
                this.driverName = "ParameterStudy";

                var parameterStudy = this.pet.Children.ParameterStudyCollection.FirstOrDefault();

                var config = AddConfigurationForMDAODriver(parameterStudy);
                config.type = "parameterStudy";
            }
        }
        public static void ApplyToolSelection(
            string progid,
            Dictionary<string, string> workflowParameters,
            CyPhyGUIs.InterpreterResult interpreterResult,
            CyPhyGUIs.IInterpreterMainParameters interpreterMainParameters,
            bool modifyLabels=true)
        {
            string toolName;
            workflowParameters.TryGetValue(AnalysisTool.ParameterNameInWorkflow, out toolName);
            if (string.IsNullOrEmpty(toolName) ||
                toolName == "Default")
            {
                return;
            }

            var tool = GetByName(toolName);

            if (tool == null)
            {
                return;
            }

            // copy tool.OutputDirectory to generated directory
            MethodDelegateCopy toolOutputDirCopy = new MethodDelegateCopy(DirectoryCopy);
            IAsyncResult ar = toolOutputDirCopy.BeginInvoke(Path.Combine(tool.InstallLocation, tool.OutputDirectory), interpreterMainParameters.OutputDirectory, true, null, null);
            toolOutputDirCopy.EndInvoke(ar);

            interpreterResult.RunCommand = tool.RunCommand;
            if (modifyLabels)
            {
                interpreterResult.Labels += " && " + tool.Name;
            }
        }