public void ClosePhaseOfSwitch(MPSwitchDevice switchDevice, EPhaseCode phaseToChange)
        {
            MPConnectivityBranch statebranch = (MPConnectivityBranch)internalModel.Branches[switchDevice.StateBranch];

            AddBranchToModel(statebranch, phaseToChange);

            switchDevice.State = switchDevice.State | phaseToChange;
        }
        public void OpenPhaseOfSwitch(MPSwitchDevice switchDevice, EPhaseCode phaseToChange)
        {
            MPConnectivityBranch statebranch = (MPConnectivityBranch)internalModel.Branches[switchDevice.StateBranch];

            RemoveBranchFromModel(statebranch, phaseToChange);

            switchDevice.State = switchDevice.State & (~phaseToChange & EPhaseCode.ABC);
        }
        public void OpenSwitch(MPSwitchDevice switchDevice, EPhaseCode phasesToRemove)
        {
            MPConnectivityBranch statebranch = (MPConnectivityBranch)internalModel.Branches[switchDevice.StateBranch];

            RemoveBranchFromModel(statebranch, phasesToRemove);

            switchDevice.State = EPhaseCode.NONE;
        }
        public void CloseSwitch(MPSwitchDevice switchDevice, EPhaseCode phasesToAdd)
        {
            MPConnectivityBranch statebranch = (MPConnectivityBranch)internalModel.Branches[switchDevice.StateBranch];

            AddBranchToModel(statebranch, phasesToAdd);

            switchDevice.State = switchDevice.OriginalPhases;
        }
        private void InsertSwitchDeviceInMatrixModel(MPSwitchDevice bay)
        {
            MPBranch oldBranch = internalModel.Branches[bay.EndBranch];

            // Krajevi grane na kojoj se nalazi prekidac
            long node2Lid = bay.EndNode;
            long node1Lid = oldBranch.EndNodes[0] == node2Lid ? oldBranch.EndNodes[1] : oldBranch.EndNodes[0];

            // Kreiranje novog cvora sa faznoscu stare grane
            long connNodeLid            = internalModel.LidManager.FindFreeTemporaryIndex("MPConnectivityNode");
            MPConnectivityNode connNode = new MPConnectivityNode(connNodeLid, oldBranch.OriginalPhases);

            AddNodeInModel(connNodeLid);
            internalModel.Nodes.Add(connNodeLid, connNode);

            // Kreiranje prve grane sa faznoscu stare grane
            long connBranch1Lid = internalModel.LidManager.FindFreeTemporaryIndex("MPConnectivityBranch");
            MPConnectivityBranch connBranch1 = new MPConnectivityBranch(connBranch1Lid, oldBranch.Lid, oldBranch.OriginalPhases, node1Lid, connNodeLid);

            AddBranchToModel(connBranch1);
            internalModel.Branches.Add(connBranch1Lid, connBranch1);

            // Kreiranje druge grane sa faznoscu i stanjem prekidaca
            long connBranch2Lid = internalModel.LidManager.FindFreeTemporaryIndex("MPConnectivityBranch");
            MPConnectivityBranch connBranch2 = new MPConnectivityBranch(connBranch2Lid, oldBranch.Lid, bay.OriginalPhases, connNodeLid, node2Lid);

            AddBranchToModel(connBranch2, bay.State);
            internalModel.Branches.Add(connBranch2Lid, connBranch2);

            // Povezivanje prekidaca sa granom koja modelira njegovo stanje
            bay.StateBranch = connBranch2Lid;

            // Brisanje stare grane
            RemoveBranchFromModel(oldBranch);
            internalModel.Branches.Remove(oldBranch.Lid);
        }