Comunicação para Allen-Bradley Rockwell PLC em .NET Core
Biblioteca LibPLCTag API C++
Baseado em libplctag-csharp
Nuget
Agradecimentos especiais por testar o Mavert
Agradecimentos especiais a Mario Averoldi pelo suporte técnico [email protected].
Corsinvest Srl
______ _ __
/ ____/___ __________(_)___ _ _____ _____/ /_
/ / / __ / ___/ ___/ / __ | / / _ / ___/ __/
/ /___/ /_/ / / (__ ) / / / / |/ / __(__ ) /_
____/____/_/ /____/_/_/ /_/|___/___/____/__/
Client Api Allen-Bradley PLC (Made in Italy)
Nota: Os PLCs controlam muitos tipos de equipamentos e podem ocorrer perdas de propriedade, produção ou até mesmo vidas se forem cometidos erros de programação ou acesso. Sempre tenha cuidado ao acessar ou programar CLPs!
Não fazemos reivindicações ou garantias sobre a adequação deste código para qualquer finalidade.
Tome cuidado!
O cliente é um wrapper da biblioteca 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 ) ;
}
É possível criar uma tag de qualquer tipo:
Os tamanhos são especificados em TagSize.
Para matrizes, especifique o tamanho na definição.
Exemplo:
public class TestArray
{
public int InTest { get ; set ; }
public int [ ] InTestArray { get ; set ; } = new int [ 5 ] ;
public string [ ] StringTestArray { get ; set ; } = new string [ 300 ] ;
}
Tipos personalizados são classes. As propriedades são lidas sequencialmente.