DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting "Date" type property from an AOP data store

Solved!
Go to solution

You are really in luck. Running from one honey pot to the next one. 🙂

I tried to create an example including all your points.

  • Time is handled as usiTimeDisp
  • how to use query object from store
  • how to load load results without getting trapped by loadconfiguration of LoadData

 

Option Explicit

Dim myDataStorePlugin : myDataStorePlugin = "ATFX"
Dim myDataStoreParam : myDataStoreParam = "<filename readonly=""yes"">" & replace(CurrentScriptPath & "EarthquakeExample.atfx", "&", "&amp;") & "</filename>"

dim oMyDataStore : set oMyDataStore = Navigator.ConnectDataStoreByParameter(myDataStorePlugin, myDataStoreParam)
dim measurementEntityName : measurementEntityName = oMyDataStore.Model.Entities("aomeasurement").SubTypes(1).Name

dim StartDate : StartDate = CreateTime(2001,1,13,17,33,0,0,0,0).VariantDate
dim EndDate : EndDate =     CreateTime(2001,1,13,17,34,0,0,0,0).VariantDate

dim query : set query=oMyDataStore.CreateQuery
query.ReturnType = measurementEntityName
Call query.Conditions.Add(measurementEntityName,"measurement_end",">=",StartDate)
Call query.Conditions.Add(measurementEntityName,"measurement_end","<=",EndDate)
Call oMyDataStore.Search(query)

data.Root.Clear
dim result : for each result in oMyDataStore.Results
  ' If you call LoadData use nothing or a load parametrization as third parameter. The default parametrization may not fit
  dim diademGroup : set diademGroup = navigator.LoadData(result, "Load", nothing)(1)
  ' if portal is empty LoadData might return the root instead of the loaded group
  if diademGroup.IsKindOf(eDataRoot) then set diademGroup = diademGroup.ChannelGroups(1)
  
  dim propItem : for each propItem in result.Properties
    
    if(propItem.Size > 0) then
      ' attribute is set in ASAM store
      select case propItem.DataType
        case DataTypeDate 
          ' date time properties return UsiTimeDisp so they have to be assigned by set
          dim usiTimeDispVar : set usiTimeDispVar = result.Properties("measurement_begin").Value
          ' if you need a CDate use
          dim cDateVar : cDateVar = usiTimeDispVar.VariantDate
          call diademGroup.properties.Add(result.Type & "_" & propItem.Name, usiTimeDispVar)
        case else
          call diademGroup.properties.Add(result.Type & "_" & propItem.Name, propItem.Value)
      end select
    end if
  next
  
Next

 I attach the running example including the atfx file as a zip.

0 Kudos
Message 11 of 12
(1,685 Views)

Thanks for being patient with me.  This stuff isn't clear in the help file to me.  I appreciate all the help you have provided.  🙂

0 Kudos
Message 12 of 12
(1,675 Views)