TIA Bibliothek zur Erstellung von KOP Code via C# in TIA

Wenn ich sowas benötigen würde, dann würde ich überlegen als Eingangs-Programm SCL-Code zu verwenden, und dieses in KOP/FUP zu übersetzen. Ggf. muss man dann im SCL Code ein paar spezielle Anweisungen einbauen können (evtl. als Kommentar //@KOP: xyz //@KOP: NeuesNetzwerk) und einige Sonderkonstrukte in KOP/FUP erzeugen zu können.
Es gab ja mal eine TIA Version (V11) in der man sich den Zwischencode vom Übersetzungsvorgang ausgeben lassen konnte. Da hatte ich mir schon überlegt, dass es für Siemens eigentlich relativ einfach wäre, bestimmten SCL Code auch in KOP/FUP übersetzen zu können.
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Man kann ja immer noch einen SCL Parser bauen und das tun. Der könnte ja dann eine Objektstruktur aus dieser Bibliothek zurückgeben (wenn es das einfacher macht).
Wobei ich dann wahrscheinlich zuerst einen AWL nach KOP bauen würde.

Wir haben halt KOP Code erzeugen wollen, und brauchten etwas um es einfacher zu machen da man das XML recht komplex zusammenbauen muss (nicht wie früher awl anweisungen aneinanderreihen). Es funktioniert für das was wir es im Moment nutzen.
 
Im Code gehört bestimmt auch einiges aufgeräumt. Problem ist wir sind das bei den einfachen Verknüpfungen am anfang recht naiv angegangen, und dann musste überall noch zeugs erweitert werden.

Aber er funktioniert :)
Und Refactorn kann man ja jederzeit
 
finde ich auch.
nur dieses C Konstrukt ist besser lesbar als der Siemens XML. Mit ging es darum eine abstraktion zu schaffen um den xml zu generieren.
um direkt aus awl den xml zu machrn bräuchte ich auch irgendwelche objekte dazwischen.

Der C# code soll nicht als syntax da sein um eine logik zu verstehen, er soll einem arbeit abnehmen wenn man xml für KOP Bausteine erstellen will, da dies meiner Meinung nach sehr konplex wird.
 
Wie ist denn der Aufbau dieser XML-Dateien, entspricht das einem gerichteten Graphen, oder wie hängt das zusammen?

Ich finde Openess auch sehr unglücklich gestaltet. Ich habe mir das nur einmal angesehen und kurz getestet was damit möglich ist, und mein Testprogramm hat dann bei einer neuen TIA Version gleich nicht mehr funktioniert weil die etwas geändert haben. Für kleine Firmen ist das aufgrund des Entwicklung- und Wartungsaufwandes meiner Meinung nach nicht sonderlich brauchbar.
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Bspw:

sample3.png

sieht in XML so aus:

Code:
<NetworkSource><FlgNet xmlns="http://www.siemens.com/automation/Openness/SW/NetworkSource/FlgNet/v1">
<Parts>
<Access Scope="LocalVariable" UId="21">
<Symbol>
<Component Name="Bool1">
</Component>
<Address Area="None" Type="Bool" BlockNumber="0" BitOffset="0" Informative="true" />
</Symbol>
</Access>
<Access Scope="LocalVariable" UId="22">
<Symbol>
<Component Name="Bool4">
</Component>
<Address Area="None" Type="Bool" BlockNumber="0" BitOffset="0" Informative="true" />
</Symbol>
</Access>
<Access Scope="LocalVariable" UId="23">
<Symbol>
<Component Name="Bool3">
</Component>
<Address Area="None" Type="Bool" BlockNumber="0" BitOffset="0" Informative="true" />
</Symbol>
</Access>
<Access Scope="LocalVariable" UId="24">
<Symbol>
<Component Name="Bool2">
</Component>
<Address Area="None" Type="Bool" BlockNumber="0" BitOffset="0" Informative="true" />
</Symbol>
</Access>
<Access Scope="LocalVariable" UId="25">
<Symbol>
<Component Name="Bool1">
</Component>
<Address Area="None" Type="Bool" BlockNumber="0" BitOffset="0" Informative="true" />
</Symbol>
</Access>
<Part Name="Contact" UId="26" /><!-- #Bool2 -->
<Part Name="Contact" UId="27" /><!-- #Bool3 -->
<Part Name="Contact" UId="28" /><!-- #Bool1 -->
<Part Name="Contact" UId="29" /><!-- #Bool4 -->
<Part Name="O" UId="30">
<TemplateValue Name="Card" Type="Cardinality">2</TemplateValue>
</Part>
<Part Name="Coil" UId="31"/><!-- #Bool1 -->
</Parts>
<Wires>
<Wire UId="32">
<Powerrail />
<NameCon UId="26" Name="in" />  <!-- #Bool2 -->
</Wire>
<Wire UId="33">
<IdentCon UId="25" />  <!-- #Bool1 -->
<NameCon UId="31" Name="operand" />  <!-- #Bool1 -->
</Wire>
<Wire UId="34">
<IdentCon UId="24" />  <!-- #Bool2 -->
<NameCon UId="26" Name="operand" />  <!-- #Bool2 -->
</Wire>
<Wire UId="35">
<IdentCon UId="23" />  <!-- #Bool3 -->
<NameCon UId="27" Name="operand" />  <!-- #Bool3 -->
</Wire>
<Wire UId="36">
<IdentCon UId="21" />  <!-- #Bool1 -->
<NameCon UId="28" Name="operand" />  <!-- #Bool1 -->
</Wire>
<Wire UId="37">
<IdentCon UId="22" />  <!-- #Bool4 -->
<NameCon UId="29" Name="operand" />  <!-- #Bool4 -->
</Wire>
<Wire UId="38">
<NameCon UId="28" Name="out" />  <!-- #Bool1 -->
<NameCon UId="29" Name="in" />  <!-- #Bool4 -->
</Wire>
<Wire UId="39">
<NameCon UId="27" Name="out" />  <!-- Signal(#Bool3) -->
<NameCon UId="30" Name="in1" />  <!-- Or (Signal(#Bool3),And (Signal(#Bool1),Signal(#Bool4))) -->
</Wire>
<Wire UId="40">
<NameCon UId="29" Name="out" />  <!-- And (Signal(#Bool1),Signal(#Bool4)) -->
<NameCon UId="30" Name="in2" />  <!-- Or (Signal(#Bool3),And (Signal(#Bool1),Signal(#Bool4))) -->
</Wire>
<Wire UId="41">
<NameCon UId="26" Name="out" />
<NameCon UId="27" Name="in" />
<NameCon UId="28" Name="in" />
</Wire>
<Wire UId="42">
<NameCon UId="30" Name="out" />  <!-- Or -->
<NameCon UId="31" Name="in" />  <!-- Signal (#Bool1) -->
</Wire>
</Wires>
</FlgNet></NetworkSource>
 
oder das:
sample1.png
Code:
<NetworkSource><FlgNet xmlns="http://www.siemens.com/automation/Openness/SW/NetworkSource/FlgNet/v1">
<Parts>
<Access Scope="LocalVariable" UId="21">
<Symbol>
<Component Name="Bool2">
</Component>
<Address Area="None" Type="Bool" BlockNumber="0" BitOffset="0" Informative="true" />
</Symbol>
</Access>
<Access Scope="LocalVariable" UId="22">
<Symbol>
<Component Name="Bool3">
</Component>
<Address Area="None" Type="Bool" BlockNumber="0" BitOffset="0" Informative="true" />
</Symbol>
</Access>
<Access Scope="LocalVariable" UId="23">
<Symbol>
<Component Name="Bool1">
</Component>
<Address Area="None" Type="Bool" BlockNumber="0" BitOffset="0" Informative="true" />
</Symbol>
</Access>
<Part Name="Contact" UId="24" /><!-- #Bool1 -->
<Part Name="RCoil" UId="25"/><!-- #Bool2 -->
<Part Name="Coil" UId="26"/><!-- #Bool3 -->
</Parts>
<Wires>
<Wire UId="27">
<Powerrail />
<NameCon UId="24" Name="in" />  <!-- #Bool1 -->
</Wire>
<Wire UId="28">
<IdentCon UId="23" />  <!-- #Bool1 -->
<NameCon UId="24" Name="operand" />  <!-- #Bool1 -->
</Wire>
<Wire UId="29">
<IdentCon UId="21" />  <!-- #Bool2 -->
<NameCon UId="25" Name="operand" />  <!-- #Bool2 -->
</Wire>
<Wire UId="30">
<IdentCon UId="22" />  <!-- #Bool3 -->
<NameCon UId="26" Name="operand" />  <!-- #Bool3 -->
</Wire>
<Wire UId="31">
<NameCon UId="24" Name="out" />  <!-- #Bool1 -->
<!-- Distributor -->
<NameCon UId="25" Name="in" />  <!-- Signal -->
<NameCon UId="26" Name="in" />  <!-- Signal -->
</Wire>
</Wires>
</FlgNet></NetworkSource>
 
Weiß nicht mehr. Glaube aber die waren nötig damit der Import klappt. Kann aber sein das dies nicht (bzw nicht mehr) nötig ist.

Die UId's? oder diese bestimmte UId?
 
Nicht das ich wüsste. Wir haben halt alles mögliche probiert.

Ich sehe es nur als problematisch an, dass wenn es von Siemens nicht dokumentiert ist, sich das Format durchaus mit jedem Servicepack wieder ändern könnte.
Ansonsten muss man eben einmal in den sauren Apfel beißen und sich eine sinnvolle Api drum herumbauen um das Ganze benutzbar zu machen, wie ihr es gemacht habt.

Der Aufbau der XML-Datei gleicht auch eher einer Mal-Anweisung wie etwas grafisch zu zeichnen ist, was es schwieriger macht das aus den sonst üblichen Syntaxbäumen zu erzeugen
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Immerhin hat Siemens irgendwann mal gesagt (kp. ob das irgendwo stand oder ob das auf einer Info Veranstaltung war), das die Openness Schnittstelle immer 2 Versionen zurück unterstützt werden soll.
 
Zurück
Oben