1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| [ { "id": "cbd2b3b600a928eb", "type": "tab", "label": "流程 1", "disabled": false, "info": "" }, { "id": "e7b11ff31b0737d4", "type": "inject", "z": "cbd2b3b600a928eb", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": "0", "topic": "", "payloadType": "date", "x": 120, "y": 80, "wires": [ [ "216def814448f2b8" ] ] }, { "id": "216def814448f2b8", "type": "function", "z": "cbd2b3b600a928eb", "name": "", "func": "var processSwapInt = function processSwapInt(id, buffer) {\n let wordlength = 2; //一个字占2字节\n \n var buf = Buffer.alloc(4);\n buf[0] = buffer[id * wordlength + 2];\n buf[1] = buffer[id * wordlength + 3];\n buf[2] = buffer[id * wordlength + 0];\n buf[3] = buffer[id * wordlength + 1];\n return buf.readIntBE(0,4);\n}\n\nvar processNoSwapInt = function (id, buffer) {\n let wordlength = 2; //一个字占2字节\n let value;\n var buf = buffer.subarray(id * wordlength, id * wordlength + 4);\n return buf.readIntBE(0,4);\n}\n\nvar processSwapFloat = function (id, buffer){\n let wordlength = 2; //一个字占2字节\n var buf = Buffer.alloc(4);\n buf[0] = msg.payload.buffer[id * wordlength + 2];\n buf[1] = msg.payload.buffer[id * wordlength + 3];\n buf[2] = msg.payload.buffer[id * wordlength + 0];\n buf[3] = msg.payload.buffer[id * wordlength + 1];\n return buf.readFloatBE(0);\n}\n\nvar processNoSwapFloat = function (id, buffer){\n let wordlength = 2; //一个字占2字节\n\tvar buf = buffer.subarray(id*wordlength,id*wordlength+4);\n\t\n\treturn buf.readFloatBE(0);\n}\n\nvar processNoSwapShort = function (id, buffer){\n let wordlength = 2; //一个字占2字节\n var buf = buffer.subarray(id * wordlength, id * wordlength + 2);\n return buf.readInt16BE(0,2);\n}\n\nglobal.set('processSwapInt', processSwapInt);\nglobal.set('processNoSwapInt', processNoSwapInt);\n\nglobal.set('processSwapFloat', processNoSwapFloat);\nglobal.set('processNoSwapFloat', processNoSwapFloat);\n\nglobal.set('processNoSwapShort', processNoSwapShort);\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 350, "y": 80, "wires": [ [ "3f820a34fd1a8f6d" ] ] }, { "id": "3f820a34fd1a8f6d", "type": "debug", "z": "cbd2b3b600a928eb", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 640, "y": 80, "wires": [] }, { "id": "5d1a746cb00206ce", "type": "function", "z": "cbd2b3b600a928eb", "name": "", "func": "\n\nreturn new Promise((reslove,reject)=>{\n global.get('processNoSwapInt',function(error, processNoSwapInt){\n \n var buf = Buffer.alloc(4);\n buf[0] = 1;\n buf[1] = 2;\n buf[2] = 3;\n buf[3] = 4;\n \n if(processNoSwapInt){\n msg.payload = processNoSwapInt(0, buf)\n }\n reslove(msg);\n })\n \n})\n\n ", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 300, "y": 320, "wires": [ [ "7dc9a6ff3a7be0b0" ] ] }, { "id": "dc0bde4b0474c180", "type": "inject", "z": "cbd2b3b600a928eb", "name": "", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 110, "y": 320, "wires": [ [ "5d1a746cb00206ce" ] ] }, { "id": "7dc9a6ff3a7be0b0", "type": "debug", "z": "cbd2b3b600a928eb", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 540, "y": 320, "wires": [] } ]
|