Esempio n. 1
0
        public void GetBaseControlConnectedToInputPort(ArrayList alControls, ArrayList alWeights, int iPortNumber)
        {
            // Finds next base control in subsystem hierarchy (Place or Transition)

            foreach (object o in this.Objects)
            {
                if (o is Input)
                {
                    Input i = (Input)o;
                    if (i.Index == iPortNumber)
                    {
                        foreach (ConnectableControl cc in i.Childs)
                        {
                            if (cc is Place)
                            {
                                alControls.Add(cc);
                                alWeights.Add(Connection.GetConnectionBetweenControls(i, cc).Weight);
                            }
                            else if (cc is Subsystem)
                            {
                                Subsystem s = (Subsystem)cc;
                                s.GetBaseControlConnectedToInputPort(alControls, alWeights, Connection.GetConnectionBetweenControls(i, cc).ToPort);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void FillInConnectionMatrices(object[,] oa, ArrayList alObjects, ArrayList alChilds)
        {
            foreach (Connection cn in this.Connections)
            {
                if (cn.From is Place && alObjects.Contains(cn.From))
                {
                    if (cn.To is Transition && alChilds.Contains(cn.To))
                    {
                        oa[alChilds.IndexOf(cn.To), alObjects.IndexOf(cn.From)] = cn.Weight;
                    }
                }
                else if (cn.From is Transition && alObjects.Contains(cn.From))
                {
                    if (cn.To is Place && alChilds.Contains(cn.To))
                    {
                        oa[alChilds.IndexOf(cn.To), alObjects.IndexOf(cn.From)] = cn.Weight;
                    }
                    if (cn.To is Subsystem)
                    {
                        // Find next connectable control
                        Subsystem s = (Subsystem)cn.To;

                        ArrayList alToControls = new ArrayList();
                        ArrayList alWeights    = new ArrayList();
                        s.GetBaseControlConnectedToInputPort(alToControls, alWeights, cn.ToPort);

                        foreach (ConnectableControl cc in alToControls)
                        {
                            if (alChilds.Contains(cc))
                            {
                                oa[alChilds.IndexOf(cc), alObjects.IndexOf(cn.From)] = alWeights[alToControls.IndexOf(cc)];
                            }
                        }
                    }
                }
                else if (cn.From is Subsystem)
                {
                    if (cn.To is Transition)
                    {
                        // Find next connectable control
                        Subsystem s = (Subsystem)cn.From;

                        ArrayList alFromControls = new ArrayList();
                        ArrayList alWeights      = new ArrayList();
                        s.GetBaseControlConnectedToOutputPort(alFromControls, alWeights, cn.FromPort);

                        foreach (ConnectableControl cc in alFromControls)
                        {
                            if (alObjects.Contains(cc))
                            {
                                oa[alChilds.IndexOf(cn.To), alObjects.IndexOf(cc)] = cn.Weight;
                            }
                        }
                    }
                }

                //Walk through all subsystems and add connections weights to matrix
                foreach (object o in this.Objects)
                {
                    if (o is Subsystem)
                    {
                        Subsystem s = (Subsystem)o;
                        s.FillInConnectionMatrices(oa, alObjects, alChilds);
                    }
                }
            }
        }