以线性插值或者前向插值的模式获取指定时刻列表的插值记录列表

Navigation:  Python > Tag类管理 > tag模块 >

以线性插值或者前向插值的模式获取指定时刻列表的插值记录列表

Previous pageReturn to chapter overviewNext page

 

方法定义

 

get_inter_records_by_mode(self, mode, times)

 

 

方法参数说明

参数名称

参数说明

参数类型

默认值

times

值时刻列表,列表个数不超过65535,列表元素类型和datetime类型相同

datetime类型的list

 

mode

插值模式(0,线性LINEAR;1,前向PREN)。插值类型:值为1表示前向插值,即将某一个时刻之前最近的一条原始值作为改时刻的插值;值为0表示线性插值,即根据某一时刻之前的最近一条原始值和该时刻之后最近一条原始值来进行线性计算该时刻的插值。

数字型

 

 

 

异常

 

如果调用失败,抛出hyperdb.HDError异常

 

如果参数错误,抛出ArgumentError异常

 

返回值

 

一个包含总的错误码( hyperdb.hd_sucess 或 hyperdb.EC_HD_API_QUERY_INTERP_REC_FAILED)、HDRecord类型的记录列表和错误码列表的tuple

 

方法调用

 

def GetInterRecordsByMode(self):

   tagname = 'tag_int16_10'

   try:

       self.myTag = self.myTagMgr.get_tag(tagname)

   except Exception as e:

       print(e)

   times = []

   for second in [5, 15, 25, 35, 45, 55]:

       self.dattime = datetime.datetime(2023, 10, 16, 15, 11, second)

       times.append(self.dattime)

   try:

    ## mode:0/1        ->        LINEAR/PREV

       ret = self.myTag.get_inter_records_by_mode(0, times)

       hdrecords = ret[1]

   except Exception as e:

       print("get_inter_records_by_mode error: ", e.errcode)

   else:

       for hdrecord in hdrecords:

           print("snapshot quality: ", hdrecord.quality, "snapshot value: ",hdrecord.value, ", timestamp: ",hdrecord.sec)