WW TSS-8: Technical Deep Dive into Historian 11 Toolkit Presented by Chris Azer Title slide [from Title Slide master] The title slide is available as a Title Master and the background and graphic elements are fixed. Text is editable for the slide heading and presentation details but the small compliance text exists in editable form only on the Title Master itself. This type area should be used only for the purposes of compliance text and should not be replaced by other content. Font, type size and colours are fixed for the Title Master style and should not be modified. Footer details Footer detail appear in the bottom-left corner of the slide and appear in fixed positions and order. Editing of the Footer details is done by accessing ‘Header and Footer’ under the ‘View’ menu in PowerPoint®.
Presenter Profile Chris Azer, Technical Account Manager, Wonderware In October 2006, he joined Wonderware as a Technical Support Engineer supporting Wonderware Historian, Operations and Performance, Historian Client (ActiveFactory), Application Server, Intelligence, Corporate Energy Management, Wonderware Information Server, and Toolkits. Chris joined the strategic support group as a Technical Account Manager in 2009.
Historian Toolkit Outline Classic Toolkit vs. Historian 11 Toolkit What has changed? What new APIs are available How to connect Understanding connection state Best practices
Historian Toolkit Outline Tag Creation Creating tag Data to retain for storage after tag creation Best Practices Storing Data Storing Streamed values Storing non-Streamed value collections Adding revised values
Historian Toolkit Outline Retrieval Retrieving data from History Retrieving Analog and State Summary History Best Practices
Historian Toolkit Overview Classic toolkit vs. Historian 11 Toolkit How to connect Tag Creation Storing Data Retrieval
Classic Toolkit vs. Historian 11 Toolkit What has changed? Data is stored using the new storage system. Historian 9 Toolkit stores to the classic storage system Real-time and late data performance is significantly improved Tag creation and storage can occur prior to connecting to the Historian Entire client interface and toolkit is completely compiled into the aahClientManaged.dll and aahStorage.exe files. MDAS not required to be installed.
Classic Toolkit vs. Historian 11 Toolkit Significant changes have been made to API. Here are the list of functions in the HistorianAccess object, once called Historian.
Historian Toolkit Overview Classic Toolkit vs. Historian 11 Toolkit How to connect Tag Creation Storing Data Retrieval
Connecting to Historian - Highlights Connection status is asynchronous. You must check status of connection to see if it is pending, in storeforward, or connected to the historian and storage process Connection is performed by WCF and requires a port. Prior, this was a DCOM connection. This also requires the username/password to be included in connection arguments. Late Data is not set during connection. It is set per tag.
Connecting to Historian Create ConnectionHistorianArgs object which will store all connection settings including username/password. Ensure that readOnly is also set as the default is true.
Connecting to Historian In a separate thread, open connection then repeatedly monitor connection status. Events not created by toolkit, so have to connection manager class to monitor the connection and raise events.
Toolkit comparison Archestra.Historian historianClient = new Archestra.Historian(); historianClient.Open("localhost"); historianClient.SetLateDataParams(true, 10, 10); historianClient.ConfigureStoreForward(true, @"C:\TestSF", 120); historianClient.ReconfigureStoreForward(); mStatus = new ArchestrA.HistorianConnectionStatus(); mLastError = null; //We will open connection then continue to monitor status if (HistorianAccess.OpenConnection(HistorianConnection, out mLastError)) { while(true) { HistorianAccess.GetConnectionStatus(ref mStatus); UpdateStatus(mStatus); System.Threading.Thread.Sleep(5000); } else UpdateStatus(null); }
Connecting to Historian - Demo
Historian Toolkit Overview Classic Toolkit vs. Historian 11 Toolkit How to connect Tag Creation Storing Data Retrieval
Tag Creation - Highlights What has changed? Tag creation can now be performed offline. HistorianTagStatus can provide information if an error occurred.
Tag Creation After adding tags, retain tags in an a local array so you can utilize the tagkey later when storing. If AddTag returns false, you can use GetTagStatusByName to find the error.
Toolkit comparison Archestra.Tag newtag = new Tag(); newtag.Tagname = "MyTag"; newtag.TagType = Archestra.TagType.Analog; newtag.AcquisitionType = AcquisitionType.Manual; newtag.DataType = DataType.Int4; newtag.Description = "This is my new tag"; newtag.EngUnit = "m/s"; newtag.MaxEU = 1000; newtag.MinEU = 0; newtag.StorageType = StorageType.Delta; //Add tag and check result Boolean result = historianClient.AddTag(ref newtag); ArchestrA.HistorianTag tag = new ArchestrA.HistorianTag(); tag.MaxEU = 100; tag.MinEU = 0; tag.ServerTimestamp = false; tag.TagChannelStatus = Convert.ToUInt16(EnableChannelStatus); tag.TagDataType = DataType; tag.TagDescription = Description; tag.TagKey = 0; tag.TagName = TagName; tag.TagStorageType = StorageType; uint tagkey = 0; mLastError = null; Boolean result = access.AddTag(tag, out tagkey, out mLastError);
Tag Creation - Demo
Historian Toolkit Overview Classic Toolkit vs. Historian 11 Toolkit How to connect Tag Creation Storing Data Retrieval
Storing Data - Highlights Data can now be stored without ever connecting to the Historian. The new Toolkit refers to real-time data now as Streamed Values. Late data still must be store in sequence of time. But unlike the classic storage, late data is processed as fast as real-time. Non-Streamed Values contain a collection of manual inserts that do not need to be in sequence of time. Data storage is much faster than the classic system and does not cause multiple data streams which affects retrieval performance. Revised Values will update existing values.
Storing Data – Streamed if(historianClient.ReadyForRealtimeStorage) { //Must register tag prior to storing. This tag must be committed as well historianClient.RegisterTag("MyTag"); //Create Value point Archestra.Value value = new Archestra.Value(); value.DoubleValue = 100; value.EndTime = DateTime.Now; value.StartTime = DateTime.Now; value.TagName = "MyTag"; value.OPCQuality = 192; historianClient.Store(ref value); } // Must get tag key to store data. Call GetTagInfoByName // to obtain the tag information including the tagkey. access.GetTagInfoByName(tagname, false, out tag, out error); value.DataValueType = HistorianDataType.Float; value.OpcQuality = 192; value.StartDateTime = System.DateTime.Now; value.Value = randomgenerator.Next(100); value.TagKey = tag.TagKey; error = null; parameters.access.AddStreamedValue(value, out error);
Storing Data – Non-Streamed if (historianClient.ReadyForOldDataStorage) { Archestra.Value value = new Archestra.Value(); value.DoubleValue = DateTime.Now.Second; value.StartTime = DateTime.Now.Subtract(new TimeSpan(5, 0, 0)); value.TagName = "MyTag"; value.OPCQuality = 192; ValueList list = new ValueList(); list.Add(value); //Insert values historianClient.Insert(ref list, VersionType.Latest); } // Must get tag key to store data. Call GetTagInfoByName to // obtain the tag information including the tagkey. access.GetTagInfoByName(tagname, false, out tag, out error); if (!access.CreateNonStreamedValueCollection(out collection, out error)) return; value.DataValueType = HistorianDataType.Float; value.OpcQuality = 192; value.StartDateTime = System.DateTime.Now; value.Value = randomgenerator.Next(100); value.TagKey = tag.TagKey; error = null; // Repeatedly add non streamed values to collection before sending values collection.AddNonStreamedValue(value, out error); // Send collection collection.SendNonStreamedValues(out error);
Storing Data – Revised Values if (historianClient.ReadyForOldDataStorage) { Archestra.Value value = new Archestra.Value(); value.DoubleValue = DateTime.Now.Second; value.EndTime = DateTime.Now; value.StartTime = DateTime.Now.Subtract( new TimeSpan(Convert.ToInt32(tbHours.Text), 0, 0)); value.TagName = "MyTag"; value.OPCQuality = 192; //Update value historianClient.Update(ref value); } ArchestrA.HistorianDataValueList valuelist = new ArchestrA.HistorianDataValueList(); // Must get tag key to store data. Call GetTagInfoByName to obtain the tag information including the tagkey. access.GetTagInfoByName(tagname, false, out tag, out error); value.DataValueType = HistorianDataType.Float; value.OpcQuality = 192; value.StartDateTime = System.DateTime.Now; value.Value = randomgenerator.Next(100); value.TagKey = tag.TagKey; error = null; // Repeatedly add revised values to collection before sending values valuelist.Add(value); // Send collection access.AddRevisionValues(ArchestrA.HistorianRevisionMode.RevisionUpdateMultiple, valuelist, out error);
Storing Data – Demo
Historian Toolkit Overview Classic Toolkit vs. Historian 11 Toolkit How to connect Tag Creation Storing Data Retrieval
Retrieval– Highlights Retrieval API has been improved significantly with this release of toolkit. Can query History or Analog and State Summaries. Data result that is received is not loaded into memory of toolkit application. Instead you can step through a pointer that loads values directly from History. Developer must clone values and manage internally their own ObservableCollection or any other collection.
Retrieval– Building Query Arguments ArchestrA.HistoryQueryArgs queryArgs = new ArchestrA.HistoryQueryArgs(); queryArgs.TagNames = new System.Collections.Specialized.StringCollection(); foreach (String tag in listBoxTagsToRetrieve.Items) queryArgs.TagNames.Add(tag); queryArgs.StartDateTime = dateTimePickerStart.Value.Value; queryArgs.EndDateTime = dateTimePickerEnd.Value.Value; queryArgs.Resolution = (ulong)Convert.ToUInt32(textBoxResolution.Text); queryArgs.TimeDeadband = Convert.ToUInt32(textBoxTimeDeadband.Text); queryArgs.ValueDeadband = Convert.ToUInt32(textBoxValueDeadband.Text); queryArgs.RetrievalMode = ArchestrA.HistorianRetrievalMode.Delta;
Retrieval– Executing Query ArchestrA.HistoryQuery result; ArchestrA.HistorianAccessError error = null; access.CreateHistoryQuery(out result); result.StartQuery(((ArchestrA.HistoryQueryArgs)param.arguments), out error); HistoryCollection = new ObservableCollection<ArchestrA.HistoryQueryResult>(); while (result.MoveNext(out error)) HistoryCollection.Add((ArchestrA.HistoryQueryResult)result.QueryResult.Clone());
Retrieval– Demo
Performance Comparison
Thank You!