You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Felix Weiß edited this page Jun 21, 2022
·
1 revision
Setup the class
Setting up the interface class is fairly easy just create a new instance:
//attaching a loggerLogger.LogLevel=LogLevel.Verbose;Logger.OnNewLogMessage((date,msg)=>{Console.WriteLine($"{date.ToString("HH:mm:ss")}{msg}");});//setting up a new PLC interface and register collectionMewtocolInterfaceplc=newMewtocolInterface("192.168.115.5");
Initiate a new connection
After that you cann call the ConnectAsync() method
awaitplc.ConnectAsync(//PLC connected(plcinf)=>{if(plcinf.OperationMode.RunMode)Console.WriteLine("PLC is in RUN");},//Connection failed()=>{Console.WriteLine("PLC failed to connect");});
Note that you cann either use the callbacks inside the ConnectAsync() method or attach to an event like:
plc.Connected+=(plcinf)=>{if(plcinf.OperationMode.RunMode)Console.WriteLine("PLC is in RUN");};awaitplc.ConnectAsync();
Change between RUN/PROG mode
awaitplc.ConnectAsync(//PLC connected(plcinf)=>{if(!plcinf.OperationMode.RunMode){awaitplc.SetOperationMode(OPMode.Run);Console.WriteLine("PLC is in RUN");}});