Beispiel #1
0
        public void Draw(SpriteBatch spriteBatch, Vector2 tileSizeVector)
        {
            var translation = Globals.DefaultTranslation;

            var rotation = 0f;

            if (Direction == Directions.Down)
            {
                rotation = 90;
            }
            else if (Direction == Directions.Left)
            {
                rotation = 180;
            }
            else if (Direction == Directions.Up)
            {
                rotation = 270;
            }

            if (rotation > 0)
            {
                translation  = Matrix.CreateTranslation(-16, -16, 0);
                translation *= Matrix.CreateRotationZ(MathHelper.ToRadians(rotation));
                translation *= Matrix.CreateTranslation(16, 16, 0);
                translation *= Globals.DefaultTranslation;
            }


            var pos = Position * tileSizeVector - new Vector2(16);

            translation *= Matrix.CreateTranslation(pos.X, pos.Y, 0);

            spriteBatch.Begin(transformMatrix: translation);


            _pacmanSprite.Draw(spriteBatch, Vector2.Zero);

            spriteBatch.End();

            spriteBatch.Begin();

            spriteBatch.DrawString(_font, NextNode.ToString(), new Vector2(10, 20), Color.Red);

            spriteBatch.End();
        }
Beispiel #2
0
 public override string ToString()
 {
     return(string.Format("{0}<->{1}", Value, NextNode == null ? "END" : NextNode.ToString()));
 }
Beispiel #3
0
        /// <summary>
        /// تابع بازگشتی یافتن درخت شبکه
        /// </summary>
        /// <param name="ConsoleObjId"></param>
        /// <param name="UpBranchGuid"></param>
        /// <param name="MaxDV"></param>
        /// <param name="FirstRun"></param>
        /// <returns></returns>
        private LoadFlowErr ProcessNode(
            ObjectId ConsoleObjId,
            System.Data.DataRow UpBranch, //Guid?
            ref double MaxDV,
            bool FirstRun)
        {
            bool TevNode = (ConsoleObjId == InvalidConsObjId);

            System.Data.DataRow   curNode;
            System.Data.DataTable dtConsInfo = null;
            //ElectricalDataSet.BranchesRow UpBranch = null;
            Complex     brCurrent, brLoad;
            double      brMinVolt;
            Guid        brGuid;
            LoadFlowErr e;

            System.Data.DataRow curBranch;

            if (TevNode)
            {
                dtConsInfo = new System.Data.DataTable();
                dtConsInfo.Columns.Add("BranchGuid");
                DataRow b = dtConsInfo.NewRow();
                b["BranchGuid"] = Guid.Empty.ToString();
                dtConsInfo.Rows.Add(b);
            }
            else
            {
                dtConsInfo = GetConsolInfoByObjectId(ConsoleObjId);
            }
            //if (UpBranchGuid.HasValue)
            //{
            //    UpBranch = dtBranches.Single(br => br.Code == UpBranchGuid.Value);
            //}

            if (FirstRun)
            {
                curNode = AddNode(TevNode ? null : dtConsInfo.Rows[0]);
            }
            else
            {
                DataRow[] curNode1 = dtNodes.Select("ConsolObjectId Like '" + ConsoleObjId.ToString() + "'");// FindByConsoleObjId(ConsoleObjId);
                curNode = curNode1[0];
                if (UpBranch != null)
                {
                    Complex v = CalcNodeVolt(UpBranch);
                    if (v.real <= 0)
                    {
                        return(LoadFlowErr.NonConverging);
                    }
                    double dv = ((Complex)(curNode["Voltage"]) - v).abs;
                    MaxDV = Math.Max(MaxDV, dv);
                    curNode["Voltage"] = v;
                }
            }

            if (!TevNode && (CalcNodeLoad(curNode) != 0))
            {
                return(LoadFlowErr.LoadCalcErr);
            }
            brCurrent = ((Complex)curNode["LoadCurrent"]);
            brLoad    = ((Complex)curNode["LoadPower"]);
            brMinVolt = ((Complex)curNode["Voltage"]).abs;

            ObjectId NextNode;

            foreach (DataRow br in dtConsInfo.Rows)
            {
                brGuid = new Guid((string)br["BranchGuid"]);

                if ((UpBranch != null) && (brGuid == new Guid(UpBranch["Code"].ToString())))
                {
                    continue;
                }
                NextNode = TevNode ? _RootConsoleObjID :
                           Atend.Global.Acad.UAcad.GetNextConsol(ConsoleObjId, brGuid);

                if (FirstRun)
                {
                    DataRow[] dr = dtNodes.Select("ConsoleObjId Like '" + NextNode.ToString() + "'");
                    if (dr.Length > 0)
                    {
                        return(LoadFlowErr.LoopExists);
                    }
                    curBranch = AddBranch(brGuid, ConsoleObjId, NextNode);
                    if (curBranch == null)
                    {
                        return(LoadFlowErr.ImpCalcErr);
                    }
                }
                else
                {
                    System.Data.DataRow[] curBranch1 = dtBranch.Select("Code like '" + brGuid.ToString() + "'");
                    curBranch = curBranch1[0];
                }

                e = ProcessNode(NextNode, curBranch, ref MaxDV, FirstRun);
                if (e != LoadFlowErr.NoError)
                {
                    return(e);
                }

                brCurrent += (Complex)curBranch["Current"];
                brLoad    += (Complex)curBranch["TotalLoad"];
                CalcBranchLoss(curBranch);
                brMinVolt = Math.Min(brMinVolt, Convert.ToDouble(curBranch["MinVoltage"]));
            }

            if (UpBranch == null)
            {
                _InputCurrent = brCurrent;
                _TotalLoad    = brLoad;
                _MinVoltage   = brMinVolt;
            }
            else
            {
                UpBranch["Current"]    = brCurrent;
                UpBranch["TotalLoad"]  = brLoad;
                UpBranch["MinVoltage"] = brMinVolt;
            }

            return(LoadFlowErr.NoError);
        }
Beispiel #4
0
 public bool CanTransiteNextNode()
 {
     if (CurrentWorksheet != null)
     {
         lock (CurrentWorksheet)
         {
             if (CurrentWorksheet.CurrentStatus == NODE_ACTION_STATUS.Approved)
             {
                 NextNode = _transitionAdapter.GetNextNode(CurrentWorksheet.CurrentNode);
                 Console.WriteLine(">>>>> acivity:" + WorkFlowName + " transite to next node: " + NextNode.ToString());
                 return(true);
             }
         }
     }
     return(false);
 }