- Beiträge
- 12.508
- Reaktionspunkte
- 4.600
Zuviel Werbung?
-> Hier kostenlos registrieren
-> Hier kostenlos registrieren
Hmm, irgendwie gibts da keinen einzigen Kommentar in dem Code...Hab es jetzt so umgesetzt wie vorgeschlagen. Hier mal worum es überhaupt geht. Ein Baustein der nacheinander eine MPI Verbindung zu maximal 10 Stationen aufbaut und dort Daten liest und schreibt.
Code:IF #stationen[#Station].MPI <> 0 THEN IF #"W/R" THEN #tANY_1 := p#DB1.DBx0.0 byte 1; #atANY_1."DB-Nr" := #stationen[#Station]."Master-In-DBNr"; #tInt := TEST_DB(DB_NUMBER := #stationen[#Station]."Master-In-DBNr", DB_LENGTH => #atANY_1.Len, WRITE_PROT => #tBool); IF #tInt = 0 THEN #tANY_2 := p#DB1.DBx0.0 byte 1; #atANY_2."DB-Nr" := #stationen[#Station]."Slave-In-DBNr"; #atANY_2.Len := #atANY_1.Len; #tInt := X_PUT(REQ := TRUE, CONT := FALSE, DEST_ID := #stationen[#Station].MPI, VAR_ADDR := #tANY_2, SD := #tANY_1, BUSY => #busy); END_IF; IF #busy THEN RETURN; ELSE #"W/R" := NOT #"W/R"; #ComStörungSchreiben := #tInt; END_IF; ELSE #tANY_1 := p#DB1.DBx0.0 byte 1; #atANY_1."DB-Nr" := #stationen[#Station]."Master-Out-DBNr"; #tInt := TEST_DB(DB_NUMBER := #stationen[#Station]."Master-Out-DBNr", DB_LENGTH => #atANY_1.Len, WRITE_PROT => #tBool); IF #tInt = 0 THEN #tANY_2 := p#DB1.DBx0.0 byte 1; #atANY_2."DB-Nr" := #stationen[0]."Slave-Out-DBNr"; #atANY_2.Len := #atANY_1.Len; #tInt := X_GET(REQ := TRUE, CONT := FALSE, DEST_ID := #stationen[#Station].MPI, VAR_ADDR := #tANY_1, BUSY => #busy, RD => #tANY_2); END_IF; IF #busy THEN RETURN; ELSE #"W/R" := NOT #"W/R"; #ComStörungLesen := #tInt; END_IF; END_IF; #ComStör[#Station] := (#ComStörungLesen < 0) OR (#ComStörungSchreiben < 0); ELSE #ComStör[#Station] := false; END_IF; IF #Station = 9 THEN #Station := 0; ELSE #Station := #Station + 1; END_IF; #ComStörungS1 := #ComStör[0]; #ComStörungS2 := #ComStör[1]; #ComStörungS3 := #ComStör[2]; #ComStörungS4 := #ComStör[3]; #ComStörungS5 := #ComStör[4]; #ComStörungS6 := #ComStör[5]; #ComStörungS7 := #ComStör[6]; #ComStörungS8 := #ComStör[7]; #ComStörungS9 := #ComStör[8]; #ComStörungS10 := #ComStör[9];
Aber das Ende ist sicher so, wie Jesper das gemeint hat.