示例#1
0
        /// <summary>
        /// Builds a linked list of transmissionUnits, over which the powerflow solver can sweep. 
        /// </summary>
        /// <param name="newLine"></param>
        private void buildLadder(Line newLine)
        {
            ladder = new LinkedList<TransmissionUnit>();
            var sourceUnit = new TransmissionUnit(newLine.ConnectivityNodes[newLine.bus1],newLine.BaseKV);
            var callStack = new Stack<TransmissionUnit>();
            var visited = new Stack<TopologicalNode.DynamicTopologicalNode>();
            callStack.Push(sourceUnit);
            TransmissionUnit currentUnit;
            TransmissionUnit newUnit;
            while (callStack.Count != 0)
            {
                currentUnit = callStack.Pop();
                ladder.AddLast(currentUnit);
                if (visited.Contains(currentUnit.Node))
                {
                    //Since the ladder powerflow only works for radial networks, as implemented.
                    throw new Exception("There was a loop in the feeder");
                }
                foreach (Terminal term in currentUnit.DownstreamTerms())
                {
                    newUnit = new TransmissionUnit(term, currentUnit);
                    callStack.Push(newUnit);
                }
                visited.Push(currentUnit.Node);
            }

        }
        public void transmit()
        {
            if (checkstatus(sock))
            {
                //Will stop the current timer. the start function at the bottom will reset the period of the timer
                transmitTimer.Stop();
                //Checks to see if there is anything waiting to be transmitted before executing
                if ((transmitBuffer.Count > 0))
                {
                    TransmissionUnit tu = transmitBuffer.ElementAt(0);      //Transmission unit in focus here
                    Console.WriteLine("transmitting:" + tu.string_dataToSend);
                    //Will convert the dynamic byte array stored in tu (which is the object storing the outbound tranmission) and then send it down the socket.
                    sock.Send(tu.byte_dataToSend.ToArray());

                    tu.currentRetryAttempt += 1;
                    LOG_IT(tu.string_dataToSend, true, ipEP);

                    //Sets the display to the text being sent out
                    if (tu.currentRetryAttempt == 1)
                    {
                        //Do something on inital attempt
                    }
                    //Will update the display with the retry counter if retries are currently underway
                    else if (tu.currentRetryAttempt > 1 && tu.currentRetryAttempt < tu.maxRetryAttempts)
                    {
                        //Do something on subsequent attempts
                    }
                    //If true, the max amount of retries for the transmission unit have occured. Exiting the function and destroying the transmission unit
                    else if (tu.currentRetryAttempt > tu.maxRetryAttempts)
                    {
                        //Do something when the all the retries fail
                        transmitBuffer.RemoveAt(0);
                    }
                }
                transmitTimer.Start();
            }
        }
示例#3
0
 internal TransmissionUnit(Terminal linkPoint, TransmissionUnit powerSource)
 {
     I = new Complex[] { 0, 0, 0 };
     UpstreamUnit = powerSource;
     DownstreamUnits = new HashSet<TransmissionUnit>();
     powerSource.DownstreamUnits.Add(this);
     var tryT = linkPoint.ParentEquipment as PowerTransformer.TransformerEnd;
     var tryLine = linkPoint.ParentEquipment as ACLineSegment;
     //For now assume that Ends[0] is always the upstream TransformerEnd
     if (tryT != null) 
     {
         typeOfBranch = "TransformerEnd";
         tbranch = tryT;
         upstreamTerm = tryT.ParentTransformer.Ends[1].Terminal1;
         Node = upstreamTerm.ConnectionPoint.DynamicTopoNode;
         BaseKV = UpstreamUnit.BaseKV * 
             (tryT.ParentTransformer.Ends[1].BaseKV / tryT.ParentTransformer.Ends[0].BaseKV);  
     }
     if (tryLine != null)
     {
         typeOfBranch = "Conductor";
         lineBranch = tryLine;
         BaseKV = UpstreamUnit.BaseKV;
         if (ReferenceEquals(tryLine.Terminal1, linkPoint))
         {
             Node = tryLine.Terminal2.ConnectionPoint.DynamicTopoNode;
             upstreamTerm = tryLine.Terminal2;
         }
         if (ReferenceEquals(tryLine.Terminal2, linkPoint))
         {
             Node = tryLine.Terminal1.ConnectionPoint.DynamicTopoNode;
             upstreamTerm = tryLine.Terminal1;
         }
     }
     V = new Complex[]{BaseKV,BaseKV,BaseKV};
 }