Hochladen von Bausteinen in eine S7 300 SPS

reniviech

Level-1
Beiträge
3
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Hallo zusammen...

Ich habe folgendes Problem:

Zu Schulungszwecken haben ich einen SPS Arbeitsplatz eingerichtet bestehend aus:

- PC mit Windows XP Pro
- Step 7 Pro
- Siemens PC Adapter über USB
- Siemens S7 314 2DP resp. 315 DP/PN
- Mechatronik (Versuchsaufbau)

Der Arbeitspaltz soll nun so eingerichtet werden, dass wenn der Computer neu gestartet wird oder der Benutzer es wünscht, eine definierte Projektierung (Programm + Systemdaten) auf die SPS geladen wird.

Habe mich schon durch diverse Beiträge in Foren gekämpft, habe aber ausser dem Einsatz LibNoDave keine Möglichkeit gefunden mein Problem zu lösen (bei LibNoDave habe ich einige Bedenken, da der Upload-Vorgang von SPS zu SPS verschieden sein kann).

Hat jemand eine Idee für mein Problem zu lösen oder kennt sich jemand mit der "Upload-Funktion" von LibNoDave aus?

Für Hilfe währe ich sehr dankbar

Freundliche Grüsse
 
Die Kommandoschnittstelle von Step 7 bietet auch eine Funktion "Download" für Blocks und HW-Konfig an.
Da Step 7 auf allen Rechnern vorhanden ist sollte es auch damit gehen.

Leider ist diese Schnittstelle äußerst spärlich dokumentiert.
 
Für alle die, die den Beitrag lesen und sich für die Kommandoschnittstelle von Step7 intressieren:
https://www.automation.siemens.com/WW/forum/guests/PostShow.aspx?PostID=20419&language=de

Zur Kommandoschnittstelle mal ein passender Codeschnipsel von mir in C#

Code:
static void DownloadProgram(string projectName, string programName)
{
    Simatic S = new Simatic();

    Console.WriteLine("Anzahl Bausteine gesamt: " + S.Projects[projectName].Programs[programName].Next["Bausteine"].Next.Count);

    foreach (S7Block bl in S.Projects[projectName].Programs[programName].Next["Bausteine"].Next)
    {
        Console.WriteLine("Block: " + bl.Name + "\t Type: " + bl.ConcreteType);
        if (bl.ConcreteType == S7BlockType.S7DB)
        {
            Console.WriteLine("Starte Download...");
            try
            {
                bl.Download(S7OverwriteFlags.S7OverwriteAll);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Fehler bei Download" + ex);
            }
        }
    }
}
Es werden dort z.B. nur die Datenbausteine hochgeladen.
Die PG/PC Schnittstelle muss vorher passend eingstellt sein. Vielleicht kann man die Konfiguration aber auch durch ein PG mit aktivierter Schnittstelle in NetPro passend setzen lassen - das habe ich noch nicht probiert.

Aufrufen kann man das dann mit
Code:
DownloadProgram("RegelTest", "S7-Programm(1)");
 
Hallo Thomas_v2.1,

es ist sehr interssant was du da machst, ich wollte es gleich mal ausprobieren. Leider habe ich mit C# noch kaum Erfahrung.

Daher die Frage:
wie wird das OLE Objekt "Simatic" in C# (Visual Studio 2008) bekannt gemacht ?

In Visual Basic 6 musste man zusätzliche Objekte in der IDE einstellen und konnte diese dann verwenden.

mfg. klaly
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Hier bin ich nochmal,

das Einbinden des Objekts "Simatic" ist mir nun gelungen.
1. Objektbrowser Benutzerdefinierte Komponenten die SimaticLib hinzufügen
2. using SimaticLib; verwenden.

Leider funktioniert das Objekt aber nicht wie gewünscht.

Näheres muß ich erst noch herausfinden.

mfG. klaly
 
Hallo Klaly,
die meisten Beispielcodes in der Dokumentation sind doch sogar in VB6.

Ich hatte mir mal notiert, dass Verweise auf Simatic x.y Type Library und S7hcom_x x.y Type Library hinzugefügt werden müssen.

Die dazugehörigen DLLs befinden sich unter STEP7/S7bin/s7abatcx.dll und STEP7/S7bin/s7hcom_x.dll.

Falls nicht vorhanden, muss der Pfad C:\Siemens\Step7\S7Bin noch zum Suchpfad (PATH Systemvariable) hinzugefügt werden.
 
Hallo zusammen,

ich arbeite momentan mit der Kommandoschnittstelle,
und benutze dafür Visual C# Express 2010.

Momentan bin ich soweit dass ich mir alle vorhandenen Projekte auflisten lassen kann. Daraus ein Projekt auswählen und dieses dann nochmals zu Selektieren.

Dies erledige ich momentan nur mittels einer Konsolenanwendung.
Da ich ersteinmal die Grundfunktion fertig stellen möchte bevor ich das ganze in eine Windows Form Anwendung baue.

Irgendwie werd ich aus der Hilfe zur Kommandoschnittstelle nicht weiter schlau. Oder ich seh den ganzen Wald vor lauter Bäumen nicht.

Ich würde mir nun gerne aus einem ausgewählten Programm,
die AWL Quelle generieren, und eine Referenzdatei.
Die Referenzdatei soll am besten alle Querverweise zeigen.

Könnte mir vll. jemand einen Tipp geben welche Befehle ich benötige um mir diese Dateien erstellen zu lassen?

Mein Bisheriger Code ist folgender:
Code:
[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] S7HCOM_XLib;[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]using[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] SimaticLib;[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af].[/COLOR][/SIZE][/FONT]
[SIZE=2][FONT=Consolas][COLOR=#2b91af].[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=Consolas][COLOR=#2b91af].[/COLOR][/FONT][/SIZE]
[SIZE=2][FONT=Consolas][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=#000000] Main([/COLOR][/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=#000000])[/COLOR][/SIZE][/FONT][/SIZE][/FONT]
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=#000000]{[/COLOR][/SIZE][/FONT]
[/SIZE][/FONT]Simatic[/COLOR][/FONT][/SIZE][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] S = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Simatic[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]();[/SIZE][/FONT][/SIZE][/FONT]
 
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]foreach[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]S7Project[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] Proj [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]in[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] S.Projects)[/SIZE][/FONT]
[SIZE=2][FONT=Consolas]{[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]   Console[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].WriteLine(Proj.Name);[/SIZE][/FONT]
[SIZE=2][FONT=Consolas]}[/FONT][/SIZE]
[SIZE=2][FONT=Consolas]
[SIZE=2][FONT=Consolas][COLOR=#0000ff][SIZE=2][FONT=Consolas][COLOR=#0000ff][SIZE=2][FONT=Consolas][COLOR=#0000ff]string[/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][/COLOR][/FONT][/SIZE][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sPrjName = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2];[/SIZE][/FONT][/SIZE][/FONT]
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].WriteLine([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"Projektname eingeben"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]);[/SIZE][/FONT]
[SIZE=2][FONT=Consolas]sPrjName = [/FONT][/SIZE][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].ReadLine();[/SIZE][/FONT][/SIZE][/FONT]
 
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]foreach[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]S7Program[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] Proj_Select [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]in[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] S.Projects[sPrjName].Programs)[/SIZE][/FONT]
[SIZE=2][FONT=Consolas]{[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]   Console[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].WriteLine(Proj_Select.Name);[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]}[/SIZE][/FONT]
 
[SIZE=2][FONT=Consolas][COLOR=#0000ff]string[/COLOR][/FONT][/SIZE][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sPrjName_Select = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]""[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2];[/SIZE][/FONT][/SIZE][/FONT]
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].WriteLine([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"Selektiertes Projekt eingeben"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]);[/SIZE][/FONT]
[SIZE=2][FONT=Consolas]sPrjName_Select = [/FONT][/SIZE][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].ReadLine();[/SIZE][/FONT]
 
[SIZE=2][FONT=Consolas].[/FONT][/SIZE][/SIZE][/FONT]
.
.
// Nun würde ich mir gerne aus dem Ausgewählten Projekt die oben erwähnten
// Dateien erstellen lassen
 
[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]
[/FONT][/SIZE][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT]

Ich hoffe ich Poste diesen Beitrag richtig, es war der einzigste wo bereits C# angesprochen wurde. Zumindest habe ich durch die SuFu nichts gefunden.

Beste Grüße
Bernhard
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Hi,
das mit dieser Funktion habe ich das mal getestet:
Code:
        static void exportBlocks(string projectName, string programName, string blockContName, S7BlockType type)
        {
            Simatic S = new Simatic();
            string filename;

            Console.WriteLine("Blocks overall: " + S.Projects[projectName].Programs[programName].Next[blockContName].Next.Count);

            foreach (S7Block bl in S.Projects[projectName].Programs[programName].Next[blockContName].Next)
            {
                if (bl.ConcreteType == type) // z.B. S7BlockType.S7DB
                {
                    filename = "C:\\Temp\\export\\" + bl.Name + ".awl";
                    Console.WriteLine("Exporting source to: " + filename);
                    try
                    {          
                        bl.GenerateSource(filename, S7GenerateSourceFlags.S7GSFDoOverwrite);                        
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error: " + ex);
                    }
                }
            }
        }

Aufzurufen wäre das mit:
Code:
exportBlocks("MyProject", "S7-Programm", "Bausteine", S7BlockType.S7FC);

um alle FCs zu exportieren.
 
Hi Thomas,

wow genial Dankeschön für die Blitzantwort.

Werd das ganze gleich morgen Testen. Deine Antwort ist ja schon so gut wie die ganze Lösung. Ein Tipp hätte mir eigentlich gereicht, aber du ersparst mir einige "grübel" Arbeit. :)

Nochmals Dankeschön, der Rest sollte ich ja dann das kleinere Übel sein :ROFLMAO:
 
Hi zusammen,

da es das letzte mal mit dem Code so gut funktioniert hat,
steh ich nun entweder komplett auf dem Schlauch oder ich kapier es einfach nicht.

Code:
[FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] vCreateRefData([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sProjectName, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sProgramName)[/SIZE][/FONT]
[SIZE=2][FONT=Consolas]{[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]List[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]<[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]> Error = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]new [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]List[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]<[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]>(); //Liste die alle Fehler enthält[/SIZE][/FONT][/SIZE][/FONT]
 
[FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Simatic[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] S = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]new [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Simatic[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]();[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]S7ProgramClass[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ProgramClass = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]new [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]S7ProgramClass[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]();[/SIZE][/FONT][/SIZE][/FONT]
 
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]S.Projects[sProjectName].Programs[sProgramName]....??[/SIZE][/FONT]
[/SIZE][/FONT][SIZE=2][FONT=Consolas] [/FONT][/SIZE]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]try[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]{[/SIZE][/FONT]
     [/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]ProgramClass[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].IS7Program3_ExportProgramStructure([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"D:\\REFDATA.dif"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], 0);.....??[/SIZE][/FONT]
[SIZE=2][FONT=Consolas]}[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]catch[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Exception[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ex)[/SIZE][/FONT]
[SIZE=2][FONT=Consolas]{[/FONT][/SIZE]
     [SIZE=2][FONT=Consolas]ERROR.Add(ex.ToString());[/FONT][/SIZE]
[SIZE=2][FONT=Consolas]}[/FONT][/SIZE]
[/SIZE][/FONT]
Aufruf mit
Code:
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]vCreateRefData(sChosenProjektName, sChosenProgramName);[/SIZE][/FONT]
[/SIZE][/FONT]
Ich weis dass hier noch ein bisschen was fehlt. Aber das is das wo ich auf dem "Schlauch" stehe.
Und zwar muss ich ja zuerst definieren welches Projekt und Unterprogramm ich auswähle.
Hätte gedacht ich mache das mit:
Code:
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]S.Projects[sProjectName].Programs[sProgramName][/SIZE][/FONT]
[/SIZE][/FONT]
Aber nun steh ich vor dem Ende....
Wie erkläre ich "Program.IS7Program3_ExportProgramStructure()" dass er das ausgewählte Projekt und das unterprojekt auswählt und daraus die Referenzdaten erstellt?

Desweitern werden zur erstellung der Referenzdaten ja die "ColumnFlags" genutzt. Das wäre ja z.B. "S7XXCSymbols" oder "S7XXCSymbolComments" und in der beschreibung steht man solle ihr eine "(Ver-Oder-ung)" übergeben. Wie kann ich mir hier denn die Übergabe vorstellen?

Sorry für die vielen Fragen,

aber vll. hat jemand die Geduld mir ein bisschen auf die Sprünge zu helfen.

Beste Grüße
 
Zuletzt bearbeitet:
Zuviel Werbung?
-> Hier kostenlos registrieren
EDIT:

hab die Lösung selber gefunden, ich weiß zwar nicht
ob es die optimale Lösung ist, aber es funktioniert zumindest :)

Code:
[FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] vCreateRefData([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sProjectName, [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] sProgramName)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]List[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]<[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]> ERROR = [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]List[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]<[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]>();
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]foreach[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]S7Program[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] Program [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]in[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] S.Projects[sProjectName].Programs)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] (Program.Name == sProgramName)
{
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]try
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]{
Program.ExportProgramStructure([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515][FONT=Consolas][SIZE=2][COLOR=#a31515]"D:\\REFDATAEXPORT.dif"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], 0);
}
[/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff][FONT=Consolas][SIZE=2][COLOR=#0000ff]catch[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]Exception[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ex)
{
ERROR.Add(ex.ToString());
} 
} 
}
[/SIZE][/FONT][/SIZE][/FONT]

es werden mir nun die Referenzdaten exportiert.
Falls jemand eine andere Lösung ohne "foreach" und "if" hat.
Bitte lasst es mich wissen.

Beste Grüße
Bernhard
 
Hallo,

kann mir bitte mal jemand ein c# programm zeigen, welches ohne OLE-Fehler (VS2008) funktioniert um damit Bausteile zu laden?

Vielen Dank!

Hast du schon einen Versuch gemacht, den du uns zeigen kannst?
Dann können wir sehen wo dein Problem bzw dein Fehler liegt.


bike
 
Folgendes habe ich programmiert:
exportBlocks("Rack_101", "Rack_101", "Bausteine", S7BlockType.S7FC);
}

staticvoid exportBlocks(string projectName, string programName, string blockContName, S7BlockType type)

Passen den der Projektname und der Programmname?

In deinem Fall würde das Projekt "Rack_101" und der Programmordner ebenfalls "Rack_101" heißen. Kann durchaus sein, aber ich ändere den Programmordnernamen eigentlich selten, und per Default legt der Step7 Manager diese mit Namen "S7-Programm" und evtl. einer angehängten Nummer an.

Und mein Code ist nur ein Beispiel wie es grundsätzlich geht. Deine Fehlerbehandlungen musst du schon selber drumzustricken.
Wenn du das passend gemacht hättest, würde es in der Exception sicher eine aussagekräftigere Meldung geben.
 
Zurück
Oben