Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可否添加数据组的管理? #18

Open
wuyang26 opened this issue Mar 16, 2020 · 1 comment
Open

可否添加数据组的管理? #18

wuyang26 opened this issue Mar 16, 2020 · 1 comment

Comments

@wuyang26
Copy link

就是对一组数据的批量刷新,批量更新的类,譬如在实际的客户端,在某一个当前页面,可能只更新30个特定变量,在另一个页面又是另一些特定变量,用组对数据进行管理可进一步简化读写操作。
我在本项目的基础上实现了一个简单的,思路类似如下:
DataItem.cs用于存储当前读取到的单个变量,最重要的是public void Refresh(DataValue dataValue)
DataGroup.cs对批量数据进行管理:
public DataGroupBase(List<string> keyList, List<string> tagList, OpcUaClient opcUaClient)
存储变量:
public Dictionary<string,DataItemBindable> Data { get;private set; }

public virtual async Task<FeedbackInfo> ReadAsync()

public virtual async Task<FeedbackInfo> WriteAsync()
对Data进行批量操作
而订阅更新的关键代码:
Data[itemKey].Refresh(notification.Value);
外部访问 Data[keyName]
目前这种方式用在WPF中非常方便,DataItem实现了数据通知(NET Standard不能实现,必须另创建一个库),在XAML中的控件只需要简单的
进行绑定,并指向KeyName即可(Word1为变量在字典中的Key):
<TextBox Text="{Binding Data[Word1].Value,Mode=TwoWay}"/>

@dathlin
Copy link
Owner

dathlin commented Mar 18, 2020

嗯,可以发起request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants