BackStaff is complementary for different types of plant software. An instrumental one is the Historian application, and among these, Wonderware Historian is a trendy one. BackStaff can integrate with Wonderware Historian to:
- Create indicators or events
- Show time trends
- Launch reports
This information can be used to generate notifications, create scorecards, launch reports, and see historical trends from the BackStaff WEB and mobile clients.
BackStaff Configuration for communication with Wonderware Historian
The first step consists of creating a database connection, similar to the next example
The standard name for the Wonderware Historian database is ‘Runtime,’ while the server, username, and passwords must be filled according to your installation. Do not forget to test the connection, to validate the server name or IP address, as well as the user and password.
Query to pull data from Wonderware Historian
The system retrieves the values of the different variables or tags within the Historian by using the following query
Select ISNULL(Value,0) from Live Where Tagname = ‘Tag’
In this query, you have to change the word ‘Tag’ by the name of the tag of your interest in the Wonderware Historian. In case the value returned is null, the ISNULL function will return a value of 0, but you can change it according to your preferences.
This query can be addapted to get real time values or aggregated values (average, maximum, minimum, standard deviation or sum) by the use of the a query similar to the following
SET NOCOUNT ON
DECLARE @StartDate DateTime
DECLARE @EndDate DateTime
SET @StartDate = DateAdd(mi,-5,GetDate())
SET @EndDate = GetDate()
SET NOCOUNT OFF
SELECT TagName, Average = Avg(AnalogHistory.Value)
FROM AnalogHistory
WHERE AnalogHistory.TagName IN (‘xReactTemp’)
AND Quality = 0
AND wwVersion = ‘Latest’
AND wwRetrievalMode = ‘Cyclic’
AND wwRowCount = 100
AND DateTime >= @StartDate
AND DateTime <= @EndDate
GROUP BY AnalogHistory.TagName
If instead of the average you want something else, you can change ‘Average=Avg(AnalogHistory.Value)’ by:
- Minimum=Min(AnalogHistory.Value)
- Maximum=Max(AnalogHistory.Value)
- StdDev=Std(AnalogHistory.Value)
- Sum=Sum(AnalogHistory.Value)
Once you know how to retrieve the data from the historical database, the rest is traditional BackStaff creation of indicators and events. For example the creation of an event that triggers when the tag XEjector is True can be seen in the following image
or the creation of an indicator for a temperature
and those can be seen as part of a scorecard or event dashboard
Trends based on Wonderware Historian Data
BackStaff is capable of storing in its database the information that reads from the Historian database. Nonetheless, it would be redundant information, so BackStaff is capable of doing trends based on queries from other databases.
To get the data for the BackStaff trend it is necessary to include the historical query into the IPGParametros table in the BackStaff IPGIndicadores table, for the field HISTORIAN-QUERY. The proper query is
SET NOCOUNT ON;
DECLARE @TagNAME NVARCHAR(200) = ‘%s’, @StartDateTime datetime = DATEADD(%s,-%s,GETDATE()), @EndDateTime datetime = GETDATE()
Select CONVERT(DATETIME, DateTime) DateTime, ISNULL(Value,0) Value
from History
Where TagName = @TagName and DateTime >= @StartDateTime and DateTime <= @EndDateTime and wwResolution = 2000 and wwRetrievalMode = ‘Cyclic’
UNION SELECT FechaHora, HI.Valor
FROM IPGIndicadores.dbo.IPGIndicador I INNER JOIN IPGIndicadores.dbo.IPGHistoriaIndicador HI ON HI.IDIndicador = I.IDIndicador
WHERE EventoActivadoEnON IS NULL AND RegistraHistoria = 1 AND I.Nombre = @TagName AND FechaHora BETWEEN @StartDateTime AND @EndDateTime
ORDER BY 1 ASC
An example of a trend where the information comes from the Wonderware Historian is the following
Wonderware Historian Reports
Wonderware offers different tools to visualize the historical data. The BackStaff apps can call the URLs that you configure in the report section.
If your Wonderware Historian includes the ActiveFactory web, then the URL must be http://ServerName/AFWeb. If you have Wonderware InSight, then the URL must be http://ServerName:32569. You can also use the server IP address instead of the server name.
Summary
BackStaff integration with Wonderware Historian is straightforward and can be ready in less than one hour. It implies the creation of a database connection to the Wonderware Historian Runtime database, the setup for the query to retrieve historical data for the BackStaff trend, and the configuration of indicators and events from the Historian information.