public static void Main(string[] args) { IedConnection con = new IedConnection(); string hostname; if (args.Length > 0) { hostname = args[0]; } else { hostname = "localhost"; } Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, 102); string objectReference = "IEDM1CPUBHKW/DRCC1.DERStr"; ControlObject control = con.CreateControlObject(objectReference); ControlModel controlModel = control.GetControlModel(); Console.WriteLine(objectReference + " has control model " + controlModel.ToString()); if (!control.Operate(true)) { Console.WriteLine("operate failed!"); } con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } }
public static void Main(string[] args) { IedConnection con = new IedConnection(); string hostname; if (args.Length > 0) { hostname = args[0]; } else { hostname = "localhost"; } Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, 102); /* direct control with normal security or SBO with normal security */ string objectReference = "simpleIOGenericIO/GGIO1.SPCSO1"; ControlObject control = con.CreateControlObject(objectReference); ControlModel controlModel = control.GetControlModel(); Console.WriteLine(objectReference + " has control model " + controlModel.ToString()); switch (controlModel) { case ControlModel.STATUS_ONLY: Console.WriteLine("Control is status-only!"); break; case ControlModel.DIRECT_NORMAL: case ControlModel.DIRECT_ENHANCED: if (!control.Operate(true)) { Console.WriteLine("operate failed!"); } else { Console.WriteLine("operated successfully!"); } break; case ControlModel.SBO_NORMAL: case ControlModel.SBO_ENHANCED: if (control.Select()) { if (!control.Operate(true)) { Console.WriteLine("operate failed!"); } else { Console.WriteLine("operated successfully!"); } } else { Console.WriteLine("Select failed!"); } break; } /* direct control with enhanced security */ objectReference = "simpleIOGenericIO/GGIO1.SPCSO3"; control = con.CreateControlObject(objectReference); controlModel = control.GetControlModel(); Console.WriteLine(objectReference + " has control model " + controlModel.ToString()); if (controlModel == ControlModel.DIRECT_ENHANCED) { control.SetCommandTerminationHandler(commandTerminationHandler, null); control.Operate(true); Thread.Sleep(1000); } con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } // release all resources - do NOT use the object after this call!! con.Dispose(); }
public static void Main(string[] args) { IedConnection con = new IedConnection(); string hostname; if (args.Length > 0) { hostname = args[0]; } else { hostname = "localhost"; } Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, 102); /* direct control with normal security */ string objectReference = "simpleIOGenericIO/GGIO1.SPCSO1"; ControlObject control = con.CreateControlObject(objectReference); ControlModel controlModel = control.GetControlModel(); Console.WriteLine(objectReference + " has control model " + controlModel.ToString()); if (controlModel != ControlModel.CONTROL_MODEL_STATUS_ONLY) { control.Operate(true); } if (!control.Operate(true)) { Console.WriteLine("operate failed!"); } /* direct control with enhanced security */ objectReference = "simpleIOGenericIO/GGIO1.SPCSO3"; control = con.CreateControlObject(objectReference); controlModel = control.GetControlModel(); Console.WriteLine(objectReference + " has control model " + controlModel.ToString()); if (controlModel == ControlModel.CONTROL_MODEL_DIRECT_ENHANCED) { control.SetCommandTerminationHandler(commandTerminationHandler, null); control.Operate(true); Thread.Sleep(1000); } con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } }