NI采集卡多通道赋值之 -- memset/memcpy

int  m_NI_Para_nPoints = 1000//一个通道点数
int  m_NI_Para_nChan  = 8//通道数 ,8通道
//创建总数组,总数组长度为 m_NI_Para_nPoints * m_NI_Para_nChan 个点,共8000
float64 *output_DATA  = NULL;

if (NULL == output_DATA)
    {
output_DATA
= new float64[m_NI_Para_nPoints * m_NI_Para_nChan]; //数组置零 memset(output_DATA, 0, sizeof(float64)*(m_NI_Para_nPoints)); } //NI写入模式为 DAQmx_Val_GroupByChannel //8个通道数据各不相同,此处假设将第4通道数据赋给总数组,float64 p_data_value[]为已知的第四通道数据 int iChan = 4; memcpy(&output_DATA[iChan * m_NI_Para_nPoints], p_data_value, sizeof(float64)*m_NI_Para_nPoints);

此时只给总数组output_DATA中的第3000~4000个值赋上数组p_data_value的值

posted @ 2021-11-25 18:01  手磨咖啡  阅读(155)  评论(0)    收藏  举报