示例#1
0
        public void SyncRead(object sender, EventArgs e)
        {
            tTimer.Stop();

            try
            {
                object ItemValues; object Quantities; object TimeStamps;//同步读取临时变量 值 质量 时间戳

                for (int i = 0; i < ModelList.Count; i++)
                {
                    opcItem[i].Read(1, out ItemValues, out Quantities, out TimeStamps);

                    if (Quantities.ToString() == "192")
                    {
                        Address            = ModelList[i].KepAddress;
                        myDcValue[Address] = ItemValues.ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                tTimer.Start();
            }
            tTimer.Start();
        }
示例#2
0
        /// <summary>
        /// 拼接数据项的设置参数
        /// </summary>
        /// <returns></returns>
        public String SetItemSettings(ref List <KeyValueEntity> list, List <SettingEntity> x_OptionList)
        {
            //获取效果参数
            List <SettingEntity> ItemSettingDB = x_OptionList;


            if (ItemSettingDB != null && ItemSettingDB.Count > 0)
            {
                ControlHelper ControlItem = new ControlHelper(PortalId);

                foreach (SettingEntity ri in ItemSettingDB)
                {
                    KeyValueEntity OldKV = ItemValues.Find(r1 => r1.Key == ri.Name);

                    if (OldKV != null && !String.IsNullOrEmpty(OldKV.Value))
                    {
                        ri.DefaultValue = OldKV.Value;
                    }

                    KeyValueEntity item = new KeyValueEntity();
                    item.Key   = ri.Name;
                    item.Value = ControlHelper.GetWebFormValue(ri, this);
                    list.Add(item);
                }
            }
            return(ConvertTo.Serialize <List <KeyValueEntity> >(list));
        }
示例#3
0
        // the final output...
        public string Render(RenderContext context)
        {
            if (this.IsString)
            {
                return(this.KeyOrExpression);
            }
            else if (this.RequireRender)
            {
                foreach (var item in ItemValues)
                {
                    if (item.Value == null)
                    {
                        var objvalue = context.DataContext.GetValueByQuery(item.Query);
                        if (objvalue != null)
                        {
                            item.Value = objvalue.ToString();
                        }
                    }
                }
            }

            if (ItemValues != null && ItemValues.Any())
            {
                var valuePara = ItemValues.Select(o => o.Value).ToArray();
                return(string.Format(this.KeyOrExpression, valuePara));
            }
            else
            {
                return(this.KeyOrExpression);
            }
        }
示例#4
0
        public void SyncRead(object sender, EventArgs e)
        {
            tTimer.Stop();
            string LabelName = string.Empty;

            try
            {
                object ItemValues; object Quantities; object TimeStamps;//同步读取临时变量 值 质量 时间戳

                for (int i = 0; i < paramClass.ParamList.Count; i++)
                {
                    opcItem[i].Read(1, out ItemValues, out Quantities, out TimeStamps);
                    if (Quantities.ToString() == "192")
                    {
                        LabelName = paramClass.ParamList[i].LabelName;

                        Type type = paramClass.GetType();                                          //获取类型
                        System.Reflection.PropertyInfo propertyInfo = type.GetProperty(LabelName); //获取指定名称的属性
                        //int value_Old = (int)propertyInfo.GetValue(paramClass, null); //获取属性值
                        if (propertyInfo != null)
                        {
                            propertyInfo.SetValue(paramClass, ItemValues.ToString(), null);                       //给对应属性赋值
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                tTimer.Start();
            }
            tTimer.Start();
        }
示例#5
0
    /*
    // Existing known properties
    private string _firstName;
    private string _lastName;

    public string FirstName
    {
      get { return _firstName; }
      set { _firstName = value; RaisePropertyChanged(); }
    }

    public string LastName
    {
      get { return _lastName; }
      set { _lastName = value; RaisePropertyChanged(); }
    }
    */
    #endregion


    public Item(ItemSchema schema)
    {
      _schema = schema;
      _values = new ItemValues(_schema);

      _values.PropertyChanged += (s, e) => PropertyChanged(this, e);
    }
示例#6
0
        protected void RepeaterOptions_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                SettingEntity ThemeSetting = (e.Item.DataItem as SettingEntity).Clone();

                KeyValueEntity KeyValue = ItemValues.Find(r1 => r1.Key == ThemeSetting.Name);
                if (KeyValue != null && !String.IsNullOrEmpty(KeyValue.Key))
                {
                    ThemeSetting.DefaultValue = KeyValue.Value.ToString();
                }

                //构造输入控件
                PlaceHolder ThemePH = e.Item.FindControl("ThemePH") as PlaceHolder;

                #region "创建控件"
                ControlHelper ctl = new ControlHelper(this);

                ThemePH.Controls.Add((Control)ctl.ViewControl(ThemeSetting));
                #endregion

                Literal liTitle = e.Item.FindControl("liTitle") as Literal;
                liTitle.Text = ViewTitleAndHelp(ThemeSetting);


                if (!String.IsNullOrEmpty(ThemeSetting.Description))
                {
                    Literal liHelp = e.Item.FindControl("liHelp") as Literal;
                    liHelp.Text = String.Format("<span class=\"help-block\"><i class=\"fa fa-info-circle\"></i> {0}</span>", ThemeSetting.Description);
                }
            }
        }
示例#7
0
    private void Start()
    {
        ItemValues item = transform.GetComponentInChildren <ItemValues>();

        currentItem = item;
        if (currentItem != null)
        {
            currentItem.GetComponent <moveitemsi_inventory>().currentLocation = this;
        }
    }
示例#8
0
    public void initialize()
    {
        sprite   = GetComponent <SpriteRenderer> ();
        collider = GetComponent <Collider2D> ();
        value    = GetComponent <ItemValues> ();

        sprite.color = defaultColor;

        setIdle();
        setConveyor();

        value.initialize();
    }
        /// <summary>
        /// 读取XML参数
        /// </summary>
        /// <param name="Name">参数名</param>
        /// <param name="DefaultValue">默认值</param>
        /// <returns></returns>
        public object ViewXmlSetting(String Name, object DefaultValue)
        {
            String o = String.Empty;

            if (!String.IsNullOrEmpty(Name) && ItemValues != null && ItemValues.Count > 0)
            {
                KeyValueEntity item = ItemValues.Find(r1 => r1.Key == Name);
                if (item != null && item.Key == Name)
                {
                    o = item.Value.ToString();
                }
            }
            return(!String.IsNullOrEmpty(o) ? ConvertTo.FormatValue(o, DefaultValue.GetType()) : DefaultValue);
        }
示例#10
0
        private void InitValue()
        {
            //同步读
            object ItemValues, Qualities, TimeStamps;

            textBoxResult.Text = "";
            for (int i = opcItem.Count() - 1; i >= 0; i--)
            {
                try
                {
                    opcItem[i].Read(1, out ItemValues, out Qualities, out TimeStamps);

                    ItemList[i].value = ItemValues.ToString();
                    labelState.Text   = "Item: " + ItemList[i].name + " value:" + ItemList[i].value;
                }
                catch (Exception ex)
                {
                    textBoxResult.Text += "Item: " + ItemList[i].name + " error: " + ex.Message + "\r\n";
                    //  labelState.Text = ex.Message;
                }
            }
        }
示例#11
0
    IEnumerator PushItemtoNextNode()      // must run every like 0.5 sec or something anyway make a another parent function to call this on start
    //maybe check if item has been in list for (beltspeed) time and THEN move it to next node
    {
        BeltS next = GetNextBelt();          //get nextbeltscript before every pushitem

        //check stuff before pushing

        //GLITCHES APPEAR HERE ITEM THAT ARE NOT SUPPOSED TO BE THERE ARE SUDDENLY THERE

        if (next != null && this.CurrentItemsScript.CurrentItems.Count > 0 && next.CurrentItemsScript.CurrentItems.Count < CurrentItemsScript.Capacity)
        {
            ItemValues tempITEM = this.CurrentItemsScript.CurrentItems[0];             //removing THEN checking if removed then adding
            //removing item from this node
            this.CurrentItemsScript.CurrentItems.Remove(this.CurrentItemsScript.CurrentItems[0]);
            //adding to next node currentItems list
            next.CurrentItemsScript.CurrentItems.Add(tempITEM);
        }


        //redo function //sometimes glitches and stops all current StartCourountines
        yield return(new WaitForSecondsRealtime(BeltSpeed));

        StartCoroutine(this.PushItemtoNextNode());
    }
示例#12
0
        /// <summary>
        /// Returns the encoding, occurrences and entropy of string
        /// </summary>
        public static ItemValues GetValues(byte[] fileBytes, string input)
        {
            ItemValues retVal = new ItemValues();

            retVal.Encoding = "ASCII";

            int count = 0;

            count += Finder.CountOccurrences(fileBytes, Encoding.UTF8.GetBytes(input));

            if (count != 0)
            {
                retVal.Encoding = "ASCII";
            }
            var oldCount = count;

            count += Finder.CountOccurrences(fileBytes, GetUTF16Bytes(input, false));

            if (count != oldCount)
            {
                if (oldCount == 0)
                {
                    retVal.Encoding = "UTF-16";
                }
                else
                {
                    retVal.Encoding = "Both";
                }
            }


            retVal.Occurrences = count.ToString();
            retVal.Entropy     = ShannonEntropy(input).ToString("F");

            return(retVal);
        }
 /// <summary>
 /// SetDefaultValues
 /// </summary>
 public void SetDefaultValues()
 {
     ItemValues.Clear();
     ItemValues.Add(DELETE_COMMAND);
     SelectedItemValues = ItemValues[0];
 }
 public float getcost(ItemValues item)
 {
     return(item.value / item.weight);
 }
示例#15
0
    // Use this for initialization
    void Start()
    {
        firstItemMoved   = false;
        tutorialFinished = false;
        sellItems        = GetComponents <AudioSource>()[0];
        error            = GetComponents <AudioSource>()[1];
        tutorialScript   = GameObject.Find("Tutorial").GetComponent <Tutorial>();

        numberItemsInCamelInventory = 0;

        levelController = GameObject.FindWithTag("GameController").GetComponent <LevelController>();

        foreach (GameObject item in inventory)
        {
            ItemValues itemVals = item.GetComponent <ItemValues>();

            //customisable item and weight for each item
            //items are organised into types: normal, cold and hot
            //for multiple items change multiplier
            switch (item.name)
            {
            case "Umbrella":
                itemVals.SetPrice(20);
                itemVals.SetWeight(8);
                if (levelController.GetLevel() == 4)
                {
                    itemVals.SetWeight(4);
                }
                goto case "Normal";

            case "Sword":
                itemVals.SetPrice(100);
                itemVals.SetWeight(10);
                if (levelController.GetLevel() == 2)
                {
                    itemVals.SetPrice(200);
                    itemVals.SetWeight(18);
                }
                if (levelController.GetLevel() == 4)
                {
                    itemVals.SetPrice(70);
                    itemVals.SetWeight(13);
                }
                goto case "Normal";

            case "Flip-Flops":
                itemVals.SetPrice(10);
                itemVals.SetWeight(2);
                goto case "Normal";

            case "Mysterious-bottle":
                itemVals.SetPrice(30);
                itemVals.SetWeight(1);
                goto case "Normal";

            case "Normal":
                itemVals.SetType(ItemValues.ItemType.Normal);
                break;

            case "Ice Cream":
                itemVals.SetPrice(50);
                itemVals.SetWeight(5);
                goto case "Cold";

            case "Ice Cube":
                itemVals.SetPrice(30);
                itemVals.SetWeight(12);
                if (levelController.GetLevel() == 4)
                {
                    itemVals.SetWeight(10);
                    itemVals.SetPrice(50);
                }
                goto case "Cold";

            case "Cold":
                itemVals.SetType(ItemValues.ItemType.Cold);
                break;

            case "Microwave":
                itemVals.SetPrice(50);
                itemVals.SetWeight(6);
                if (levelController.GetLevel() == 4)
                {
                    itemVals.SetWeight(9);
                }
                goto case "Hot";

            case "Torch":
                itemVals.SetPrice(30);
                itemVals.SetWeight(7);
                goto case "Hot";

            case "Hot":
                itemVals.SetType(ItemValues.ItemType.Hot);
                break;

            default:
                Debug.Log("Item Not Recognised");
                break;
            }
        }

        if (!(levelController.GetLevel() == 1))
        {
            weightText      = GameObject.Find("MaxWeight").GetComponent <TextMeshProUGUI>();
            weightText.text = "0";
        }

        currentCamelInventoryWeight = 0;
        camelMoving = GameObject.FindGameObjectWithTag("Camel").GetComponent <Moving> ();

        levelController.SetWeight(0);   //set the weight to 0
    }
示例#16
0
        private void buttonCheckItem_Click(object sender, EventArgs e)
        {
            string        inpath   = textBoxInFile.Text;
            string        outpath  = textBoxCheckItemOutPath.Text;
            List <string> itemlist = new List <string> {
            };

            if (textBoxInFile.Text.Equals(""))
            {
                MessageBox.Show("输入文件路径不存在");
            }
            if (textBoxCheckItemOutPath.Text.Equals(""))
            {
                MessageBox.Show("输出文件路径不存在");
            }
            //FileStream chefile = new FileStream(outpath, FileMode.Create);
            if (!textBoxInFile.Text.Equals("") && !textBoxCheckItemOutPath.Text.Equals(""))
            {
                try
                {
                    StreamReader sr = new StreamReader(inpath, Encoding.Default);
                    string       line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        //读取一行outpath
                        line = line.Replace("\t", "");
                        line = line.Replace(" ", "");
                        line = line.Replace(",", "");
                        itemlist.Add(line);
                    }
                    sr.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("读取文件失败");
                }
                try
                {
                    opcGroups = opcServer.OPCGroups;
                    DateTime dt = new DateTime();
                    dt = DateTime.Now;
                    dt.Second.ToString();
                    opcGroup = opcGroups.Add("Group" + dt.Hour.ToString() + dt.Second.ToString());
                    //以下设置属性
                    {
                        opcGroups.DefaultGroupIsActive   = true;    //激活组
                        opcGroups.DefaultGroupDeadband   = 0;       //死区值,设为0时,服务器端该组内任何数据变化都通知组
                        opcGroups.DefaultGroupUpdateRate = 5000;    //默认组群的刷新频率为200ms
                        this.labelState.Text             = "UpdateRate = 5000ms";

                        opcGroup.UpdateRate   = 5000; //刷新频率为5秒
                        opcGroup.IsSubscribed = true; //如果没有订阅,则该组的DataChange回调事件不会发生
                    }
                    //添加Item
                    //设置组内的Items
                    opcItems = opcGroup.OPCItems;
                    opcItem  = new OPCItem[itemlist.Count];
                    for (int i = 0; i < itemlist.Count; i++)
                    {
                        opcItem[i] = opcItems.AddItem(itemlist[i], i + 1);
                    }
                    //同步读
                    object ItemValues, Qualities, TimeStamps;

                    for (int i = opcItem.Count() - 1; i >= 0; i--)
                    {
                        try
                        {
                            opcItem[i].Read(1, out ItemValues, out Qualities, out TimeStamps);
                            string value = ItemValues.ToString();
                            File.AppendAllText(outpath, "Item: " + itemlist[i] + " value:" + value + "\r\n");
                        }
                        catch (Exception ex)
                        {
                            File.AppendAllText(outpath, "Item: " + itemlist[i] + " error: " + ex.Message + "\r\n");
                            //  labelState.Text = ex.Message;
                        }
                    }
                }
                catch (Exception err)
                {
                    //throw new Exception("CreateGroup:" + err.Message);
                }
            }
        }