added master gain control flow
This commit is contained in:
173
flows/master_gain_control_flow.json
Normal file
173
flows/master_gain_control_flow.json
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "tabXilicaDash",
|
||||||
|
"type": "tab",
|
||||||
|
"label": "Xilica FR1 Dashboard"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ui_slider_gain",
|
||||||
|
"type": "ui_slider",
|
||||||
|
"z": "tabXilicaDash",
|
||||||
|
"name": "MASTER_GAIN (dB)",
|
||||||
|
"label": "MASTER_GAIN (dB)",
|
||||||
|
"tooltip": "",
|
||||||
|
"group": "ui_group_1",
|
||||||
|
"order": 1,
|
||||||
|
"width": 6,
|
||||||
|
"height": 1,
|
||||||
|
"passthru": false,
|
||||||
|
"outs": "all",
|
||||||
|
"topic": "",
|
||||||
|
"topicType": "str",
|
||||||
|
"min": "-100",
|
||||||
|
"max": "-18",
|
||||||
|
"step": "0.5",
|
||||||
|
"className": "",
|
||||||
|
"x": 210,
|
||||||
|
"y": 160,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"fn_build_set_from_slider"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ui_text_curr",
|
||||||
|
"type": "ui_text",
|
||||||
|
"z": "tabXilicaDash",
|
||||||
|
"group": "ui_group_1",
|
||||||
|
"order": 2,
|
||||||
|
"width": 6,
|
||||||
|
"height": 1,
|
||||||
|
"name": "Current (dB)",
|
||||||
|
"label": "Current (dB)",
|
||||||
|
"format": "{{msg.payload}}",
|
||||||
|
"layout": "row-spread",
|
||||||
|
"x": 650,
|
||||||
|
"y": 100,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fn_build_set_from_slider",
|
||||||
|
"type": "function",
|
||||||
|
"z": "tabXilicaDash",
|
||||||
|
"name": "build SET MASTER_GAIN <v>",
|
||||||
|
"func": "const v = Number(msg.payload);\n// show value on the slider label while sending\nnode.status({text: v.toFixed(1)+\" dB\"});\nmsg.payload = `SET MASTER_GAIN ${v}`;\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"noerr": 0,
|
||||||
|
"x": 450,
|
||||||
|
"y": 160,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"fn_append_cr"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "inj_poll",
|
||||||
|
"type": "inject",
|
||||||
|
"z": "tabXilicaDash",
|
||||||
|
"name": "poll GET (every 2s)",
|
||||||
|
"props": [
|
||||||
|
{
|
||||||
|
"p": "payload",
|
||||||
|
"v": "GET MASTER_GAIN",
|
||||||
|
"vt": "str"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"repeat": "2",
|
||||||
|
"once": true,
|
||||||
|
"onceDelay": "0.5",
|
||||||
|
"x": 170,
|
||||||
|
"y": 100,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"fn_append_cr"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fn_append_cr",
|
||||||
|
"type": "function",
|
||||||
|
"z": "tabXilicaDash",
|
||||||
|
"name": "append \\r",
|
||||||
|
"func": "if (typeof msg.payload !== 'string') msg.payload = String(msg.payload);\nmsg.payload += \"\\r\";\nreturn msg;",
|
||||||
|
"outputs": 1,
|
||||||
|
"x": 470,
|
||||||
|
"y": 100,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"tcp_req"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "tcp_req",
|
||||||
|
"type": "tcp request",
|
||||||
|
"z": "tabXilicaDash",
|
||||||
|
"name": "FR1 192.168.1.244:10007",
|
||||||
|
"server": "192.168.1.244",
|
||||||
|
"port": "10007",
|
||||||
|
"out": "time",
|
||||||
|
"ret": "string",
|
||||||
|
"splitc": "\\r",
|
||||||
|
"x": 670,
|
||||||
|
"y": 160,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"fn_parse_get",
|
||||||
|
"dbg"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fn_parse_get",
|
||||||
|
"type": "function",
|
||||||
|
"z": "tabXilicaDash",
|
||||||
|
"name": "parse GET reply → number",
|
||||||
|
"func": "// Expected: MASTER_GAIN=-6.0\\r or OK\\r after SET\nconst s = (msg.payload||\"\").trim();\nif (/^MASTER_GAIN\\s*=/.test(s)) {\n const m = s.match(/=\\s*([-+]?\\d+(?:\\.\\d+)?)/);\n if (m) {\n const val = Number(m[1]);\n // update text and slider\n node.send([{payload: val.toFixed(1)}, {payload: val}]);\n }\n}\nreturn null; // outputs handled via node.send",
|
||||||
|
"outputs": 2,
|
||||||
|
"x": 910,
|
||||||
|
"y": 160,
|
||||||
|
"wires": [
|
||||||
|
[
|
||||||
|
"ui_text_curr"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"ui_slider_gain"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "dbg",
|
||||||
|
"type": "debug",
|
||||||
|
"z": "tabXilicaDash",
|
||||||
|
"name": "Raw replies",
|
||||||
|
"active": true,
|
||||||
|
"tosidebar": true,
|
||||||
|
"complete": "payload",
|
||||||
|
"statusVal": "",
|
||||||
|
"statusType": "auto",
|
||||||
|
"x": 870,
|
||||||
|
"y": 100,
|
||||||
|
"wires": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ui_group_1",
|
||||||
|
"type": "ui_group",
|
||||||
|
"name": "Master Gain",
|
||||||
|
"tab": "ui_tab_1",
|
||||||
|
"order": 1,
|
||||||
|
"disp": true,
|
||||||
|
"width": "6",
|
||||||
|
"collapse": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ui_tab_1",
|
||||||
|
"type": "ui_tab",
|
||||||
|
"name": "Solaro FR1",
|
||||||
|
"icon": "fa-volume-up",
|
||||||
|
"disabled": false,
|
||||||
|
"hidden": false
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user