活动介绍
file-type

Oracle位图索引(Bitmap Index)详解

PDF文件

下载需积分: 9 | 134KB | 更新于2024-12-24 | 44 浏览量 | 2 评论 | 2 下载量 举报 收藏
download 立即下载
"Bitmap Index是数据库中的一种特殊索引类型,尤其适用于处理具有低区分度(如性别、部门等)的列。它通过位图的方式来存储索引项,每个索引对应一个位,用于标记该索引项在哪些行中出现。这种方式在处理大量重复值时,能有效减少存储空间,并在特定查询场景下提高性能。" 正文: 位图索引(Bitmap Index)是数据库管理系统中一种特别设计的索引结构,主要针对那些具有较低区分度的列,即某一列中存在大量重复的值。在这种情况下,传统的B-Tree索引可能会因为数据分布不均导致查询效率降低。例如,一个包含性别信息的列,只有“男”和“女”两个值,如果使用B-Tree索引,将会产生大量的索引页,因为每种性别都有大量的记录。 位图索引的工作原理是为每个可能的值分配一个位图,位图中的每一位对应表中的一行。如果某一行在某一列上有特定的值,那么在对应的位图中,对应的位就会被设置为1。例如,对于性别列,男性位图中的每一位代表一位男性员工,女性位图同样如此。当执行查询时,数据库系统可以高效地进行位运算来找到满足条件的行,而不需要遍历整个表。 建立位图索引的SQL语法大致如下: ```sql CREATE BITMAP INDEX bitmap_index_name ON table_name(column_name); ``` 位图索引的优点在于节省存储空间,特别是在处理大数据量和低区分度列时,可以显著减少索引的大小。此外,它们在处理多列组合查询时特别有效,因为可以对多个位图进行并集或交集运算,快速找出满足多个条件的行。 然而,位图索引也有其局限性。它们不适合频繁的更新操作,因为每次插入、删除或更新都会涉及到位图的修改,这可能会变得非常昂贵。此外,位图索引在全范围扫描(即查询所有行)时并不适用,此时全表扫描通常更快。因此,位图索引更适合于那些查询条件明确且涉及低区分度列的场景。 在Oracle数据库中,位图索引是自动管理的,但数据库优化器会选择何时使用位图索引。如果查询预计会返回超过5%的行,Oracle可能不会使用位图索引,而是选择全表扫描。因此,位图索引的使用需要根据实际的查询模式和表的统计信息来决定。 位图索引是数据库优化的一个重要工具,尤其是在数据仓库和分析型应用中,它可以显著提升某些类型查询的性能。然而,理解其工作原理和适用场景至关重要,以便正确地应用和管理这些索引,避免可能的性能反效果。在实际使用中,应结合业务需求和查询分析,谨慎考虑是否使用位图索引,以及如何最佳地利用它来优化数据库的性能。

相关推荐

filetype

import pygame from OpenGL.GL import * from OpenGL.GLU import * def load_obj(filename): vertices = [] faces = [] texcoords = [] with open(filename, 'r') as f: for line in f: if line.startswith('#'): continue values = line.split() if not values: continue if values[0] == 'v': if len(values) == 4: vertices.append(list(map(float, values[1:4]))) elif len(values) == 3: texcoords.append(list(map(float, values[1:3]))) elif values[0] == 'f': face = [] texcoord_face = [] for face_str in values[1:]: vertex_index, texcoord_index, _ = face_str.split('/') face.append(int(vertex_index)) texcoord_face.append(int(texcoord_index)) faces.append(face) texcoords.append(texcoord_face) return vertices, faces, texcoords def draw_obj(filename, tex_id): vertices, faces, texcoords = load_obj(filename) glBindTexture(GL_TEXTURE_2D, tex_id) glBegin(GL_TRIANGLES) for face, texcoord_face in zip(faces, texcoords): for vertex_index, texcoord_index in zip(face, texcoord_face): glVertex3fv(vertices[vertex_index - 1]) glTexCoord2fv(texcoords[texcoord_index - 1]) glEnd() pygame.init() display = (800, 600) pygame.display.set_mode(display, pygame.DOUBLEBUF | pygame.OPENGL) gluPerspective(45, (display[0]/display[1]), 0.1, 50.0) glTranslatef(0.0, 0.0, -5) tex_surface = pygame.image.load('texture.jpg') tex_data = pygame.image.tostring(tex_surface, 'RGB', 1) tex_id = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, tex_id) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex_surface.get_width(), tex_surface.get_height(), 0, GL_RGB, GL_UNSIGNED_BYTE, tex_data) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) draw_obj('model.obj', tex_id) pygame.display.flip() pygame.time.wait(10)

filetype

### dec_gen.py ### # Created by Lorenzo Lagostina in 07/10/2022 and revised by Deborah Volpe # The program allows to create a behavioral description of the ctrl_mask generation block in VHDL import sys import math def dec_gen(qubit_number): N = int(qubit_number) entityName = 'STATE_DECODER_N_' + qubit_number fileOuTName = '../basic_blocks/decoders/src/state_decoder_N_' + qubit_number + '.vhd' fileOut = open (fileOuTName, 'w') ##### Write entity # newLine = 'LIBRARY IEEE;\n USE IEEE.STD_LOGIC_1164.ALL;\n ENTITY state_decoder_N_' + qubit_number + ' IS\n PORT (\n ' + entityName + '_IN_QTGT : IN STD_LOGIC_VECTOR( ' + str(math.ceil(math.log2(N))-1) + ' DOWNTO 0);\n ' + entityName + '_IN_QCTRL : IN STD_LOGIC_VECTOR( ' + str(math.ceil(math.log2(N))-1) + ' DOWNTO 0);\n ' + entityName + '_IN_OPCODE : IN STD_LOGIC_VECTOR (3 DOWNTO 0);\n ' + entityName + '_IN_SAVE_QBIT_NUMBER : IN STD_LOGIC;\n ' + entityName + '_IN_CLEAR : IN STD_LOGIC;\n ' + entityName + '_IN_CLK : IN STD_LOGIC;\n ' + entityName + '_OUT_MASK_FIRST : OUT STD_LOGIC; \n' + entityName + '_OUT_CTRL_MASK : OUT STD_LOGIC_VECTOR ( ' + str((2**N)-1) + ' DOWNTO 0)\n );\n END ENTITY;\n' fileOut.write(newLine) # ##### ##### Begin architecture and declare components and signals # newLine = 'ARCHITECTURE generated OF state_decoder_N_' + str(N) + ' IS\n ' fileOut.write(newLine) #register newLine = 'COMPONENT n_bit_register IS\n generic (n_bit: INTEGER);\n port (REG_IN_DATA: IN STD_LOGIC_VECTOR(n_bit - 1 DOWNTO 0);\n REG_IN_CLK, REG_IN_CLEAR, REG_IN_ENABLE: IN STD_LOGIC;\n REG_OUT_DATA: OUT STD_LOGIC_VECTOR(n_bit - 1 DOWNTO 0));\nEND COMPONENT;\n' fileOut.write(newLine) newLine = 'SIGNAL TO_SAVE_BUF, FROM_SAVE_BUF : STD_LOGIC_VECTOR(0 DOWNTO 0);\n' fileOut.write(newLine) newLine = 'SIGNAL DEC_QCTRL, DEC_USED, QUBIT_USED, QUBIT_MASK, QCTRL_ENABLED_STATES : STD_LOGIC_VECTOR(' + str(N-1) + ' DOWNTO 0);\n' fileOut.write(newLine) newLine = 'SIGNAL CLR_SAVE_QUBIT, ctrl_tgt_diff : STD_LOGIC;\n' fileOut.write(newLine) newLine = 'BEGIN\n' fileOut.write(newLine) # ##### ##### Generate mask_first # newLine = '' + entityName + '_OUT_MASK_FIRST <= \'0\' WHEN ' + entityName + '_IN_OPCODE = \"0010\" OR ' + entityName + '_IN_OPCODE = \"0100\" OR ' + entityName + '_IN_OPCODE = \"0101\" OR ' + entityName + '_IN_OPCODE = \"0110\" OR ' + entityName + '_IN_OPCODE = \"0111\" OR ' + entityName + '_IN_OPCODE = \"1011\" ELSE \'1\';\n' fileOut.write(newLine) # ##### ##### Generate qctrl decoder and qubit mask # newLine = 'DEC_QCTRL <= \n' fileOut.write(newLine) for qubit_index in range(N): newLine = '\"' + '{0:b}'.format(2**qubit_index).zfill(N) + '\" WHEN ' + entityName + '_IN_QCTRL = \"' + '{0:b}'.format(qubit_index).zfill(math.ceil(math.log2(N))) + '\" ELSE\n' fileOut.write(newLine) newLine = '(OTHERS => \'0\');\n' fileOut.write(newLine) newLine = 'ctrl_tgt_diff <= \'1\' WHEN STATE_DECODER_N_' + str(N) + '_IN_QCTRL = STATE_DECODER_N_' + str(N) + '_IN_QTGT ELSE \'0\';\n' fileOut.write(newLine) newLine = 'QCTRL_ENABLED_STATES <= (OTHERS => \'1\') WHEN ctrl_tgt_diff = \'1\' ELSE DEC_QCTRL;\n' fileOut.write(newLine) newLine = 'DEC_USED <= \n' fileOut.write(newLine) for qubit_index in range(N): newLine = '\"' + '{0:b}'.format((2**(qubit_index+1))-1).zfill(N) + '\" WHEN ' + entityName + '_IN_QCTRL = \"' + '{0:b}'.format(qubit_index).zfill(math.ceil(math.log2(N))) + '\" ELSE\n' fileOut.write(newLine) newLine = '(OTHERS => \'0\');\n' fileOut.write(newLine) for qubit_index in range(N): newLine = 'QUBIT_MASK(' + str(qubit_index) + ') <= QCTRL_ENABLED_STATES(' + str(qubit_index) + ') ;\n' fileOut.write(newLine) # ##### ##### Generate registers # newLine = 'TO_SAVE_BUF(0) <= ' + entityName + '_IN_SAVE_QBIT_NUMBER;\n' fileOut.write(newLine) newLine = 'CLR_SAVE_QUBIT <= ' + entityName + '_IN_CLEAR OR FROM_SAVE_BUF(0);\n' fileOut.write(newLine) newLine = 'REG_SAVE_FLAG : n_bit_register\nGENERIC MAP (1)\nPORT MAP(\n REG_IN_DATA => TO_SAVE_BUF ,\n REG_IN_ENABLE => ' + entityName + '_IN_SAVE_QBIT_NUMBER ,\n REG_IN_CLEAR => CLR_SAVE_QUBIT ,\n REG_IN_CLK => ' + entityName + '_IN_CLK ,\n REG_OUT_DATA => FROM_SAVE_BUF);\n' fileOut.write(newLine) newLine = 'REG_SAVE_QUBIT_NUMBER : n_bit_register\nGENERIC MAP (' + str(N) + ')\nPORT MAP(\n REG_IN_DATA => DEC_USED ,\n REG_IN_ENABLE => FROM_SAVE_BUF(0) ,\n REG_IN_CLEAR => ' + entityName + '_IN_CLEAR ,\n REG_IN_CLK => ' + entityName + '_IN_CLK ,\n REG_OUT_DATA => QUBIT_USED);\n' fileOut.write(newLine) # ##### ##### Generate mask decoder # for out_index in range (2**N): if out_index == 0: newLine = entityName + '_OUT_CTRL_MASK(' + str(out_index) + ') <= ctrl_tgt_diff;\n' fileOut.write(newLine) else : signalList = [] for qubit_index in range(N): if not( (out_index & (2**qubit_index)) == 0 ): newLine = 'QUBIT_MASK(' + str(qubit_index) + ')' signalList.append(newLine) newLine = entityName + '_OUT_CTRL_MASK(' + str(out_index) + ') <= ' + ' OR '.join(signalList) + ';\n' fileOut.write(newLine) # ##### newLine = '' fileOut.write(newLine) newLine = 'END generated;' fileOut.write(newLine) dec_gen(sys.argv[1])

filetype

uint8_t SD_Init(spi_index_enum spi_n) { uint8_t response; uint8_t ocr[4]; uint32_t timeout; // 初始化CS引脚(增加上拉) gpio_init(SD_CS_PIN, GPO, 1, GPI_PULL_UP ); gpio_high(SD_CS_PIN); // CS置高(未选中) // 1. 初始化SPI为低速模式(100-400kHz) spi_init(spi_n, SPI_MODE0, 400000, SPI1_MAP0_SCK_A5, SPI1_MAP0_MOSI_A7, SPI1_MAP0_MISO_A6, A4); // 2. 发送80+个时钟脉冲(确保SD卡完成上电) gpio_high(SD_CS_PIN); // 保持CS高电平 for(uint8_t i = 0; i < 10; i++) { spi_write_8bit(spi_n, 0xFF); system_delay_us(10); // 增加延时确保稳定 } // 3. 发送CMD0复位卡(需要精确CS控制) gpio_low(SD_CS_PIN); // 选中SD卡 response = SD_SendCmd(spi_n, CMD0, 0, 0x95); gpio_high(SD_CS_PIN); // 释放SD卡 spi_write_8bit(spi_n, 0xFF); // 额外时钟周期 if(response != 0x01) { return 0xFF; // 复位失败 } // 4. 发送CMD8检查SD卡版本(增加电压检查) gpio_low(SD_CS_PIN); response = SD_SendCmd(spi_n, CMD8, 0x000001AA, 0x87); // 固定参数0x1AA if(response == 0x01) { // 正确读取4字节响应 spi_read_8bit_array(spi_n, ocr, 4); // 检查电压范围(必须包含3.3V) if((ocr[2] & 0x0F) != 0x01) { gpio_high(SD_CS_PIN); return 0xFE; // 电压不兼容 } } else if(response != 0x05) { // 0x05是非法命令(SDv1卡) gpio_high(SD_CS_PIN); return 0xFD; // CMD8失败 } gpio_high(SD_CS_PIN); spi_write_8bit(spi_n, 0xFF); // 5. 初始化循环(修复逻辑错误) timeout = 1000; // 超时时间1s uint8_t sd_type = 0; do { // 先发送CMD55 gpio_low(SD_CS_PIN); SD_SendCmd(spi_n, CMD55, 0, 0x65); gpio_high(SD_CS_PIN); spi_write_8bit(spi_n, 0xFF); // 发送ACMD41(带HCS标志) gpio_low(SD_CS_PIN); response = SD_SendCmd(spi_n, ACMD41, 0x40000000, 0x77); // 必须带HCS gpio_high(SD_CS_PIN); spi_write_8bit(spi_n, 0xFF); system_delay_ms(10); // 增加延时 } while((response != 0x00) && timeout--); if(response != 0x00) { return 0xFC; // 初始化超时 } // 6. 发送CMD58读取OCR(修复读取逻辑) gpio_low(SD_CS_PIN); response = SD_SendCmd(spi_n, CMD58, 0, 0xFD); if(response != 0x00) { gpio_high(SD_CS_PIN); return 0xFB; // CMD58失败 } // 正确读取OCR spi_read_8bit_array(spi_n, ocr, 4); gpio_high(SD_CS_PIN); spi_write_8bit(spi_n, 0xFF); // 7. 设置块大小(必须步骤!) gpio_low(SD_CS_PIN); response = SD_SendCmd(spi_n, CMD16, 512, 0xFF); gpio_high(SD_CS_PIN); spi_write_8bit(spi_n, 0xFF); if(response != 0x00) { return 0xFA; // 设置块大小失败 } // 8. 切换高速SPI模式 spi_init(spi_n, SPI_MODE0, 25000000, SPI1_MAP0_SCK_A5, SPI1_MAP0_MOSI_A7, SPI1_MAP0_MISO_A6, SPI_CS_NULL); // 9. 返回卡类型 return (ocr[0] & 0x40) ? SD_TYPE_SDHC : SD_TYPE_SD2; } // SD卡命令发送函数 uint8_t SD_SendCmd(spi_index_enum spi_n, uint8_t cmd, uint32_t arg, uint8_t crc) { gpio_low(SD_CS_PIN); // CS置低 spi_write_8bit(spi_n, (uint8_t)(cmd | 0x40)); // 强制转换为uint8_t spi_write_8bit(spi_n, (uint8_t)((arg >> 24) & 0xFF)); spi_write_8bit(spi_n, (uint8_t)((arg >> 16) & 0xFF)); spi_write_8bit(spi_n, (uint8_t)((arg >> 8) & 0xFF)); spi_write_8bit(spi_n, (uint8_t)(arg & 0xFF)); spi_write_8bit(spi_n, crc); // CRC校验 // 等待响应(R1格式) uint8_t retry = 20; uint8_t response; do { response = (uint8_t)spi_read_8bit(spi_n); // 确保返回值为uint8_t } while((response == 0xFF) && retry--); return response; } 上面函数调用时显示超出超过屏幕分辨率范围,下面时oled报错的函数位置void oled_show_string (uint16 x, uint16 y, const char ch[]) { // 如果程序在输出了断言信息 并且提示出错位置在这里 // 那么一般是屏幕显示的时候超过屏幕分辨率范围了 // 检查一下你的显示调用的函数 自己计算一下哪里超过了屏幕显示范围 zf_assert(128 > x); zf_assert(8 > y); OLED_CS(0); uint8 c = 0, i = 0, j = 0; while ('\0' != ch[j]) { switch(oled_display_font) { case OLED_6X8_FONT: { c = ch[j] - 32; if(x > 126) { x = 0; y ++; } oled_set_coordinate(x, y); for(i = 0; 6 > i; i ++) { oled_write_data(ascii_font_6x8[c][i]); } x += 6; j ++; }break; case OLED_8X16_FONT: { c = ch[j] - 32; if(x > 120) { x = 0; y ++; } oled_set_coordinate(x, y); for(i = 0; i < 8; i ++) { oled_write_data(ascii_font_8x16[c][i]); } oled_set_coordinate(x, y + 1); for(i = 0; i < 8; i ++) { oled_write_data(ascii_font_8x16[c][i + 8]); } x += 8; j ++; }break; case OLED_16X16_FONT: { // 暂不支持 }break; } } OLED_CS(1); }

filetype

解释这段代码#include "qemu/osdep.h" #include "qapi/error.h" #include "ui/console.h" #include "hw/hw.h" #include "hw/boards.h" #include "hw/loader.h" #include "hw/display/framebuffer.h" #include "hw/arm/fsl-imx6ul.h" #include "ui/pixel_ops.h" //#include "hw/m68k/next-cube.h" #include "hw/gpio/imx_gpio.h" #include "hw/gpio/100ask_imx6ull_buttons.h" #include "ui/console.h" #include "ui/file.h" #include "ui/pic_operation.h" #include "ui/picfmt_manager.h" #include "ui/fonts.h" #include "ui/input.h" #include "ui/button_ui.h" /* * button1 : GPIO05_01 * button2 : GPIO01_18 * */ static int pin_to_button_map[][3] = { /* group, pin, button(0-button1, 1-button2) */ {5, 1, 0}, {1, 18, 1}, }; void notify_board_button_change(int index) { int group = pin_to_button_map[index][0]; int pin = pin_to_button_map[index][1]; int level = is_button_pressed(index); notify_imx_gpio_change(group, pin, level); } static void imx6ull_gpio_button_realize(DeviceState *dev, Error **errp) { button_ui_create(dev); } static void imx6ull_gpio_button_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories); dc->realize = imx6ull_gpio_button_realize; } static const TypeInfo imx6ull_gpio_button_info = { .name = TYPE_BUTTON, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(ButtonState), .class_init = imx6ull_gpio_button_class_init, }; void create_imx6ull_buttons(void) { DeviceState *dev; dev = qdev_create(NULL, TYPE_BUTTON); qdev_init_nofail(dev); } static void imx6ull_gpio_button_register_types(void) { type_register_static(&imx6ull_gpio_button_info); } type_init(imx6ull_gpio_button_register_types)

filetype

``` #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <algorithm> #include <unordered_map> #include <tuple> #include <queue> #include <string> #include <cstring> #include<cstdio> using namespace std; using ll = long long; #define N 10000005 int trie[N][4], fail[N], lens[N]; char cm[100005][100]; bool vis[N]; int cnt = 0, ans = 0, root = 0; int calc(char a) { if (a == 'N')return 0; else if (a == 'S')return 1; else if (a == 'W')return 2; else return 3; } void insert(char* a) { int now = root; int n = strlen(a); for (int i = 0; a[i] != '\0'; i++) { int bit = calc(a[i]); if (!trie[now][bit])trie[now][bit] = ++cnt; now = trie[now][bit]; } lens[ans] = n; } void buildfail() { queue<int>line; fail[root] = root; for (int i = 0; i < 4; i++) { if (trie[root][i]) { fail[trie[root][i]] = root; line.push(trie[root][i]); } } while (line.size()) { int now = line.front(); line.pop(); for (int i = 0; i < 4; i++) { if (!trie[now][i])trie[now][i] = trie[fail[now]][i]; else { fail[trie[now][i]] = trie[fail[now]][i]; line.push(trie[now][i]); } } } } void search(string a) { int now = root; for (int i = 0; i < a.size(); i++) { int index = calc(a[i]); now = trie[now][index]; int temp = now; while (temp != root) { if (!vis[temp]) vis[temp] = true; else break; temp = fail[temp]; } } } int nizhao(char* a) { int now = root; int res = 0; for (int i = 0; a[i] != '\0'; i++) { int bit = calc(a[i]); if (vis[trie[now][bit]])res++; else break; now = trie[now][bit]; } return res; } int main() { int n, m; cin >> n >> m; string mu; cin >> mu; for (int i = 0; i < m; i++) { scanf("%s", cm[i]); insert(cm[i]); } buildfail(); search(mu); for (int i = 0; i < m; i++) cout << nizhao(cm[i]) << endl; }```哪里有问题

filetype

static float LineTracker_DistanceCalc(SignalDef_u *pSignal) { float Distance; uint8_t num; num = 0; if(pSignal->bit.ls1 == LineTracker_Struct.active_level) num++; if(pSignal->bit.ls2 == LineTracker_Struct.active_level) num++; if(pSignal->bit.ls3 == LineTracker_Struct.active_level) num++; if(pSignal->bit.ls4 == LineTracker_Struct.active_level) num++; if(pSignal->bit.ls5 == LineTracker_Struct.active_level) num++; if(pSignal->bit.ls6 == LineTracker_Struct.active_level) num++; if(pSignal->bit.ls7 == LineTracker_Struct.active_level) num++; if(pSignal->bit.ls8 == LineTracker_Struct.active_level) num++; if( ( num >= LINETRACKER_LINE_REFERENCE ) || \ ( ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls3 == pSignal->bit.ls6 ) ) ) { Distance = 7; } //==========================双线================================= else if( ( pSignal->bit.ls3 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls6 == LineTracker_Struct.active_level ) ) Distance = 7; else if( ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls6 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls7 == LineTracker_Struct.active_level ) ) Distance = 9; else if( ( pSignal->bit.ls2 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls3 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) ) Distance = 5; else if( ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls6 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls7 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls8 == LineTracker_Struct.active_level ) ) Distance = 11; else if( ( pSignal->bit.ls1 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls2 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls3 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) ) Distance = 3; else if( ( pSignal->bit.ls3 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) ) Distance = 6; else if( ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls6 == LineTracker_Struct.active_level ) ) Distance = 8; else if( ( pSignal->bit.ls2 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls3 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) ) Distance = 4; else if( ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls6 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls7 == LineTracker_Struct.active_level ) ) Distance = 10; else if( ( pSignal->bit.ls1 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls2 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls3 == LineTracker_Struct.active_level ) ) Distance = 2; else if( ( pSignal->bit.ls6 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls7 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls8 == LineTracker_Struct.active_level ) ) Distance = 12; //==========================单线================================= else if( ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) ) Distance = 7; else if( ( pSignal->bit.ls3 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls4 == LineTracker_Struct.active_level ) ) Distance = 5; else if( ( pSignal->bit.ls5 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls6 == LineTracker_Struct.active_level ) ) Distance = 9; else if( ( pSignal->bit.ls2 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls3 == LineTracker_Struct.active_level ) ) Distance = 3; else if( ( pSignal->bit.ls6 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls7 == LineTracker_Struct.active_level ) ) Distance = 11; else if( ( pSignal->bit.ls1 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls2 == LineTracker_Struct.active_level ) ) Distance = 1; else if( ( pSignal->bit.ls7 == LineTracker_Struct.active_level ) && \ ( pSignal->bit.ls8 == LineTracker_Struct.active_level ) ) Distance = 13; else if( pSignal->bit.ls4 == LineTracker_Struct.active_level ) Distance = 6; else if( pSignal->bit.ls5 == LineTracker_Struct.active_level ) Distance = 8; else if( pSignal->bit.ls3 == LineTracker_Struct.active_level ) Distance = 4; else if( pSignal->bit.ls6 == LineTracker_Struct.active_level ) Distance = 10; else if( pSignal->bit.ls2 == LineTracker_Struct.active_level ) Distance = 2; else if( pSignal->bit.ls7 == LineTracker_Struct.active_level ) Distance = 12; else if( pSignal->bit.ls1 == LineTracker_Struct.active_level ) Distance = 0; else if( pSignal->bit.ls8 == LineTracker_Struct.active_level ) Distance = 14; return (Distance*RL_LENGTH_FAC/14.0f); }

filetype

这是生成的map文件module SPI_Master_SPI_MODE0_CLKS_PER_HALF_BIT5 ( i_Rst_L, i_Clk, i_TX_Byte, i_TX_DV, o_TX_Ready, o_RX_DV, o_RX_Byte, o_SPI_Clk, i_SPI_MISO, o_SPI_MOSI, o_SPI_CS_n ); input [7:0] i_TX_Byte; output [7:0] o_RX_Byte; input i_Rst_L, i_Clk, i_TX_DV, i_SPI_MISO; output o_TX_Ready, o_RX_DV, o_SPI_Clk, o_SPI_MOSI, o_SPI_CS_n; wire r_i_SPI_MISO, n76, n77, n78, n79, n80, n81, n82, n83, n84, n85, n86, n87, n88, n89, n90, n91, n92, n93, n94, n95, n96, n97, n98, n99, n100, n101, n102, n103, n104, n105, n106, n107, n108, n109, n110, n111, n112, n113, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16, n17, n18, n19, n20, n21, n22, n23, n24, n25, n26, n27, n28, n29, n30, n31, n32, n33, n34, n35, n36, n37, n38, n39, n40, n41, n42, n43, n44, n45, n46, n47, n48, n49, n50, n51, n52, n53, n54, n55, n56, n57, n58, n59, n60, n61, n62, n63, n64, n65, n66, n67, n68; wire [1:0] r_SM_CS; wire [3:0] r_Clk_Count; wire [2:0] r_Bit_Index; wire [7:0] r_TX_Byte; wire [7:0] r_RX_Byte; QDFFRBS r_i_SPI_MISO_reg ( .D(i_SPI_MISO), .CK(i_Clk), .RB(i_Rst_L), .Q( r_i_SPI_MISO) ); QDFFRBS r_SM_CS_reg_1_ ( .D(n109), .CK(i_Clk), .RB(i_Rst_L), .Q(r_SM_CS[1]) ); QDFFRBS r_Clk_Count_reg_0_ ( .D(n105), .CK(i_Clk), .RB(i_Rst_L), .Q( r_Clk_Count[0]) ); QDFFRBS r_Clk_Count_reg_1_ ( .D(n110), .CK(i_Clk), .RB(i_Rst_L), .Q( r_Clk_Count[1]) ); QDFFRBS r_Clk_Count_reg_2_ ( .D(n111), .CK(i_Clk), .RB(i_Rst_L), .Q( r_Clk_Count[2]) ); QDFFRBS r_Clk_Count_reg_3_ ( .D(n112), .CK(i_Clk), .RB(i_Rst_L), .Q( r_Clk_Count[3]) ); QDFFRBS r_Bit_Index_reg_0_ ( .D(n107), .CK(i_Clk), .RB(i_Rst_L), .Q( r_Bit_Index[0]) ); QDFFRBS r_Bit_Index_reg_1_ ( .D(n106), .CK(i_Clk), .RB(i_Rst_L), .Q( r_Bit_Index[1]) ); QDFFRBS r_Bit_Index_reg_2_ ( .D(n113), .CK(i_Clk), .RB(i_Rst_L), .Q( r_Bit_Index[2]) ); QDFFRBS r_RX_Byte_reg_4_ ( .D(n100), .CK(i_Clk), .RB(i_Rst_L), .Q( r_RX_Byte[4]) ); QDFFRBS r_RX_Byte_reg_5_ ( .D(n99), .CK(i_Clk), .RB(i_Rst_L), .Q( r_RX_Byte[5]) ); QDFFRBS r_RX_Byte_reg_6_ ( .D(n98), .CK(i_Clk), .RB(i_Rst_L), .Q( r_RX_Byte[6]) ); QDFFRBS r_RX_Byte_reg_7_ ( .D(n97), .CK(i_Clk), .RB(i_Rst_L), .Q( r_RX_Byte[7]) ); QDFFRBS r_RX_Byte_reg_1_ ( .D(n103), .CK(i_Clk), .RB(i_Rst_L), .Q( r_RX_Byte[1]) ); QDFFRBS r_RX_Byte_reg_2_ ( .D(n102), .CK(i_Clk), .RB(i_Rst_L), .Q( r_RX_Byte[2]) ); QDFFRBS r_RX_Byte_reg_3_ ( .D(n101), .CK(i_Clk), .RB(i_Rst_L), .Q( r_RX_Byte[3]) ); QDFFRBS r_RX_Byte_reg_0_ ( .D(n104), .CK(i_Clk), .RB(i_Rst_L), .Q( r_RX_Byte[0]) ); QDFFRBS o_RX_DV_reg ( .D(n95), .CK(i_Clk), .RB(i_Rst_L), .Q(o_RX_DV) ); QDFFRBS o_RX_Byte_reg_7_ ( .D(n94), .CK(i_Clk), .RB(i_Rst_L), .Q( o_RX_Byte[7]) ); QDFFRBS o_RX_Byte_reg_6_ ( .D(n93), .CK(i_Clk), .RB(i_Rst_L), .Q( o_RX_Byte[6]) ); QDFFRBS o_RX_Byte_reg_5_ ( .D(n92), .CK(i_Clk), .RB(i_Rst_L), .Q( o_RX_Byte[5]) ); QDFFRBS o_RX_Byte_reg_4_ ( .D(n91), .CK(i_Clk), .RB(i_Rst_L), .Q( o_RX_Byte[4]) ); QDFFRBS o_RX_Byte_reg_3_ ( .D(n90), .CK(i_Clk), .RB(i_Rst_L), .Q( o_RX_Byte[3]) ); QDFFRBS o_RX_Byte_reg_2_ ( .D(n89), .CK(i_Clk), .RB(i_Rst_L), .Q( o_RX_Byte[2]) ); QDFFRBS o_RX_Byte_reg_1_ ( .D(n88), .CK(i_Clk), .RB(i_Rst_L), .Q( o_RX_Byte[1]) ); QDFFRBS o_RX_Byte_reg_0_ ( .D(n87), .CK(i_Clk), .RB(i_Rst_L), .Q( o_RX_Byte[0]) ); QDFFRBS r_o_SPI_Clk_reg ( .D(n86), .CK(i_Clk), .RB(i_Rst_L), .Q(o_SPI_Clk) ); QDFFRBS r_SM_CS_reg_0_ ( .D(n85), .CK(i_Clk), .RB(i_Rst_L), .Q(r_SM_CS[0]) ); QDFFRBS r_TX_Byte_reg_0_ ( .D(n84), .CK(i_Clk), .RB(i_Rst_L), .Q( r_TX_Byte[0]) ); QDFFRBS r_TX_Byte_reg_1_ ( .D(n83), .CK(i_Clk), .RB(i_Rst_L), .Q( r_TX_Byte[1]) ); QDFFRBS r_TX_Byte_reg_2_ ( .D(n82), .CK(i_Clk), .RB(i_Rst_L), .Q( r_TX_Byte[2]) ); QDFFRBS r_TX_Byte_reg_3_ ( .D(n81), .CK(i_Clk), .RB(i_Rst_L), .Q( r_TX_Byte[3]) ); QDFFRBS r_TX_Byte_reg_4_ ( .D(n80), .CK(i_Clk), .RB(i_Rst_L), .Q( r_TX_Byte[4]) ); QDFFRBS r_TX_Byte_reg_5_ ( .D(n79), .CK(i_Clk), .RB(i_Rst_L), .Q( r_TX_Byte[5]) ); QDFFRBS r_TX_Byte_reg_6_ ( .D(n78), .CK(i_Clk), .RB(i_Rst_L), .Q( r_TX_Byte[6]) ); QDFFRBS r_TX_Byte_reg_7_ ( .D(n77), .CK(i_Clk), .RB(i_Rst_L), .Q( r_TX_Byte[7]) ); QDFFRBS r_o_SPI_MOSI_reg ( .D(n76), .CK(i_Clk), .RB(i_Rst_L), .Q(o_SPI_MOSI) ); DFFSBN r_o_SPI_CS_n_reg ( .D(n108), .CK(i_Clk), .SB(i_Rst_L), .Q(o_SPI_CS_n) ); DFFSBN o_TX_Ready_reg ( .D(n96), .CK(i_Clk), .SB(i_Rst_L), .Q(o_TX_Ready) ); MOAI1 U3 ( .A1(n57), .A2(n65), .B1(r_SM_CS[0]), .B2(n29), .O(n37) ); OR2B1 U4 ( .I1(n28), .B1(n56), .O(n60) ); NR2 U5 ( .I1(r_Clk_Count[1]), .I2(r_Clk_Count[0]), .O(n62) ); INV1S U6 ( .I(n62), .O(n18) ); NR2 U7 ( .I1(n18), .I2(r_Clk_Count[3]), .O(n1) ); INV1S U8 ( .I(r_SM_CS[0]), .O(n30) ); ND2S U9 ( .I1(r_SM_CS[1]), .I2(n30), .O(n65) ); INV1S U10 ( .I(n65), .O(n31) ); ND3S U11 ( .I1(n1), .I2(n31), .I3(r_Clk_Count[2]), .O(n9) ); NR2 U12 ( .I1(r_Bit_Index[1]), .I2(r_Bit_Index[0]), .O(n50) ); INV1S U13 ( .I(r_Bit_Index[1]), .O(n35) ); ND2S U14 ( .I1(n35), .I2(r_Bit_Index[0]), .O(n17) ); INV1S U15 ( .I(n17), .O(n42) ); AOI22S U16 ( .A1(n50), .A2(r_TX_Byte[4]), .B1(n42), .B2(r_TX_Byte[5]), .O(n3) ); ND2S U17 ( .I1(r_Bit_Index[1]), .I2(r_Bit_Index[0]), .O(n13) ); INV1S U18 ( .I(n13), .O(n46) ); NR2 U19 ( .I1(r_Bit_Index[0]), .I2(n35), .O(n44) ); AOI22S U20 ( .A1(n46), .A2(r_TX_Byte[7]), .B1(n44), .B2(r_TX_Byte[6]), .O(n2) ); ND2S U21 ( .I1(n3), .I2(n2), .O(n7) ); AOI22S U22 ( .A1(n50), .A2(r_TX_Byte[0]), .B1(n42), .B2(r_TX_Byte[1]), .O(n5) ); AOI22S U23 ( .A1(n46), .A2(r_TX_Byte[3]), .B1(n44), .B2(r_TX_Byte[2]), .O(n4) ); ND2S U24 ( .I1(n5), .I2(n4), .O(n6) ); INV1S U25 ( .I(r_Bit_Index[2]), .O(n11) ); AOI22S U26 ( .A1(r_Bit_Index[2]), .A2(n7), .B1(n6), .B2(n11), .O(n8) ); MOAI1S U27 ( .A1(n9), .A2(n8), .B1(n9), .B2(o_SPI_MOSI), .O(n76) ); INV1S U28 ( .I(r_Clk_Count[0]), .O(n39) ); INV1S U29 ( .I(r_Clk_Count[2]), .O(n61) ); INV1S U30 ( .I(r_Clk_Count[1]), .O(n25) ); ND2S U31 ( .I1(n61), .I2(n25), .O(n19) ); NR2 U32 ( .I1(n39), .I2(n19), .O(n10) ); ND3S U33 ( .I1(n10), .I2(r_Clk_Count[3]), .I3(n31), .O(n40) ); NR2 U34 ( .I1(n11), .I2(n40), .O(n49) ); ND2S U35 ( .I1(r_i_SPI_MISO), .I2(n49), .O(n53) ); ND2S U36 ( .I1(n46), .I2(n49), .O(n12) ); MOAI1S U37 ( .A1(n53), .A2(n13), .B1(r_RX_Byte[7]), .B2(n12), .O(n97) ); INV1S U38 ( .I(n44), .O(n15) ); ND2S U39 ( .I1(n44), .I2(n49), .O(n14) ); MOAI1S U40 ( .A1(n53), .A2(n15), .B1(r_RX_Byte[6]), .B2(n14), .O(n98) ); ND2S U41 ( .I1(n42), .I2(n49), .O(n16) ); MOAI1S U42 ( .A1(n53), .A2(n17), .B1(r_RX_Byte[5]), .B2(n16), .O(n99) ); INV1S U43 ( .I(n50), .O(n52) ); NR2 U44 ( .I1(r_Bit_Index[2]), .I2(n52), .O(n56) ); OA12S U45 ( .B1(r_Clk_Count[2]), .B2(n18), .A1(r_Clk_Count[3]), .O(n57) ); ND2S U46 ( .I1(n31), .I2(n57), .O(n28) ); NR3 U47 ( .I1(r_Bit_Index[0]), .I2(n56), .I3(n28), .O(n36) ); NR2 U48 ( .I1(n30), .I2(r_SM_CS[1]), .O(n64) ); INV1S U49 ( .I(n64), .O(n32) ); NR2 U50 ( .I1(r_Clk_Count[3]), .I2(n19), .O(n29) ); OR2S U51 ( .I1(n32), .I2(n29), .O(n34) ); ND2S U52 ( .I1(r_Bit_Index[0]), .I2(n28), .O(n20) ); OR3B2S U53 ( .I1(n36), .B1(n34), .B2(n20), .O(n107) ); ND2S U54 ( .I1(n36), .I2(n35), .O(n33) ); MOAI1S U55 ( .A1(n29), .A2(n32), .B1(r_Bit_Index[2]), .B2(n33), .O(n113) ); ND3S U56 ( .I1(r_Clk_Count[0]), .I2(r_Clk_Count[1]), .I3(n37), .O(n24) ); NR2 U57 ( .I1(r_SM_CS[0]), .I2(r_SM_CS[1]), .O(n27) ); OR2B1S U58 ( .I1(i_TX_DV), .B1(n27), .O(n38) ); OR2B1S U59 ( .I1(n37), .B1(n38), .O(n21) ); MOAI1S U60 ( .A1(n61), .A2(n24), .B1(r_Clk_Count[3]), .B2(n21), .O(n112) ); ND2S U61 ( .I1(r_Clk_Count[1]), .I2(r_Clk_Count[0]), .O(n22) ); ND2S U62 ( .I1(n37), .I2(n22), .O(n26) ); ND2S U63 ( .I1(n38), .I2(n26), .O(n23) ); MOAI1S U64 ( .A1(r_Clk_Count[2]), .A2(n24), .B1(r_Clk_Count[2]), .B2(n23), .O(n111) ); OAI22S U65 ( .A1(n62), .A2(n26), .B1(n38), .B2(n25), .O(n110) ); ND2 U66 ( .I1(n27), .I2(i_TX_DV), .O(n68) ); NR2 U67 ( .I1(n30), .I2(n29), .O(n54) ); AN3B1S U68 ( .I1(n68), .I2(n60), .B1(n54), .O(n67) ); NR2 U69 ( .I1(n31), .I2(n64), .O(n59) ); MOAI1S U70 ( .A1(n67), .A2(n59), .B1(n67), .B2(r_SM_CS[1]), .O(n109) ); OA12S U71 ( .B1(n54), .B2(o_SPI_CS_n), .A1(n32), .O(n108) ); OAI112HS U72 ( .C1(n36), .C2(n35), .A1(n34), .B1(n33), .O(n106) ); MOAI1S U73 ( .A1(n39), .A2(n38), .B1(n39), .B2(n37), .O(n105) ); NR2 U74 ( .I1(r_Bit_Index[2]), .I2(n40), .O(n47) ); ND2S U75 ( .I1(n50), .I2(n47), .O(n41) ); MUX2S U76 ( .A(r_i_SPI_MISO), .B(r_RX_Byte[0]), .S(n41), .O(n104) ); ND2S U77 ( .I1(n47), .I2(n42), .O(n43) ); MUX2S U78 ( .A(r_i_SPI_MISO), .B(r_RX_Byte[1]), .S(n43), .O(n103) ); ND2S U79 ( .I1(n47), .I2(n44), .O(n45) ); MUX2S U80 ( .A(r_i_SPI_MISO), .B(r_RX_Byte[2]), .S(n45), .O(n102) ); ND2S U81 ( .I1(n47), .I2(n46), .O(n48) ); MUX2S U82 ( .A(r_i_SPI_MISO), .B(r_RX_Byte[3]), .S(n48), .O(n101) ); ND2S U83 ( .I1(n50), .I2(n49), .O(n51) ); MOAI1S U84 ( .A1(n53), .A2(n52), .B1(r_RX_Byte[4]), .B2(n51), .O(n100) ); MOAI1S U85 ( .A1(r_SM_CS[1]), .A2(r_SM_CS[0]), .B1(r_SM_CS[1]), .B2(n54), .O(n55) ); OA12S U86 ( .B1(o_TX_Ready), .B2(n55), .A1(n68), .O(n96) ); AOI13HS U87 ( .B1(n57), .B2(r_SM_CS[1]), .B3(n56), .A1(o_RX_DV), .O(n58) ); NR2 U88 ( .I1(n59), .I2(n58), .O(n95) ); MUX2S U89 ( .A(r_RX_Byte[7]), .B(o_RX_Byte[7]), .S(n60), .O(n94) ); MUX2S U90 ( .A(r_RX_Byte[6]), .B(o_RX_Byte[6]), .S(n60), .O(n93) ); MUX2S U91 ( .A(r_RX_Byte[5]), .B(o_RX_Byte[5]), .S(n60), .O(n92) ); MUX2S U92 ( .A(r_RX_Byte[4]), .B(o_RX_Byte[4]), .S(n60), .O(n91) ); MUX2S U93 ( .A(r_RX_Byte[3]), .B(o_RX_Byte[3]), .S(n60), .O(n90) ); MUX2S U94 ( .A(r_RX_Byte[2]), .B(o_RX_Byte[2]), .S(n60), .O(n89) ); MUX2S U95 ( .A(r_RX_Byte[1]), .B(o_RX_Byte[1]), .S(n60), .O(n88) ); MUX2S U96 ( .A(r_RX_Byte[0]), .B(o_RX_Byte[0]), .S(n60), .O(n87) ); NR2 U97 ( .I1(n62), .I2(n61), .O(n63) ); NR2 U98 ( .I1(r_Clk_Count[3]), .I2(n63), .O(n66) ); MOAI1S U99 ( .A1(n66), .A2(n65), .B1(n64), .B2(o_SPI_Clk), .O(n86) ); MOAI1S U100 ( .A1(r_SM_CS[0]), .A2(n67), .B1(r_SM_CS[0]), .B2(n67), .O(n85) ); MUX2S U101 ( .A(i_TX_Byte[0]), .B(r_TX_Byte[0]), .S(n68), .O(n84) ); MUX2S U102 ( .A(i_TX_Byte[1]), .B(r_TX_Byte[1]), .S(n68), .O(n83) ); MUX2S U103 ( .A(i_TX_Byte[2]), .B(r_TX_Byte[2]), .S(n68), .O(n82) ); MUX2S U104 ( .A(i_TX_Byte[3]), .B(r_TX_Byte[3]), .S(n68), .O(n81) ); MUX2S U105 ( .A(i_TX_Byte[4]), .B(r_TX_Byte[4]), .S(n68), .O(n80) ); MUX2S U106 ( .A(i_TX_Byte[5]), .B(r_TX_Byte[5]), .S(n68), .O(n79) ); MUX2S U107 ( .A(i_TX_Byte[6]), .B(r_TX_Byte[6]), .S(n68), .O(n78) ); MUX2S U108 ( .A(i_TX_Byte[7]), .B(r_TX_Byte[7]), .S(n68), .O(n77) ); endmodule module spi_top ( sys_clk, sys_rst_n, tx_start, tx_data, tx_ready, rx_valid, rx_data, spi_clk, spi_mosi, spi_miso, spi_cs_n ); input [7:0] tx_data; output [7:0] rx_data; input sys_clk, sys_rst_n, tx_start, spi_miso; output tx_ready, rx_valid, spi_clk, spi_mosi, spi_cs_n; wire r_tx_start, r_spi_miso, w_tx_ready, w_rx_valid, w_spi_clk, w_spi_mosi, w_spi_cs_n; wire [7:0] r_tx_data; wire [7:0] w_rx_data; SPI_Master_SPI_MODE0_CLKS_PER_HALF_BIT5 u_spi_master ( .i_Rst_L(sys_rst_n), .i_Clk(sys_clk), .i_TX_Byte(r_tx_data), .i_TX_DV(r_tx_start), .o_TX_Ready(w_tx_ready), .o_RX_DV(w_rx_valid), .o_RX_Byte(w_rx_data), .o_SPI_Clk(w_spi_clk), .i_SPI_MISO(r_spi_miso), .o_SPI_MOSI(w_spi_mosi), .o_SPI_CS_n(w_spi_cs_n) ); QDFFRBS r_tx_data_reg_7_ ( .D(tx_data[7]), .CK(sys_clk), .RB(sys_rst_n), .Q( r_tx_data[7]) ); QDFFRBS r_tx_data_reg_6_ ( .D(tx_data[6]), .CK(sys_clk), .RB(sys_rst_n), .Q( r_tx_data[6]) ); QDFFRBS r_tx_data_reg_5_ ( .D(tx_data[5]), .CK(sys_clk), .RB(sys_rst_n), .Q( r_tx_data[5]) ); QDFFRBS r_tx_data_reg_4_ ( .D(tx_data[4]), .CK(sys_clk), .RB(sys_rst_n), .Q( r_tx_data[4]) ); QDFFRBS r_tx_data_reg_3_ ( .D(tx_data[3]), .CK(sys_clk), .RB(sys_rst_n), .Q( r_tx_data[3]) ); QDFFRBS r_tx_data_reg_2_ ( .D(tx_data[2]), .CK(sys_clk), .RB(sys_rst_n), .Q( r_tx_data[2]) ); QDFFRBS r_tx_data_reg_1_ ( .D(tx_data[1]), .CK(sys_clk), .RB(sys_rst_n), .Q( r_tx_data[1]) ); QDFFRBS r_tx_data_reg_0_ ( .D(tx_data[0]), .CK(sys_clk), .RB(sys_rst_n), .Q( r_tx_data[0]) ); QDFFRBS r_spi_miso_reg ( .D(spi_miso), .CK(sys_clk), .RB(sys_rst_n), .Q( r_spi_miso) ); QDFFRBS r_tx_start_reg ( .D(tx_start), .CK(sys_clk), .RB(sys_rst_n), .Q( r_tx_start) ); DFFSBN r_spi_cs_n_reg ( .D(w_spi_cs_n), .CK(sys_clk), .SB(sys_rst_n), .Q( spi_cs_n) ); QDFFRBN r_spi_mosi_reg ( .D(w_spi_mosi), .CK(sys_clk), .RB(sys_rst_n), .Q( spi_mosi) ); QDFFRBN r_tx_ready_reg ( .D(w_tx_ready), .CK(sys_clk), .RB(sys_rst_n), .Q( tx_ready) ); QDFFRBN r_rx_valid_reg ( .D(w_rx_valid), .CK(sys_clk), .RB(sys_rst_n), .Q( rx_valid) ); QDFFRBN r_rx_data_reg_7_ ( .D(w_rx_data[7]), .CK(sys_clk), .RB(sys_rst_n), .Q(rx_data[7]) ); QDFFRBN r_rx_data_reg_6_ ( .D(w_rx_data[6]), .CK(sys_clk), .RB(sys_rst_n), .Q(rx_data[6]) ); QDFFRBN r_rx_data_reg_5_ ( .D(w_rx_data[5]), .CK(sys_clk), .RB(sys_rst_n), .Q(rx_data[5]) ); QDFFRBN r_rx_data_reg_4_ ( .D(w_rx_data[4]), .CK(sys_clk), .RB(sys_rst_n), .Q(rx_data[4]) ); QDFFRBN r_rx_data_reg_3_ ( .D(w_rx_data[3]), .CK(sys_clk), .RB(sys_rst_n), .Q(rx_data[3]) ); QDFFRBN r_rx_data_reg_2_ ( .D(w_rx_data[2]), .CK(sys_clk), .RB(sys_rst_n), .Q(rx_data[2]) ); QDFFRBN r_rx_data_reg_1_ ( .D(w_rx_data[1]), .CK(sys_clk), .RB(sys_rst_n), .Q(rx_data[1]) ); QDFFRBN r_rx_data_reg_0_ ( .D(w_rx_data[0]), .CK(sys_clk), .RB(sys_rst_n), .Q(rx_data[0]) ); QDFFRBN r_spi_clk_reg ( .D(w_spi_clk), .CK(sys_clk), .RB(sys_rst_n), .Q( spi_clk) ); endmodule

filetype

Failed to compile with 25 errors 12:33:46 error in ./src/components/charts/scorePart.vue Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (127) For more information on which environments are supported please see: https://github.com/sass/node-sass/releases/tag/v4.14.1 at module.exports (E:\毕设\论文及源码\前端源代码\exam\node_modules\node-sass\lib\binding.js:13:13) at Object.<anonymous> (E:\毕设\论文及源码\前端源代码\exam\node_modules\node-sass\lib\index.js:14:35) at Module._compile (node:internal/modules/cjs/loader:1730:14) at Object..js (node:internal/modules/cjs/loader:1895:10) at Module.load (node:internal/modules/cjs/loader:1465:32) at Function._load (node:internal/modules/cjs/loader:1282:12) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) at Module.require (node:internal/modules/cjs/loader:1487:12) at require (node:internal/modules/helpers:135:16) at getDefaultSassImpl (E:\毕设\论文及源码\前端源代码\exam\node_modules\sass-loader\dist\index.js:198:10) at Object.loader (E:\毕设\论文及源码\前端源代码\exam\node_modules\sass-loader\dist\index.js:80:29) @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data- v-abb7320a","scoped":true,"hasInlineConfig":false}!./node_modules/sass-loader/dist/cjs.js?{"sourceMap":true}!./node_modules/vue-loader/lib/selector. js?type=styles&index=0!./src/components/charts/scorePart.vue 4:14-386 13:3-17:5 14:22-394 @ ./src/components/charts/scorePart.vue @ ./src/router/index.js @ ./src/main.js @ multi (webpack)-dev-server/client?http://localhost:8088 webpack/hot/dev-server ./src/main.js error in ./src/components/student/startExam.vue Module build failed: Error: Node Sass does not yet suppor

filetype

/work/pcl-cross-compile/src/boost$ ls /work/pcl-cross-compile/install/boost/include/ algorithm dynamic_bitset.hpp make_unique.hpp qvm throw_exception.hpp align enable_shared_from_this.hpp math qvm.hpp timer aligned_storage.hpp exception math_fwd.hpp qvm_lite.hpp timer.hpp align.hpp exception_ptr.hpp move random token_functions.hpp archive foreach_fwd.hpp mpi random.hpp token_iterator.hpp asio foreach.hpp mpi.hpp range tokenizer.hpp asio.hpp format mpl range.hpp tti assign format.hpp multi_array rational.hpp tuple assign.hpp functional multi_array.hpp redis type_erasure call_traits.hpp functional.hpp multi_index redis.hpp type_index cerrno.hpp fusion multi_index_container_fwd.hpp regex type_index.hpp charconv geometry multi_index_container.hpp regex_fwd.hpp typeof charconv.hpp geometry.hpp multiprecision regex.h type_traits circular_buffer gil nondet_random.hpp regex.hpp type_traits.hpp circular_buffer_fwd.hpp gil.hpp none.hpp safe_numerics units circular_buffer.hpp graph none_t.hpp scoped_array.hpp unordered cobalt heap nowide scoped_ptr.hpp unordered_map.hpp cobalt.hpp histogram numeric scope_exit.hpp unordered_set.hpp compressed_pair.hpp histogram.hpp operators.hpp serialization url concept hof operators_v1.hpp shared_array.hpp url.hpp concept_archetype.hpp hof.hpp optional shared_ptr.hpp utility concept_check icl optional.hpp signals2 utility.hpp concept_check.hpp interprocess parameter signals2.hpp uuid config intrusive pending smart_ptr uuid.hpp config.hpp intrusive_ptr.hpp phoenix smart_ptr.hpp variant container io phoenix.hpp sort variant2 context io_fwd.hpp pointer_cast.hpp spirit variant2.hpp convert json pointer_to_other.hpp spirit.hpp variant.hpp convert.hpp json.hpp polygon stacktrace version.hpp cregex.hpp leaf pool stacktrace.hpp vmd cstdfloat.hpp leaf.hpp predef statechart wave cstdint.hpp limits.hpp predef.h static_assert.hpp wave.hpp cxx11_char_types.hpp locale program_options static_string weak_ptr.hpp date_time locale.hpp program_options.hpp static_string.hpp winapi date_time.hpp local_function progress.hpp stl_interfaces xpressive describe local_function.hpp property_map system yap describe.hpp lockfree proto system.hpp detail logic ptr_container test dynamic_bitset make_default.hpp python thread dynamic_bitset_fwd.hpp make_shared.hpp python.hpp thread.hpp uidq8326@hzh27145u:/work/pcl-cross-compile/src/boost$ ./b2 install toolset=gcc architecture=arm address-model=64 \--prefix=/work/pcl-cross-compile/install/boost -j$(nproc) Performing configuration checks - default address-model : 64-bit [1] - default architecture : arm [1] - symlinks supported : yes error: Unable to find file or target named error: '/boost/headers' error: referred to from project at error: 'libs/date_time/build'

filetype

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <ctype.h> #include <stdbool.h> #include <unistd.h> #include <time.h> /* 定义常量 */ #define MODBUS_MAX_REGISTERS 125 // modbus最多只支持采集125个 #define MAX_DATA_PACKET_SIZE 4096 // 地址类型宏定义 #define SINGLE_BYTE_TYPES “%V”, “%IX”, “%QX”, “%MX”, “%DBX” #define DOUBLE_BYTE_TYPES “%MD”, “%DBD”, “%DBW”, “%DB” #define BIT_ADDR_TYPES “%MX”, “%DBX” #define SINGLE_BYTE_THRESHOLD 1 // 单字节地址连续阈值 #define DOUBLE_BYTE_THRESHOLD 2 // 双字节地址连续阈值 /* 寄存器类型枚举 / typedef enum { REG_V, / V寄存器 / REG_IX, / IX寄存器 / REG_QX, / QX寄存器 / REG_MX, / MX寄存器 / REG_MW, / MW寄存器 / REG_MD, / MD寄存器 / REG_DBX, / DBX寄存器 / REG_DBW, / DBW寄存器 / REG_DBD, / DBD寄存器 / REG_DB, / DB寄存器 / REG_UNKNOWN / 未知类型 */ } RegType; /* 寄存器类型属性 */ typedef struct { RegType type; const char prefix; / 字符串前缀 / bool is_bit_addressable; / 是否支持位寻址 / int byte_size; / 字节大小(2或4) */ } RegTypeInfo; /* 地址解析结果 / typedef struct { RegType type; / 寄存器类型 / int base_addr; / 基地址 / int bit_offset; / 位偏移 (-1表示无位偏移) */ } AddrParseResult; /* 定义参数位置信息结构体 */ typedef struct { DEVICEID_PARAID *param; // 参数指针 int device_index; // 设备在DeviceNumber数组中的索引 int data_index; // 设备数据在DeviceData数组中的索引 int param_index; // 参数在DeviceParaID数组中的索引 } ParamLocation; /* 地址分组结构 / typedef struct AddrGroup { RegType type; / 寄存器类型 / int slave_addr; / 从机地址 / int portfd; / 使用的485端口 / int start_addr; / 起始地址 / int end_addr; / 结束地址 / int param_count; / 包含的参数数量 */ DEVICEID_PARAID **params; /* 动态参数指针数组 */ int *bit_offsets; /* 位偏移数组 */ struct AddrGroup *next; /* 链表指针 */ } AddrGroup; // 全局地址组链表头 AddrGroup *addr_groups_head; void init_addr_groups(DEVICE_PARA *device_para, DEVICE_ARGV *device_argv); void print_addr_groups(); /* 获取寄存器类型信息 */ const RegTypeInfo *get_reg_type_info(RegType type); void perform_collection(uint8_t *read_buffer, AddrGroup *group, const RegTypeInfo *info, int bytes_read); /* 寄存器类型信息表 / static const RegTypeInfo reg_type_info[] = { {REG_V, “%V”, false, 2}, {REG_IX, “%IX”, false, 2}, {REG_QX, “%QX”, false, 2}, {REG_MX, “%MX”, true, 2}, / 虽然支持位寻址,但byte_size为2 / {REG_MW, “%MW”, false, 2}, {REG_MD, “%MD”, false, 4}, {REG_DBX, “%DBX”, true, 2}, / 虽然支持位寻址,但byte_size为2 */ {REG_DBW, “%DBW”, false, 2}, {REG_DBD, “%DBD”, false, 4}, {REG_DB, “%DB”, false, 2}, {REG_UNKNOWN, “”, false, 0}}; /* 获取寄存器类型信息 */ const RegTypeInfo get_reg_type_info(RegType type) { size_t i; for (i = 0; i < sizeof(reg_type_info) / sizeof(reg_type_info[0]); i++) { if (reg_type_info[i].type == type) { return ®_type_info[i]; } } return ®_type_info[sizeof(reg_type_info) / sizeof(reg_type_info[0]) - 1]; / 返回UNKNOWN */ } /* 解析地址(支持位偏移) */ AddrParseResult parse_address(const char *reg_addr) { int i = 0; AddrParseResult result = {REG_UNKNOWN, -1, -1}; const RegTypeInfo *info; // 提取寄存器类型和数值地址 char type_str[10] = {0}; int addr_value = 0; int bit_offset = -1; // 解析地址字符串 if (sscanf(reg_addr, "%4[^0-9]%d.%d", type_str, &addr_value, &bit_offset) >= 2 || sscanf(reg_addr, "%4[^0-9]%d", type_str, &addr_value) >= 1) { // 转换为大写以便比较 for (i = 0; type_str[i]; i++) { type_str[i] = toupper(type_str[i]); } /* 确定寄存器类型 */ if (strcmp(type_str, "%V") == 0) result.type = REG_V; else if (strcmp(type_str, "%IX") == 0) result.type = REG_IX; else if (strcmp(type_str, "%QX") == 0) result.type = REG_QX; else if (strcmp(type_str, "%MX") == 0) result.type = REG_MX; else if (strcmp(type_str, "%MW") == 0) result.type = REG_MW; else if (strcmp(type_str, "%MD") == 0) result.type = REG_MD; else if (strcmp(type_str, "%DBX") == 0) result.type = REG_DBX; else if (strcmp(type_str, "%DBW") == 0) result.type = REG_DBW; else if (strcmp(type_str, "%DBD") == 0) result.type = REG_DBD; else if (strcmp(type_str, "%DB") == 0) result.type = REG_DB; else result.type = REG_UNKNOWN; result.base_addr = addr_value; result.bit_offset = bit_offset; } return result; } /* 获取从机地址 */ int get_slave_addr(DEVICE_NUMBER *dev_num) { return dev_num->Number; } /* 获取端口fd */ int get_portfd(int device_index, DEVICE_ARGV *device_argv) { int i; for (i = 0; i < device_argv->Device_num; i++) { if (device_argv->DeviceArgvList[i].DeviceNumber_s[device_index] == ‘1’) { return device_argv->DeviceArgvList[i].portfd; } } return -1; } /* 创建新的地址分组 */ AddrGroup *create_addr_group(RegType type, int slave_addr, int portfd, int base_addr) { AddrGroup *new_group = (AddrGroup *)malloc(sizeof(AddrGroup)); if (!new_group) return NULL; new_group->type = type; new_group->slave_addr = slave_addr; new_group->portfd = portfd; new_group->start_addr = base_addr; new_group->end_addr = base_addr; new_group->param_count = 0; new_group->next = NULL; /* 初始化动态数组 */ new_group->params = (DEVICEID_PARAID **)malloc(sizeof(DEVICEID_PARAID *) * 10); new_group->bit_offsets = (int *)malloc(sizeof(int) * 10); if (!new_group->params || !new_group->bit_offsets) { free(new_group->params); free(new_group->bit_offsets); free(new_group); return NULL; } return new_group; } /* 向地址组添加参数 */ bool add_param_to_group(AddrGroup *group, DEVICEID_PARAID param, int bit_offset) { / 检查是否需要扩展数组 */ if (group->param_count % 10 == 0) { size_t new_size = (group->param_count + 10) * sizeof(DEVICEID_PARAID *); DEVICEID_PARAID **new_params = (DEVICEID_PARAID **)realloc( group->params, new_size); if (!new_params) return false; group->params = new_params; int *new_offsets = (int *)realloc( group->bit_offsets, (group->param_count + 10) * sizeof(int)); if (!new_offsets) return false; group->bit_offsets = new_offsets; } /* 添加参数 */ group->params[group->param_count] = param; group->bit_offsets[group->param_count] = bit_offset; group->param_count++; return true; } /* 查找匹配的地址分组 */ AddrGroup *find_matching_group(RegType type, int slave_addr, int portfd, int base_addr) { AddrGroup *current = addr_groups_head; const RegTypeInfo *info = get_reg_type_info(type); int threshold; int min_next; while (current != NULL) { if (current->type == type && current->slave_addr == slave_addr && current->portfd == portfd) { /* 检查地址连续性 (考虑阈值) */ threshold = info->byte_size / 2; /* 使用字节大小计算阈值 */ min_next = current->end_addr + threshold; if (base_addr >= current->start_addr && base_addr <= min_next) { return current; } } current = current->next; } return NULL; } /* 参数排序比较函数 */ int compare_params(const void *a, const void *b) { const ParamLocation *pa = (const ParamLocation *)a; const ParamLocation *pb = (const ParamLocation *)b; AddrParseResult res_a = parse_address(pa->param->RegAddress); AddrParseResult res_b = parse_address(pb->param->RegAddress); // 先按类型排序 if (res_a.type != res_b.type) return res_a.type - res_b.type; // 相同类型按基地址排序 return res_a.base_addr - res_b.base_addr; } /* 初始化地址分组 */ void init_addr_groups(DEVICE_PARA *device_para, DEVICE_ARGV *device_argv) { int i = 0; int t1, t2, t3; AddrGroup *current; AddrGroup *next; DEVICE_NUMBER *dev_num; DEVICE_DATA *dev_data; DEVICEID_PARAID *param; AddrParseResult parsed; AddrGroup *group; int slave_addr; int portfd; /* 清空现有分组 */ current = addr_groups_head; while (current != NULL) { next = current->next; free(current->params); free(current->bit_offsets); free(current); current = next; } addr_groups_head = NULL; /* 第一步:收集所有参数位置信息 */ int total_params = 0; for (t1 = 0; t1 < device_para->DeviceNumberIndex; t1++) { dev_num = &device_para->DeviceNumber[t1]; for (t2 = 0; t2 < dev_num->DeviceDataIndex; t2++) { dev_data = &dev_num->DeviceData[t2]; total_params += dev_data->DeviceIdIndex; } } if (total_params == 0) return; // 创建参数位置数组 ParamLocation *param_locations = (ParamLocation *)malloc(total_params * sizeof(ParamLocation)); if (!param_locations) return; int index = 0; for (t1 = 0; t1 < device_para->DeviceNumberIndex; t1++) { dev_num = &device_para->DeviceNumber[t1]; for (t2 = 0; t2 < dev_num->DeviceDataIndex; t2++) { dev_data = &dev_num->DeviceData[t2]; for (t3 = 0; t3 < dev_data->DeviceIdIndex; t3++) { param_locations[index].param = &dev_data->DeviceParaID[t3]; param_locations[index].device_index = t1; param_locations[index].data_index = t2; param_locations[index].param_index = t3; index++; } } } /* 第二步:按类型和基地址排序 */ qsort(param_locations, total_params, sizeof(ParamLocation), compare_params); /* 第三步:处理排序后的参数 */ for (i = 0; i < total_params; i++) { param = param_locations[i].param; parsed = parse_address(param->RegAddress); if (parsed.base_addr < 0 || parsed.type == REG_UNKNOWN) continue; // 直接从位置信息获取设备索引 t1 = param_locations[i].device_index; dev_num = &device_para->DeviceNumber[t1]; slave_addr = get_slave_addr(dev_num); portfd = get_portfd(t1, device_argv); if (portfd == -1) continue; /* 查找匹配的分组 */ group = find_matching_group(parsed.type, slave_addr, portfd, parsed.base_addr); if (group) { /* 更新地址范围 */ if (parsed.base_addr < group->start_addr) { group->start_addr = parsed.base_addr; } if (parsed.base_addr > group->end_addr) { group->end_addr = parsed.base_addr; } /* 添加参数到组 */ if (!add_param_to_group(group, param, parsed.bit_offset)) { printf("Failed to add param to group!\n"); } } else { /* 创建新分组 */ AddrGroup *new_group = create_addr_group(parsed.type, slave_addr, portfd, parsed.base_addr); if (!new_group) { printf("Failed to create new group!\n"); continue; } /* 添加到链表 */ if (!addr_groups_head) { addr_groups_head = new_group; } else { new_group->next = addr_groups_head; addr_groups_head = new_group; } /* 添加第一个参数 */ if (!add_param_to_group(new_group, param, parsed.bit_offset)) { printf("Failed to add param to new group!\n"); } } } free(param_locations); } /* 从位偏移中提取位值 */ uint8_t extract_bit_value(uint8_t byte_value, int bit_offset) { if (bit_offset < 0 || bit_offset > 7) return 0; return (byte_value >> bit_offset) & 0x01; } /* 执行采集 */ void perform_collection(uint8_t *read_buffer, AddrGroup *group, const RegTypeInfo *info, int bytes_read) { int i; DEVICEID_PARAID *param; int bit_offset; AddrParseResult parsed; int addr_offset; int buffer_offset; int bytes_to_copy; uint8_t byte_value; uint8_t bit_value; /* 处理每个参数 */ for (i = 0; i < group->param_count; i++) { param = group->params[i]; bit_offset = group->bit_offsets[i]; parsed = parse_address(param->RegAddress); /* 计算数据在缓冲区中的位置 */ addr_offset = parsed.base_addr - group->start_addr; buffer_offset = addr_offset * (info->byte_size / 2); /* 2字节为单位 */ if (buffer_offset < 0 || buffer_offset >= bytes_read) { printf("Invalid buffer offset: %d\n", buffer_offset); continue; } /* 处理位访问 */ if (bit_offset >= 0) { /* 位寻址:数据长度为1字节 */ byte_value = read_buffer[buffer_offset]; bit_value = extract_bit_value(byte_value, bit_offset); memset(param->RegByteValue, 0, sizeof(param->RegByteValue)); param->RegByteValue[0] = bit_value; param->RegByteLen = 1; } else { /* 非位寻址:使用寄存器类型的byte_size */ bytes_to_copy = info->byte_size; if (buffer_offset + bytes_to_copy > bytes_read) { bytes_to_copy = bytes_read - buffer_offset; } memcpy(param->RegByteValue, read_buffer + buffer_offset, bytes_to_copy); param->RegByteLen = bytes_to_copy; } } } /* 主采集循环 */ void collection_loop(DEVICE_PARA *device_para, DEVICE_ARGV *device_argv) { uint32_t start_time; uint32_t elapsed; AddrGroup *current; int i; /* 初始化分组 */ init_addr_groups(device_para, device_argv); print_addr_groups(); /* 主循环 */ while (1) { /* 执行采集 */ perform_single_collection(); /* 等待下一个采集周期 */ } } /* 打印分组信息 */ void print_addr_groups() { AddrGroup *current = addr_groups_head; int group_num = 0; const RegTypeInfo *info; printf("\n===== Address Groups =====\n"); while (current != NULL) { info = get_reg_type_info(current->type); printf("Group %d: %s, slave=%d, portfd=%d, addr_range=%d-%d, params=%d\n", group_num, info->prefix, current->slave_addr, current->portfd, current->start_addr, current->end_addr, current->param_count); current = current->next; group_num++; } printf("==========================\n\n"); } // 执行单次采集 void perform_single_collection() { AddrGroup *current = addr_groups_head; uint32_t current_time = get_current_timestamp(); while (current != NULL) { AddrGroup *group = current; current = current->next; // 检查是否需要采集 if (current_time - group->last_collection_time < COLLECTION_INTERVAL_MS) { continue; } group->last_collection_time = current_time; group->needs_collection = false; const RegTypeInfo* info = get_reg_type_info(group->type); int reg_count = group->end_addr - group->start_addr + 1; // 根据数据类型调整寄存器计数 if (info->is_double_byte) { reg_count = (reg_count + 1) / 2; } if (reg_count > MODBUS_MAX_REGISTERS) { reg_count = MODBUS_MAX_REGISTERS; } // 分配缓冲区 uint8_t *read_buffer = (uint8_t*)malloc(reg_count * 2); if (!read_buffer) { printf("Memory allocation failed for read buffer!\n"); continue; } // 执行MODBUS读取 int bytes_read = modbus_read(group->portfd, group->slave_addr, group->start_addr, reg_count, read_buffer); if (bytes_read != reg_count * 2) { printf("MODBUS read error! Expected %d bytes, got %d\n", reg_count * 2, bytes_read); free(read_buffer); continue; } // 处理每个参数 for (int i = 0; i < group->param_count; i++) { DEVICEID_PARAID *param = group->params[i]; int bit_offset = group->bit_offsets[i]; AddrParseResult parsed = parse_address(param->RegAddress); // 计算数据在缓冲区中的位置 int addr_offset = parsed.base_addr - group->start_addr; int buffer_offset = addr_offset * (info->is_double_byte ? 2 : 1); if (buffer_offset < 0 || buffer_offset >= bytes_read) { printf("Invalid buffer offset: %d\n", buffer_offset); continue; } // 处理位访问 if (bit_offset >= 0) { uint8_t byte_value = read_buffer[buffer_offset]; uint8_t bit_value = extract_bit_value(byte_value, bit_offset); memset(param->RegByteValue, 0, sizeof(param->RegByteValue)); param->RegByteValue[0] = bit_value; } else { int bytes_to_copy = info->byte_size; if (buffer_offset + bytes_to_copy > bytes_read) { bytes_to_copy = bytes_read - buffer_offset; } memcpy(param->RegByteValue, read_buffer + buffer_offset, bytes_to_copy); } param->lastUpdate = current_time; } free(read_buffer); } } // 测试函数 void test_parse_address() { const char *test_addresses[] = { “MX10”, “MX10.3”, “DBD200”, “V123”, “QX55”, “UNKNOWN30” }; printf("===== Address Parsing Test =====\n"); for (int i = 0; i < sizeof(test_addresses)/sizeof(test_addresses[0]); i++) { AddrParseResult result = parse_address(test_addresses[i]); const RegTypeInfo* info = get_reg_type_info(result.type); printf("Address: %s\n", test_addresses[i]); printf(" Type: %s (%d)\n", info->prefix, result.type); printf(" Base: %d\n", result.base_addr); printf(" Bit offset: %d\n", result.bit_offset); printf(" Byte size: %d\n", info->byte_size); printf(" Bit addressable: %s\n", info->is_bit_addressable ? "yes" : "no"); printf(" Double byte: %s\n\n", info->is_double_byte ? "yes" : "no"); } printf("===============================\n\n"); } int main() { // 运行地址解析测试 test_parse_address(); // 初始化设备参数和采集参数 DEVICE_PARA device_para = {0}; DEVICE_ARGV device_argv = {0}; // 设置示例数据 device_para.DeviceNumberIndex = 2; device_para.DeviceNumber = (DEVICE_NUMBER*)malloc(2 * sizeof(DEVICE_NUMBER)); memset(device_para.DeviceNumber, 0, 2 * sizeof(DEVICE_NUMBER)); // 设备1 (包含位访问) device_para.DeviceNumber[0].Number = 1; device_para.DeviceNumber[0].DeviceDataIndex = 1; device_para.DeviceNumber[0].DeviceData = (DEVICE_DATA*)malloc(sizeof(DEVICE_DATA)); memset(device_para.DeviceNumber[0].DeviceData, 0, sizeof(DEVICE_DATA)); device_para.DeviceNumber[0].DeviceData->DeviceIdIndex = 3; device_para.DeviceNumber[0].DeviceData->DeviceParaID = (DEVICEID_PARAID*)malloc(3 * sizeof(DEVICEID_PARAID)); strcpy(device_para.DeviceNumber[0].DeviceData->DeviceParaID[0].RegAddress, "MX10"); device_para.DeviceNumber[0].DeviceData->DeviceParaID[0].ParaId = 101; strcpy(device_para.DeviceNumber[0].DeviceData->DeviceParaID[1].RegAddress, "MX10.3"); device_para.DeviceNumber[0].DeviceData->DeviceParaID[1].ParaId = 102; strcpy(device_para.DeviceNumber[0].DeviceData->DeviceParaID[2].RegAddress, "MD20"); device_para.DeviceNumber[0].DeviceData->DeviceParaID[2].ParaId = 103; // 设备2 (双字节类型) device_para.DeviceNumber[1].Number = 2; device_para.DeviceNumber[1].DeviceDataIndex = 1; device_para.DeviceNumber[1].DeviceData = (DEVICE_DATA*)malloc(sizeof(DEVICE_DATA)); memset(device_para.DeviceNumber[1].DeviceData, 0, sizeof(DEVICE_DATA)); device_para.DeviceNumber[1].DeviceData->DeviceIdIndex = 2; device_para.DeviceNumber[1].DeviceData->DeviceParaID = (DEVICEID_PARAID*)malloc(2 * sizeof(DEVICEID_PARAID)); strcpy(device_para.DeviceNumber[1].DeviceData->DeviceParaID[0].RegAddress, "DBD200"); device_para.DeviceNumber[1].DeviceData->DeviceParaID[0].ParaId = 201; strcpy(device_para.DeviceNumber[1].DeviceData->DeviceParaID[1].RegAddress, "DBX55"); device_para.DeviceNumber[1].DeviceData->DeviceParaID[1].ParaId = 202; // 设置采集参数 device_argv.Device_num = 2; device_argv.DeviceArgvList[0].portfd = 1; strcpy(device_argv.DeviceArgvList[0].DeviceNumber_s, "10"); device_argv.DeviceArgvList[1].portfd = 2; strcpy(device_argv.DeviceArgvList[1].DeviceNumber_s, "01"); // 进入采集循环 collection_loop(&device_para, &device_argv); // 释放资源 cleanup(&device_para); return 0; } 这里有以下改动:首先地址分组规则需要改动,首先还是fd优于从机地址优于地址大小排序,然后对地址分组,首先在初始化函数会加一个参数用于区分西门子还是施耐德,还有RegType有变动,现在为QX BDX M MB MW BDW VW BDB MD IX MX ,其中当参数表示西门子时IX MX 和QX分在一组,功能码标志为1 ,表示为施莱德时IX MX 和DBX M分在一组功能码标志为2,剩下其他的功能码都标志为3,但是其中DBD和MD byte_size字节大小为4,采集个数为2,地址连续判断为2,其余的都是字节大小为2,采集个数为1,地址连续判断为1,还希望有些地址中间不连续但相差很小可以分在一组一次采集, 因为在功能码03中采集个数不一致,所以在最后放在原来结构体时需要注意偏移量,依旧支持有些寄存器的位寻址,有些在同一组内地址是相同,计算采集个数时需要注意

filetype

/******************************************************************************* * Function Name : USB_Init * Description : USB初始化 * Input : None * * Output : None * Return : None ******************************************************************************/ void USB_Init(void) { //CCM->PHYPA = 0x10;//usbphy clk sel 60M USB_POWER_ON; USB_SoftReset(); //释放USB_PHY CPM->CPM_SRSTCR1 &= ~(1 << USBPHY_RST_RELEASE_BIT); USBPHY_CLK_SEL_60M; g_RevOffset = 0; g_transLens = 0; g_Ep0Data_Stage = 0; g_usbVer = 0;//USB1.1 /* Global USB Register */ gUSBC_fifoReg = (USBC_FIFOTypeDef*)(USBC_BASE_ADDR+0x60); gUSBC_ComReg = (USBC_CommonTypeDef*)USBC_BASE_ADDR; gUSBC_IdxReg = (USBC_IndexedTypeDef*)(USBC_BASE_ADDR+0x10); //The suspend mode is disable before BULK-Only tranfer start g_suspendMode = 0; /* Setup USB register */ //enable usb common interrupt //0 1 2 3 4 5 6 7 (bit) //Susp Resume Reset SOF Conn Discon SessReq VBusErr gUSBC_ComReg->INTRUSBE = USB_INTERRUPT_RESET |USB_INTERRUPT_CONNECT |USB_INTERRUPT_DISCON |USB_INTERRUPT_SUSPEND |USB_INTERRUPT_RESUME; //|USB_INTERRUPT_SOF; //enable ep0 and ep1 tx interrupts,clear other tx interrupts gUSBC_ComReg->INTRTXE_L = USB_INTERRUPT_EP0|(1<<USB_ENDPOINT_INDEX); //enable ep1 rx interrupt,clear other rx interrupts gUSBC_ComReg->INTRRXE_L = (1<<USB_ENDPOINT_INDEX); g_usb_data_in_ep = USB_ENDPOINT_INDEX; g_usb_data_out_ep = USB_ENDPOINT_INDEX;//send //ensure ep0 control/status regesters appeare in the memory map. gUSBC_ComReg->EINDEX = CONTROL_EP; SetFIFO_Addr(USBEPX_TABLE[0],3); //Enable Soft connection if(g_usbVer == 1) gUSBC_ComReg->UCSR = USB_POWER_SOFT_CONN|USB_POWER_HS_ENAB; else { gUSBC_ComReg->UCSR = USB_POWER_SOFT_CONN; } interrupt_setup(USB_INT_NUM, 0x00); }解析,如果需要提供相关手册资料,请提出

filetype

{ "_shards": { "total": 2, "successful": 2, "failed": 0 }, "_all": { "primaries": { "docs": { "count": 1015, "deleted": 0, "total_size_in_bytes": 82976 }, "shard_stats": { "total_count": 1 }, "store": { "size_in_bytes": 83352, "total_data_set_size_in_bytes": 83352, "reserved_in_bytes": 0 }, "indexing": { "index_total": 57, "index_time_in_millis": 32, "index_current": 0, "index_failed": 0, "index_failed_due_to_version_conflict": 0, "delete_total": 0, "delete_time_in_millis": 0, "delete_current": 0, "noop_update_total": 0, "is_throttled": false, "throttle_time_in_millis": 0, "write_load": 0.000053649427411387194 }, "get": { "total": 0, "time_in_millis": 0, "exists_total": 0, "exists_time_in_millis": 0, "missing_total": 0, "missing_time_in_millis": 0, "current": 0 }, "search": { "open_contexts": 0, "query_total": 0, "query_time_in_millis": 0, "query_current": 0, "query_failure": 0, "fetch_total": 0, "fetch_time_in_millis": 0, "fetch_current": 0, "fetch_failure": 0, "scroll_total": 0, "scroll_time_in_millis": 0, "scroll_current": 0, "suggest_total": 0, "suggest_time_in_millis": 0, "suggest_current": 0 }, "merges": { "current": 0, "current_docs": 0, "current_size_in_bytes": 0, "total": 1, "total_time_in_millis": 34, "total_docs": 1015, "total_size_in_bytes": 126880, "total_stopped_time_in_millis": 0, "total_throttled_time_in_millis": 0, "total_auto_throttle_in_bytes": 20971520 }, "refresh": { "total": 12, "total_time_in_millis": 158, "external_total": 6, "external_total_time_in_millis": 70, "listeners": 0 }, "flush": { "total": 1, "periodic": 1, "total_time_in_millis": 11, "total_time_excluding_waiting_on_lock_in_millis": 65 }, "warmer": { "current": 0, "total": 5, "total_time_in_millis": 4 }, "query_cache": { "memory_size_in_bytes": 0, "total_count": 0, "hit_count": 0, "miss_count": 0, "cache_size": 0, "cache_count": 0, "evictions": 0 }, "fielddata": { "memory_size_in_bytes": 0, "evictions": 0, "global_ordinals": { "build_time_in_millis": 0 } }, "completion": { "size_in_bytes": 0 }, "segments": { "count": 1, "memory_in_bytes": 0, "terms_memory_in_bytes": 0, "stored_fields_memory_in_bytes": 0, "term_vectors_memory_in_bytes": 0, "norms_memory_in_bytes": 0, "points_memory_in_bytes": 0, "doc_values_memory_in_bytes": 0, "index_writer_memory_in_bytes": 0, "version_map_memory_in_bytes": 0, "fixed_bit_set_memory_in_bytes": 168, "max_unsafe_auto_id_timestamp": -1, "file_sizes": {} }, "translog": { "operations": 0, "size_in_bytes": 55, "uncommitted_operations": 0, "uncommitted_size_in_bytes": 55, "earliest_last_modified_age": 606716 }, "request_cache": { "memory_size_in_bytes": 0, "evictions": 0, "hit_count": 0, "miss_count": 0 }, "recovery": { "current_as_source": 0, "current_as_target": 0, "throttle_time_in_millis": 0 }, "bulk": { "total_operations": 57, "total_time_in_millis": 34, "total_size_in_bytes": 114084, "avg_time_in_millis": 0, "avg_size_in_bytes": 2156 }, "dense_vector": { "value_count": 0 }, "sparse_vector": { "value_count": 0 } }, "total": { "docs": { "count": 2030, "deleted": 0, "total_size_in_bytes": 166945 }, "shard_stats": { "total_count": 2 }, "store": { "size_in_bytes": 167697, "total_data_set_size_in_bytes": 167697, "reserved_in_bytes": 0 }, "indexing": { "index_total": 108, "index_time_in_millis": 65, "index_current": 0, "index_failed": 0, "index_failed_due_to_version_conflict": 0, "delete_total": 0, "delete_time_in_millis": 0, "delete_current": 0, "noop_update_total": 0, "is_throttled": false, "throttle_time_in_millis": 0, "write_load": 0.000042064075365212696 }, "get": { "total": 0, "time_in_millis": 0, "exists_total": 0, "exists_time_in_millis": 0, "missing_total": 0, "missing_time_in_millis": 0, "current": 0 }, "search": { "open_contexts": 0, "query_total": 1, "query_time_in_millis": 0, "query_current": 0, "query_failure": 0, "fetch_total": 1, "fetch_time_in_millis": 0, "fetch_current": 0, "fetch_failure": 0, "scroll_total": 0, "scroll_time_in_millis": 0, "scroll_current": 0, "suggest_total": 0, "suggest_time_in_millis": 0, "suggest_current": 0 }, "merges": { "current": 0, "current_docs": 0, "current_size_in_bytes": 0, "total": 2, "total_time_in_millis": 78, "total_docs": 2030, "total_size_in_bytes": 255483, "total_stopped_time_in_millis": 0, "total_throttled_time_in_millis": 0, "total_auto_throttle_in_bytes": 41943040 }, "refresh": { "total": 22, "total_time_in_millis": 294, "external_total": 12, "external_total_time_in_millis": 148, "listeners": 0 }, "flush": { "total": 3, "periodic": 2, "total_time_in_millis": 162, "total_time_excluding_waiting_on_lock_in_millis": 268 }, "warmer": { "current": 0, "total": 10, "total_time_in_millis": 8 }, "query_cache": { "memory_size_in_bytes": 0, "total_count": 0, "hit_count": 0, "miss_count": 0, "cache_size": 0, "cache_count": 0, "evictions": 0 }, "fielddata": { "memory_size_in_bytes": 0, "evictions": 0, "global_ordinals": { "build_time_in_millis": 0 } }, "completion": { "size_in_bytes": 0 }, "segments": { "count": 2, "memory_in_bytes": 0, "terms_memory_in_bytes": 0, "stored_fields_memory_in_bytes": 0, "term_vectors_memory_in_bytes": 0, "norms_memory_in_bytes": 0, "points_memory_in_bytes": 0, "doc_values_memory_in_bytes": 0, "index_writer_memory_in_bytes": 0, "version_map_memory_in_bytes": 0, "fixed_bit_set_memory_in_bytes": 336, "max_unsafe_auto_id_timestamp": -1, "file_sizes": {} }, "translog": { "operations": 0, "size_in_bytes": 110, "uncommitted_operations": 0, "uncommitted_size_in_bytes": 110, "earliest_last_modified_age": 606716 }, "request_cache": { "memory_size_in_bytes": 0, "evictions": 0, "hit_count": 0, "miss_count": 1 }, "recovery": { "current_as_source": 0, "current_as_target": 0, "throttle_time_in_millis": 0 }, "bulk": { "total_operations": 108, "total_time_in_millis": 70, "total_size_in_bytes": 214234, "avg_time_in_millis": 0, "avg_size_in_bytes": 2153 }, "dense_vector": { "value_count": 0 }, "sparse_vector": { "value_count": 0 } } }, "indices": { "all_template": { "uuid": "dJqU_kRlRUyIqzF3SJTNrA", "health": "green", "status": "open", "primaries": { "docs": { "count": 1015, "deleted": 0, "total_size_in_bytes": 82976 }, "shard_stats": { "total_count": 1 }, "store": { "size_in_bytes": 83352, "total_data_set_size_in_bytes": 83352, "reserved_in_bytes": 0 }, "indexing": { "index_total": 57, "index_time_in_millis": 32, "index_current": 0, "index_failed": 0, "index_failed_due_to_version_conflict": 0, "delete_total": 0, "delete_time_in_millis": 0, "delete_current": 0, "noop_update_total": 0, "is_throttled": false, "throttle_time_in_millis": 0, "write_load": 0.000053649427411387194 }, "get": { "total": 0, "time_in_millis": 0, "exists_total": 0, "exists_time_in_millis": 0, "missing_total": 0, "missing_time_in_millis": 0, "current": 0 }, "search": { "open_contexts": 0, "query_total": 0, "query_time_in_millis": 0, "query_current": 0, "query_failure": 0, "fetch_total": 0, "fetch_time_in_millis": 0, "fetch_current": 0, "fetch_failure": 0, "scroll_total": 0, "scroll_time_in_millis": 0, "scroll_current": 0, "suggest_total": 0, "suggest_time_in_millis": 0, "suggest_current": 0 }, "merges": { "current": 0, "current_docs": 0, "current_size_in_bytes": 0, "total": 1, "total_time_in_millis": 34, "total_docs": 1015, "total_size_in_bytes": 126880, "total_stopped_time_in_millis": 0, "total_throttled_time_in_millis": 0, "total_auto_throttle_in_bytes": 20971520 }, "refresh": { "total": 12, "total_time_in_millis": 158, "external_total": 6, "external_total_time_in_millis": 70, "listeners": 0 }, "flush": { "total": 1, "periodic": 1, "total_time_in_millis": 11, "total_time_excluding_waiting_on_lock_in_millis": 65 }, "warmer": { "current": 0, "total": 5, "total_time_in_millis": 4 }, "query_cache": { "memory_size_in_bytes": 0, "total_count": 0, "hit_count": 0, "miss_count": 0, "cache_size": 0, "cache_count": 0, "evictions": 0 }, "fielddata": { "memory_size_in_bytes": 0, "evictions": 0, "global_ordinals": { "build_time_in_millis": 0 } }, "completion": { "size_in_bytes": 0 }, "segments": { "count": 1, "memory_in_bytes": 0, "terms_memory_in_bytes": 0, "stored_fields_memory_in_bytes": 0, "term_vectors_memory_in_bytes": 0, "norms_memory_in_bytes": 0, "points_memory_in_bytes": 0, "doc_values_memory_in_bytes": 0, "index_writer_memory_in_bytes": 0, "version_map_memory_in_bytes": 0, "fixed_bit_set_memory_in_bytes": 168, "max_unsafe_auto_id_timestamp": -1, "file_sizes": {} }, "translog": { "operations": 0, "size_in_bytes": 55, "uncommitted_operations": 0, "uncommitted_size_in_bytes": 55, "earliest_last_modified_age": 606716 }, "request_cache": { "memory_size_in_bytes": 0, "evictions": 0, "hit_count": 0, "miss_count": 0 }, "recovery": { "current_as_source": 0, "current_as_target": 0, "throttle_time_in_millis": 0 }, "bulk": { "total_operations": 57, "total_time_in_millis": 34, "total_size_in_bytes": 114084, "avg_time_in_millis": 0, "avg_size_in_bytes": 2156 }, "dense_vector": { "value_count": 0 }, "sparse_vector": { "value_count": 0 } }, "total": { "docs": { "count": 2030, "deleted": 0, "total_size_in_bytes": 166945 }, "shard_stats": { "total_count": 2 }, "store": { "size_in_bytes": 167697, "total_data_set_size_in_bytes": 167697, "reserved_in_bytes": 0 }, "indexing": { "index_total": 108, "index_time_in_millis": 65, "index_current": 0, "index_failed": 0, "index_failed_due_to_version_conflict": 0, "delete_total": 0, "delete_time_in_millis": 0, "delete_current": 0, "noop_update_total": 0, "is_throttled": false, "throttle_time_in_millis": 0, "write_load": 0.000042064075365212696 }, "get": { "total": 0, "time_in_millis": 0, "exists_total": 0, "exists_time_in_millis": 0, "missing_total": 0, "missing_time_in_millis": 0, "current": 0 }, "search": { "open_contexts": 0, "query_total": 1, "query_time_in_millis": 0, "query_current": 0, "query_failure": 0, "fetch_total": 1, "fetch_time_in_millis": 0, "fetch_current": 0, "fetch_failure": 0, "scroll_total": 0, "scroll_time_in_millis": 0, "scroll_current": 0, "suggest_total": 0, "suggest_time_in_millis": 0, "suggest_current": 0 }, "merges": { "current": 0, "current_docs": 0, "current_size_in_bytes": 0, "total": 2, "total_time_in_millis": 78, "total_docs": 2030, "total_size_in_bytes": 255483, "total_stopped_time_in_millis": 0, "total_throttled_time_in_millis": 0, "total_auto_throttle_in_bytes": 41943040 }, "refresh": { "total": 22, "total_time_in_millis": 294, "external_total": 12, "external_total_time_in_millis": 148, "listeners": 0 }, "flush": { "total": 3, "periodic": 2, "total_time_in_millis": 162, "total_time_excluding_waiting_on_lock_in_millis": 268 }, "warmer": { "current": 0, "total": 10, "total_time_in_millis": 8 }, "query_cache": { "memory_size_in_bytes": 0, "total_count": 0, "hit_count": 0, "miss_count": 0, "cache_size": 0, "cache_count": 0, "evictions": 0 }, "fielddata": { "memory_size_in_bytes": 0, "evictions": 0, "global_ordinals": { "build_time_in_millis": 0 } }, "completion": { "size_in_bytes": 0 }, "segments": { "count": 2, "memory_in_bytes": 0, "terms_memory_in_bytes": 0, "stored_fields_memory_in_bytes": 0, "term_vectors_memory_in_bytes": 0, "norms_memory_in_bytes": 0, "points_memory_in_bytes": 0, "doc_values_memory_in_bytes": 0, "index_writer_memory_in_bytes": 0, "version_map_memory_in_bytes": 0, "fixed_bit_set_memory_in_bytes": 336, "max_unsafe_auto_id_timestamp": -1, "file_sizes": {} }, "translog": { "operations": 0, "size_in_bytes": 110, "uncommitted_operations": 0, "uncommitted_size_in_bytes": 110, "earliest_last_modified_age": 606716 }, "request_cache": { "memory_size_in_bytes": 0, "evictions": 0, "hit_count": 0, "miss_count": 1 }, "recovery": { "current_as_source": 0, "current_as_target": 0, "throttle_time_in_millis": 0 }, "bulk": { "total_operations": 108, "total_time_in_millis": 70, "total_size_in_bytes": 214234, "avg_time_in_millis": 0, "avg_size_in_bytes": 2153 }, "dense_vector": { "value_count": 0 }, "sparse_vector": { "value_count": 0 } } } } }你看看这个主分片和副分片各一个,然后我这个索引也是新建立之后就插入了57条文档,不存在之前就有文档。到底是什么原因导致出现这个情况啊啊啊啊,而且你说的是docs.count就是实际的文档数啊,显然我这个很矛盾我已经搞了一下午了也不知道为啥啊啊啊

资源评论
用户头像
田仲政
2025.07.19
对bit map index有研究兴趣的朋友不可错过这篇文章。🍓
用户头像
余青葭
2025.05.17
Tolywang对bit map index的研究深入细致,内容质量高。