Problem-Resolution article


Prerequisites

Access to Bazefield Portal, SQL Backend server as well as Master instance running aggregation service.


Problem


The aggregation service is time zone attribute aware. If the timezone is set for the asset, that in tern is associated with an object and its object attribute and finally the tag is aware of the object association to load the attribute all aggregations will be calculated in the appropriate time zone.


If you are finding that the timestamp of the aggregation is not in the appropriate time zone, i.e. site time is 1 behind off of server time, and the aggregation timestamp is still at server time midnight and not 00:59:59, you are most likely running into this issue.


Resolution


Step 1: Verify the attribute exists for asset/object

By default not all object types will come with a time zone attribute to set. This will prevent it being set from asset manager. If you don't see the Time Zone attribute listed under properties below as an option, you will need to insert the attributes.


To insert new domain attributes you'll need to run an insert script similar to below.

INSERT INTO Bazefield.DomainAttribute
SELECT typeid,CategoryId,'timeZone','Time Zone',NULL,4,1,0,NULL,1,Null FROM Bazefield.ObjectType
WHERE TypeID not like 200




Step 2: Edit/Set the Time Zone Attribute Value


The time zone attribute, as well as other domain attributes can be viewed in the properties of the edit asset page of Asset Manager



To do this in bulk, you can utilize a script similar to below.


INSERT INTO Bazefield.DomainObjectAttribute (ObjectId,AttributeId,Value)
SELECT do.ObjectId,da.AttributeId,'America/New_York'
FROM Bazefield.DomainObject do
join bazefield.DomainAttribute da
on da.TypeId = do.TypeId
inner join bazefield.DomainObjectAttribute doa
on doa.ObjectId = do.ObjectId
WHERE da.[Name] like 'Time Zone'
and do.[Key] like 'FGWD%'
and do.ObjectId not in (select objectid from bazefield.domainobjectattribute where attributeid in (select attributeid from bazefield.DomainAttribute where [Name] like 'Time Zone'))
GROUP BY do.ObjectId,da.attributeid


Step 3: Ensure than you run Update Domain Points from Tags 


The "FreeComment" column on the TAG table in sql holds the reference to the domain objects. You can check if this is lost by running a script similar to the following.

SELECT * FROM TAG WHERE FreeComment is NULL or FreeComment = ''


You can update the domain points from tags by going to the asset model and selecting the Update point list from tags button under the domain points tab as shown below.

Step 4: Restart Aggregation Service

This reloads the configurations for the aggregation tags


Step 5:Re-aggregate the tag and verify the result


You can trigger a re-aggregation by re-calculating the source/reference tag. Alternatively, you can follow the script below to force re-aggregations.

insert into tag_aggregate_pending(tagid,numericref) 
select tagid,numericref  from tagvalue_history where  numericref > imatis.fn_pims_getgdateUtc('2019-11-25') and  numericref < imatis.fn_pims_getgdateUtc('2019-12-04')
and TAGID IN (select tagid from tag where tagname like 'SITE-ASSET-TOT-ProducedEnergy.1h%')


Step 6: Troubleshooting


The aggregation service log on verbose prints out the time zones and object ids that it finds. The actual timestamps for start and end entered into the log don't reference this timezone change, but the timestamp saved to the aggregated data tag will be appropriate.

Background

The new domain objects hold attributes for time zones that ensure aggregations are calculated for the correct site timezone.


Product Environment and Version

Bazefield Aggregation Service 1.1.0.3

Bazefield Portal 8.0.28