Exemple #1
0
        /// <summary>
        /// Creates a new SummingPoint between the given input and the outputs connected to it.
        /// </summary>
        /// <param name="spName"></param>
        /// <param name="summingPointsAsSim"></param>
        /// <param name="input"></param>
        private SummingPoint createNewSummingPoint(string spName,
                                                   Dictionary <string, SimulationModel> summingPointsAsSim,
                                                   IOput input)
        {
            IOput newOutput = new IOput("out", spName, input.SemanticId);

            SummingPoint summingPoint = new SummingPoint(newOutput, spName, createSemanticIdSummingPoint());

            createConnectionBetweenOutputsConnectedToInputAndSummingPoint(summingPoint, input, spName);

            input.AddConnection(summingPoint.output);
            summingPoint.output.Domain = "SimToolSubset";


            return(summingPoint);
        }
Exemple #2
0
        /// <summary>
        /// Creates the connection between the output ports which are connected to input and the summingpoint.
        /// And removes the existing connections.
        /// </summary>
        /// <param name="summingPoint"></param>
        /// <param name="input"></param>
        /// <param name="name"></param>
        private void createConnectionBetweenOutputsConnectedToInputAndSummingPoint(SummingPoint summingPoint,
                                                                                   IOput input,
                                                                                   string name)
        {
            for (int i = input.ConnectedTo.Count - 1; i >= 0; i--)
            {
                var output = input.ConnectedTo[i];
                output.Domain = "SimToolSubset";
                IOput newSPPort = new IOput("in_" + (i + 1), name);
                newSPPort.SemanticId = output.SemanticId;
                newSPPort.Domain     = "SimToolSubset";
                //Einfügen eines neuen input in den summingpoint
                summingPoint.inputs.Add(newSPPort);

                // An stelle dessen einfügen einer Verbindung zwischen dem neuen input und dem output
                newSPPort.AddConnection(output);
                // Finden der alten Verbindung und entfernen dieser
                output.RemoveConnection(input);
            }
        }
Exemple #3
0
        /// <summary>
        /// Creates multiplication points in case there is a connection where the ports to not share the same unit
        /// but were connected because of a mapping. The mapping conatains a value which is used here as the factor
        /// for the multiplication. The existing output port of the existing connection gets connected to the multports
        /// input port and the input port of the connection gets connected to the multports output port.
        /// The old connection is removed.
        /// </summary>
        /// <returns></returns>
        public bool CreateMultPoints()
        {
            int multCount = 0;
            List <SimulationModel> newSimMod = new List <SimulationModel>();


            AdminShellNS.AdminShell.SemanticId semanticId = new AdminShellNS.AdminShell.SemanticId();
            AdminShellNS.AdminShell.Key        key        = new AdminShellNS.AdminShell.Key();
            key.value  = SemanticPort.GetInstance().GetSemanticForPort("BoM_SmdComp_Mult");
            key.type   = "ConceptDescription";
            key.local  = true;
            key.index  = 0;
            key.idType = "IRI";
            semanticId.Keys.Add(key);

            foreach (var simmod in SimulationsModels.Values)
            {
                foreach (var input in simmod.Inputs)
                {
                    if (input.EclassID != null && simmod.Mappings.ContainsKey(input.EclassID))
                    {
                        foreach (var connected in input.ConnectedTo.ToList())
                        {
                            string          name     = "mult_" + multCount++;
                            SimulationModel multPort = new SimulationModel();
                            multPort.SemanticId = semanticId;
                            multPort.Multfactor = simmod.Mappings[input.EclassID].Value;

                            IOput iput = new IOput("in", name);
                            iput.SemanticId = input.SemanticId;

                            IOput oput = new IOput("out", name);
                            oput.SemanticId = input.SemanticId;

                            input.RemoveConnection(connected);

                            oput.AddConnection(input);
                            iput.AddConnection(connected);

                            multPort.Outputs.Add(oput);
                            multPort.Inputs.Add(iput);
                            multPort.Name = name;
                            newSimMod.Add(multPort);
                        }
                    }
                }


                foreach (var output in simmod.Outputs)
                {
                    if (output.EclassID != null && simmod.Mappings.ContainsKey(output.EclassID))
                    {
                        foreach (var connected in output.ConnectedTo.ToList())
                        {
                            string          name     = "mult_" + multCount++;
                            SimulationModel multPort = new SimulationModel();
                            multPort.SemanticId = semanticId;
                            multPort.Multfactor = simmod.Mappings[output.EclassID].Value;

                            IOput iput = new IOput("in", name);
                            iput.SemanticId = output.SemanticId;

                            IOput oput = new IOput("out", name);
                            oput.SemanticId = output.SemanticId;

                            output.RemoveConnection(connected);

                            iput.AddConnection(output);
                            oput.AddConnection(connected);

                            multPort.Outputs.Add(oput);
                            multPort.Inputs.Add(iput);
                            multPort.Name = name;
                            newSimMod.Add(multPort);
                        }
                    }
                }
            }
            foreach (var simMod in newSimMod)
            {
                SimulationsModels.Add(simMod.Name, simMod);
            }

            return(true);
        }