diff --git a/README.md b/README.md index f13a8d6..ba6ebcd 100644 --- a/README.md +++ b/README.md @@ -2,51 +2,51 @@ - 硬件核心(Hardware Core) - Controller(控制器) - + CPU - + MCU - + 51 - + HCS12 - + AVR XMEGA - + ESP8266 - + Coldfire - + ARM STM32 - + MPU - + DSP - + MSP430 - + SOC - + OMAP - + CPLD - + Altera EPM7128S - + Lattice LC4128V - + FPGA - + Altera Cyclone - + Xilinx XC9500 - + DSC - + TMS320F28x - + MC56 F83x + - CPU + - MCU + - 51 + - HCS12 + - AVR XMEGA + - ESP8266 + - Coldfire + - ARM STM32 + - MPU + - DSP + - MSP430 + - SOC + - OMAP + - CPLD + - Altera EPM7128S + - Lattice LC4128V + - FPGA + - Altera Cyclone + - Xilinx XC9500 + - DSC + - TMS320F28x + - MC56 F83x - Actuator(执行器) - + 电机 + - 电机 - Sensor(传感器) - + RIP(人体红外) - + Temperture(温度) - + Light - + Motion(运动) - + Camera + - RIP(人体红外) + - Temperture(温度) + - Light + - Motion(运动) + - Camera - electronic component(电子元件) - 电容 - 保护装置 - 端子与连接器 - 电线 - 开关 - + Switch - + Keypad - + Relay + - Switch + - Keypad + - Relay - 电阻 - + Thermistor (热敏电阻) - + Varistor(压敏电阻) + - Thermistor (热敏电阻) + - Varistor(压敏电阻) - 电磁感应装置 - network - + 电阻排 + - 电阻排 - 忆阻器 - 压电装置、晶体谐振器 - 电源 @@ -73,55 +73,55 @@ - Interrupt (中断) - Communication(通信) - 硬件间通信 - + Bluetooth - + Xbee / Zigbee - + Z-Wave - + 6LoWPAN - + NFC - + Wifi - + Radio - + IR (红外) - + 802.11 + - Bluetooth + - Xbee / Zigbee + - Z-Wave + - 6LoWPAN + - NFC + - Wifi + - Radio + - IR (红外) + - 802.11 - 硬件通信 - + UART - + S2C - + RS232C/RS485 - + HDLC - + SPI/SCI/SI - + CAN - + USB - + FireWire + - UART + - S2C + - RS232C/RS485 + - HDLC + - SPI/SCI/SI + - CAN + - USB + - FireWire - 网络协议 - + HTTP - + CoAP - + MQTT - + XMPP - + WebSocket - + UDP - + TCP + - HTTP + - CoAP + - MQTT + - XMPP + - WebSocket + - UDP + - TCP - 软件编程 - Common - + ISR - + Driver - + DMA - + I2C + - ISR + - Driver + - DMA + - I2C - OS - + uCOS - + Contiki - + TinyOS - + VXWorks - + FreeRTOS - + Windows CE - + Windows 10 IoT Core - + mbed OS - + emOS - + Salvo - + MQX - + uCLinux - + openWRT - + RIOT + - uCOS + - Contiki + - TinyOS + - VXWorks + - FreeRTOS + - Windows CE + - Windows 10 IoT Core + - mbed OS + - emOS + - Salvo + - MQX + - uCLinux + - openWRT + - RIOT - non-OS - + LwIP + - LwIP ##内容贡献者 diff --git a/bin/generator.js b/bin/generator.js new file mode 100644 index 0000000..a609db8 --- /dev/null +++ b/bin/generator.js @@ -0,0 +1,87 @@ +// code basis on https://github.com/JacksonTian/fks/blob/master/bin/generate.js +// Thanks to JacksonTian +var fs = require('fs'); +var path = require('path'); + +var readme = fs.readFileSync(path.join(__dirname, '../README.md'), 'utf8'); + +var getItems = function (str) { + var patt = /([ ]*)-(.*)/g; + var result; + + var list = []; + while ((result = patt.exec(str)) != null) { + list.push({level: result[1].length / 4, content: result[2].trim()}); + } + return list; +}; + +var filter = function (list) { + var j = 0; + var f2e = []; + for (var i = 0; i < list.length; i++) { + var item = list[i]; + if (item.level === 0) { + j = j + 1; + if (j === 2) { + break; + } + } + + f2e.push(item); + } + return f2e; +}; + +var format = function (list) { + var result = []; + for (var i = 0; i < list.length; i++) { + var item = list[i]; + var data = { + id: '' + i, + name: item.content, + level: item.level + }; + result.push(data); + } + return result; +}; + +var items = getItems(readme); +var f2e = filter(items); +var formated = format(f2e); + +var buildTree = function (list) { + var root = null; + for (var i = 0; i < list.length; i++) { + var item = list[i]; + if (root === null) { + root = item; + root.children = []; + } + + var lastLevel0 = root.children; + if (item.level === 1) { + delete item.level; + lastLevel0.push(item); + } + + if (item.level === 2) { + var lastLevel1 = lastLevel0[lastLevel0.length - 1]; + lastLevel1.children = lastLevel1.children || []; + lastLevel1.children.push(item); + } + + if (item.level === 3) { + var lastLevel1Child = lastLevel0[lastLevel0.length - 1].children; + var lastLevel2 = lastLevel1Child[lastLevel1Child.length - 1]; + lastLevel2.children = lastLevel2.children || []; + lastLevel2.children.push(item); + } + delete item.level; + } + return root; +}; + +var tree = buildTree(formated); +fs.writeFileSync(path.join(__dirname, '../data/eks.json'), JSON.stringify(tree, null, ' ')); \ No newline at end of file diff --git a/data/eks.json b/data/eks.json new file mode 100644 index 0000000..39151e2 --- /dev/null +++ b/data/eks.json @@ -0,0 +1,82 @@ +{ + "id": "0", + "name": "硬件核心(Hardware Core)", + "children": [ + { + "id": "2", + "name": "CPU" + }, + { + "id": "3", + "name": "MCU" + }, + { + "id": "10", + "name": "MPU" + }, + { + "id": "11", + "name": "DSP" + }, + { + "id": "13", + "name": "SOC" + }, + { + "id": "15", + "name": "CPLD" + }, + { + "id": "18", + "name": "FPGA" + }, + { + "id": "21", + "name": "DSC" + }, + { + "id": "27", + "name": "RIP(人体红外)" + }, + { + "id": "28", + "name": "Temperture(温度)" + }, + { + "id": "29", + "name": "Light" + }, + { + "id": "30", + "name": "Motion(运动)" + }, + { + "id": "31", + "name": "Camera" + }, + { + "id": "38", + "name": "Switch" + }, + { + "id": "39", + "name": "Keypad" + }, + { + "id": "40", + "name": "Relay" + }, + { + "id": "42", + "name": "Thermistor (热敏电阻)" + }, + { + "id": "43", + "name": "Varistor(压敏电阻)" + }, + { + "id": "46", + "name": "电阻排" + } + ] +} \ No newline at end of file diff --git a/make.sh b/make.sh new file mode 100755 index 0000000..8d98c44 --- /dev/null +++ b/make.sh @@ -0,0 +1 @@ +node ./bin/generator.js \ No newline at end of file