根据插值模式、tagID列表,tagType列表,时间戳列表,获取对应的批量插值记录

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

根据插值模式、tagID列表,tagType列表,时间戳列表,获取对应的批量插值记录

Previous pageReturn to chapter overviewNext page

 

方法定义

 

get_inter_records_multitags_by_mode(self,mode,nTagIDs,strTagTy pes,times)

 

 

方法参数说明

参数名称

参数说明

参数类型

默认值

mode

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

数字类型

 

nTagIDs

tagID的列表,列表个数不超过65535

数字型的list

 

strTagTypes

tagType的列表,tagType为字符串,如’int8’

字符串型的list

 

times

插值的时间戳列表,与datetime,or HDTime同类型

datetime或HDTime的list

 

 

 

异常

 

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

 

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

 

返回值

 

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

 

方法调用

 

def GetInterRecordsMultitagsByMode(self):

   tagnames = []

   for i in range(10, 20):

       tagnames.append('tag_int16_' + str(i))

   try:

       ret = self.myTagMgr.get_tagIDs(tagnames)

   except Exception as e:

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

   tagIDs = ret[1]

   try:

       snapshots_ret = self.myDateProvider.get_snapshot_by_IDs(tagIDs)

   except Exception as e:

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

   snapshots = snapshots_ret[1]

   tagtypes = []

   times = []

   for i_hdrecord in snapshots:

       tagtypes.append(i_hdrecord.tagtype)

   for i in range(10):

       self.dattime = datetime.datetime(2023, 10, 17, 13, 53, 37)

       times.append(self.dattime)

       recret = self.myTag.get_inter_records_multitags_by_mode(mode=1, nTagIDs=tagIDs, strTagTypes=tagtypes, times=times)

       hdrecord_ret = recret[1]

   for i in range(len(tagnames)):

       print(tagnames[i], ":snapshot quality: ", hdrecord_ret[i].quality, "snapshot value: ", hdrecord_ret[i].value, ", timestamp: ",hdrecord_ret[i].sec)