コード例 #1
0
        public void readval(string i, string val)
        {
            L1tag curitem = listTag.Find(o => o.id == Convert.ToInt16(i));

            //如果扫描周期小于1,按事件采集的,则不向数据库插入数据
            if (curitem.scanrate < 1)
            {
                return;
            }
            if ((DateTime.Now - curitem.lasttime).TotalSeconds >= curitem.scanrate)
            {
                curitem.lasttime = DateTime.Now;
                savedata(Convert.ToInt16(i), Convert.ToDouble(val));
            }
        }
コード例 #2
0
        public List <L1tag> dt_to_list(DataTable dt)
        {
            List <L1tag> taglist = new List <L1tag>();

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    L1tag tag = new L1tag();
                    tag.id       = Convert.ToInt16(item["id"]);
                    tag.name     = item["name"].ToString();
                    tag.scanrate = Convert.ToInt16(item["scanrate"]);
                    tag.lasttime = DateTime.Now.AddHours(-2);
                    taglist.Add(tag);
                }
            }

            return(taglist);
        }
コード例 #3
0
        /// <summary>
        /// 根据变量id获取服务端句柄
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int getHandleServerById(int id)
        {
            L1tag curitem = listTag.Find(o => o.id == id);

            return(curitem.itmHandleServer);
        }