Showing
1 changed file
with
376 additions
and
202 deletions
@@ -7641,7 +7641,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7641,7 +7641,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7641 | 7641 | ||
7642 | const COMMAND_TYPE_ENUM = { | 7642 | const COMMAND_TYPE_ENUM = { |
7643 | CUSTOM: '0', | 7643 | CUSTOM: '0', |
7644 | - SERVICE: '1' | 7644 | + SERVICE: '1', |
7645 | + MODBUS: '2' | ||
7645 | } | 7646 | } |
7646 | 7647 | ||
7647 | /** | 7648 | /** |
@@ -7681,7 +7682,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7681,7 +7682,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7681 | form.val(enumActionEl.INPUT_DATA_FORM_FILTER, content[enumConst.SERVICE_COMMAND]) | 7682 | form.val(enumActionEl.INPUT_DATA_FORM_FILTER, content[enumConst.SERVICE_COMMAND]) |
7682 | } | 7683 | } |
7683 | 7684 | ||
7684 | - controlFormDisplay(content.type, isTCPTransportType, isCustom) | 7685 | + controlFormDisplay(content.type, val) |
7685 | 7686 | ||
7686 | form.val(enumActionEl.FORM_FILTER, val) | 7687 | form.val(enumActionEl.FORM_FILTER, val) |
7687 | } | 7688 | } |
@@ -7690,40 +7691,26 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7690,40 +7691,26 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7690 | * @description 控制form | 7691 | * @description 控制form |
7691 | * @param {enumActionType} value | 7692 | * @param {enumActionType} value |
7692 | */ | 7693 | */ |
7693 | - async function controlFormDisplay(value, isTCP, isCustom) { | 7694 | + async function controlFormDisplay(value, formValue) { |
7695 | + $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' }) | ||
7696 | + $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' }) | ||
7697 | + $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' }) | ||
7698 | + $(`#${enumActionEl.WAY_SELECT}`).css({ display: 'none' }) | ||
7699 | + $(`#${enumActionEl.COMMAND_TYPE_EL}`).css({ display: 'none' }) | ||
7700 | + $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: 'none' }) | ||
7701 | + $(`#${enumActionEl.SERVICE_EL}`).css({ display: 'none' }) | ||
7702 | + $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: 'none' }) | ||
7703 | + $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' }) | ||
7704 | + | ||
7694 | if (value === enumActionType.PAGE) { | 7705 | if (value === enumActionType.PAGE) { |
7695 | - $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' }) | ||
7696 | $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'block' }) | 7706 | $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'block' }) |
7697 | - $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' }) | ||
7698 | - $(`#${enumActionEl.WAY_SELECT}`).css({ display: 'none' }) | ||
7699 | - $(`#${enumActionEl.COMMAND_TYPE_EL}`).css({ display: 'none' }) | ||
7700 | - | ||
7701 | - $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: 'none' }) | ||
7702 | - $(`#${enumActionEl.SERVICE_EL}`).css({ display: 'none' }) | ||
7703 | - $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: 'none' }) | ||
7704 | - $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' }) | ||
7705 | } else if (value === enumActionType.LINK) { | 7707 | } else if (value === enumActionType.LINK) { |
7706 | - $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' }) | ||
7707 | $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'block' }) | 7708 | $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'block' }) |
7708 | - $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' }) | ||
7709 | - $(`#${enumActionEl.WAY_SELECT}`).css({ display: 'none' }) | ||
7710 | - $(`#${enumActionEl.COMMAND_TYPE_EL}`).css({ display: 'none' }) | ||
7711 | - | ||
7712 | - $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: 'none' }) | ||
7713 | - $(`#${enumActionEl.SERVICE_EL}`).css({ display: 'none' }) | ||
7714 | - // $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: 'none' }) | ||
7715 | - $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' }) | ||
7716 | } else if (value === enumActionType.PARAMS_SETTING) { | 7709 | } else if (value === enumActionType.PARAMS_SETTING) { |
7717 | - $(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' }) | ||
7718 | - $(`#${enumActionEl.PAGE_EL_ID}`).css({ display: 'none' }) | ||
7719 | - // $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'flex' }) | ||
7720 | $(`#${enumActionEl.COMMAND_TYPE_EL}`).css({ display: 'block' }) | 7710 | $(`#${enumActionEl.COMMAND_TYPE_EL}`).css({ display: 'block' }) |
7721 | - | ||
7722 | - $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: isCustom ? 'none' : 'block' }) | ||
7723 | - $(`#${enumActionEl.WAY_SELECT}`).css({ display: !isTCP && isCustom ? 'block' : 'none' }) | ||
7724 | - $(`#${enumActionEl.SERVICE_EL}`).css({ display: isCustom ? 'none' : 'block' }) | ||
7725 | - // $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCP && isCustom ? 'block' : 'none' }) | ||
7726 | - $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCP && isCustom ? 'flex' : 'none' }) | 7711 | + const { commandType, transportType } = formValue |
7712 | + handleDiffCommandType(commandType, transportType === 'TCP') | ||
7713 | + editorAssignValue() | ||
7727 | } | 7714 | } |
7728 | } | 7715 | } |
7729 | 7716 | ||
@@ -7746,29 +7733,41 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7746,29 +7733,41 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7746 | 7733 | ||
7747 | if (isParamsSetting) { | 7734 | if (isParamsSetting) { |
7748 | const isCustom = formVal[enumConst.COMMAND_TYPE] === COMMAND_TYPE_ENUM.CUSTOM | 7735 | const isCustom = formVal[enumConst.COMMAND_TYPE] === COMMAND_TYPE_ENUM.CUSTOM |
7736 | + const commandType = formVal[enumConst.COMMAND_TYPE] | ||
7749 | let inputData = form.val(enumActionEl.INPUT_DATA_FORM_FILTER) | 7737 | let inputData = form.val(enumActionEl.INPUT_DATA_FORM_FILTER) |
7750 | 7738 | ||
7751 | const validateParamsSetting = () => { | 7739 | const validateParamsSetting = () => { |
7752 | - if (isCustom) { | 7740 | + if (commandType === COMMAND_TYPE_ENUM.CUSTOM) { |
7753 | if (isTCPTransportType) { | 7741 | if (isTCPTransportType) { |
7754 | - const dataSource = currentNodeData?.dataSources?.[0] | ||
7755 | - if (dataSource) { | ||
7756 | - const additional = dataSource?.additional || {} | ||
7757 | - if (dataSource?.deviceType !== 'SENDOR' && !additional?.deviceCode) { | ||
7758 | - UseLayUi.topErrorMsg('设备地址码不存在') | ||
7759 | - return false | ||
7760 | - } | 7742 | + if (!formVal[enumConst.TCP_COMMAND]) { |
7743 | + UseLayUi.topErrorMsg('请输入自定义下发指令') | ||
7744 | + return false | ||
7761 | } | 7745 | } |
7762 | - // if (!formVal[enumConst.TCP_COMMAND]) { | ||
7763 | - // UseLayUi.topErrorMsg('请输入自定义下发指令') | ||
7764 | - // return false | ||
7765 | - // } | ||
7766 | } else { | 7746 | } else { |
7767 | if (!isJson(formVal[enumConst.JSON_COMMAND])) { | 7747 | if (!isJson(formVal[enumConst.JSON_COMMAND])) { |
7768 | UseLayUi.topErrorMsg('命令配置存在错误') | 7748 | UseLayUi.topErrorMsg('命令配置存在错误') |
7769 | return false | 7749 | return false |
7770 | } | 7750 | } |
7771 | } | 7751 | } |
7752 | + } else if (commandType === COMMAND_TYPE_ENUM.MODBUS) { | ||
7753 | + const dataSource = currentNodeData?.dataSources?.[0] | ||
7754 | + if (dataSource) { | ||
7755 | + const additional = dataSource?.additional || {} | ||
7756 | + if (dataSource?.deviceType !== 'SENDOR' && !additional?.deviceCode) { | ||
7757 | + UseLayUi.topErrorMsg('设备地址码不存在') | ||
7758 | + return false | ||
7759 | + } | ||
7760 | + | ||
7761 | + if (UseLayUi.isNullOrUnDef(additional?.registerAddress)) { | ||
7762 | + UseLayUi.topErrorMsg('寄存器地址不存在') | ||
7763 | + return false | ||
7764 | + } | ||
7765 | + | ||
7766 | + if (UseLayUi.isNullOrUnDef(additional?.method)) { | ||
7767 | + UseLayUi.topErrorMsg('操作类型不存在') | ||
7768 | + return false | ||
7769 | + } | ||
7770 | + } | ||
7772 | } else { | 7771 | } else { |
7773 | if (!formVal[enumConst.SERVICE]) { | 7772 | if (!formVal[enumConst.SERVICE]) { |
7774 | UseLayUi.topErrorMsg('请选择服务') | 7773 | UseLayUi.topErrorMsg('请选择服务') |
@@ -7779,6 +7778,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7779,6 +7778,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7779 | return flag | 7778 | return flag |
7780 | } | 7779 | } |
7781 | } | 7780 | } |
7781 | + | ||
7782 | return true | 7782 | return true |
7783 | } | 7783 | } |
7784 | 7784 | ||
@@ -7790,6 +7790,19 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7790,6 +7790,19 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7790 | } | 7790 | } |
7791 | } | 7791 | } |
7792 | 7792 | ||
7793 | + const getParamsSettingData = (formVal = {}) => { | ||
7794 | + let fields = [enumConst.COMMAND_TYPE, enumConst.TRANSPORTTYPE, enumConst.WAY] | ||
7795 | + const commandType = formVal[enumConst.COMMAND_TYPE] | ||
7796 | + | ||
7797 | + if (commandType === COMMAND_TYPE_ENUM.CUSTOM) { | ||
7798 | + fields = [...fields, enumConst.JSON_COMMAND, enumConst.TCP_COMMAND] | ||
7799 | + } else if (commandType === COMMAND_TYPE_ENUM.SERVICE) { | ||
7800 | + fields = [...fields, enumConst.CALL_TYPE, enumConst.IDENTIFIER, enumConst.SERVICE, enumConst.SERVICE_COMMAND, enumConst.SERVICE_ORIGINAL_CONFIGURATION] | ||
7801 | + } | ||
7802 | + | ||
7803 | + return fields.reduce((prev, next) => ({ ...prev, [next]: formVal[next] }), {}) | ||
7804 | + } | ||
7805 | + | ||
7793 | const data = { | 7806 | const data = { |
7794 | type: event.data.type, | 7807 | type: event.data.type, |
7795 | configurationId, | 7808 | configurationId, |
@@ -7800,18 +7813,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7800,18 +7813,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7800 | content: { | 7813 | content: { |
7801 | type: formVal[enumConst.ACTION], | 7814 | type: formVal[enumConst.ACTION], |
7802 | value: formVal[enumGetValue[formVal[enumConst.ACTION]]], | 7815 | value: formVal[enumGetValue[formVal[enumConst.ACTION]]], |
7803 | - ...(isParamsSetting ? { | ||
7804 | - [enumConst.CALL_TYPE]: formVal[enumConst.CALL_TYPE], | ||
7805 | - [enumConst.IDENTIFIER]: formVal[enumConst.IDENTIFIER], | ||
7806 | - [enumConst.JSON_COMMAND]: formVal[enumConst.JSON_COMMAND], | ||
7807 | - [enumConst.WAY]: isTCPTransportType ? 'oneway' : formVal[enumConst.WAY], | ||
7808 | - [enumConst.COMMAND_TYPE]: formVal[enumConst.COMMAND_TYPE], | ||
7809 | - [enumConst.TCP_COMMAND]: formVal[enumConst.TCP_COMMAND], | ||
7810 | - [enumConst.TRANSPORTTYPE]: formVal[enumConst.TRANSPORTTYPE], | ||
7811 | - [enumConst.SERVICE]: formVal[enumConst.SERVICE], | ||
7812 | - [enumConst.SERVICE_COMMAND]: formVal[enumConst.SERVICE_COMMAND], | ||
7813 | - [enumConst.SERVICE_ORIGINAL_CONFIGURATION]: formVal[enumConst.SERVICE_ORIGINAL_CONFIGURATION], | ||
7814 | - } : {}), | 7816 | + ...(isParamsSetting ? getParamsSettingData(formVal) : {}), |
7815 | }, | 7817 | }, |
7816 | } | 7818 | } |
7817 | await to(autoSaveGraphInfo()) | 7819 | await to(autoSaveGraphInfo()) |
@@ -7843,6 +7845,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7843,6 +7845,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7843 | function generateCommandTypeOptions() { | 7845 | function generateCommandTypeOptions() { |
7844 | const options = [ | 7846 | const options = [ |
7845 | { name: '自定义命令', id: COMMAND_TYPE_ENUM.CUSTOM }, | 7847 | { name: '自定义命令', id: COMMAND_TYPE_ENUM.CUSTOM }, |
7848 | + { name: 'modbus命令', id: COMMAND_TYPE_ENUM.MODBUS }, | ||
7846 | { name: '服务调用', id: COMMAND_TYPE_ENUM.SERVICE }, | 7849 | { name: '服务调用', id: COMMAND_TYPE_ENUM.SERVICE }, |
7847 | ] | 7850 | ] |
7848 | return UseLayUi.generateOptionTemplate({ dataSource: options, addPlaceholderOption: false }) | 7851 | return UseLayUi.generateOptionTemplate({ dataSource: options, addPlaceholderOption: false }) |
@@ -7856,6 +7859,24 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7856,6 +7859,24 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7856 | return UseLayUi.generateOptionTemplate({ dataSource: options, addPlaceholderOption: false }) | 7859 | return UseLayUi.generateOptionTemplate({ dataSource: options, addPlaceholderOption: false }) |
7857 | } | 7860 | } |
7858 | 7861 | ||
7862 | + function handleDiffCommandType(type, isTCPTransportType) { | ||
7863 | + $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: 'none' }) | ||
7864 | + $(`#${enumActionEl.WAY_SELECT}`).css({ display: 'none' }) | ||
7865 | + $(`#${enumActionEl.SERVICE_EL}`).css({ display: 'none' }) | ||
7866 | + $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: 'none' }) | ||
7867 | + $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' }) | ||
7868 | + | ||
7869 | + if (type === COMMAND_TYPE_ENUM.CUSTOM) { | ||
7870 | + $(`#${enumActionEl.WAY_SELECT}`).css({ display: isTCPTransportType ? 'none' : 'block' }) | ||
7871 | + $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCPTransportType ? 'block' : 'NONE' }) | ||
7872 | + $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: isTCPTransportType ? 'none' : 'flex' }) | ||
7873 | + } else if (type === COMMAND_TYPE_ENUM.MODBUS) { | ||
7874 | + } else { | ||
7875 | + $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: 'block' }) | ||
7876 | + $(`#${enumActionEl.SERVICE_EL}`).css({ display: 'block' }) | ||
7877 | + } | ||
7878 | + } | ||
7879 | + | ||
7859 | async function generatorEventListen(data) { | 7880 | async function generatorEventListen(data) { |
7860 | const info = getLayerBindInfo('event', event.data.type) || {} | 7881 | const info = getLayerBindInfo('event', event.data.type) || {} |
7861 | let originType = (info.content || {}).type | 7882 | let originType = (info.content || {}).type |
@@ -7877,9 +7898,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7877,9 +7898,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7877 | form.val(enumActionEl.FORM_FILTER, { | 7898 | form.val(enumActionEl.FORM_FILTER, { |
7878 | [enumConst.COMMAND_TYPE]: COMMAND_TYPE_ENUM.CUSTOM | 7899 | [enumConst.COMMAND_TYPE]: COMMAND_TYPE_ENUM.CUSTOM |
7879 | }) | 7900 | }) |
7880 | - const isCustom = form.val(enumActionEl.FORM_FILTER)[enumConst.COMMAND_TYPE] === COMMAND_TYPE_ENUM.CUSTOM | 7901 | + const formValue = form.val(enumActionEl.FORM_FILTER) |
7881 | 7902 | ||
7882 | - controlFormDisplay(value, transportType === 'TCP', isCustom) | 7903 | + controlFormDisplay(value, formValue) |
7883 | }) | 7904 | }) |
7884 | 7905 | ||
7885 | /** | 7906 | /** |
@@ -7887,13 +7908,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7887,13 +7908,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7887 | */ | 7908 | */ |
7888 | form.on(`select(${enumActionEl.COMMAND_TYPE_EL})`, (data) => { | 7909 | form.on(`select(${enumActionEl.COMMAND_TYPE_EL})`, (data) => { |
7889 | const { value } = data | 7910 | const { value } = data |
7890 | - const flag = value === COMMAND_TYPE_ENUM.CUSTOM | ||
7891 | const isTCPTransportType = transportType === 'TCP' | 7911 | const isTCPTransportType = transportType === 'TCP' |
7892 | - $(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: flag ? 'none' : 'block' }) | ||
7893 | - $(`#${enumActionEl.WAY_SELECT}`).css({ display: !isTCPTransportType && flag ? 'block' : 'none' }) | ||
7894 | - $(`#${enumActionEl.SERVICE_EL}`).css({ display: flag ? 'none' : 'block' }) | ||
7895 | - // $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: !isTCPTransportType && flag ? 'block' : 'none' }) | ||
7896 | - $(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCPTransportType && flag ? 'flex' : 'none' }) | 7912 | + handleDiffCommandType(value, isTCPTransportType) |
7913 | + | ||
7897 | form.val(enumActionEl.FORM_FILTER, { [enumConst.TCP_COMMAND]: '', [enumConst.SERVICE]: '', [enumConst.COMMAND]: '', [enumConst.IDENTIFIER]: '' }) | 7914 | form.val(enumActionEl.FORM_FILTER, { [enumConst.TCP_COMMAND]: '', [enumConst.SERVICE]: '', [enumConst.COMMAND]: '', [enumConst.IDENTIFIER]: '' }) |
7898 | $(`#${enumActionEl.INPUT_DATA_FORM}`).html('') | 7915 | $(`#${enumActionEl.INPUT_DATA_FORM}`).html('') |
7899 | editorAssignValue() | 7916 | editorAssignValue() |
@@ -7987,6 +8004,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -7987,6 +8004,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
7987 | const stringValue = JSON.stringify(defaultValue, null, 2) | 8004 | const stringValue = JSON.stringify(defaultValue, null, 2) |
7988 | editor.insert(stringValue) | 8005 | editor.insert(stringValue) |
7989 | $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.JSON_COMMAND}"]`).val(stringValue) | 8006 | $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.JSON_COMMAND}"]`).val(stringValue) |
8007 | + console.log($(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.JSON_COMMAND}"]`).val()) | ||
7990 | editor.session.setMode("ace/mode/json"); | 8008 | editor.session.setMode("ace/mode/json"); |
7991 | editor.getSession().on('change', (event, editor) => { | 8009 | editor.getSession().on('change', (event, editor) => { |
7992 | $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.JSON_COMMAND}"]`).val(editor.getValue()) | 8010 | $(`#${enumActionEl.EDITOR_CONTAINER}`).parent().find(`textarea[name="${enumConst.JSON_COMMAND}"]`).val(editor.getValue()) |
@@ -8069,12 +8087,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8069,12 +8087,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8069 | <div id="${enumActionEl.EDITOR}" style="width: 100%; height: 100%;border: 2px solid #eee;"></div> | 8087 | <div id="${enumActionEl.EDITOR}" style="width: 100%; height: 100%;border: 2px solid #eee;"></div> |
8070 | <textarea name="${enumConst.JSON_COMMAND}" class="layui-textarea" style="display: none;" /> | 8088 | <textarea name="${enumConst.JSON_COMMAND}" class="layui-textarea" style="display: none;" /> |
8071 | </div> | 8089 | </div> |
8072 | - <!-- <div id="${enumActionEl.TCP_COMMAND_INPUT}" style="display: none;"> | 8090 | + <div id="${enumActionEl.TCP_COMMAND_INPUT}" style="display: none;"> |
8073 | <label class="layui-form-label" style="width: 120px;">命令 ${createHelpMessage('用户预览模式下,点击参数设置后。输入的变量值将作为"attrPlaceholder"的值,并以JSON格式下发给服务器。', 'command')}</label> | 8091 | <label class="layui-form-label" style="width: 120px;">命令 ${createHelpMessage('用户预览模式下,点击参数设置后。输入的变量值将作为"attrPlaceholder"的值,并以JSON格式下发给服务器。', 'command')}</label> |
8074 | <div class="layui-input-block" style="margin-left: 150px;"> | 8092 | <div class="layui-input-block" style="margin-left: 150px;"> |
8075 | <input type="text" lay-verType="tips" name="${enumConst.TCP_COMMAND}" placeholder="请输入自定义下发命令" class="layui-input"> | 8093 | <input type="text" lay-verType="tips" name="${enumConst.TCP_COMMAND}" placeholder="请输入自定义下发命令" class="layui-input"> |
8076 | </div> | 8094 | </div> |
8077 | - </div> --> | 8095 | + </div> |
8078 | <div style="display: none;"> | 8096 | <div style="display: none;"> |
8079 | <input type="text" lay-verType="tips" name="${enumConst.TRANSPORTTYPE}" placeholder="请输入自定义下发命令" class="layui-input"> | 8097 | <input type="text" lay-verType="tips" name="${enumConst.TRANSPORTTYPE}" placeholder="请输入自定义下发命令" class="layui-input"> |
8080 | </div> | 8098 | </div> |
@@ -8701,7 +8719,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8701,7 +8719,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8701 | METHOD: 'method', | 8719 | METHOD: 'method', |
8702 | DEVICE_COED: 'deviceCode', | 8720 | DEVICE_COED: 'deviceCode', |
8703 | REGISTER_ADDRESS: 'registerAddress', | 8721 | REGISTER_ADDRESS: 'registerAddress', |
8704 | - DATA_TYPE: 'dataType' | 8722 | + DATA_TYPE: 'dataType', |
8723 | + ACTION_TYPE: 'actionType' | ||
8705 | } | 8724 | } |
8706 | 8725 | ||
8707 | /** | 8726 | /** |
@@ -8760,6 +8779,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8760,6 +8779,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8760 | [enumDataSourceConst.METHOD]: null, | 8779 | [enumDataSourceConst.METHOD]: null, |
8761 | [enumDataSourceConst.REGISTER_ADDRESS]: null, | 8780 | [enumDataSourceConst.REGISTER_ADDRESS]: null, |
8762 | [enumDataSourceConst.DATA_TYPE]: null, | 8781 | [enumDataSourceConst.DATA_TYPE]: null, |
8782 | + [enumDataSourceConst.ACTION_TYPE]: null, | ||
8763 | }) | 8783 | }) |
8764 | 8784 | ||
8765 | currentDataSource[enumDataSourceConst.DEVICE_TYPE] = value | 8785 | currentDataSource[enumDataSourceConst.DEVICE_TYPE] = value |
@@ -8788,6 +8808,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8788,6 +8808,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8788 | [enumDataSourceConst.METHOD]: null, | 8808 | [enumDataSourceConst.METHOD]: null, |
8789 | [enumDataSourceConst.REGISTER_ADDRESS]: null, | 8809 | [enumDataSourceConst.REGISTER_ADDRESS]: null, |
8790 | [enumDataSourceConst.DATA_TYPE]: null, | 8810 | [enumDataSourceConst.DATA_TYPE]: null, |
8811 | + [enumDataSourceConst.ACTION_TYPE]: null, | ||
8791 | 8812 | ||
8792 | }) | 8813 | }) |
8793 | currentDataSource[enumDataSourceConst.DEVICE_PROFILE_ID] = value | 8814 | currentDataSource[enumDataSourceConst.DEVICE_PROFILE_ID] = value |
@@ -8821,6 +8842,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8821,6 +8842,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8821 | <div class="layui-form-item" style="margin-bottom: 0; display: none;"> | 8842 | <div class="layui-form-item" style="margin-bottom: 0; display: none;"> |
8822 | <input style="display: none" type="text" name="${enumDataSourceConst.DATA_TYPE}" class="layui-input"> | 8843 | <input style="display: none" type="text" name="${enumDataSourceConst.DATA_TYPE}" class="layui-input"> |
8823 | </div> | 8844 | </div> |
8845 | + <div class="layui-form-item" style="margin-bottom: 0; display: none;"> | ||
8846 | + <input style="display: none" type="text" name="${enumDataSourceConst.ACTION_TYPE}" class="layui-input"> | ||
8847 | + </div> | ||
8824 | ` | 8848 | ` |
8825 | $(component).append(template) | 8849 | $(component).append(template) |
8826 | } | 8850 | } |
@@ -8915,7 +8939,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8915,7 +8939,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8915 | 8939 | ||
8916 | if (!selected) return | 8940 | if (!selected) return |
8917 | form.val(componentFilter, { | 8941 | form.val(componentFilter, { |
8918 | - [enumDataSourceConst.DEVICE_NAME]: selected?.name, | 8942 | + [enumDataSourceConst.DEVICE_NAME]: selected?.alias || selected?.name, |
8919 | [enumDataSourceConst.DEVICE_COED]: selected?.code, | 8943 | [enumDataSourceConst.DEVICE_COED]: selected?.code, |
8920 | [enumDataSourceConst.ATTR]: null, | 8944 | [enumDataSourceConst.ATTR]: null, |
8921 | [enumDataSourceConst.ATTR_NAME]: null, | 8945 | [enumDataSourceConst.ATTR_NAME]: null, |
@@ -8947,22 +8971,23 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8947,22 +8971,23 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8947 | const selected = thingsModel.find(item => item.identifier === value) | 8971 | const selected = thingsModel.find(item => item.identifier === value) |
8948 | 8972 | ||
8949 | if (!selected) return | 8973 | if (!selected) return |
8950 | - const type = selected?.extensionDesc?.dataType | 8974 | + // const type = selected?.extensionDesc?.dataType |
8951 | 8975 | ||
8952 | - let method | 8976 | + // let method |
8953 | 8977 | ||
8954 | - if (type === 'short' || type === 'unshort') { | ||
8955 | - method = '06' | ||
8956 | - } else if (type === 'bit') { | ||
8957 | - method = '05' | ||
8958 | - } else { | ||
8959 | - method = '10' | ||
8960 | - } | 8978 | + // if (type === 'short' || type === 'unshort') { |
8979 | + // method = '06' | ||
8980 | + // } else if (type === 'bit') { | ||
8981 | + // method = '05' | ||
8982 | + // } else { | ||
8983 | + // method = '10' | ||
8984 | + // } | ||
8961 | 8985 | ||
8962 | form.val(componentFilter, { | 8986 | form.val(componentFilter, { |
8963 | - [enumDataSourceConst.METHOD]: method, | 8987 | + [enumDataSourceConst.METHOD]: selected?.extensionDesc?.actionType, |
8964 | [enumDataSourceConst.REGISTER_ADDRESS]: selected?.extensionDesc?.registerAddress, | 8988 | [enumDataSourceConst.REGISTER_ADDRESS]: selected?.extensionDesc?.registerAddress, |
8965 | [enumDataSourceConst.DATA_TYPE]: selected?.extensionDesc?.dataType, | 8989 | [enumDataSourceConst.DATA_TYPE]: selected?.extensionDesc?.dataType, |
8990 | + [enumDataSourceConst.ACTION_TYPE]: selected?.extensionDesc?.actionType, | ||
8966 | }) | 8991 | }) |
8967 | } | 8992 | } |
8968 | }) | 8993 | }) |
@@ -8974,7 +8999,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8974,7 +8999,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8974 | * @param {{orgId: string, deviceId: string, slaveDeviceId?: string, attr: string}} dataSource | 8999 | * @param {{orgId: string, deviceId: string, slaveDeviceId?: string, attr: string}} dataSource |
8975 | */ | 9000 | */ |
8976 | function echoDataSource(dataSource = {}) { | 9001 | function echoDataSource(dataSource = {}) { |
8977 | - const { orgId, deviceId, deviceProfileId, deviceType, attr, method, deviceCode, registerAddress, dataType } = dataSource | 9002 | + const { orgId, deviceId, deviceProfileId, deviceType, attr, method, deviceCode, registerAddress, dataType, actionType } = dataSource |
8978 | const queue = [] | 9003 | const queue = [] |
8979 | currentDataSource = { organizationId: orgId, deviceProfileId, deviceType } | 9004 | currentDataSource = { organizationId: orgId, deviceProfileId, deviceType } |
8980 | queue.push(getProduct(deviceType)) | 9005 | queue.push(getProduct(deviceType)) |
@@ -8995,7 +9020,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -8995,7 +9020,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
8995 | method, | 9020 | method, |
8996 | deviceCode, | 9021 | deviceCode, |
8997 | registerAddress, | 9022 | registerAddress, |
8998 | - dataType | 9023 | + dataType, |
9024 | + actionType | ||
8999 | }) | 9025 | }) |
9000 | 9026 | ||
9001 | }) | 9027 | }) |
@@ -13227,6 +13253,176 @@ class UseLayUi { | @@ -13227,6 +13253,176 @@ class UseLayUi { | ||
13227 | constructor() { | 13253 | constructor() { |
13228 | } | 13254 | } |
13229 | 13255 | ||
13256 | + static numberToHex(value) { | ||
13257 | + function InsertString(t, c, n) { | ||
13258 | + var r = new Array(); | ||
13259 | + | ||
13260 | + for (var i = 0; | ||
13261 | + i * 2 < t.length; | ||
13262 | + i++) { | ||
13263 | + r.push(t.substr(i * 2, n)); | ||
13264 | + | ||
13265 | + } | ||
13266 | + return r.join(c); | ||
13267 | + | ||
13268 | + } | ||
13269 | + function FillString(t, c, n, b) { | ||
13270 | + if ((t == "") || (c.length != 1) || (n <= t.length)) { | ||
13271 | + return t; | ||
13272 | + | ||
13273 | + } | ||
13274 | + var l = t.length; | ||
13275 | + | ||
13276 | + for (var i = 0; | ||
13277 | + i < n - l; | ||
13278 | + i++) { | ||
13279 | + if (b == true) { | ||
13280 | + t = c + t; | ||
13281 | + | ||
13282 | + } else { | ||
13283 | + t += c; | ||
13284 | + | ||
13285 | + } | ||
13286 | + } | ||
13287 | + return t; | ||
13288 | + | ||
13289 | + } | ||
13290 | + function SingleToHex(t) { | ||
13291 | + if (t == "") { | ||
13292 | + return ""; | ||
13293 | + | ||
13294 | + } | ||
13295 | + t = parseFloat(t); | ||
13296 | + | ||
13297 | + if (isNaN(t) == true) { | ||
13298 | + return "Error"; | ||
13299 | + | ||
13300 | + } | ||
13301 | + if (t == 0) { | ||
13302 | + return "00000000"; | ||
13303 | + | ||
13304 | + } | ||
13305 | + var s, | ||
13306 | + e, | ||
13307 | + m; | ||
13308 | + | ||
13309 | + if (t > 0) { | ||
13310 | + s = 0; | ||
13311 | + | ||
13312 | + } else { | ||
13313 | + s = 1; | ||
13314 | + | ||
13315 | + t = 0 - t; | ||
13316 | + | ||
13317 | + } | ||
13318 | + m = t.toString(2); | ||
13319 | + | ||
13320 | + if (m >= 1) { | ||
13321 | + if (m.indexOf(".") == -1) { | ||
13322 | + m = m + ".0"; | ||
13323 | + | ||
13324 | + } | ||
13325 | + e = m.indexOf(".") - 1; | ||
13326 | + | ||
13327 | + } else { | ||
13328 | + e = 1 - m.indexOf("1"); | ||
13329 | + | ||
13330 | + } | ||
13331 | + if (e >= 0) { | ||
13332 | + m = m.replace(".", ""); | ||
13333 | + | ||
13334 | + } else { | ||
13335 | + m = m.substring(m.indexOf("1")); | ||
13336 | + | ||
13337 | + } | ||
13338 | + if (m.length > 24) { | ||
13339 | + m = m.substr(0, 24); | ||
13340 | + | ||
13341 | + } else { | ||
13342 | + m = FillString(m, "0", 24, false) | ||
13343 | + } | ||
13344 | + m = m.substring(1); | ||
13345 | + | ||
13346 | + e = (e + 127).toString(2); | ||
13347 | + | ||
13348 | + e = FillString(e, "0", 8, true); | ||
13349 | + | ||
13350 | + var r = parseInt(s + e + m, 2).toString(16); | ||
13351 | + | ||
13352 | + r = FillString(r, "0", 8, true); | ||
13353 | + | ||
13354 | + return InsertString(r, " ", 2).toUpperCase(); | ||
13355 | + | ||
13356 | + } | ||
13357 | + function FormatHex(t, n, ie) { | ||
13358 | + var r = new Array(); | ||
13359 | + | ||
13360 | + var s = ""; | ||
13361 | + | ||
13362 | + var c = 0; | ||
13363 | + | ||
13364 | + for (var i = 0; | ||
13365 | + i < t.length; | ||
13366 | + i++) { | ||
13367 | + if (t.charAt(i) != " ") { | ||
13368 | + s += t.charAt(i); | ||
13369 | + | ||
13370 | + c += 1; | ||
13371 | + | ||
13372 | + if (c == n) { | ||
13373 | + r.push(s); | ||
13374 | + | ||
13375 | + s = ""; | ||
13376 | + | ||
13377 | + c = 0; | ||
13378 | + | ||
13379 | + } | ||
13380 | + } | ||
13381 | + if (ie == false) { | ||
13382 | + if ((i == t.length - 1) && (s != "")) { | ||
13383 | + r.push(s); | ||
13384 | + | ||
13385 | + } | ||
13386 | + } | ||
13387 | + } | ||
13388 | + return r.join("\n"); | ||
13389 | + | ||
13390 | + } | ||
13391 | + function FormatHexBatch(t, n, ie) { | ||
13392 | + var a = t.split("\n"); | ||
13393 | + | ||
13394 | + var r = new Array(); | ||
13395 | + | ||
13396 | + for (var i = 0; | ||
13397 | + i < a.length; | ||
13398 | + i++) { | ||
13399 | + r[i] = FormatHex(a[i], n, ie); | ||
13400 | + | ||
13401 | + } | ||
13402 | + return r.join("\n"); | ||
13403 | + | ||
13404 | + } | ||
13405 | + function SingleToHexBatch(t) { | ||
13406 | + var a = t.split("\n"); | ||
13407 | + | ||
13408 | + var r = new Array(); | ||
13409 | + | ||
13410 | + for (var i = 0; | ||
13411 | + i < a.length; | ||
13412 | + i++) { | ||
13413 | + r[i] = SingleToHex(a[i]); | ||
13414 | + | ||
13415 | + } | ||
13416 | + return r.join("\r\n"); | ||
13417 | + | ||
13418 | + } | ||
13419 | + return SingleToHex(value) | ||
13420 | + } | ||
13421 | + | ||
13422 | + static isNullOrUnDef = value => { | ||
13423 | + return value === null || value === undefined | ||
13424 | + } | ||
13425 | + | ||
13230 | static isFunction = fn => { | 13426 | static isFunction = fn => { |
13231 | const result = Object.prototype.toString.call(fn) | 13427 | const result = Object.prototype.toString.call(fn) |
13232 | return result === '[object Function]' || result === '[object AsyncFunction]' | 13428 | return result === '[object Function]' || result === '[object AsyncFunction]' |
@@ -14674,16 +14870,34 @@ class DispatchCenter { | @@ -14674,16 +14870,34 @@ class DispatchCenter { | ||
14674 | 14870 | ||
14675 | const setSubscribeMapping = (cmdId, record) => this.subscribeIdMapping.set(cmdId, record) | 14871 | const setSubscribeMapping = (cmdId, record) => this.subscribeIdMapping.set(cmdId, record) |
14676 | 14872 | ||
14873 | + const componentType = Sidebar.prototype.enumComponentType | ||
14874 | + | ||
14875 | + const attributeFieldEnum = Sidebar.prototype.enumCellBasicAttribute | ||
14876 | + | ||
14677 | this.deviceIdMapping.forEach((value, key) => { | 14877 | this.deviceIdMapping.forEach((value, key) => { |
14678 | - const basicRecord = value.filter(item => !item.additional) | ||
14679 | - const moreFilterRecord = value.filter(item => item.additional) | ||
14680 | 14878 | ||
14681 | - const message = basicRecord.length ? generateMessage({ entityId: key, cmdId, keys: getKeys(basicRecord.map(item => item.attr)) }) : null | ||
14682 | - basicRecord.length && setSubscribeMapping(cmdId, basicRecord) | 14879 | + const chartRecord = [] |
14880 | + const otherRecord = [] | ||
14881 | + for (const item of value) { | ||
14882 | + const id = item.nodeId | ||
14883 | + const cell = this.graph.model.getCell(id) | ||
14884 | + if (cell) { | ||
14885 | + const type = cell.getAttribute(attributeFieldEnum.COMPONENT_TYPE) | ||
14886 | + if ([componentType.LINE_CHART, componentType.BAR_CHART, componentType.DASHBOARD_CHART].includes(type)) { | ||
14887 | + chartRecord.push(item) | ||
14888 | + continue | ||
14889 | + } | ||
14890 | + } | ||
14891 | + | ||
14892 | + otherRecord.push(item) | ||
14893 | + } | ||
14894 | + | ||
14895 | + const message = otherRecord.length ? generateMessage({ entityId: key, cmdId, keys: getKeys(otherRecord.map(item => item.attr)) }) : null | ||
14896 | + otherRecord.length && setSubscribeMapping(cmdId, otherRecord) | ||
14683 | cmdId++ | 14897 | cmdId++ |
14684 | 14898 | ||
14685 | // 图表控件订阅 | 14899 | // 图表控件订阅 |
14686 | - moreFilterRecord.forEach(item => { | 14900 | + chartRecord.forEach(item => { |
14687 | const { additional = {} } = item | 14901 | const { additional = {} } = item |
14688 | const { dataType = 'tsSubCmds', interval, effectScope, agg } = additional | 14902 | const { dataType = 'tsSubCmds', interval, effectScope, agg } = additional |
14689 | const message = generateMessage({ | 14903 | const message = generateMessage({ |
@@ -14706,7 +14920,8 @@ class DispatchCenter { | @@ -14706,7 +14920,8 @@ class DispatchCenter { | ||
14706 | return messageList | 14920 | return messageList |
14707 | } | 14921 | } |
14708 | 14922 | ||
14709 | - return generateGroupMessage() | 14923 | + const returnMessage = generateGroupMessage() |
14924 | + return returnMessage | ||
14710 | } | 14925 | } |
14711 | 14926 | ||
14712 | /** | 14927 | /** |
@@ -14729,49 +14944,12 @@ class DispatchCenter { | @@ -14729,49 +14944,12 @@ class DispatchCenter { | ||
14729 | } | 14944 | } |
14730 | 14945 | ||
14731 | /** | 14946 | /** |
14732 | - * @description 生成节点映射表 | ||
14733 | - * @param dataSources | ||
14734 | - * @return {{cmdId: number, entityType: string, keys: string, scope: string, entityId: string}[]} | ||
14735 | - */ | ||
14736 | - generatorDataSourceMapping(dataSources = []) { | ||
14737 | - return dataSources.map((datum) => { | ||
14738 | - const { deviceId, attr, nodeId, slaveDeviceId } = datum | ||
14739 | - const cmdId = this.getCmdId(nodeId) | ||
14740 | - const sendMsgTemplate = { | ||
14741 | - entityType: "DEVICE", | ||
14742 | - entityId: slaveDeviceId ? slaveDeviceId : deviceId, | ||
14743 | - scope: "LATEST_TELEMETRY", | ||
14744 | - cmdId, | ||
14745 | - keys: attr, | ||
14746 | - } | ||
14747 | - this.subscribeDataSources(datum, cmdId, attr) | ||
14748 | - return sendMsgTemplate | ||
14749 | - }) | ||
14750 | - } | ||
14751 | - | ||
14752 | - /** | ||
14753 | * @description 分发事件 | 14947 | * @description 分发事件 |
14754 | */ | 14948 | */ |
14755 | publishEvent(eventName, data, message, event, ws) { | 14949 | publishEvent(eventName, data, message, event, ws) { |
14756 | this.eventBus.emit(eventName, message, event, ws) | 14950 | this.eventBus.emit(eventName, message, event, ws) |
14757 | } | 14951 | } |
14758 | 14952 | ||
14759 | - /** | ||
14760 | - * @description 订阅数据源 | ||
14761 | - * @param datum | ||
14762 | - * @param eventName | ||
14763 | - * @param key | ||
14764 | - */ | ||
14765 | - subscribeDataSources(datum, eventName, key) { | ||
14766 | - const node = this.contentAllCell.find(item => item.id === datum.nodeId) | ||
14767 | - this.eventBus.on(eventName, (message) => { | ||
14768 | - node && this.updatePage(() => { | ||
14769 | - const { data } = message | ||
14770 | - const [[timespan, value]] = data[key] | ||
14771 | - node.setValue(value) | ||
14772 | - }, node) | ||
14773 | - }) | ||
14774 | - } | ||
14775 | 14953 | ||
14776 | /** | 14954 | /** |
14777 | * @description 更新页面 | 14955 | * @description 更新页面 |
@@ -15177,39 +15355,7 @@ class HandleDataSource { | @@ -15177,39 +15355,7 @@ class HandleDataSource { | ||
15177 | 15355 | ||
15178 | const chartOption = this.getChartComponentOption(chartInstanceType, { dataList: historyDataList, attr, chartType: chartInstanceType, action, additional }) | 15356 | const chartOption = this.getChartComponentOption(chartInstanceType, { dataList: historyDataList, attr, chartType: chartInstanceType, action, additional }) |
15179 | 15357 | ||
15180 | - let interval | ||
15181 | - // TODO 清除定时器 | ||
15182 | - function autoMove() { | ||
15183 | - if (seriesValue.length <= 5) return | ||
15184 | - interval = setInterval(() => { | ||
15185 | - if (Number(chartOption.dataZoom[0].endValue) === seriesValue.length - 1) { | ||
15186 | - chartOption.dataZoom[0].endValue = showNumberOf | ||
15187 | - chartOption.dataZoom[0].startValue = 0 | ||
15188 | - } else { | ||
15189 | - chartOption.dataZoom[0].endValue = chartOption.dataZoom[0].endValue + 1 | ||
15190 | - chartOption.dataZoom[0].startValue = chartOption.dataZoom[0].startValue + 1 | ||
15191 | - } | ||
15192 | - if (!chartInstanceMap.has(chartInstanceId)) { | ||
15193 | - clearInterval(interval) | ||
15194 | - return | ||
15195 | - } | ||
15196 | - instance && instance.setOption(chartOption) | ||
15197 | - | ||
15198 | - }, 2000); | ||
15199 | - } | ||
15200 | - | ||
15201 | - function stop() { | ||
15202 | - clearInterval(interval) | ||
15203 | - } | ||
15204 | - | ||
15205 | - function goMove() { | ||
15206 | - autoMove() | ||
15207 | - } | ||
15208 | - | ||
15209 | instance.setOption(chartOption) | 15358 | instance.setOption(chartOption) |
15210 | - // instance.on('mouseover', stop) | ||
15211 | - // instance.on('mouseout', goMove) | ||
15212 | - // autoMove() | ||
15213 | } | 15359 | } |
15214 | 15360 | ||
15215 | getChartComponentOption(chartInstanceType, params) { | 15361 | getChartComponentOption(chartInstanceType, params) { |
@@ -15320,18 +15466,20 @@ class HandleDataSource { | @@ -15320,18 +15466,20 @@ class HandleDataSource { | ||
15320 | getRealTimeUpdateBasicChartOption(params = { oldOptions: {}, dataList: [], additional: {} }) { | 15466 | getRealTimeUpdateBasicChartOption(params = { oldOptions: {}, dataList: [], additional: {} }) { |
15321 | const { oldOptions, dataList, additional = {} } = params | 15467 | const { oldOptions, dataList, additional = {} } = params |
15322 | const { slaveDeviceName, deviceName, attrName } = additional | 15468 | const { slaveDeviceName, deviceName, attrName } = additional |
15323 | - const xAxisData = oldOptions.xAxis[0].data || [] | ||
15324 | - const seriesValue = oldOptions.series[0].data || [] | ||
15325 | - const oldEndValue = Number(oldOptions.dataZoom[0].endValue) || 0 | ||
15326 | - const oldStartValue = Number(oldOptions.dataZoom[0].startValue) || 0 | 15469 | + let xAxisData = oldOptions.xAxis[0].data || [] |
15470 | + let seriesValue = oldOptions.series[0].data || [] | ||
15327 | const showNumberOf = 4 | 15471 | const showNumberOf = 4 |
15472 | + const maxDataLength = 15 | ||
15328 | 15473 | ||
15329 | for (let i = dataList.length - 1; i >= 0; i--) { | 15474 | for (let i = dataList.length - 1; i >= 0; i--) { |
15330 | const [timespan, value] = dataList[i] | 15475 | const [timespan, value] = dataList[i] |
15331 | xAxisData.push(new Date(Number(timespan)).toLocaleTimeString()) | 15476 | xAxisData.push(new Date(Number(timespan)).toLocaleTimeString()) |
15332 | seriesValue.push(Number(value)) | 15477 | seriesValue.push(Number(value)) |
15333 | - xAxisData = xAxisData.slice(0, 30) | ||
15334 | - seriesValue = seriesValue.slice(0, 30) | 15478 | + } |
15479 | + | ||
15480 | + if (xAxisData?.length > maxDataLength) { | ||
15481 | + xAxisData = xAxisData.slice(xAxisData.length - maxDataLength, xAxisData.length) | ||
15482 | + seriesValue = seriesValue.slice(seriesValue.length - maxDataLength, seriesValue.length) | ||
15335 | } | 15483 | } |
15336 | 15484 | ||
15337 | if (Number(oldOptions.dataZoom[0].endValue) === seriesValue.length - 1) { | 15485 | if (Number(oldOptions.dataZoom[0].endValue) === seriesValue.length - 1) { |
@@ -15619,7 +15767,6 @@ class HandleDataInteraction { | @@ -15619,7 +15767,6 @@ class HandleDataInteraction { | ||
15619 | } | 15767 | } |
15620 | 15768 | ||
15621 | get contentAllCell() { | 15769 | get contentAllCell() { |
15622 | - // return this.graph.getDefaultParent().children || [] | ||
15623 | return Object.entries(this.graph?.getModel()?.cells || {}).map(([_, item]) => item) || [] | 15770 | return Object.entries(this.graph?.getModel()?.cells || {}).map(([_, item]) => item) || [] |
15624 | } | 15771 | } |
15625 | 15772 | ||
@@ -15918,7 +16065,7 @@ class HandleDataInteraction { | @@ -15918,7 +16065,7 @@ class HandleDataInteraction { | ||
15918 | <div class="layui-form-item"> | 16065 | <div class="layui-form-item"> |
15919 | <label class="layui-form-label" style="width: 120px;">自定义下发值</label> | 16066 | <label class="layui-form-label" style="width: 120px;">自定义下发值</label> |
15920 | <div class="layui-input-block" style="margin-left: 150px;"> | 16067 | <div class="layui-input-block" style="margin-left: 150px;"> |
15921 | - <input type="text" name="${enumActionEl.SERVICE_TCP_COMMAND}" lay-verify="required" autocomplete="off" disabled placeholder="请输入下发值" class="layui-input"> | 16068 | + <input type="text" name="${enumActionEl.SERVICE_TCP_COMMAND}" lay-verify="required" autocomplete="off" placeholder="请输入下发值" class="layui-input"> |
15922 | </div> | 16069 | </div> |
15923 | </div> | 16070 | </div> |
15924 | </div> | 16071 | </div> |
@@ -15933,22 +16080,23 @@ class HandleDataInteraction { | @@ -15933,22 +16080,23 @@ class HandleDataInteraction { | ||
15933 | 16080 | ||
15934 | function createContent() { | 16081 | function createContent() { |
15935 | const { commandType, tcpCommand, jsonCommand, serviceCommand, serviceOriginalConfiguration, transportType } = content | 16082 | const { commandType, tcpCommand, jsonCommand, serviceCommand, serviceOriginalConfiguration, transportType } = content |
15936 | - const isCustom = commandType === '0' | ||
15937 | const isTCP = transportType === 'TCP' | 16083 | const isTCP = transportType === 'TCP' |
15938 | 16084 | ||
15939 | let template | 16085 | let template |
15940 | - if (isCustom) { | 16086 | + if (commandType == '0') { |
15941 | if (isTCP) { | 16087 | if (isTCP) { |
15942 | template = createCustomTCPParams() | 16088 | template = createCustomTCPParams() |
15943 | } else { | 16089 | } else { |
15944 | template = createCustomJSONParams() | 16090 | template = createCustomJSONParams() |
15945 | } | 16091 | } |
15946 | - } else { | 16092 | + } else if (commandType == '1') { |
15947 | if (isTCP) { | 16093 | if (isTCP) { |
15948 | template = createServiceTCPParams() | 16094 | template = createServiceTCPParams() |
15949 | } else { | 16095 | } else { |
15950 | template = createServiceInputDataParams() | 16096 | template = createServiceInputDataParams() |
15951 | } | 16097 | } |
16098 | + } else { | ||
16099 | + template = createCustomTCPParams() | ||
15952 | } | 16100 | } |
15953 | return `<form class="layui-form" lay-filter="${enumActionEl.FORM_FILTER}">${template}</form>` | 16101 | return `<form class="layui-form" lay-filter="${enumActionEl.FORM_FILTER}">${template}</form>` |
15954 | } | 16102 | } |
@@ -16056,50 +16204,65 @@ class HandleDataInteraction { | @@ -16056,50 +16204,65 @@ class HandleDataInteraction { | ||
16056 | const { attr, additional } = dataSource | 16204 | const { attr, additional } = dataSource |
16057 | let flag = false | 16205 | let flag = false |
16058 | let value | 16206 | let value |
16059 | - | ||
16060 | - const isCustom = commandType === '0' | ||
16061 | const isTCP = transportType === 'TCP' | 16207 | const isTCP = transportType === 'TCP' |
16062 | 16208 | ||
16063 | - let template | ||
16064 | - if (isCustom) { | 16209 | + const enumCommandType = { |
16210 | + CUSTOM: '0', | ||
16211 | + SERVICE: '1', | ||
16212 | + MODBUS: '2', | ||
16213 | + } | ||
16214 | + | ||
16215 | + if (commandType == enumCommandType.MODBUS) { | ||
16216 | + value = data[enumActionEl.CUSTOM_TCP_COMMAND] | ||
16217 | + const { method } = additional | ||
16218 | + const validate = new Validate([ | ||
16219 | + { value, required: true, message: '下发值是必填项' }, | ||
16220 | + ...(method == '05' ? [{ value, message: '下发类型必须为0或1', validator(value) { return value == 0 || value == 1 } }] : []), | ||
16221 | + ...(method == '06' ? [{ value, message: '下发类型必须为整型', validator(value) { return !isNaN(value) && Number(value) % 1 === 0 } }, { value, message: '最大值不能超过65535', validator(value) { return Number(value) <= parseInt('ffff', 16) } }] : []), | ||
16222 | + ...(method == '16' ? [{ value, message: '下发类型精确到两位小数', validator(value) { return /^\d+(\.\d{0,2})?$/.test(value) } }] : []) | ||
16223 | + ]) | ||
16224 | + | ||
16225 | + if (method == '16') { | ||
16226 | + const hexValue = UseLayUi.numberToHex(value).split(' ').slice(0, 2).join('') | ||
16227 | + value = [parseInt(hexValue, 16), 0] | ||
16228 | + } | ||
16229 | + | ||
16230 | + if (validate.begin()) flag = true | ||
16231 | + } else if (commandType == enumCommandType.SERVICE) { | ||
16065 | if (isTCP) { | 16232 | if (isTCP) { |
16066 | - value = data[enumActionEl.CUSTOM_TCP_COMMAND] | ||
16067 | - const { dataType } = additional | 16233 | + value = content.serviceCommand |
16068 | const validate = new Validate([ | 16234 | const validate = new Validate([ |
16069 | { value, required: true, message: '下发值是必填项' }, | 16235 | { value, required: true, message: '下发值是必填项' }, |
16070 | - ...(dataType === 'bit' ? [{ value, message: '下发类型必须为0或1', validator(value) { return value == 0 || value == 1 } }] : []), | ||
16071 | - ...(dataType === 'short' || dataType === 'unshort' ? [{ value, message: '下发类型必须为整型', validator(value) { return value % 1 === 0 } }, { value, message: '最大值不能超过65535', validator(value) { return Number(value) <= parseInt('ffff', 16) } }] : []) | ||
16072 | ]) | 16236 | ]) |
16073 | if (validate.begin()) flag = true | 16237 | if (validate.begin()) flag = true |
16074 | } else { | 16238 | } else { |
16075 | - value = data[enumActionEl.CUSTOM_JSON_COMMAND] | ||
16076 | - const validate = new Validate([ | ||
16077 | - { value, required: true, message: '下发值是必填项' }, | ||
16078 | - { value, message: 'json格式校验不正确', validator: isJson }, | ||
16079 | - ]) | ||
16080 | - if (validate.begin()) { | ||
16081 | - const replaceValue = currentNode.getAttribute(SWITCH_SEND_VALUE) | 16239 | + value = data |
16240 | + const { flag: validateFlag, value: validateValue } = UseLayUi.validateThingsModelInputDataForm(Utils.stringToJSON(content.serviceOriginalConfiguration), value, true) | ||
16241 | + if (validateFlag) { | ||
16082 | flag = true | 16242 | flag = true |
16083 | - value = jsonParse(value) | ||
16084 | - value = replaceAttrPlaceholder(value, attr) | 16243 | + value = validateValue |
16085 | } | 16244 | } |
16086 | - template = createCustomJSONParams() | ||
16087 | } | 16245 | } |
16088 | } else { | 16246 | } else { |
16089 | if (isTCP) { | 16247 | if (isTCP) { |
16090 | - value = content.serviceCommand | 16248 | + value = data[enumActionEl.CUSTOM_TCP_COMMAND] |
16091 | const validate = new Validate([ | 16249 | const validate = new Validate([ |
16092 | { value, required: true, message: '下发值是必填项' }, | 16250 | { value, required: true, message: '下发值是必填项' }, |
16093 | ]) | 16251 | ]) |
16094 | if (validate.begin()) flag = true | 16252 | if (validate.begin()) flag = true |
16095 | } else { | 16253 | } else { |
16096 | - value = data | ||
16097 | - const { flag: validateFlag, value: validateValue } = UseLayUi.validateThingsModelInputDataForm(Utils.stringToJSON(content.serviceOriginalConfiguration), value, true) | ||
16098 | - if (validateFlag) { | 16254 | + value = data[enumActionEl.CUSTOM_JSON_COMMAND] |
16255 | + const validate = new Validate([ | ||
16256 | + { value, required: true, message: '下发值是必填项' }, | ||
16257 | + { value, message: 'json格式校验不正确', validator: isJson }, | ||
16258 | + ]) | ||
16259 | + if (validate.begin()) { | ||
16099 | flag = true | 16260 | flag = true |
16100 | - value = validateValue | 16261 | + value = jsonParse(value) |
16262 | + value = replaceAttrPlaceholder(value, attr) | ||
16101 | } | 16263 | } |
16102 | } | 16264 | } |
16265 | + | ||
16103 | } | 16266 | } |
16104 | 16267 | ||
16105 | return { flag, value } | 16268 | return { flag, value } |
@@ -16117,13 +16280,18 @@ class HandleDataInteraction { | @@ -16117,13 +16280,18 @@ class HandleDataInteraction { | ||
16117 | const { additional } = dataSource || {} | 16280 | const { additional } = dataSource || {} |
16118 | const { method, deviceCode, registerAddress } = additional || {} | 16281 | const { method, deviceCode, registerAddress } = additional || {} |
16119 | 16282 | ||
16283 | + if (Number(deviceCode) > parseInt('ff', 16) || Number(deviceCode) <= 1) { | ||
16284 | + UseLayUi.topErrorMsg('设备地址码范围不在1~255之间') | ||
16285 | + return | ||
16286 | + } | ||
16287 | + | ||
16120 | const params = { | 16288 | const params = { |
16121 | crc: 'CRC_16_LOWER', | 16289 | crc: 'CRC_16_LOWER', |
16122 | - deviceCode, | ||
16123 | - method, | 16290 | + deviceCode: Number(deviceCode).toString(16).padStart(2, 0).toUpperCase(), |
16291 | + method: Number(method).toString(16).padStart(2, 0), | ||
16124 | registerAddr: Number(registerAddress), | 16292 | registerAddr: Number(registerAddress), |
16125 | - registerNumber: 1, | ||
16126 | - registerValues: [Number(registerValue)] | 16293 | + registerNumber: Array.isArray(registerValue) ? 2 : 1, |
16294 | + registerValues: Array.isArray(registerValue) ? registerValue.map(item => Number(item)) : [Number(registerValue)] | ||
16127 | } | 16295 | } |
16128 | 16296 | ||
16129 | const command = await ConfigurationNodeApi.getModbusCommand(params) | 16297 | const command = await ConfigurationNodeApi.getModbusCommand(params) |
@@ -16139,15 +16307,29 @@ class HandleDataInteraction { | @@ -16139,15 +16307,29 @@ class HandleDataInteraction { | ||
16139 | */ | 16307 | */ |
16140 | let { command, way, service, callType } = content | 16308 | let { command, way, service, callType } = content |
16141 | const identifier = content?.identifier | 16309 | const identifier = content?.identifier |
16142 | - const params = content?.transportType === 'TCP' | ||
16143 | - ? await getTCPCommand(value, dataSource) | ||
16144 | - : identifier | 16310 | + |
16311 | + let params | ||
16312 | + | ||
16313 | + if (content?.commandType == '0') { | ||
16314 | + params = value | ||
16315 | + } | ||
16316 | + | ||
16317 | + if (content?.commandType == '1') { | ||
16318 | + params = identifier | ||
16145 | ? { [identifier]: value } | 16319 | ? { [identifier]: value } |
16146 | : value | 16320 | : value |
16321 | + } | ||
16322 | + | ||
16323 | + if (content?.commandType == '2') { | ||
16324 | + params = await getTCPCommand(value, dataSource) | ||
16325 | + } | ||
16326 | + | ||
16327 | + if (!params) return | ||
16147 | 16328 | ||
16148 | if (service) { | 16329 | if (service) { |
16149 | way = callType === 'ASYNC' ? 'oneway' : 'twoway' | 16330 | way = callType === 'ASYNC' ? 'oneway' : 'twoway' |
16150 | } | 16331 | } |
16332 | + | ||
16151 | const instructionData = { | 16333 | const instructionData = { |
16152 | method: "methodThingskit", | 16334 | method: "methodThingskit", |
16153 | additionalInfo: { cmdType: service ? '1' : 'API' }, | 16335 | additionalInfo: { cmdType: service ? '1' : 'API' }, |
@@ -16364,7 +16546,6 @@ class HandleDynamicEffect { | @@ -16364,7 +16546,6 @@ class HandleDynamicEffect { | ||
16364 | } | 16546 | } |
16365 | 16547 | ||
16366 | get contentAllCell() { | 16548 | get contentAllCell() { |
16367 | - // return this.graph.getDefaultParent().children || [] | ||
16368 | return Object.entries(this.graph?.getModel()?.cells || {}).map(([_, item]) => item) || [] | 16549 | return Object.entries(this.graph?.getModel()?.cells || {}).map(([_, item]) => item) || [] |
16369 | } | 16550 | } |
16370 | 16551 | ||
@@ -16399,14 +16580,7 @@ class HandleDynamicEffect { | @@ -16399,14 +16580,7 @@ class HandleDynamicEffect { | ||
16399 | if (!this.actNodeMapping.has(id)) this.actNodeMapping.set(id, { display: true, value: new Map() }) | 16580 | if (!this.actNodeMapping.has(id)) this.actNodeMapping.set(id, { display: true, value: new Map() }) |
16400 | const temp = this.actNodeMapping.get(id) | 16581 | const temp = this.actNodeMapping.get(id) |
16401 | temp.value.set(type, each) | 16582 | temp.value.set(type, each) |
16402 | - | ||
16403 | - // const cmdId = this.DispatchInstance.getCmdId(id) | ||
16404 | - | ||
16405 | - // tsSubCmds.push(this.generatorMessage(slaveDeviceId ? slaveDeviceId : deviceId, cmdId, attr)) | ||
16406 | - | ||
16407 | - // this.subscribeEvent(cmdId, this.dispatch(type)) | ||
16408 | }) | 16583 | }) |
16409 | - // if (tsSubCmds.length) this.sendMsg({ tsSubCmds }) | ||
16410 | } | 16584 | } |
16411 | 16585 | ||
16412 | /** | 16586 | /** |