基本信息
源码名称:访问网关WEB范例(C#)
源码大小:1.59M
文件格式:.zip
开发语言:C#
更新时间:2018-09-25
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 5 元 
   源码介绍

OPC XML-DA规范的WEB接口,允许具有开发能力的用户可以通过C#或者Java访问网关

 XMLWrapper.OPC_XML_DA_WrapperService service = new XMLWrapper.OPC_XML_DA_WrapperService();
            service.Url = txtUrl.Text;

            ReadRequestItemList iList = new ReadRequestItemList();
            RequestOptions Options = new RequestOptions
            {
                ReturnItemTime = true,
                ReturnItemName = true,
                LocaleID = "en-US",
                ClientRequestHandle = ""
            };

            iList.Items = new ReadRequestItem[m_list.Count];

            for (int i = 0; i < m_list.Count; i )
            {
                iList.Items[i] = new ReadRequestItem();
                iList.Items[i].ClientItemHandle = i.ToString();
                iList.Items[i].ItemName = m_list[i].OPCName;
            }

            ReplyItemList rVal;
            OPCError[] Errors;
            ReplyBase reply;
            try
            {
                reply = service.Read(Options, iList, out rVal, out Errors);
                if (rVal.Items.Count() > 0)
                {
                    foreach (ItemValue it in rVal.Items)
                    {
                        int n = Convert.ToInt32(it.ClientItemHandle.ToString());
                        m_list[n].OPCValue = it.Value.ToString();
                        m_list[n].OPCTime = DateTime.Now.ToString();
                    }

                    dataGridView1.Refresh();
                }
            }
            catch (Exception excp)
            {
                MessageBox.Show(excp.Message);
            }
            finally
            {
            }