Sonstiges DotNetSiemensPLCToolBoxLibrary - "var list"

R3DLINE

Level-1
Beiträge
9
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Hello,
i 'm sorry but i can speak only English and Italian. I wrote here because this is the only place where i can find help.
I used this library for simple tasks like connection and reading/writing simple data (like int, bit, byte) and complex data (like string and struct).
Now i need the list of the variables used in the PLC. For example i need to know all the variables declared in DB1 and their values.
Is it possible?
Thank you
Roberto
 
Zuletzt bearbeitet:
The question is in english, chrome translated it before i posted -.-'
Do you kidding me? I want to help you!
:evil:
Ciao,
i 'm dispiace ma posso solo parlare inglese e italiano. Ho scritto qui:. Perché questo è l'unico posto dove posso trovare aiuto
ho usato questa biblioteca per compiti semplici come connessione e di lettura / scrittura di (stringhe, struct) dati semplici (int, bit, byte) e complessi.
Ora ho bisogno una lista della variabile in uso nel controllore. Ad esempio, ho bisogno di sapere la variabile dichiarata in DB1 ed i loro valori.
E 'possibile?
Grazie
Roberto
http://webcache.googleusercontent.c...brary-var-list.html+&cd=1&hl=de&ct=clnk&gl=de
 
You can read the DB from the PLC with the Lib.

Maybe this Code Helps you...

Code:
[COLOR=#B4261A][FONT=Consolas][COLOR=#000000]            myConn = [/COLOR][COLOR=#0433ff]new[/COLOR][COLOR=#000000] [/COLOR][COLOR=#33a2bd]PLCConnection[/COLOR][COLOR=#000000]([/COLOR]"SimpleCSharpDemonstrationConnection"[COLOR=#000000]);[/COLOR][/FONT][/COLOR]
[FONT=Consolas]            myConn.Connect();[/FONT]
[FONT=Consolas]
[/FONT]
[FONT=Consolas]            [COLOR=#0433ff]var[/COLOR] bytes = myConn.PLCGetBlockInMC7([COLOR=#b4261a]"DB1"[/COLOR]);[/FONT]
[FONT=Consolas]            [COLOR=#0433ff]var[/COLOR] db = [COLOR=#33a2bd]MC7Converter[/COLOR].GetAWLBlock(bytes, 0) [COLOR=#0433ff]as[/COLOR] [COLOR=#33a2bd]S7DataBlock[/COLOR];[/FONT]
[FONT=Consolas]            [COLOR=#0433ff]var[/COLOR] plctagList = db.Structure.Children.Cast<[COLOR=#33a2bd]S7DataRow[/COLOR]>().Flatten(x => x.Children.Cast<[COLOR=#33a2bd]S7DataRow[/COLOR]>()).Select(x => x.PlcTag);[/FONT]
 
Thank you Jochen Kühner.

I have this error with your code:
System.Collections.Generic.IEnumerable<DotNetSiemensPLCToolBoxLibrary.DataTypes.Blocks.Step7V5.S7DataRow> don't contain a definition of Flatten

And i have another question.. if i want to list also the variables used in OB1? i can use the same method?
Thank you again
 
Zuviel Werbung?
-> Hier kostenlos registrieren
I don't understand what you mean with "if i want to list also the variables used in OB1? i can use the same method?"

The Flatten is a ExtesionMethod defined in my Assembly, you must add a using to "
DotNetSiemensPLCToolBoxLibrary.General"!

And also maybe you need the newest DLL
 
Thank you for your hints, i updated the lib and added a using statement: the code compile.
Now i have a problem at runtime.
after the call to GetAWLBlock i get a warning (index out of range) in the Class DotNetSiemensPLCToolBoxLibrary.PLCs.S7_xxx.MC7.Parameter
in the function GetVarTypeEN

Code:
case 0x11: //Struct
                    {
                        if (Arry) pos += 7;
                        Result = S7DataRowType.STRUCT;
                        var akPar = new S7DataRow(VarNamePrefix + VarCounter.ToString(), Result, myBlk) { StartValue = startVal };
                        currPar.Add(akPar);
                        VarCounter++;
                        max = interfaceBytes[pos + 2] - 1;
                        for (i = 0; i <= max; i++)
                        {






                            if ((interfaceBytes[pos + 3] == 0x11) || (interfaceBytes[pos + 3] == 0x10))   <-----HERE

I'm not sure what's happening here, but... i tried with different DB and also with a DB without struct... but the code fails always here.
Any suggestion?
 
I'm try to find the error in the call Stack...
I noticed this:
the first parameter of the function GetVarTypeEN (for the static variables) is parameterSTAT.

Code:
parameterSTAT 
{000.0: STATIC: STRUCT
000.0: 	STAT0: STRUCT
000.0: 		STAT1: STRING[0]
002.0: 		STAT1: STRING[2]
006.0: 		STAT2: STRUCT
006.0: 			STAT3: DINT
010.0: 			STAT4: DINT
014.0: 			STAT5: STRING[0]
016.0: 			STAT5: STRING[4]
}

but my db is:
http://prntscr.com/4o842d
i think there is an error when the GetAWLBlock function parse the byte array. I'm wrong?
 
Zurück
Oben