Ejemplo n.º 1
0
        //获取标签列表(2018.04.12完成)
        #region 获取标签列表 public  List<String> GetTagList()
        public List <SignalComm> GetTagList(string tagname, string tablename = "")
        /// <summary>
        /// 获取标签列表
        /// </summary>
        /// <returns>在数据库所有符合tagname搜索条件的标签列表(在所有表中查询)</returns>
        {
            List <SignalComm> results = new List <SignalComm>();      //存放标签名

            PISDK.PointList QuerySignals = new PISDK.PointList();

            //对过滤条件tagname进行整理,如果tagname为空,则返回所有标签
            //——这意味着GetTagList的参数tagname,即可以是具体的过滤条件,返回符合条件的对象
            //——也可以是tagname为空,返回所有的标签对象。
            if (tagname == "")
            {
                tagname = "Tag = '*'";  //返回全部标签的写法,参考PI-SDK手册,Server对象,GetPoints()方法
            }

            try
            {
                QuerySignals = this._piServer.GetPoints(tagname);
            }
            catch (Exception ex)     //后面这个异常的类型应该改为PI的异常类型
            {
                //将PI的异常记录在_exception中,并以ex的名称继续抛出异常
                this._exception = ex.ToString();
                throw new Exception(ex.ToString());     //将PI的异常继续向外传递。
            }

            foreach (PIPoint pipoint in QuerySignals)
            {
                results.Add(new SignalComm(pipoint.Name, pipoint.PathName)); //返回标签名和描述。PI数据点,目前没有在手册中找到描述字段的位置。
            }
            return(results);                                                 //返回那些数据库中没有找到的标签
        }
Ejemplo n.º 2
0
        void btnClear_Click(object sender, EventArgs e)
        {
            ptList = pisrv.GetPoints("tag='" + tbFilter.Text + "'");

            ProgressBar.Minimum = 0;
            ProgressBar.Maximum = ptList.Count;
            ProgressBar.Value   = 0;

            int i = 0;

            lbTags.Items.Clear();
            foreach (PIPoint p in ptList)
            {
                i++;
                this.Text = i.ToString() + " / " + ptList.Count.ToString();

                lbTags.Items.Add(p.Name);

                try {
                    p.Data.RemoveValues(dtpStart.Value, dtpFinish.Value, DataRemovalConstants.drRemoveAll);
                } catch (Exception ex) {
                    textBox1.AppendText(ex.Message.ToString() + " [" + p.Name + ", " + i.ToString() + "]\n");
                }

                ProgressBar.Increment(1);
                Application.DoEvents();
            }

            ProgressBar.Value = 0;
        }
Ejemplo n.º 3
0
        void btnTagsView_Click(object sender, EventArgs e)
        {
            ptList = pisrv.GetPoints("tag='" + tbFilter.Text + "'");

            ProgressBar.Minimum = 0;
            ProgressBar.Maximum = ptList.Count;
            ProgressBar.Value   = 0;

            lbTags.Items.Clear();
            foreach (PIPoint p in ptList)
            {
                lbTags.Items.Add(p.Name);
                ProgressBar.Increment(1);
            }

            ProgressBar.Value = 0;
        }
Ejemplo n.º 4
0
        //检查标签是否存在(2018.04.12完成)
        #region 检查标签是否存在    public List<string> CheckTags(string[] tagnames)
        public List <string> CheckTags(string[] tagnames)
        {
            List <string> results = new List <string>();

            PISDK.PointList QuerySignals = new PISDK.PointList();
            foreach (string tagname in tagnames)
            {
                try
                {
                    QuerySignals = this._piServer.GetPoints(tagname);
                    if (QuerySignals.Count == 0)
                    {
                        results.Add(tagname);   //返回没有找到的标签
                    }
                }
                catch (Exception ex)      //后面这个异常的类型应该改为PI的异常类型
                {
                    results.Add(tagname); //返回没有找到的标签
                }
            }
            return(results);                                     //返回没有找到的标签
        }
Ejemplo n.º 5
0
        /// <summary>
        /// ������ֻ����CSģʽ��ʹ��
        /// </summary>
        /// <returns></returns>
        public List<string> GetPointList()
        {
            List<string> l = new List<string>();
            try {
                PISDKDlg.ApplicationObject AppObj = new PISDKDlg.ApplicationObject();
                PISDKDlg.TagSearch tagsearch = AppObj.TagSearch;

                PISDK.PointList PtList = new PISDK.PointList();
                PISDKCommon.NamedValues nv = new PISDKCommon.NamedValues();
                string piserver_name = ConfigurationManager.AppSettings["PIServer"].ToString();
                nv.LoadFromString(piserver_name);

                PtList = tagsearch.Show(nv, PISDKDlg.TagSearchOptions.tsoptSingleSelect);  //tsoptDisableServerPickList

                foreach (PIPoint pt in PtList) {
                    l.Add(pt.PointAttributes["tag"].Value.ToString().ToUpper() + "," + pt.PointAttributes["descriptor"].Value.ToString().ToUpper() + "," + pt.PointAttributes["engunits"].Value.ToString().ToUpper());
                }
            }
            catch (Exception ex) {
                _ErrorInfo = ex.Message;
            }
            return l;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// ��ʵʱ���ݿ��PointList��ֵ
        /// </summary>
        /// <param name="lttvs"></param>
        /// <returns></returns>
        public bool SetPointList(Dictionary<string, TagValue> lttvs, out string strError)
        {
            if (piPointList == null || piPointList.Count == 0) {
                piPointList = new PointList();
            }

            if (piPointList == null || piPointList.Count == 0) {
                piPointList = new PointList();
            }

            strError = "";
            //List<String> PointNameList = new List<String>();
            List<string> PointList = new List<string>(lttvs.Keys);
            PISDK.PIPoint pt;
            for (int i = 0; i < PointList.Count; i++) {
                try {
                    pt = piServer.PIPoints[PointList[i]];
                    if ((!TagList.Contains(PointList[i])) && (pt != null)) {
                        piPointList.Add(pt);
                        TagList.Add(PointList[i]);
                    }
                }
                catch (System.Exception ex) {
                    strError += PointList[i] + ",";
                    PointList.RemoveAt(i);
                    i = i - 1;
                    continue;
                }
            }

            foreach (PIPoint Point in piPointList) {
                Console.WriteLine(Point.Name);
            }

            if (strError == "") {
                return true;
            }
            else {
                strError = "ʵʱ���ݿ���δ�ҵ��ĵ�: " + strError;
                return false;
            }
        }