Details:
You can record the TIMESTAMP field (as well as the obligatory field CHRONO) when you configure an archive unit in HDS format in PcVue.
The limitation is that this field is only useful for interpreting the Date-time value of a CHRONO field. To avoid registration of the TIMESTAMP field, which would take up space in the SQL Server database, we advise you to use a SQL Server view.
Reminder: Changing the structure of existing HDS tables is not allowed, which is why we create an SQL Server view. That provides a different appearance for a table without modifying its structure. In our case access to a view will limited to read-only mode.
What you need to know:
- In the present structure of the HDS tables, two fields let you know the date-time value for an entry in UTC format. These two fields let you to identify the seasonal clock changes. You must always use them for export, purging etc. processes.
- Chrono (UTC time in DateTime format) – required
- TS (UTC time in text format) – optional
- There is also a DLL for transforming a Chrono value to local time (AIHdsTSConversion.dll) and vice versa. This DLL is programmed in the .NET language for best performance in conversion but it requires prior activation of the CLR code in the SQL Server database.
How to create a view with the local time field
- In your SQL Server database, install the DLL “AIHdsTSConversion.dll” via the script “Deploy.sql” and its documentation.
- Test the installation of this DLL via the script “Test.sql” and its documentation.
- Create a SQL Server view containing all fields of the Trend and Log tables plus the new LocalTime field.
To set up a view of the table, enter the following request in SSMS:
USE [DATABASE_NAME] GO CREATE VIEW [dbo].[TABLE1_VIEW] AS SELECT *, [dbo].[fn_GetLocalDatetimeFromUTCFiletime](Chrono) AS [LocalTime] FROM [DATABASE_NAME].[dbo].[TABLE1] GO
Where :
- DATABASE_NAME is the name of the database that contains the HDS tables.
- TABLE1 is the name of the table of tendency or log.
- TABLE1_VIEW is the name of the view that you create.
Now that the view is set up, you can request it as if it were a table.
SELECT * FROM [DATABASE_NAME].[dbo].[TABLE1_VIEW]
LocalTime
|
|
Chrono
|
Name
|
Value
|
Quality
|
2011-04-11
|
11:22:41.227
|
129469873612260000
|
Register01
|
0
|
192
|
2011-04-11
|
11:24:05.450
|
129469874454510000
|
Register01
|
1
|
192
|
2011-04-11
|
11:24:06.450
|
129469874464510000
|
Register01
|
2
|
192
|
2011-04-11
|
11:24:07.450
|
129469874474510000
|
Register01
|
3
|
192
|
2011-04-11
|
11:24:08.450
|
129469874484510000
|
Register01
|
4
|
192
|
2011-04-11
|
11:24:09.450
|
129469874494510000
|
Register01
|
5
|
192
|
2011-04-11
|
11:24:10.450
|
129469874504510000
|
Register01
|
6
|
192
|
2011-04-11
|
11:24:11.450
|
129469874514510000
|
Register01
|
7
|
192
|
2011-04-11
|
11:24:12.450
|
129469874524510000
|
Register01
|
8
|
192
|
Download attachments: AI_HdsTsConversion.zip
|