@@ -161,7 +161,6 @@ public int BrowseAllBlocks(out List<BlockInfo> exploreData)
161161 #region Evaluate all data blocks that then need to be browsed
162162
163163 var obj = exploreRes . Objects . First ( o => o . ClassId == Ids . PLCProgram_Class_Rid ) ;
164-
165164 foreach ( var ob in obj . GetObjects ( ) )
166165 {
167166 switch ( ob . ClassId )
@@ -196,10 +195,61 @@ public int BrowseAllBlocks(out List<BlockInfo> exploreData)
196195
197196 #endregion
198197
198+ return 0 ;
199+ }
200+
201+ public int GetPlcStructureXML ( out string plcStrutureXml )
202+ {
203+ int res ;
204+ Browser vars = new Browser ( ) ;
205+ ExploreRequest exploreReq ;
206+ ExploreResponse exploreRes ;
207+ plcStrutureXml = null ;
208+
209+ #region Read all objects
210+
211+ exploreReq = new ExploreRequest ( ProtocolVersion . V2 ) ;
212+ exploreReq . ExploreId = Ids . Constants | 0x0000ffff ;
213+ exploreReq . ExploreRequestId = Ids . None ;
214+ exploreReq . ExploreChildsRecursive = 1 ;
215+ exploreReq . ExploreParents = 1 ;
216+
217+ exploreReq . AddressList . Add ( Ids . ConstantsGlobal_Symbolics ) ;
218+
219+ res = SendS7plusFunctionObject ( exploreReq ) ;
220+ if ( res != 0 )
221+ {
222+ return res ;
223+ }
224+ m_LastError = 0 ;
225+ WaitForNewS7plusReceived ( m_ReadTimeout ) ;
226+ if ( m_LastError != 0 )
227+ {
228+ return m_LastError ;
229+ }
230+
231+ exploreRes = ExploreResponse . DeserializeFromPdu ( m_ReceivedPDU , true ) ;
232+ res = checkResponseWithIntegrity ( exploreReq , exploreRes ) ;
233+ if ( res != 0 )
234+ {
235+ return res ;
236+ }
237+
238+ #endregion
239+
240+ var attr = exploreRes ? . Objects ? [ 0 ] ? . Objects ? . First ( ) . Value ? . Objects ? . First ( ) . Value ? . Attributes ? [ Ids . ConstantsGlobal_Symbolics ] as ValueBlob ;
241+ if ( attr != null )
242+ {
243+ BlobDecompressor bd3 = new BlobDecompressor ( ) ;
244+ var v = attr . GetValue ( ) ;
245+ var xml = bd3 . decompress ( v , 0 ) ;
246+ plcStrutureXml = xml ;
247+ }
248+
199249 return 0 ;
200250 }
201251
202- public int GetBlockXml ( uint relid , out string blockName , out ProgrammingLanguage lang , out uint blockNumber , out string xml_linecomment , out Dictionary < uint , string > xml_comment , out string interfaceDescription , out string [ ] blockBody , out string fuctionalObjectCode , out string [ ] intRef , out string [ ] extRef )
252+ public int GetBlockXml ( uint relid , out string blockName , out ProgrammingLanguage lang , out uint blockNumber , out BlockType blockType , out string xml_linecomment , out Dictionary < uint , string > xml_comment , out string interfaceDescription , out string [ ] blockBody , out string fuctionalObjectCode , out string [ ] intRef , out string [ ] extRef )
203253 {
204254 int res ;
205255 // With requesting DataInterface_InterfaceDescription, whe would be able to get all informations like the access ids and
@@ -215,6 +265,7 @@ public int GetBlockXml(uint relid, out string blockName, out ProgrammingLanguage
215265 blockName = null ;
216266 lang = ProgrammingLanguage . Undef ;
217267 blockNumber = relid & 0xffff ;
268+ blockType = BlockType . unkown ;
218269
219270 var exploreReq = new ExploreRequest ( ProtocolVersion . V2 ) ;
220271 exploreReq . ExploreId = relid ;
@@ -254,7 +305,16 @@ public int GetBlockXml(uint relid, out string blockName, out ProgrammingLanguage
254305 }
255306
256307 foreach ( var obj in exploreRes . Objects )
257- {
308+ {
309+ blockType = obj . ClassId switch
310+ {
311+ Ids . DB_Class_Rid => BlockType . DB ,
312+ Ids . FB_Class_Rid => BlockType . FB ,
313+ Ids . FC_Class_Rid => BlockType . FC ,
314+ Ids . OB_Class_Rid => BlockType . OB ,
315+ } ;
316+
317+
258318 foreach ( var att in obj . Attributes )
259319 {
260320 switch ( att . Key )
0 commit comments