python-snap7 icon indicating copy to clipboard operation
python-snap7 copied to clipboard

function to match the native DB TIA portal export with the python snap 7 db specification layout

Open Novecento99 opened this issue 1 year ago • 11 comments

Hi,

the siemens tia portal permits the export of a DB in a semi automatic method (copy and paste the view). The result is a text like this:

anotherTest	Byte	1.0	16#0	---	False	True	True	True	False		
test test	String	2.0	''	---	False	True	True	True	False		
lole	Byte	258.0	16#0	---	False	True	True	True	False	

the DB layout specification of this library is currently formatted as follow,:

24.0	LockAct		    BOOL
24.1	GrpErr		    BOOL
24.2	RuyToStart	    BOOL
24.3	RdyToReset	    BOOL
24.4	LocalAct	    BOOL
24.5	AutAct		    BOOL
24.6	ManAct		    BOOL
24.7	OoSAct		    BOOL

Since a DB can contain thousands of variables modified daily (by machine manufacturers for example) converting the native TIA export to this db layout is source of errors and fatigue

I decided to firstly create an utiliy function that convert the native tia layout to the current accepted layout as a starting point that therefore can pass the string argument as the db specification

The ideal solution could be directly change the DB layout format that snap7 library takes in and therefore the parsing block.

let me know your thoughts

thanks

Novecento99 avatar Aug 05 '24 08:08 Novecento99

Nice ! I a have, do locally a branch, the same, with interpretation from Inputs/Outputs/Merk and DB with the S7 PLCTags.xml generated from SIMANTIC Manager and WinCC Tag Converter

But with TIA, I am blocked with non-optimized DB's that aren't exported in the PLCTags.xml

lupaulus avatar Aug 25 '24 20:08 lupaulus

Nice ! I a have, do locally a branch, the same, with interpretation from Inputs/Outputs/Merk and DB with the S7 PLCTags.xml generated from SIMANTIC Manager and WinCC Tag Converter

But with TIA, I am blocked with non-optimized DB's that aren't exported in the PLCTags.xml

wait let me understand better: you made a branch to ingest input/outputs/merk/db through an .xml generated by the winCCconverter. It is also able to read/write optimized dbs?

Novecento99 avatar Aug 26 '24 07:08 Novecento99

Hi nice work / effort.

When I created the first version of this layout parsing code I copy pasted the DB information / the view from inspecting the DB object in siematic.manager i think. I discovered that the layout often required manual edits amd changes. Sometimes the starting point of the entire DB object was just moved.

I did not find a reliable way to just access a DB objects layout. How DB object ended up in a plc seemed a bit unpredicatble for me.

If there is a way that can reliable work to extract that information that would be awesome!

Cheers,

Stephan.

spreeker avatar Aug 26 '24 07:08 spreeker

Hi, thankyou

what I want to add, is the possibility to copy and paste the view from the TIA portal to a file and therefore use it to construct a db object. I'm not familiar with the simatic manager, I've never used it actually. Does it permit to access optimized DBs?

Novecento99 avatar Aug 26 '24 07:08 Novecento99

also, a discussion that I would like to brought up is about the arrays of structs. There will be multiple variables with the same name.. how to manage them ? A possibility, that I implemented for a specific case, is to assign a number at the end of the name which increases if there are duplicates

Novecento99 avatar Aug 26 '24 07:08 Novecento99

Nice ! I a have, do locally a branch, the same, with interpretation from Inputs/Outputs/Merk and DB with the S7 PLCTags.xml generated from SIMANTIC Manager and WinCC Tag Converter But with TIA, I am blocked with non-optimized DB's that aren't exported in the PLCTags.xml

wait let me understand better: you made a branch to ingest input/outputs/merk/db through an .xml generated by the winCCconverter. It is also able to read/write optimized dbs?

No, optimized or non optimized db, because the export of the variable in TIA doesn't include DB's variables. I talked with Siemens people, they say, there would be the SCADA export possibility, but it is encrypted or the DB file (.db) as plain text that need to be reinterpreted...

For the moment, on TIA Project, I use OPC UA with the XML that can be exported from TIA or only the variable table from TIA (Inputs/Output/Merkers)

lupaulus avatar Aug 26 '24 20:08 lupaulus

Hi, thankyou

what I want to add, is the possibility to copy and paste the view from the TIA portal to a file and therefore use it to construct a db object. I'm not familiar with the simatic manager, I've never used it actually. Does it permit to access optimized DBs?

Optimized DB's didn't exist, at the time of Simatic Manager.

lupaulus avatar Aug 26 '24 20:08 lupaulus

also, a discussion that I would like to brought up is about the arrays of structs. There will be multiple variables with the same name.. how to manage them ? A possibility, that I implemented for a specific case, is to assign a number at the end of the name which increases if there are duplicates

In the case you want to handle custom Structs, I would prefer use OPC UA, because of the description of the Struct built in the export

lupaulus avatar Aug 26 '24 20:08 lupaulus

also, a discussion that I would like to brought up is about the arrays of structs. There will be multiple variables with the same name.. how to manage them ? A possibility, that I implemented for a specific case, is to assign a number at the end of the name which increases if there are duplicates

In the case you want to handle custom Structs, I would prefer use OPC UA, because of the description of the Struct built in the export

well I would prefer it too, except it seems too slow for some applications that I need to implement. For the moment, I just added "_0", "_1" , "_X" to the variabile name in case of arrays and it works

Novecento99 avatar Aug 27 '24 06:08 Novecento99

also, a discussion that I would like to brought up is about the arrays of structs. There will be multiple variables with the same name.. how to manage them ? A possibility, that I implemented for a specific case, is to assign a number at the end of the name which increases if there are duplicates

In the case you want to handle custom Structs, I would prefer use OPC UA, because of the description of the Struct built in the export

well I would prefer it too, except it seems too slow for some applications that I need to implement. For the moment, I just added "_0", "_1" , "_X" to the variabile name in case of arrays and it works

I did the same lol for arrays

lupaulus avatar Aug 27 '24 16:08 lupaulus

okay, I'm going to implement the changes then, I will submit a new cleaner PR, this one has the commits of my last one....

Novecento99 avatar Aug 28 '24 06:08 Novecento99