Example #1
0
        /// <summary>
        /// Serialize to XML
        /// </summary>
        /// <param name="writer"></param>
        public virtual void Serialize(XmlWriter writer)
        {
            writer.WriteStartElement("Scenario");
            writer.WriteAttributeString("Type", "FORM");
            writer.WriteAttributeString("Version", "1");
            writer.WriteAttributeString("Name", Name);

            writer.WriteStartElement("Form");

            writer.WriteAttributeString("X", PosX.ToString());
            writer.WriteAttributeString("Y", PosY.ToString());
            writer.WriteAttributeString("W", Width.ToString());
            writer.WriteAttributeString("H", Height.ToString());

            foreach (string key in Properties.Keys)
            {
                writer.WriteStartElement("Property");
                writer.WriteAttributeString("Name", key);
                writer.WriteValue(Properties[key]);
                writer.WriteEndElement();
            }

            // Form
            writer.WriteEndElement();

            // Scenario
            writer.WriteEndElement();
        }
Example #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            // ushort axis = GetAxis(); //轴号
            double dcurrent_speedX = 0, dcurrent_speedY = 0, dcurrent_speedZ = 0, dcurrent_speedW = 0; //速度值
            //  double dunitPosX, dunitPosY, dunitPosZ, dunitPosW; //脉冲当量转换后指令值
            int PosX, PosY, PosZ, PosW;                                                                //脉冲值

            LTDMC.dmc_read_current_speed_unit(_CardID, 0, ref dcurrent_speedX);                        // 读取轴当前速度
            LTDMC.dmc_read_current_speed_unit(_CardID, 1, ref dcurrent_speedY);
            LTDMC.dmc_read_current_speed_unit(_CardID, 2, ref dcurrent_speedZ);
            LTDMC.dmc_read_current_speed_unit(_CardID, 3, ref dcurrent_speedW);
            txtCurrentSpeedX.Text = dcurrent_speedX.ToString();
            txtCurrentSpeedY.Text = dcurrent_speedY.ToString();
            txtCurrentSpeedZ.Text = dcurrent_speedZ.ToString();
            txtCurrentSpeedW.Text = dcurrent_speedW.ToString();
            //LTDMC.dmc_get_position_unit(_CardID, 0, ref dunitPosX); //读取指定轴指令位置值
            //txtFinalPosY.Text = dunitPosX.ToString();
            PosX = LTDMC.dmc_get_position(_CardID, 0);//读取指定轴的脉冲值
            PosY = LTDMC.dmc_get_position(_CardID, 1);
            PosZ = LTDMC.dmc_get_position(_CardID, 2);
            PosW = LTDMC.dmc_get_position(_CardID, 3);
            txtCurrentPosX.Text = PosX.ToString();
            txtCurrentPosY.Text = PosY.ToString();
            txtCurrentPosZ.Text = PosZ.ToString();
            txtCurrentPosW.Text = PosW.ToString();
            if (LTDMC.dmc_check_done(_CardID, 0) == 0) // 读取指定轴运动状态
            {
                txtStateX.Text = "运行中";
            }
            else
            {
                txtStateX.Text = "停止中";
            }
            if (LTDMC.dmc_check_done(_CardID, 1) == 0) // 读取指定轴运动状态
            {
                txtStateY.Text = "运行中";
            }
            else
            {
                txtStateY.Text = "停止中";
            }
            if (LTDMC.dmc_check_done(_CardID, 2) == 0) // 读取指定轴运动状态
            {
                txtStateZ.Text = "运行中";
            }
            else
            {
                txtStateZ.Text = "停止中";
            }
            if (LTDMC.dmc_check_done(_CardID, 3) == 0) // 读取指定轴运动状态
            {
                txtStateW.Text = "运行中";
            }
            else
            {
                txtStateW.Text = "停止中";
            }
        }
Example #3
0
        public override string ToString()
        {
            string corral = "Corral(" + PosX.ToString() + ", " + PosY.ToString() + ")";

            if (HasKid)
            {
                corral += " <<with " + Kid.ToString() + ">>";
            }
            return(corral);
        }
Example #4
0
 public void Show()
 {
     _body_.Visible = true;
     Active         = true;
     _body_.Show();
     #if DEBUG
     int maxx = PosX + Width;
     int maxy = PosY + Height;
     _body_.Text = PosX.ToString() + '-' + maxx.ToString() + "::" + PosY.ToString() + '-' + maxy.ToString();
     #endif
 }
Example #5
0
 public override void WriteXml(XmlWriter writer)
 {
     WriteXmlAttributes(writer);
     writer.WriteAttributeString("x", PosX.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("y", PosY.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("text-anchor", Anchor.ToString());
     writer.WriteAttributeString("dominant-baseline", DominantBaseline.ToString());
     writer.WriteAttributeString("font-size", $"{_style.Size.ToString(CultureInfo.InvariantCulture)}px");
     writer.WriteAttributeString("font-family", $"{_style.Font}");
     writer.WriteValue(Label);
     writer.WriteEndElement();
 }
Example #6
0
 public override string ToString()
 {
     return(String.Format("[{0}][{1}],[{2}],[{3}],[{4}],[{5}],[{6}],[{7}],[{8}],[{9}]", (Frame + 1).ToString().PadLeft(5),
                          PosX.ToString().ToFixedString(size, ' ').PadRight(padding),
                          PosY.ToString().ToFixedString(size, ' ').PadRight(padding),
                          PosZ.ToString().ToFixedString(size, ' ').PadRight(padding),
                          RotX.ToString().ToFixedString(size, ' ').PadRight(padding),
                          RotY.ToString().ToFixedString(size, ' ').PadRight(padding),
                          RotZ.ToString().ToFixedString(size, ' ').PadRight(padding),
                          RotW.ToString().ToFixedString(size, ' ').PadRight(padding),
                          ScaX.ToString().ToFixedString(size, ' ').PadRight(padding),
                          ScaY.ToString().ToFixedString(size, ' ').PadRight(padding),
                          ScaZ.ToString().ToFixedString(size, ' ').PadRight(padding)));
 }
Example #7
0
 public override void WriteXml(XmlWriter writer)
 {
     WriteXmlAttributes(writer);
     if (!string.IsNullOrWhiteSpace(Id))
     {
         writer.WriteAttributeString("id", Id);
     }
     if (!string.IsNullOrWhiteSpace(Label))
     {
         writer.WriteAttributeString("label", Label);
     }
     writer.WriteAttributeString("cx", PosX.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("cy", PosY.ToString(CultureInfo.InvariantCulture));
     writer.WriteAttributeString("r", Radius.ToString(CultureInfo.InvariantCulture));
     writer.WriteEndElement();
 }
Example #8
0
 public override string ToString()
 {
     return(string.Format("What={0};ItemId={1};ItemPlayer={2};PosX={3};PosY={4};Units={5}", GetType().ToString(), ItemId, ItemPlayer, PosX.ToString("F"), PosY.ToString("F"), numberOfUnits));
 }
Example #9
0
        public void UpdatePerceptions(RolePlayCharacterAsset rpc)
        {
            /*
             * Find every InSight, InInventory, and IsEquipped belief and set them to false
             * */
            CleanBeliefs(rpc);

            /*
             * Update the KB with the new beliefs
             * */
            string bv = rpc.GetBeliefValue("Hunger(" + rpc.CharacterName.ToString() + ")");

            if (bv == null || !bv.Equals(Hunger.ToString()))
            {
                Debug.WriteLine("Hunger: " + bv + " -> " + Hunger.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Hunger(" + rpc.CharacterName.ToString() + ")", Hunger.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Health(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Health.ToString()))
            {
                Debug.WriteLine("Health: " + bv + " -> " + Health.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Health(" + rpc.CharacterName.ToString() + ")", Health.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Sanity(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Sanity.ToString()))
            {
                Debug.WriteLine("Sanity: " + bv + " -> " + Sanity.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Sanity(" + rpc.CharacterName.ToString() + ")", Sanity.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsFreezing(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsFreezing.ToString()))
            {
                Debug.WriteLine("IsFreezing: " + bv + " -> " + IsFreezing.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsFreezing(" + rpc.CharacterName.ToString() + ")", IsFreezing.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsOverheating(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsOverheating.ToString()))
            {
                Debug.WriteLine("IsOverheating: " + bv + " -> " + IsOverheating.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsOverheating(" + rpc.CharacterName.ToString() + ")", IsOverheating.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Moisture(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Moisture.ToString()))
            {
                Debug.WriteLine("Moisture: " + bv + " -> " + Moisture.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Moisture(" + rpc.CharacterName.ToString() + ")", Moisture.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("Temperature(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(Temperature.ToString()))
            {
                Debug.WriteLine("Temperature: " + bv + " -> " + Temperature.ToString());
                rpc.Perceive(EventHelper.PropertyChange("Temperature(" + rpc.CharacterName.ToString() + ")", Temperature.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("IsBusy(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(IsBusy.ToString()))
            {
                Debug.WriteLine("IsBusy: " + bv + " -> " + IsBusy.ToString());
                rpc.Perceive(EventHelper.PropertyChange("IsBusy(" + rpc.CharacterName.ToString() + ")", IsBusy.ToString(), rpc.CharacterName.ToString()));
            }

            bv = rpc.GetBeliefValue("PosX(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(PosX.ToString()))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosX(" + rpc.CharacterName.ToString() + ")", PosX.ToString(), rpc.CharacterName.ToString()));
            }

            /*
             * The Y-axis is always equal to zero, no need to save it in the knowledge base
             * */
            //bv = rpc.GetBeliefValue("PosY(" + rpc.CharacterName.ToString() + ")");
            //if (bv == null || !bv.Equals(PosY.ToString()))
            //    rpc.Perceive(EventHelper.PropertyChange("PosY(" + rpc.CharacterName.ToString() + ")", PosY.ToString(), rpc.CharacterName.ToString()));

            bv = rpc.GetBeliefValue("PosZ(" + rpc.CharacterName.ToString() + ")");
            if (bv == null || !bv.Equals(PosZ.ToString()))
            {
                rpc.Perceive(EventHelper.PropertyChange("PosZ(" + rpc.CharacterName.ToString() + ")", PosZ.ToString(), rpc.CharacterName.ToString()));
            }


            foreach (Item i in Vision)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("InSight(" + i.GUID + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("InSight(" + i.GUID + ")", "True", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            foreach (Item i in ItemSlots)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("InInventory(" + i.GUID + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("InInventory(" + i.GUID + ")", "TRUE", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            foreach (EquippedItems i in EquipSlots)
            {
                if (i != null)
                {
                    bv = rpc.GetBeliefValue("IsEquipped(" + i.GUID + "," + i.Slot + ")");
                    if (bv == null || !bv.Equals("True"))
                    {
                        rpc.Perceive(EventHelper.PropertyChange("IsEquipped(" + i.GUID + "," + i.Slot + ")", "TRUE", rpc.CharacterName.ToString()));
                    }
                    i.UpdatePerception(rpc);
                }
            }

            rpc.Update();
        }
Example #10
0
        public string getResponseString()
        {
            string responseString = "(" + PosX.ToString() + "," + PosY.ToString() + ")";

            return(responseString);
        }
Example #11
0
 }                             //纵坐标
 public override string ToString()
 {
     return(PosX.ToString() + ' ' + PosY.ToString());
 }
Example #12
0
        /// <summary>
        /// ueberschreibe Base.ToString.  Für mehr Log-Informationen zu erhalten
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string strLogPosition = "Pos X = " + PosX.ToString() + ", Pos Y = " + PosY.ToString();

            return(strLogPosition);
        }
Example #13
0
 private void UpdatePos()
 {
     transform.localPosition = new Vector3(PosX * offsetX, PosY * offsetY, 0);
     transform.name          = PosX.ToString() + PosY.ToString();
 }
Example #14
0
 public override string ToString()
 {
     return("Obstacle(" + PosX.ToString() + ", " + PosY.ToString() + ")");
 }
Example #15
0
 public override string ToString()
 {
     return("Dirt(" + PosX.ToString() + ", " + PosY.ToString() + ")");
 }
Example #16
0
 public override string ToString()
 {
     return("Kid<" + Id + ">(" + PosX.ToString() + ", " + PosY.ToString() + ")");
 }
Example #17
0
 public override string ToString()
 {
     return(PosX.ToString("0.#") + " " + PosY.ToString("0.#"));
 }