Wonderware Historian Servers 操作
1、概述? ?
? 工控軟件Wonderware System Platform帶有Historian實(shí)時(shí)歸檔數(shù)據(jù)庫(kù),采用SQL Server+本地文件形式管理和存儲(chǔ)歸檔數(shù)據(jù)。數(shù)據(jù)的元數(shù)據(jù)(包括標(biāo)簽名、說(shuō)明、采樣頻率等)存儲(chǔ)在SQL Server的Runtime庫(kù)中,歸檔的結(jié)果數(shù)據(jù)存儲(chǔ)在本地。
2、Historian架構(gòu)
? ?Historian架構(gòu)圖如下:
3、Microsoft SQL Server Management Studio
? ? ? 數(shù)據(jù)庫(kù)的分析等,可以使用Microsoft SQL Server Management Studio直接操作,主要是數(shù)據(jù)在視圖中。可以使用標(biāo)準(zhǔn)SQL語(yǔ)法,但需要注意相關(guān)約束。
4、插入和查詢(xún)語(yǔ)法示例
INSERT INSQL.Runtime.dbo.AnalogHistory (DateTime, TagName, Value,
QualityDetail)
VALUES ('1999-11-11 16:05:10', 'NonIOTag1', 56, 192)
INSERT INTO INSQL.Runtime.dbo.StringHistory (DateTime, TagName, Value,
wwTimeZone, wwVersion)
VALUES ('1999-11-11 16:05:10', 'IOstring1', 'Batch 10', 'Eastern Standard
Time', 'latest')
INSERT v_History (TagName, QualityDetail, Value, DateTime)Importing, Inserting, or Updating History Data Wonderware Historian Administration Guide
Version 17.3.100 163
VALUES ('NonIOtag1', 192, 56, '1999-11-11 16:05:10')
INSERT INTO v_History (TagName, DateTime, Value, QualityDetail)
SELECT 'ManualReactTemp', DateTime, 32 + Value * 9 / 5, 192 FROM
v_AnalogHistory
WHERE TagName = 'ReactTemp'
AND DateTime >= dateadd(mi, -50, getdate())
AND DateTime < dateadd(mi, -10, getdate())
AND wwRetrievalMode = 'Delta'
DECLARE @Value float
DECLARE @DateTime DateTime
SET @Value = 1.2345
SET @DateTime = DateAdd(Minute, -10, GetDate())
INSERT v_History (DateTime, TagName, Value, QualityDetail)
VALUES (@DateTime, 'NonIOTag1', @Value, 192)
5、編程開(kāi)發(fā)
? ? ?在本機(jī)連接和操作數(shù)據(jù),C#參考代碼段如下:
?
? ? ? ?private string SqlServerConnString = "Persist Security Info=False;Integrated Security=true;Initial Catalog=runtime;server=(local)";
? ? ? ? using (SqlConnection conn = new SqlConnection())
? ? ? ? {
? ? ? ? ? ? String sql = "SELECT TagName,Description,AcquisitionType,ItemName,TagType FROM _Tag";
? ? ? ? ? ? conn.ConnectionString = SqlServerConnString;
? ? ? ? ? ? conn.Open();
? ? ? ? ? ? SqlCommand cmd_query = new SqlCommand(sql, conn);
? ? ? ? ? ? cmd_query.ExecuteNonQuery();
? ? ? ? ? ? using (SqlDataReader reader = cmd_query.ExecuteReader())
? ? ? ? ? ? {
? ? ? ? ? ? ? ? while (reader.Read())
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? String TagName = reader["TagName"].ToString();
? ? ? ? ? ? ? ? ? ? String Description = reader["Description"].ToString();
? ? ? ? ? ? ? ? ? ? String AcquisitionType = reader["AcquisitionType"].ToString();
? ? ? ? ? ? ? ? ? ? String ItemName = reader["ItemName"].ToString();
? ? ? ? ? ? ? ? ? ? String TagType = reader["TagType"].ToString();
? ? ? ? ? ? ? ? ? ? System.Console.WriteLine($"{TagName},{Description},{AcquisitionType},{ItemName},{TagType}");
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
?? ??? ?}
其他語(yǔ)言代碼可以參考上面的進(jìn)行修改。
Historian默認(rèn)是僅允許本機(jī)訪(fǎng)問(wèn),如果需要提供遠(yuǎn)程訪(fǎng)問(wèn),需要修改SQL Server的相關(guān)配置
總結(jié)
以上是生活随笔為你收集整理的Wonderware Historian Servers 操作的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。