/// <summary> /// Initializes the test with session, configuration and logger. /// </summary> public TestBase( string name, Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) { m_name = name; m_session = session; m_configuration = configuration; m_reportMessage = reportMessage; m_reportProgress = reportProgress; if (template != null && Object.ReferenceEquals(session, template.m_session)) { m_blockSize = template.BlockSize; m_availableNodes = template.m_availableNodes; m_writeableVariables = template.m_writeableVariables; } else { m_blockSize = 1000; m_availableNodes = new NodeIdDictionary<Node>(); m_writeableVariables = new List<VariableNode>(); } }
/// <summary> /// Initializes the test with session, configuration and logger. /// </summary> public TestBase( string name, Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) { m_name = name; m_session = session; m_configuration = configuration; m_reportMessage = reportMessage; m_reportProgress = reportProgress; if (template != null && Object.ReferenceEquals(session, template.m_session)) { m_blockSize = template.BlockSize; m_availableNodes = template.m_availableNodes; m_writeableVariables = template.m_writeableVariables; } else { m_blockSize = 1000; m_availableNodes = new NodeIdDictionary <Node>(); m_writeableVariables = new List <VariableNode>(); } }
/// <summary> /// Creates the test object. /// </summary> public TranslatePathTest( Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) : base("TranslatePath", session, configuration, reportMessage, reportProgress, template) { }
/// <summary> /// Creates the test object. /// </summary> public TranslatePathTest( Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) : base("TranslatePath", session, configuration, reportMessage, reportProgress, template) { }
/// <summary> /// Creates the test object. /// </summary> public SessionTest( Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) : base("Activate", session, configuration, reportMessage, reportProgress, template) { m_errorEvent = new ManualResetEvent(false); m_messages = new Dictionary<uint,List<uint>>(); }
/// <summary> /// Creates the test object. /// </summary> public SessionTest( Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) : base("Activate", session, configuration, reportMessage, reportProgress, template) { m_errorEvent = new ManualResetEvent(false); m_messages = new Dictionary <uint, List <uint> >(); }
/// <summary> /// Reports a progress change. /// </summary> /// <param name="value">The value of the updated progress.</param> protected virtual void OnReport(T value) { // If there's no handler, don't bother going through the sync context. // Inside the callback, we'll need to check again, in case // an event handler is removed between now and then. ReportProgressEventHandler handler = ProgressChanged; if (handler != null) { SynchronizationContext.Post(_invokeReportProgressHandlers, value); } }
/// <summary> /// Creates the test object. /// </summary> public BrowseTest( Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) : base("Browse", session, configuration, reportMessage, reportProgress, template) { m_view = new ViewDescription(); m_view.ViewId = null; m_view.Timestamp = DateTime.MinValue; m_view.ViewVersion = 0; m_maxReferencesPerNode = 0; }
/// <summary> /// Creates the test object. /// </summary> public SubscribeTest( Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) : base("Subscribe", session, configuration, reportMessage, reportProgress, template) { m_subscriptions = new List<Subscription>(); m_errorEvent = new ManualResetEvent(false); m_acknowledgements = new SubscriptionAcknowledgementCollection(); m_publishPipelineDepth = 10; m_idealTimingError = 400; m_maximumTimingError = 500; }
/// <summary> /// Creates the test object. /// </summary> public WriteTest( Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) : base("Write", session, configuration, reportMessage, reportProgress, template) { m_generator = new Opc.Ua.Test.DataGenerator(new Opc.Ua.Test.RandomSource(configuration.Seed)); m_generator.NamespaceUris = Session.NamespaceUris; m_generator.ServerUris = Session.ServerUris; m_generator.MaxArrayLength = 3; m_generator.MaxStringLength = 10; m_generator.MaxXmlElementCount = 3; m_generator.MaxXmlAttributeCount = 3; }
/// <summary> /// Creates the test object. /// </summary> public CallTest( Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) : base("Call", session, configuration, reportMessage, reportProgress, template) { m_generator = new Opc.Ua.Test.DataGenerator(new Opc.Ua.Test.RandomSource(configuration.Seed)); m_generator.NamespaceUris = Session.NamespaceUris; m_generator.ServerUris = Session.ServerUris; m_generator.MaxArrayLength = 3; m_generator.MaxStringLength = 10; m_generator.MaxXmlElementCount = 3; m_generator.MaxXmlAttributeCount = 3; }
/// <summary> /// Creates the test object. /// </summary> public MonitoredItemTest( Session session, ServerTestConfiguration configuration, ReportMessageEventHandler reportMessage, ReportProgressEventHandler reportProgress, TestBase template) : base("MonitoredItem", session, configuration, reportMessage, reportProgress, template) { m_generator = new Opc.Ua.Test.DataGenerator(new Opc.Ua.Test.RandomSource(configuration.Seed)); m_generator.NamespaceUris = Session.NamespaceUris; m_generator.ServerUris = Session.ServerUris; m_generator.MaxArrayLength = 3; m_generator.MaxStringLength = 10; m_generator.MaxXmlElementCount = 3; m_generator.MaxXmlAttributeCount = 3; m_comparer = new Opc.Ua.Test.DataComparer(Session.MessageContext); m_comparer.ThrowOnError = false; m_errorEvent = new ManualResetEvent(false); m_maximumTimingError = 300; m_variables = new List<TestVariable>(); }
/// <summary> /// Constructor method that opens and reads a Starling database (.dbf). /// </summary> /// <param name="dbfFilename">Filename of the Starling database to be read.</param> /// <param name="progressHandler">Optional event handler for progress reports.</param> public StarlingDbfReader(String dbfFilename, ReportProgressEventHandler progressHandler = null) { // register optional event if (progressHandler != null) { onProgressChanged += progressHandler; } // get var filename String VarFilename = Path.ChangeExtension(dbfFilename, "var"); table_name = Path.GetFileNameWithoutExtension(dbfFilename); if (File.Exists(dbfFilename)) { // read header with database structure reportProgress(0, "Reading header"); header = new StarlingDbfHeader(dbfFilename); reportProgress(10, "Reading header: fields"); // log header info Trace.WriteLine(dbfFilename); Trace.WriteLine(String.Format("DBF Filesize:\t\t{0}", header.getFileSize())); Trace.WriteLine(String.Format("Actual filesize:\t{0}", new FileInfo(dbfFilename).Length)); Trace.WriteLine("Header"); Trace.Indent(); foreach (String s in header.ToString().Split('\n')) { Trace.WriteLine(s); } Trace.Unindent(); Trace.WriteLine(String.Format("Fields ({0})", header.field_structures.Count)); Trace.Indent(); // read field structures for (int i = 0; i < header.field_structures.Count; i++) { StarlingDbfField rec = header.field_structures[i]; // log field info Trace.WriteLine(String.Format("Field {0}", i)); Trace.Indent(); foreach (String s in rec.ToString().Split('\n')) { Trace.WriteLine(s); } Trace.Unindent(); // report progress reportProgress(10 + 10 * ((float)i / header.field_structures.Count), "Reading header: fields"); } Trace.Unindent(); // read byte content for all records reportProgress(20, "Reading records"); records = new List <StarlingDbfRecord>(); using (BinaryReader dbfFile = new BinaryReader(File.OpenRead(dbfFilename), Encoding.ASCII)) { dbfFile.ReadBytes(header.HSZ); while (dbfFile.BaseStream.Length - dbfFile.BaseStream.Position >= header.DRS) { StarlingDbfRecord rec = new StarlingDbfRecord(header, dbfFile.ReadBytes(header.DRS)); records.Add(rec); reportProgress(20 + (40d * dbfFile.BaseStream.Position) / dbfFile.BaseStream.Length, "Reading records"); } } if (File.Exists(VarFilename)) { // in case of an accompanying .var file, replace byte content of record fields if they are pointers to data in .var file // first check if we are dealing with a .dbf file and if it contains data pointers bool varfile_is_needed = false; if (String.Equals(Path.GetExtension(dbfFilename), ".dbf", StringComparison.OrdinalIgnoreCase)) { for (int i = 0; i < header.field_structures.Count && !varfile_is_needed; i++) { StarlingDbfField fld = header.field_structures[i]; varfile_is_needed = (fld.type == StarlingDbfField.FieldType.character && fld.fieldlength == 6); } } if (varfile_is_needed) { reportProgress(60, "Processing records"); using (BinaryReader varFile = new BinaryReader(File.OpenRead(VarFilename), Encoding.ASCII)) { // walk through all fields (columns) for (int i = 0; i < header.field_structures.Count; i++) { // check if the field contains data pointers, if so update each record's contents StarlingDbfField fld = header.field_structures[i]; if (fld.type == StarlingDbfField.FieldType.character && fld.fieldlength == 6) { /* * We are dealing with a pointer to the VAR file here. * The first 4 bytes give the position, the last 2 bytes give length. */ foreach (StarlingDbfRecord rec in records) { byte[] old_content = rec.field_contents[i]; if (!StarlingDbfRecord.emptyVarRef(old_content)) { uint position = BitConverter.ToUInt32(old_content, 0); ushort length = BitConverter.ToUInt16(old_content, 4); varFile.BaseStream.Seek(position, SeekOrigin.Begin); byte[] new_content = varFile.ReadBytes(length); rec.field_contents[i] = new_content; } } } reportProgress(60 + (40d * i) / header.field_structures.Count, "Processing records"); } } } } reportProgress(100, "Database loaded"); // log records //foreach (StarlingDbfRecord rec in records) // Trace.WriteLine(rec.ToString()); } else { Trace.WriteLine("DBF file not found."); } // unregister event if (progressHandler != null) { onProgressChanged -= progressHandler; } }
/// <summary> /// Invokes the progress event callbacks. /// </summary> /// <param name="state">The progress value.</param> private void InvokeReportProgressHandlers(object state) { ReportProgressEventHandler handler = ProgressChanged; handler?.Invoke(this, (T)state); }