| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 381 人关注过本帖
标题:委托已回收
只看楼主 加入收藏
chenfeng21g
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2012-8-24
结帖率:50%
收藏
 问题点数:0 回复次数:1 
委托已回收
源码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using OnlineSigmatek;

namespace RefreshListSample
{
    /// <summary>
    /// Interaktionslogik für Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        int iRlb;
        Lasal32.SRLVarInfo var1;
        Lasal32.SRLVarInfo var2;
        uint VarID;
        int Data;
        public Window1()
        {
            InitializeComponent();
            this.iRlb = 0;
            this.var1 = new Lasal32.SRLVarInfo();
            this.var2 = new Lasal32.SRLVarInfo();
           
        }


        // delegate
        public void RefListCallBack(uint dwCallbackData, uint dwAddr, uint dwVarID, int nData)
        {
            Console.WriteLine("Id=" + dwVarID.ToString() + " Data=" + nData.ToString());
            // dwCallbackData ... will be 2345 (user specified)
            // dwAddr ........... lasalid of changed server
            // dwVarID .......... will be 88 or 99 (user specified)
            // nData ............ changed value (datasize <= 32bit) or crc32 of changed data (datasize > 32bit)
            //... // user has to act on changed value
            VarID = dwVarID;
            Data = nData;
            textBox1.Text = VarID.ToString();
            textBox2.Text = Data.ToString();
        }


        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Lasal32.CB_RLADD_FUNCTYPE methptr = new Lasal32.CB_RLADD_FUNCTYPE(RefListCallBack);

            this.iRlb = Lasal32.LslRefreshListCreateExt("TCP:10.10.150.37;ApplID=10", 0, 0, 0, null, methptr, 2345, 10000);
            if (this.iRlb != 0)
            {
                if (Lasal32.LslRefreshListGetVarInfo(this.iRlb, "Obj_Csharptest.ListServer", ref this.var1) == true)
                    Lasal32.LslRefreshListAdd(this.iRlb, ref this.var1, 88, 100, Lasal32.CpReflist.RF_DYNAMIC); // add entry to refreshlist
                if (Lasal32.LslRefreshListGetVarInfo(this.iRlb, "Obj_Csharptest.Position", ref this.var2) == true)
                    Lasal32.LslRefreshListAdd(this.iRlb, ref this.var2, 99, 100, Lasal32.CpReflist.RF_DYNAMIC);  // add entry to refreshlist
                // ... add some more if you want

                Lasal32.LslRefreshListStart(this.iRlb, Lasal32.CpReflist.RF_DYNAMIC); // start refreshlist
                // ... watch outputwindow
              
            }

        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if(this.iRlb != 0)
                Lasal32.LslRefreshListDestroy(this.iRlb); // destroy refreshlist
        }
    }
}
搜索更多相关主题的帖子: namespace 回收 
2013-02-19 16:02
chenfeng21g
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2012-8-24
收藏
得分:0 
老师好,我在委托里面设断点测试了下,PLC值改变时可以触发C#,但是正常运行时会报委托已回收,要保证委托处于活动状态。
我想得到的效果是PLC有值发生变化时,C#能立即反应出来,这个要做怎么的修改 求指教。谢谢
2013-02-19 16:05
快速回复:委托已回收
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029991 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved