Beispiel #1
0
    /// <summary>
    /// 构建电路
    /// </summary>
    public void JionCircuit(ref Circuit sim)
    {
        if (sim == null)
        {
            return;
        }
        foreach (EleLine line in m_linkEleLine)
        {
            if (line == null || line.ConnectLink != true)
            {
                continue;
            }
            NDCircuitLeap other = line.GetOtherElementLeap(this);
            if (other == null || other.m_Parent == null)
            {
                continue;
            }

            CircuitElement myCircuit    = LabObjectDataFactory.GetCircuit(m_Parent.LabObjID);
            CircuitElement OtherCircuit = LabObjectDataFactory.GetCircuit(other.m_Parent.LabObjID);


            if (myCircuit == null || OtherCircuit == null)
            {
                return;
            }

            if (m_Type == ElementLeapType.leadOut)
            {
                if (other.m_Type == ElementLeapType.leadIn)
                {
                    sim.Connect(myCircuit.leadOut, OtherCircuit.leadIn);
                    Debug.Log("[" + m_Parent.LabObjID + "]" + "[leadOut]" + "------->" + "[" + other.m_Parent.LabObjID + "]" + "[leadIn]");
                }
                else
                {
                    sim.Connect(myCircuit.leadOut, OtherCircuit.leadOut);
                    Debug.Log("[" + m_Parent.LabObjID + "]" + "[leadOut]" + "------->" + "[" + other.m_Parent.LabObjID + "]" + "[leadOut]");
                }
            }
            else
            {
                if (other.m_Type == ElementLeapType.leadIn)
                {
                    sim.Connect(myCircuit.leadIn, OtherCircuit.leadIn);
                    Debug.Log("[" + m_Parent.LabObjID + "]" + "[leadIn]" + "------->" + "[" + other.m_Parent.LabObjID + "]" + "[leadIn]");
                }
                else
                {
                    sim.Connect(myCircuit.leadIn, OtherCircuit.leadOut);
                    Debug.Log("[" + m_Parent.LabObjID + "]" + "[leadIn]" + "------->" + "[" + other.m_Parent.LabObjID + "]" + "[leadOut]");
                }
            }
        }
    }
Beispiel #2
0
    public static void JionCircuit()
    {
        List <NDlabObject> lineList = NDlabObject.SearchLabObject(SearchCicuitType.ELELINE, false);

        foreach (NDlabObject obj in lineList)
        {
            if (obj != null && obj is EleLine)
            {
                EleLine eleLine = obj as EleLine;
                if (eleLine.ConnectLink == true)
                {
                    NDlabObject    start        = eleLine.StartLineLeap.Link.m_Parent;
                    NDlabObject    end          = eleLine.EndLineLeap.Link.m_Parent;
                    CircuitElement myCircuit    = LabObjectDataFactory.GetCircuit(start.LabObjID);
                    CircuitElement OtherCircuit = LabObjectDataFactory.GetCircuit(end.LabObjID);

                    Circuit.Lead startLead = eleLine.StartLineLeap.Link.m_Type == ElementLeapType.leadIn?myCircuit.leadIn:myCircuit.leadOut;
                    Circuit.Lead endLead   = eleLine.EndLineLeap.Link.m_Type == ElementLeapType.leadIn ? OtherCircuit.leadIn : OtherCircuit.leadOut;
                    g_sim.Connect(startLead, endLead);
                }
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// 构建电路
    /// </summary>
    public static bool CreateCircuit()
    {
        ClearCircuit();
        //
        if (CheckCircuitLoop() == false)
        {
            Debug.Log("电路不连通");
            g_IsCreateCircuit = false;
            return(false);
        }
        else
        {
            Debug.Log("电路连通");
        }
        //
        List <NDlabObject> l = NDlabObject.SearchLabObject(SearchCicuitType.NormalCircuit, false);

        //先加入元气件
        foreach (NDlabObject Lab in l)
        {
            if (Lab == null)
            {
                continue;
            }
            else
            {
                CircuitElement e = LabObjectDataFactory.GetCircuit(Lab.LabObjID);
                if (e != null)
                {
                    g_sim.AddElement(e);
                }
            }
        }
        //元气件进行连接
        foreach (NDlabObject Lab in l)
        {
            if (Lab == null)
            {
                continue;
            }
            else
            {
                (Lab as NDCircuitObject).JionCircuit(ref g_sim);
            }
        }
        //JionCircuit();
        try

        {
            //g_sim.needAnalyze();
            if (g_sim.doTick() == false)
            {
                //g_IsCreateCircuit = false;
                Debug.Log("CreateCircuit is false");
                return(false);
            }
            else
            {
                Debug.Log("CreateCircuit is true");
                g_IsCreateCircuit = true;
            }
        }
        catch (SharpCircuit.Circuit.CircuitException e)
        {
            Debug.Log(e.ToString());
            return(false);
        }
        return(true);
    }