Skip to content

Commit 75844bd

Browse files
committed
Add sample code for Plc run and stop, and read absolute addresses
1 parent 22ae6b4 commit 75844bd

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/DriverTest/Program.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,41 @@ static void Main(string[] args)
9999
100100
#endregion
101101
*/
102-
102+
103+
104+
#region Test: Absolutadressen lesen
105+
// Daten aus nicht "optimierten" Datenbausteinen lesen
106+
readlist.Clear();
107+
ItemAddress absAdr = new ItemAddress();
108+
absAdr.SetAccessAreaToDatablock(100); // DB 100
109+
absAdr.SymbolCrc = 0;
110+
111+
absAdr.AccessSubArea = Ids.DB_ValueActual;
112+
absAdr.LID.Add(3); // LID_OMS_STB_ClassicBlob
113+
absAdr.LID.Add(0); // Blob Start Offset, Anfangsadresse
114+
absAdr.LID.Add(20); // 20 Bytes
115+
116+
readlist.Add(absAdr);
117+
118+
values.Clear();
119+
errors.Clear();
120+
121+
res = conn.ReadValues(readlist, out values, out errors);
122+
Console.WriteLine(values.ToString());
123+
124+
#endregion
125+
126+
127+
#region Test: SPS in Stopp setzen
128+
Console.WriteLine("Setze SPS in STOP...");
129+
conn.SetPlcOperatingState(1);
130+
Console.WriteLine("Taste drücken um wieder in RUN zu setzen...");
131+
Console.ReadKey();
132+
Console.WriteLine("Setze SPS in RUN...");
133+
conn.SetPlcOperatingState(3);
134+
135+
#endregion
136+
103137
conn.Disconnect();
104138
}
105139
else

0 commit comments

Comments
 (0)