示例#1
0
        /// <summary>
        /// Sets the semantich ID
        /// </summary>
        /// <param name="jObject"></param>
        public void SetSemanticIdDict(JObject jObject)
        {
            if (jObject.SelectToken("submodelElements") == null)
            {
                return;
            }
            foreach (var subEle in jObject["submodelElements"])
            {
                if (subEle["idShort"] != null)
                {
                    var idshort = subEle["idShort"].ToString();

                    if (!SemanticIdDict.ContainsKey(idshort))
                    {
                        if (subEle["semanticId"] != null)
                        {
                            AdminShellNS.AdminShell.SemanticId semantic
                                = JsonConvert.DeserializeObject <AdminShellNS.AdminShell.SemanticId>
                                      (subEle["semanticId"].ToString());
                            SemanticIdDict.Add(idshort, semantic);
                        }
                    }
                }
            }
        }
示例#2
0
 public SummingPoint(IOput output, string name, AdminShellNS.AdminShell.SemanticId semanticId)
 {
     this.output     = output;
     this.Name       = name;
     this.SemanticId = semanticId;
     inputs          = new List <IOput>();
 }
示例#3
0
 public IOput(string idShort, string owner, AdminShellNS.AdminShell.SemanticId semanticId)
 {
     this.IdShort    = idShort;
     this.Owner      = owner;
     this.SemanticId = semanticId;
     this.Unit       = "";
     this.Domain     = "";
 }
示例#4
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);
 }
示例#5
0
        /// <summary>
        /// Creates a node, represented as a Simulationmodel, for all physical ports which are connected.
        /// </summary>
        public void CreateNodesForPhysicalPorts()
        {
            int nodeCount = 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  = "www.tedz.itsowl.com/ids/cd/1132_9030_2102_4033";
            key.type   = "ConceptDescription";
            key.local  = true;
            key.index  = 0;
            key.idType = "IRI";
            semanticId.Keys.Add(key);

            List <List <IOput> > nodeLists = new List <List <IOput> >();

            foreach (var simmod in SimulationsModels.Values)
            {
                foreach (var port in simmod.PhysicalPorts)
                {
                    if (!nodeLists.Contains(port.ConnectedTo) && port.ConnectedTo.Count > 1)
                    {
                        nodeLists.Add(port.ConnectedTo);
                    }
                }
            }

            foreach (var list in nodeLists)
            {
                SimulationModel nodeModel = createNode(nodeCount, semanticId, list);

                if (nodeModel.PhysicalPorts.Count > 0)
                {
                    newSimMod.Add(nodeModel);
                    nodeCount++;
                }
            }

            foreach (var simmod in newSimMod)
            {
                SimulationsModels.Add(simmod.Name, simmod);
            }
        }
示例#6
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);
        }
示例#7
0
        /// <summary>
        /// Creates a node between the given ports
        /// </summary>
        /// <param name="nodeCount"></param>
        /// <param name="semanticId"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        private static SimulationModel createNode(int nodeCount,
                                                  AdminShellNS.AdminShell.SemanticId semanticId,
                                                  List <IOput> list)
        {
            SimulationModel nodeModel = new SimulationModel();

            nodeModel.IsNode = true;
            string name = "node_" + nodeCount;

            nodeModel.Name       = name;
            nodeModel.SemanticId = semanticId;
            int portnumber = 0;

            foreach (var port in list)
            {
                IOput newport = new IOput(port.IdShort + "_" + portnumber++, name);
                newport.IsPhysical = true;
                newport.ConnectedTo.Add(port);
                nodeModel.PhysicalPorts.Add(newport);
            }

            return(nodeModel);
        }
示例#8
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);
        }