public static void RunLoggerExample() { var myLogger = new plctag.log_callback_func(MyLogger); var statusAfterRegistration = plctag.plc_tag_register_logger(myLogger); if (statusAfterRegistration != 0) { Console.WriteLine($"Something went wrong {statusAfterRegistration}"); } var tagHandle = plctag.plc_tag_create("protocol=ab_eip&gateway=192.168.0.10&path=1,0&plc=LGX&elem_size=4&elem_count=1&name=MY_DINT&debug=4", 1000); while (plctag.plc_tag_status(tagHandle) == 1) { Thread.Sleep(100); } var statusBeforeRead = plctag.plc_tag_status(tagHandle); if (statusBeforeRead != 0) { Console.WriteLine($"Something went wrong {statusBeforeRead}"); } plctag.plc_tag_read(tagHandle, 1000); while (plctag.plc_tag_status(tagHandle) == 1) { Thread.Sleep(100); } var statusAfterRead = plctag.plc_tag_status(tagHandle); if (statusAfterRead != 0) { Console.WriteLine($"Something went wrong {statusAfterRead}"); } var theValue = plctag.plc_tag_get_uint32(tagHandle, 0); plctag.plc_tag_destroy(tagHandle); Console.WriteLine(theValue); }
public static extern int plc_tag_register_logger(plctag.log_callback_func func);