cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong DateTime value returned from Tag Query

Former Member
0 Kudos

Dear gurus,

I have a quite simple tag query that targets an Yokogawa PIMS implementation. I am using SAP UDS Server to connect MII to PIMS (DA).

The tag query configuration is:

- Query mode: Current

- Date interval: none

Below you can see an exemple of XML returned from the query:

<?xml version="1.0" encoding="UTF-8"?>
<Rowsets DateCreated="2010-01-25T13:36:45" EndDate="2010-01-22T22:07:50"
	StartDate="2010-01-22T22:07:36" Version="12.0.8 Build(24)">
	<Rowset>
		<Columns>
			<Column Description="DateTime" MaxRange="0" MinRange="0"
				Name="DateTime" SQLDataType="93" SourceColumn="DateTime"></Column>
			<Column Description="Perda de Produção do Branqueamento 1"
				MaxRange="100" MinRange="0" Name="Root.PocMII.Mii_Branq1_Producao.Value"
				SQLDataType="8" SourceColumn="Root.PocMII.Mii_Branq1_Producao.Value"></Column>
		</Columns>
		<Row>
			<DateTime>2010-01-25T13:36:41</DateTime>
			<Root.PocMII.Mii_Branq1_Producao.Value>0</Root.PocMII.Mii_Branq1_Producao.Value>
		</Row>
	</Rowset>
</Rowsets>

The datetime field returned by the query is matching the date/time the query is executed. I was expecting the datetime field to match the tag value timestamp (the time the tag value is added to PIMS) from the PIMS datastore.

For example. If a tag value "1" was created on PIMS on 12:10:10, when I ask for the current value using MII tag query I get the expected value "1" but the timespamp doesn't match "12:10:10". The timespamp always match the current date/time. I understand current value as the newest value added to PIMS for that tag, am I right?

I think this is a MII behavior because when I run the query for the current tag value using other tool (MS Excel based) I get the expected date time.

Is this the expected behavior? Do I need to change something in the tag query configuration to get the actual tag timestamp?

Thank you,

--

Wilson Freitas

Vetta Technologies

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I think what you want to do is a HistoryEvent query and set your rowcount to 1. This will give you the actual timestamp that is in the historian.

Be mindful though if your data source allows for storing of "Bad" data, this last value might be a bad value, unless you select the option in your UDS to ignore these.

Edited by: Doug Holtke on Jan 25, 2010 7:50 PM

Former Member
0 Kudos

Doug,

Your solution is pointing to the right direction but I am still not able to get an one row resultset containg the last value/datetime pair.

Changing to history mode I get the following response:

<?xml version="1.0" encoding="UTF-8" ?>
<Rowsets DateCreated="2010-01-26T17:02:04" EndDate="2010-01-26T17:02:04"
	StartDate="2010-01-26T16:02:04" Version="12.0.8 Build(24)">
	<Rowset>
		<Columns>
			<Column Description="DateTime" MaxRange="0" MinRange="0"
				Name="DateTime" SQLDataType="93" SourceColumn="DateTime"></Column>
			<Column Description="Perda de Produção do Branqueamento 1"
				MaxRange="100" MinRange="0" Name="Root.PocMII.Mii_Branq1_Producao.Value"
				SQLDataType="8" SourceColumn="Root.PocMII.Mii_Branq1_Producao.Value"></Column>
		</Columns>
		<Row>
			<DateTime>2010-01-26T16:02:04</DateTime>
			<Root.PocMII.Mii_Branq1_Producao.Value>0
			</Root.PocMII.Mii_Branq1_Producao.Value>
		</Row>
		<Row>
			<DateTime>2010-01-26T17:01:53</DateTime>
			<Root.PocMII.Mii_Branq1_Producao.Value>0
			</Root.PocMII.Mii_Branq1_Producao.Value>
		</Row>
		<Row>
			<DateTime>2010-01-26T17:02:04</DateTime>
			<Root.PocMII.Mii_Branq1_Producao.Value>0
			</Root.PocMII.Mii_Branq1_Producao.Value>
		</Row>
	</Rowset>
</Rowsets>

The Duration parameter is set to 60 minutes. If I run the same query over and over I always get the current datetime in the last row, the current datetime - 1 hour in the first row, and a valid datetime in the middle row. Something like this:

row1: currentDateTime - 1hour

row2: validTagDateTime

row3: currentDateTime

If I increase the Duration parameter I get more rows and the first row returns the current datetime - (duration parameter). For me the first and last rows are invalid rows because they are not related to actual tag values. Do I need to change anything in UDS server or in the query configuration in order to discard these rows?

If I change the resultset limit to 1 as you suggested I get one row containing the current datetime.

In theory I could get the row in the middle and use it but this does not look right.

Thank you

--

Wilson Freitas

Vetta Technologies

0 Kudos

Wilson,

There is a parameter in the Tag Query template in the Tag Query Details page named Resolution which will affect these values back from the data server.

Sam

Former Member
0 Kudos

Dear Salvatore,

I tried changing the Resolution parameter value but it had no effect on the resultsets.

Thank you.

Former Member
0 Kudos

Are you using History or HistoryEvent mode? You need to use HistoryEvent mode. Your post says you used history mode. History mode will interpolate values where HistoryEvent mode shows raw data.

Former Member
0 Kudos

Doug,

Changing from History to HistoryEvent mode solved the problem.

I also had to set the row count to 1 and the duration to a short interval: 1 minute in my scenario.

If someone else have the same problem these are the steps to solve it:

- Change the tag query mode to HistoryEvent

- Set row count to 1

- Set duration to a short value. I think the duration must not be greater than the frequency that new tag value are generated in the tag datastore.

Thank you all you guys for your help.

Best regards,

--

Wilson Freitas

Vetta Technologies

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

when you use the selection option as current for the tag query, it returns the value with current datetime stamp. To get the value of a particular datetime stamp, you can modify the query and you can set your date time stamp.

Hope this helps !!

Thanks,

Amit

Former Member
0 Kudos

I get my XML from OPC through PCo. Don't remember having a problem with datetime. Can you give us the XPath expression and any other relevant details that you are using to extract the information that you need?

Chanti.