Created
July 13, 2018 07:15
-
-
Save rapha-dev/129c04571c8d95eace572bb5bee4dcb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dataItems = new List<DataItem>(); | |
for (int i = 0; i < 1; i += 2) | |
{ | |
dataItems.Add(DataItem.FromAddress("DB800.DBW" + i)); | |
} | |
var ip = "10.10.11.38"; | |
var plc = new S7.Net.Plc(CpuType.S7300, ip, 0, 2); | |
Console.WriteLine("Connecting " + ip); | |
plc.Open(); | |
Console.WriteLine("IsConnected=" + plc.IsConnected); | |
Console.WriteLine("Reading items"); | |
plc.ReadMultipleVars(dataItems); | |
foreach (var item in dataItems) | |
{ | |
Console.WriteLine("DB" + item.DB + ".DBW" + item.StartByteAdr + ": " + item.Value.ToString()); | |
} | |
Console.WriteLine("Writing items"); | |
dataItems[0].Value = 88; | |
plc.Write(dataItems[0]); | |
Console.WriteLine("Reading items"); | |
plc.ReadMultipleVars(dataItems); | |
foreach (var item in dataItems) | |
{ | |
Console.WriteLine("DB" + item.DB + ".DBW" + item.StartByteAdr + ": " + item.Value.ToString()); | |
} | |
plc.Close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment