コード例 #1
0
        private void BtnAddAll_Click(object sender, RoutedEventArgs e)
        {
            if (!_OpcClient.IsConnected)
            {
                Msg("请先连接服务器");
                return;
            }
            tagModals = new List <TagInfoModal>();
            List <TagItem> items = _OpcClient.GetUserItems();

            foreach (var i in items)
            {
                i.CallBack = TagCallBack;
                tagModals.Add(new TagInfoModal()
                {
                    ID       = i.Id,
                    ServerID = i.ServerId,
                    TagName  = i.Name,
                    Value    = i.Value?.ToString(),
                    Quality  = i.Quality
                               //Timesnamp = i.Timestamp?.ToString("yyyy-mm-dd HH:mm:ss:fff")
                });
            }

            DgTagInfo.ItemsSource = tagModals;
            _OpcClient.AddSubscription(items);
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: storm12/OpcHelper
        private void BtnAddAll_Click(object sender, RoutedEventArgs e)
        {
            if (!_OpcClient.IsConnected)
            {
                Msg("请先连接服务器");
                return;
            }
            tagModals = new List <TagInfoModal>();
            List <TagItem> items = _OpcClient.GetUserItems();

            /*
             * items = new List<TagItem>();
             * items.Add(new TagItem() { ServerId = "K-CU01_A_LIGHT#K-CU01_A_ERROR" });
             * items.Add(new TagItem() { ServerId = "POWER_B_STATUS#POWER_B_INSERT" });
             */
            foreach (var i in items)
            {
                i.CallBack = TagCallBack;
                tagModals.Add(new TagInfoModal()
                {
                    ID       = i.Id,
                    ServerID = i.ServerId,
                    TagName  = i.Name,
                    Value    = i.Value?.ToString(),
                    Quality  = i.Quality
                               //Timesnamp = i.Timestamp?.ToString("yyyy-mm-dd HH:mm:ss:fff")
                });
            }



            DgTagInfo.ItemsSource = tagModals;
            //_OpcClient.AddSubscription(new TagItem(){ ServerId = "POWER_B_STATUS.POWER_B_INSERT" });
            IList <TagItem> addSubscription = _OpcClient.AddSubscription(items);
        }