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 { IsoConnectionParameters parameters = con.GetConnectionParameters(); parameters.UsePasswordAuthentication("top secret"); con.Connect(hostname, 102); List<string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } con.Release(); } 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 = "10.0.2.2"; } Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, 102); Console.WriteLine("Files in server root directory:"); List <string> serverDirectory = con.GetServerDirectory(true); foreach (string entry in serverDirectory) { Console.WriteLine(entry); } Console.WriteLine(); Console.WriteLine("File directory tree at server:"); printFiles(con, "", ""); Console.WriteLine(); string filename = "IEDSERVER.BIN"; Console.WriteLine("Download file " + filename); /* Download file from server and write it to a new local file */ FileStream fs = new FileStream(filename, FileMode.Create); BinaryWriter w = new BinaryWriter(fs); con.GetFile(filename, new IedConnection.GetFileHandler(getFileHandler), w); fs.Close(); 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 = "10.0.2.2"; Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, 102); Console.WriteLine ("Files in server root directory:"); List<string> serverDirectory = con.GetServerDirectory(true); foreach (string entry in serverDirectory) { Console.WriteLine(entry); } Console.WriteLine(); Console.WriteLine ("File directory tree at server:"); printFiles(con, "", ""); Console.WriteLine(); string filename = "IEDSERVER.BIN"; Console.WriteLine("Download file " + filename); /* Download file from server and write it to a new local file */ FileStream fs = new FileStream(filename, FileMode.Create); BinaryWriter w = new BinaryWriter(fs); con.GetFile(filename, new IedConnection.GetFileHandler(getFileHandler), w); fs.Close(); 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 { IsoConnectionParameters parameters = con.GetConnectionParameters(); parameters.SetRemoteAddresses(1, new byte[] { 0x00, 0x01 }, new byte[] { 0x00, 0x01, 0x02, 0x03 }); con.ConnectTimeout = 10000; con.GetMmsConnection().SetLocalDetail(1200); con.Connect(hostname, 102); Console.WriteLine("Negotiated PDU size: " + con.GetMmsConnection().GetLocalDetail()); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } con.Release(); } 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 { IsoConnectionParameters parameters = con.GetConnectionParameters(); parameters.UsePasswordAuthentication("top secret"); con.Connect(hostname, 102); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } con.Release(); } 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 { IsoConnectionParameters parameters = con.GetConnectionParameters(); parameters.SetRemoteAddresses(1, 1, new byte[] { 0x00, 0x01, 0x02, 0x03 }); con.ConnectTimeout = 10000; con.Connect(hostname, 102); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } con.Release(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } }
public m61850(string host) { _host = host; _conn = new IedConnection(); Console.WriteLine("Connect to " + _host); try { IedConnect(); Console.WriteLine("Files in server root directory:"); List <string> serverDirectory = _conn.GetServerDirectory(true); foreach (string entry in serverDirectory) { Console.WriteLine(entry); } Console.WriteLine(); Console.WriteLine("File directory tree at server:"); printFiles(_conn, "", ""); Console.WriteLine(); if (!Directory.Exists(@"COMTRADE")) { Directory.CreateDirectory(@"COMTRADE"); } DirectoryInfo di = new DirectoryInfo(@"COMTRADE"); foreach (var fi in di.GetFiles()) { fileList.Add($"/COMTRADE/{fi.Name}"); } _conn.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } //_conn.Dispose(); }
public void UpdateComtradeFiles() { IedConnect(); List <string> serverDirectory = _conn.GetServerDirectory(true); foreach (string entry in serverDirectory) { string tmp = entry.Replace("/", "\\"); if (!fileList.Contains(entry)) { string filename = $"{AppDomain.CurrentDomain.BaseDirectory}{tmp}"; Console.WriteLine($"Download file {entry}"); FileStream fs = new FileStream(filename, FileMode.Create); BinaryWriter w = new BinaryWriter(fs); fileList.Add(entry); _conn.GetFile(entry, new IedConnection.GetFileHandler(getFileHandler), w); //fs.Close(); } } _conn.Abort(); }
public void ConnectToServer() { IedModel iedModel = ConfigFileParser.CreateModelFromConfigFile("../../model.cfg"); IedServer iedServer = new IedServer(iedModel); iedServer.Start(10002); IedConnection connection = new IedConnection(); connection.Connect("localhost", 10002); List <string> list = connection.GetServerDirectory(); Assert.IsNotEmpty(list); Assert.AreEqual(list.ToArray() [0], "simpleIOGenericIO"); iedServer.Stop(); iedServer.Destroy(); }
public bool FillPathDA() { try { _listItem.Clear(); var nodeLD = _connection.GetServerDirectory(); foreach (var ld in nodeLD) { var nodeLN = _connection.GetLogicalDeviceDirectory(ld); foreach (var ln in nodeLN) { FillDataObject(ld, ln); } } return(true); } catch (Exception e) { Log.Write(e, Log.Code.ERROR); return(false); } }
/////////////////////////////////////////////////////////////////////////////////////////////////// // Test implementations public static void TestClient() { IedConnection con = new IedConnection(); try { System.Windows.Forms.MessageBox.Show("Server Start"); con.Connect("localhost", 102); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { System.Windows.Forms.MessageBox.Show("LD: " + entry); } con.Abort(); } catch (IedConnectionException e) { System.Windows.Forms.MessageBox.Show(e.Message); } 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 { IsoConnectionParameters parameters = con.GetConnectionParameters(); parameters.SetRemoteAddresses(1,1, new byte[] {0x00, 0x01, 0x02, 0x03}); con.ConnectTimeout = 10000; con.Connect(hostname, 102); List<string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } con.Release(); } 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 = "10.0.2.2"; } Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, 102); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } List <string> lnDirectory = con.GetLogicalNodeDirectory("simpleIOGenericIO/LLN0", ACSIClass.ACSI_CLASS_DATA_SET); foreach (string entry in lnDirectory) { Console.WriteLine("Dataset: " + entry); } string vendor = con.ReadStringValue("simpleIOGenericIO/LLN0.NamPlt.vendor", FunctionalConstraint.DC); Console.WriteLine("Vendor: " + vendor); /* read FCDO */ MmsValue value = con.ReadValue("simpleIOGenericIO/GGIO1.AnIn1", FunctionalConstraint.MX); if (value.GetType() == MmsType.MMS_STRUCTURE) { Console.WriteLine("Value is of complex type"); for (int i = 0; i < value.Size(); i++) { Console.WriteLine(" element: " + value.GetElement(i).GetType()); if (value.GetElement(i).GetType() == MmsType.MMS_UTC_TIME) { Console.WriteLine(" -> " + value.GetElement(i).GetUtcTimeAsDateTimeOffset()); } } } DataSet dataSet = con.ReadDataSetValues("simpleIOGenericIO/LLN0.Events", null); Console.WriteLine("Read data set " + dataSet.GetReference()); con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } System.Threading.Thread.Sleep(2000); // 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 = "127.0.0.1"; } int port = 102; if (args.Length > 1) { port = Int32.Parse(args [1]); } Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, port); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } List <string> lnDirectory = con.GetLogicalNodeDirectory("simpleIOGenericIO/LLN0", ACSIClass.ACSI_CLASS_DATA_SET); foreach (string entry in lnDirectory) { Console.WriteLine("Dataset: " + entry); } string vendor = con.ReadStringValue("simpleIOGenericIO/LLN0.NamPlt.vendor", FunctionalConstraint.DC); Console.WriteLine("Vendor: " + vendor); /* read FCDO */ MmsValue value = con.ReadValue("simpleIOGenericIO/GGIO1.AnIn1", FunctionalConstraint.MX); if (value.GetType() == MmsType.MMS_STRUCTURE) { Console.WriteLine("Value is of complex type"); for (int i = 0; i < value.Size(); i++) { Console.WriteLine(" element: " + value.GetElement(i).GetType()); if (value.GetElement(i).GetType() == MmsType.MMS_UTC_TIME) { Console.WriteLine(" -> " + value.GetElement(i).GetUtcTimeAsDateTimeOffset()); } } } DataSet dataSet = con.ReadDataSetValues("simpleIOGenericIO/LLN0.Events", null); Console.WriteLine("Read data set " + dataSet.GetReference()); /* read multiple variables (WARNING: this is not IEC 61850 standard compliant but might * be supported by most servers). */ MmsConnection mmsConnection = con.GetMmsConnection(); MmsValue result = mmsConnection.ReadMultipleVariables("simpleIOGenericIO", new List <string>() { "GGIO1$ST$Ind1", "GGIO1$ST$Ind1", "GGIO1$ST$Ind1", "GGIO1$ST$Ind1" }); Console.WriteLine(result.ToString()); con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } System.Threading.Thread.Sleep(2000); // 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); Console.WriteLine("Negotiated PDU size: " + con.GetMmsConnection().GetLocalDetail()); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string deviceName in serverDirectory) { Console.WriteLine("LD: " + deviceName); List <string> deviceDirectory = con.GetLogicalDeviceDirectory(deviceName); foreach (string lnName in deviceDirectory) { Console.WriteLine(" LN: " + lnName); List <string> lcbs = con.GetLogicalNodeDirectory(deviceName + "/" + lnName, IEC61850.Common.ACSIClass.ACSI_CLASS_LCB); foreach (string lcbName in lcbs) { Console.WriteLine(" LCB: " + lcbName); MmsValue lcbValues = con.ReadValue(deviceName + "/" + lnName + "." + lcbName, FunctionalConstraint.LG); Console.WriteLine(" values: " + lcbValues.ToString()); } List <string> logs = con.GetLogicalNodeDirectory(deviceName + "/" + lnName, IEC61850.Common.ACSIClass.ACSI_CLASS_LOG); foreach (string logName in logs) { Console.WriteLine(" LOG: " + logName); } } } bool moreFollows; Console.WriteLine("\nQueryLogAfter:"); List <MmsJournalEntry> journalEntries = con.QueryLogAfter("simpleIOGenericIO/LLN0$EventLog", new byte[] { 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0, out moreFollows); PrintJournalEntries(journalEntries); Console.WriteLine("\nQueryLogByTime:"); journalEntries = con.QueryLogByTime("simpleIOGenericIO/LLN0$EventLog", new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc), DateTime.UtcNow, out moreFollows); PrintJournalEntries(journalEntries); con.Release(); } 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"; } try { Console.WriteLine("Connect to " + hostname + " ..."); con.Connect(hostname, 102); Console.WriteLine("Connected."); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string ldName in serverDirectory) { Console.WriteLine("LD: " + ldName); List <string> lnNames = con.GetLogicalDeviceDirectory(ldName); foreach (string lnName in lnNames) { Console.WriteLine(" LN: " + lnName); string logicalNodeReference = ldName + "/" + lnName; // discover data objects List <string> dataObjects = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_DATA_OBJECT); foreach (string dataObject in dataObjects) { Console.WriteLine(" DO: " + dataObject); } // discover data sets List <string> dataSets = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_DATA_SET); foreach (string dataSet in dataSets) { Console.WriteLine(" Dataset: " + dataSet); } // discover unbuffered report control blocks List <string> urcbs = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_URCB); foreach (string urcb in urcbs) { Console.WriteLine(" URCB: " + urcb); } // discover buffered report control blocks List <string> brcbs = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_BRCB); foreach (string brcb in brcbs) { Console.WriteLine(" BRCB: " + brcb); } } } 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 = "10.0.2.2"; } Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, 102); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } // create a new data set List <string> dataSetElements = new List <string>(); dataSetElements.Add("IEDM1CPUBHKW/DRCS1.ModOnConn.stVal[ST]"); dataSetElements.Add("IEDM1CPUBHKW/DRCS1.ModOnConn.t[ST]"); con.CreateDataSet("IEDM1CPUBHKW/LLN0.ds1", dataSetElements); // get the directory of the data set List <string> dataSetDirectory = con.GetDataSetDirectory("IEDM1CPUBHKW/LLN0.ds1"); foreach (string entry in dataSetDirectory) { Console.WriteLine("DS element: " + entry); } // read the values of the newly created data set DataSet dataSet = con.ReadDataSetValues("IEDM1CPUBHKW/LLN0.ds1", null); MmsValue dataSetValues = dataSet.GetValues(); Console.WriteLine("Data set contains " + dataSetValues.Size() + " elements"); foreach (MmsValue value in dataSetValues) { Console.WriteLine(" DS value: " + value + " type: " + value.GetType()); } // delete the data set con.DeleteDataSet("IEDM1CPUBHKW/LLN0.ds1"); 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 = "10.0.2.2"; Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, 102); List<string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } List<string> lnDirectory = con.GetLogicalNodeDirectory("simpleIOGenericIO/LLN0", ACSIClass.ACSI_CLASS_DATA_SET); foreach (string entry in lnDirectory) { Console.WriteLine("Dataset: " + entry); } string vendor = con.ReadStringValue ("simpleIOGenericIO/LLN0.NamPlt.vendor", FunctionalConstraint.DC); Console.WriteLine ("Vendor: " + vendor); /* read FCDO */ MmsValue value = con.ReadValue("simpleIOGenericIO/GGIO1.AnIn1", FunctionalConstraint.MX); if (value.GetType() == MmsType.MMS_STRUCTURE) { Console.WriteLine("Value is of complex type"); for (int i = 0; i < value.Size(); i++) { Console.WriteLine(" element: " + value.GetElement(i).GetType()); if (value.GetElement(i).GetType() == MmsType.MMS_UTC_TIME) { Console.WriteLine(" -> " + value.GetElement(i).GetUtcTimeAsDateTimeOffset()); } } } DataSet dataSet = con.ReadDataSetValues("simpleIOGenericIO/LLN0.Events", null); Console.WriteLine("Read data set " + dataSet.GetReference()); con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } System.Threading.Thread.Sleep(2000); }
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); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } // create a new data set List <string> dataSetElements = new List <string>(); dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn1.mag.f[MX]"); dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn2.mag.f[MX]"); con.CreateDataSet("simpleIOGenericIO/LLN0.ds1", dataSetElements); // get the directory of the data set List <string> dataSetDirectory = con.GetDataSetDirectory("simpleIOGenericIO/LLN0.ds1"); foreach (string entry in dataSetDirectory) { Console.WriteLine("DS element: " + entry); } // read the values of the newly created data set DataSet dataSet = con.ReadDataSetValues("simpleIOGenericIO/LLN0.ds1", null); MmsValue dataSetValues = dataSet.GetValues(); Console.WriteLine("Data set contains " + dataSetValues.Size() + " elements"); foreach (MmsValue value in dataSetValues) { Console.WriteLine(" DS value: " + value + " type: " + value.GetType()); } // delete the data set con.DeleteDataSet("simpleIOGenericIO/LLN0.ds1"); con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message + " reason: " + e.GetIedClientError().ToString()); } }
public static void Main(string[] args) { IedConnection con = new IedConnection (); string hostname; if (args.Length > 0) hostname = args[0]; else hostname = "localhost"; try { Console.WriteLine("Connect to " + hostname + " ..."); con.Connect(hostname, 102); Console.WriteLine("Connected."); MmsConnection mmsCon = con.GetMmsConnection(); MmsServerIdentity identity = mmsCon.GetServerIdentity(); Console.WriteLine("Vendor: " + identity.vendorName); Console.WriteLine("Model: " + identity.modelName); Console.WriteLine("Revision: " + identity.revision); List<string> serverDirectory = con.GetServerDirectory(false); foreach (string ldName in serverDirectory) { Console.WriteLine("LD: " + ldName); List<string> lnNames = con.GetLogicalDeviceDirectory(ldName); foreach (string lnName in lnNames) { Console.WriteLine(" LN: " + lnName); string logicalNodeReference = ldName + "/" + lnName; // discover data objects List<string> dataObjects = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_DATA_OBJECT); foreach (string dataObject in dataObjects) { Console.WriteLine(" DO: " + dataObject); List<string> dataDirectory = con.GetDataDirectoryFC(logicalNodeReference + "." + dataObject); foreach (string dataDirectoryElement in dataDirectory) { string daReference = logicalNodeReference + "." + dataObject + "." + ObjectReference.getElementName(dataDirectoryElement); // get the type specification of a variable MmsVariableSpecification specification = con.GetVariableSpecification(daReference, ObjectReference.getFC(dataDirectoryElement)); Console.WriteLine (" DA/SDO: [" + ObjectReference.getFC(dataDirectoryElement) + "] " + ObjectReference.getElementName(dataDirectoryElement) + " : " + specification.GetType() + "(" + specification.Size() + ")"); if (specification.GetType() == MmsType.MMS_STRUCTURE) { foreach (MmsVariableSpecification elementSpec in specification) { Console.WriteLine(" " + elementSpec.GetName() + " : " + elementSpec.GetType()); } } } } // discover data sets List<string> dataSets = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_DATA_SET); foreach (string dataSet in dataSets) { Console.WriteLine(" Dataset: " + dataSet); } // discover unbuffered report control blocks List<string> urcbs = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_URCB); foreach (string urcb in urcbs) { Console.WriteLine(" URCB: " + urcb); } // discover buffered report control blocks List<string> brcbs = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_BRCB); foreach (string brcb in brcbs) { Console.WriteLine(" BRCB: " + brcb); } } } 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); List<string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } // create a new data set List<string> dataSetElements = new List<string>(); string dataSetName = "simpleIOGenericIO/UNKNOWN.ds1"; //string dataSetName = "simpleIOGenericIO/LLN0.ds1"; dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn1.mag.f[MX]"); dataSetElements.Add("simpleIOGenericIO/GGIO1.AnIn2.mag.f[MX]"); con.CreateDataSet(dataSetName, dataSetElements); // get the directory of the data set List<string> dataSetDirectory = con.GetDataSetDirectory(dataSetName); foreach (string entry in dataSetDirectory) { Console.WriteLine("DS element: " + entry); } // read the values of the newly created data set DataSet dataSet = con.ReadDataSetValues(dataSetName, null); MmsValue dataSetValues = dataSet.GetValues(); Console.WriteLine ("Data set contains " + dataSetValues.Size() + " elements"); foreach (MmsValue value in dataSetValues) { Console.WriteLine(" DS value: " + value + " type: " + value.GetType()); } // delete the data set con.DeleteDataSet(dataSetName); con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message + " reason: " + e.GetIedClientError().ToString()); } }
public static void Main(string[] args) { TLSConfiguration tlsConfig = new TLSConfiguration(); tlsConfig.SetOwnCertificate(new X509Certificate2("client1.cer")); tlsConfig.SetOwnKey("client1-key.pem", null); // Add a CA certificate to check the certificate provided by the server - not required when ChainValidation == false tlsConfig.AddCACertificate(new X509Certificate2("root.cer")); // Check if the certificate is signed by a provided CA tlsConfig.ChainValidation = true; // Check that the shown server certificate is in the list of allowed certificates tlsConfig.AllowOnlyKnownCertificates = false; IedConnection con = new IedConnection(tlsConfig); string hostname; if (args.Length > 0) { hostname = args[0]; } else { hostname = "127.0.0.1"; } int port = -1; if (args.Length > 1) { port = Int32.Parse(args [1]); } Console.WriteLine("Connect to " + hostname); try { con.Connect(hostname, port); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string entry in serverDirectory) { Console.WriteLine("LD: " + entry); } List <string> lnDirectory = con.GetLogicalNodeDirectory("simpleIOGenericIO/LLN0", ACSIClass.ACSI_CLASS_DATA_SET); foreach (string entry in lnDirectory) { Console.WriteLine("Dataset: " + entry); } string vendor = con.ReadStringValue("simpleIOGenericIO/LLN0.NamPlt.vendor", FunctionalConstraint.DC); Console.WriteLine("Vendor: " + vendor); /* read FCDO */ MmsValue value = con.ReadValue("simpleIOGenericIO/GGIO1.AnIn1", FunctionalConstraint.MX); if (value.GetType() == MmsType.MMS_STRUCTURE) { Console.WriteLine("Value is of complex type"); for (int i = 0; i < value.Size(); i++) { Console.WriteLine(" element: " + value.GetElement(i).GetType()); if (value.GetElement(i).GetType() == MmsType.MMS_UTC_TIME) { Console.WriteLine(" -> " + value.GetElement(i).GetUtcTimeAsDateTimeOffset()); } } } DataSet dataSet = con.ReadDataSetValues("simpleIOGenericIO/LLN0.Events", null); Console.WriteLine("Read data set " + dataSet.GetReference()); con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } System.Threading.Thread.Sleep(2000); // 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"; } try { Console.WriteLine("Connect to " + hostname + " ..."); con.Connect(hostname, 102); Console.WriteLine("Connected."); List <string> serverDirectory = con.GetServerDirectory(false); foreach (string ldName in serverDirectory) { Console.WriteLine("LD: " + ldName); List <string> lnNames = con.GetLogicalDeviceDirectory(ldName); foreach (string lnName in lnNames) { Console.WriteLine(" LN: " + lnName); string logicalNodeReference = ldName + "/" + lnName; // discover data objects List <string> dataObjects = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_DATA_OBJECT); foreach (string dataObject in dataObjects) { Console.WriteLine(" DO: " + dataObject); List <string> dataDirectory = con.GetDataDirectoryFC(logicalNodeReference + "." + dataObject); foreach (string dataDirectoryElement in dataDirectory) { string daReference = logicalNodeReference + "." + dataObject + "." + ObjectReference.getElementName(dataDirectoryElement); // get the type specification of a variable MmsVariableSpecification specification = con.GetVariableSpecification(daReference, ObjectReference.getFC(dataDirectoryElement)); Console.WriteLine(" DA/SDO: [" + ObjectReference.getFC(dataDirectoryElement) + "] " + ObjectReference.getElementName(dataDirectoryElement) + " : " + specification.GetType() + "(" + specification.Size() + ")"); if (specification.GetType() == MmsType.MMS_STRUCTURE) { foreach (MmsVariableSpecification elementSpec in specification) { Console.WriteLine(" " + elementSpec.GetName() + " : " + elementSpec.GetType()); } } } } // discover data sets List <string> dataSets = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_DATA_SET); foreach (string dataSet in dataSets) { Console.WriteLine(" Dataset: " + dataSet); } // discover unbuffered report control blocks List <string> urcbs = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_URCB); foreach (string urcb in urcbs) { Console.WriteLine(" URCB: " + urcb); } // discover buffered report control blocks List <string> brcbs = con.GetLogicalNodeDirectory(logicalNodeReference, ACSIClass.ACSI_CLASS_BRCB); foreach (string brcb in brcbs) { Console.WriteLine(" BRCB: " + brcb); } } } con.Abort(); } catch (IedConnectionException e) { Console.WriteLine(e.Message); } }