@@ -39,7 +39,7 @@ public async Task Connect_Ok()
3939 var endpoint = new ConfiguredEndpoint ( null , endpointDescription , endpointConfiguration ) ;
4040
4141 // 创建会话
42- var identity = new UserIdentity ( ) ; // 匿名登录,或提供用户名密码
42+ var identity = new UserIdentity ( "BB" , "123456@163.com" ) ; // 匿名登录,或提供用户名密码
4343 var session = await Session . Create (
4444 config ,
4545 endpoint ,
@@ -79,5 +79,35 @@ public async Task FindServersAsync()
7979 sessionTimeout : 60000 ,
8080 identity : null ,
8181 preferredLocales : null ) ;
82+
83+ // Browser
84+ var browser = new Browser ( session )
85+ {
86+ BrowseDirection = BrowseDirection . Forward ,
87+ NodeClassMask = ( int ) NodeClass . Variable | ( int ) NodeClass . Object | ( int ) NodeClass . Method ,
88+ ReferenceTypeId = ReferenceTypeIds . HierarchicalReferences ,
89+ IncludeSubtypes = true ,
90+ MaxReferencesReturned = 1000
91+ } ;
92+
93+ // 浏览节点
94+ var references = browser . Browse ( ObjectIds . ObjectsFolder ) ;
95+
96+ var readValueId = new ReadValueId
97+ {
98+ NodeId = new NodeId ( "ns=2;s=Simulation Examples.Functions.Ramp1" ) ,
99+ AttributeId = Attributes . Value
100+ } ;
101+
102+ var readValues = new ReadValueIdCollection { readValueId } ;
103+
104+ // 读取节点值
105+ var resp = await session . ReadAsync (
106+ null ,
107+ 0 ,
108+ TimestampsToReturn . Both ,
109+ readValues , CancellationToken . None ) ;
110+
111+ await session . CloseAsync ( ) ;
82112 }
83113}
0 commit comments