public bool CreateSMD(string host, string machine)
        {
            if (SemanticPort.GetInstance() == null)
            {
                logs.Enqueue("Missing semantic ID csv");
                Console.WriteLine("Missing semantic ID csv");
            }
            else
            {
                if (EClass.InitEclass(logs) && SemanticPort.GetInstance() != null)
                {
                    try
                    {
                        if (exporter.CreateSMD(host, machine))
                        {
                            List <SimulationModel> noFmu = exporter.GetSimulationModelsWithoutFMU();
                            foreach (var sim in noFmu)
                            {
                                Console.WriteLine($"SimulationModel {sim.Name} has no Fmu");
                                Console.WriteLine();
                                logs.Enqueue($"SimulationModel {sim.Name} has no Fmu");
                                logs.Enqueue("");
                            }

                            foreach (var warning in SimulationModel.Warnings)
                            {
                                Console.WriteLine(warning);
                                logs.Enqueue(warning);
                            }
                        }
                        else
                        {
                            Console.WriteLine($"Could not find or read {machine}." +
                                              $" Please check the name of the AAS and structure of the aasx");
                            logs.Enqueue($"Could not find or read {machine}." +
                                         $" Please check the name of the AAS and structure of the aasx");
                            return(false);
                        }
                    }
                    catch (AggregateException e)
                    {
                        print("No Connection:" + e.Message);
                        Console.WriteLine();
                        logs.Enqueue("No Connection:" + e.Message);
                        logs.Enqueue("");
                        return(false);
                    }

                    return(true);
                }
                else
                {
                    Console.WriteLine("No mappings.csv found or does not contain all rows");
                    logs.Enqueue("No mappings.csv found or does not contain all rows");
                    return(false);
                }
            }
            return(false);
        }
Exemple #2
0
 /// <summary>
 /// Creates a new semantic id for the summing points
 /// </summary>
 /// <returns></returns>
 private AdminShellNS.AdminShell.SemanticId createSemanticIdSummingPoint()
 {
     AdminShellNS.AdminShell.SemanticId semanticId = new AdminShellNS.AdminShell.SemanticId();
     AdminShellNS.AdminShell.Key        key        = new AdminShellNS.AdminShell.Key();
     key.value  = SemanticPort.GetInstance().GetSemanticForPort("BoM_SmdComp_Sum");
     key.type   = "ConceptDescription";
     key.local  = true;
     key.index  = 0;
     key.idType = "IRI";
     semanticId.Keys.Add(key);
     return(semanticId);
 }
Exemple #3
0
        /// <summary>
        /// Sets the SemanticID of the relation depending in the semanticPort class.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="output"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public AdminShellNS.AdminShell.SemanticId SetSemanticIdRelEle(IOput input, IOput output, int type)
        {
            AdminShellNS.AdminShell.SemanticId semantic = new AdminShellNS.AdminShell.SemanticId();
            AdminShellNS.AdminShell.Key        key      = new AdminShellNS.AdminShell.Key();
            key.idType = "IRI";
            key.index  = 0;
            key.local  = true;
            key.type   = "ConceptDescription";
            switch (type)
            {
            case 0: key.value = SemanticPort.GetInstance().GetSemanticForPort("SmdComp_SignalFlow"); break;

            case 1: key.value = SemanticPort.GetInstance().GetSemanticForPort("SmdComp_PhysicalElectric"); break;

            case 2: key.value = "mechanic"; break;
            }
            semantic.JsonKeys.Add(key);
            return(semantic);
        }
Exemple #4
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);
        }