cv4ab api dotnet
v0.1.7
.NET Core 中 Allen-Bradley Rockwell PLC 的通信
LibPLCTag 函式庫 C++ Api
基於libplctag-csharp
努蓋特
特別感謝您測試 Mavert
特別感謝 Mario Averoldi 的技術支援 [email protected]。
科斯投資有限公司
______ _ __
/ ____/___ __________(_)___ _ _____ _____/ /_
/ / / __ / ___/ ___/ / __ | / / _ / ___/ __/
/ /___/ /_/ / / (__ ) / / / / |/ / __(__ ) /_
____/____/_/ /____/_/_/ /_/|___/___/____/__/
Client Api Allen-Bradley PLC (Made in Italy)
注意: PLC控制多種設備,如果編程或存取出現錯誤,可能會造成財產、生產甚至生命的損失。造訪或編程 PLC 時務必小心!
我們不對本代碼對於任何目的的適用性做出任何聲明或保證。
當心!
客戶端是 LibPLCTag 庫的包裝器。
[ 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 ) ;
}
可以建立任何類型的標籤:
大小在 TagSize 中指定。
對於數組,在定義中指定大小。
例子:
public class TestArray
{
public int InTest { get ; set ; }
public int [ ] InTestArray { get ; set ; } = new int [ 5 ] ;
public string [ ] StringTestArray { get ; set ; } = new string [ 300 ] ;
}
自訂類型是類別。屬性按順序讀取。