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

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

Closed
wants to merge 18 commits into from

Conversation

Novecento99
Copy link
Contributor

@Novecento99 Novecento99 commented Aug 5, 2024

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

@lupaulus
Copy link
Contributor

lupaulus commented Aug 25, 2024

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

@Novecento99
Copy link
Contributor Author

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?

@spreeker
Copy link
Collaborator

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.

@Novecento99
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@lupaulus
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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

@Novecento99
Copy link
Contributor Author

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

@lupaulus
Copy link
Contributor

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

@Novecento99
Copy link
Contributor Author

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 Novecento99 closed this Sep 9, 2024
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

Successfully merging this pull request may close these issues.

3 participants