Comunication for Allen-Bradley Rockwell PLC in .NET Core
LibPLCTag library C++ Api
Based on libplctag-csharp
Nuget
Special thanks for testing Mavert
Special thanks to Mario Averoldi for technical support [email protected].
Corsinvest Srl
______ _ __
/ ____/___ __________(_)___ _ _____ _____/ /_
/ / / __ / ___/ ___/ / __ | / / _ / ___/ __/
/ /___/ /_/ / / (__ ) / / / / |/ / __(__ ) /_
____/____/_/ /____/_/_/ /_/|___/___/____/__/
Client Api Allen-Bradley PLC (Made in Italy)
Note: PLCs control many kinds of equipment and loss of property, production or even life can happen if mistakes in programming or access are made. Always use caution when accessing or programming PLCs!
We make no claims or warrants about the suitability of this code for any purpose.
Be careful!
The client is wrapper of LibPLCTag library.
[Serializable]
public class Test12
{
public int AA1 { get; set; }
public int AA2 { get; set; }
public int AA3 { get; set; }
public int AA4 { get; set; }
public int AA5 { get; set; }
public int AA6 { get; set; }
public int AA7 { get; set; }
public int AA8 { get; set; }
}
public static void Main(string[] args)
{
//initialize controller
using (var controller = new Controller("10.155.128.192", "1, 0", CPUType.LGX))
{
//ping controller
Console.Out.WriteLine("Ping " + controller.Ping(true));
//create group tag
var grp = controller.CreateGroup();
//add tag
var tag = grp.CreateTagType<string[]>("Track", TagSize.STRING, 300);
tag.Changed += TagChanged;
var value = tag.Read();
//add tag from Class
var tag1 = grp.CreateTagType<Test12>("Test");
tag.Changed += TagChanged;
var tag2 = grp.CreateTagFloat32("Fl32");
grp.Changed += GroupChanged;
grp.Read();
}
}
private static void PrintChange(string @event, ResultOperation result)
{
Console.Out.WriteLine($"{@event} {result.Timestamp} Changed: {result.Tag.Name}");
}
static void TagChanged(ResultOperation result)
{
PrintChange("TagChanged", result);
}
static void GroupChanged(IEnumerable<ResultOperation> results)
{
foreach (var result in results) PrintChange("GroupTagChanged", result);
}
It is possible to create a tag of any type:
Sizes are specified in TagSize.
For arrays specify the size in the definition.
Example:
public class TestArray
{
public int InTest { get; set; }
public int[] InTestArray { get; set; } = new int[5];
public string[] StringTestArray { get; set; } = new string[300];
}
Custom types are classes. The properties are read sequentially.