//////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////// static void Main(string[] args) { // Interfaces list List <Tuple <String, String, String> > Interfaces = GetAvailableInterfaces(); // Start network activity on the first interface (indice 0) String PcapInterfaceName = "\\Device\\NPF_" + Interfaces[0].Item3; int NumberofSlavesDetected = SoemInterrop.StartActivity(PcapInterfaceName, 1); // Until now if the parameter is missing it's Operational, otherwise slaves are // in there default mode (SafeOperational is not used). SoemInterrop.Run(SlaveState.SafeOperational); byte[] buf = new byte[50]; // must be large enough int size = buf.Length; // some Acyclic Read/Write // Could be also realize in operational, init, .... state SoemInterrop.ReadPDO(1, 0x6000, -1, ref size, buf); SoemInterrop.WritePDO(1, 0x7000, 0, 4, buf); DeviceInfo(); // Change to Operational SoemInterrop.WriteState(1, SlaveState.Operational); for (; ;) { SoemInterrop.RefreshSlavesState(); DeviceInfo(); Thread.Sleep(2000); } }
public void WriteState(SlaveState state) { SoemInterrop.WriteState(Id, state); }