...
|
...
|
@@ -5075,7 +5075,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
5075
|
5075
|
|
5076
|
5076
|
/**
|
5077
|
5077
|
* @description 用于在其他位置获取数据源绑定的数据,在生成数据源面板中进行了改写
|
5078
|
|
- * @return {{orgId: string, attr: string, deviceId: string, deviceType: string, deviceProfileId: string}}
|
|
5078
|
+ * @return {{orgId: string, attr: string, deviceId: string, deviceType: string, deviceProfileId: string, deviceCode: string, registerAddress: string, method: string, dataType: string}}
|
5079
|
5079
|
*/
|
5080
|
5080
|
function getDataSourceBindValue() {
|
5081
|
5081
|
|
...
|
...
|
@@ -5248,7 +5248,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
5248
|
5248
|
echoRefreshFn = function () {
|
5249
|
5249
|
refreshFn.apply(this)
|
5250
|
5250
|
const { dataSources: [dataSource] = [] } = currentNodeData || {}
|
5251
|
|
- echoDataSource(dataSource)
|
|
5251
|
+ echoDataSource({ ...dataSource, ...(dataSource?.additional || {}) })
|
5252
|
5252
|
form.render(null, CONTAINER_FILTER)
|
5253
|
5253
|
}
|
5254
|
5254
|
|
...
|
...
|
@@ -6586,7 +6586,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
6586
|
6586
|
function getSwitchSubmitValue(field) {
|
6587
|
6587
|
const dataSources = getDataSourceBindValue()
|
6588
|
6588
|
const enableStatus = getEnableStatus(field)
|
6589
|
|
- return { configurationId, contentId: currentPageId.id, nodeId: graphId, dataSources, ...enableStatus }
|
|
6589
|
+ return { configurationId, contentId: currentPageId.id, nodeId: graphId, dataSources: { ...dataSources, additional: { deviceCode: dataSources?.deviceCode, method: dataSources?.method, registerAddress: dataSources?.registerAddress, dataType: dataSources?.dataType } }, ...enableStatus }
|
6590
|
6590
|
}
|
6591
|
6591
|
|
6592
|
6592
|
|
...
|
...
|
@@ -7711,7 +7711,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7711
|
7711
|
|
7712
|
7712
|
$(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: 'none' })
|
7713
|
7713
|
$(`#${enumActionEl.SERVICE_EL}`).css({ display: 'none' })
|
7714
|
|
- $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: 'none' })
|
|
7714
|
+ // $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: 'none' })
|
7715
|
7715
|
$(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: 'none' })
|
7716
|
7716
|
} else if (value === enumActionType.PARAMS_SETTING) {
|
7717
|
7717
|
$(`#${enumActionEl.LINK_EL_ID}`).css({ display: 'none' })
|
...
|
...
|
@@ -7720,9 +7720,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7720
|
7720
|
$(`#${enumActionEl.COMMAND_TYPE_EL}`).css({ display: 'block' })
|
7721
|
7721
|
|
7722
|
7722
|
$(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: isCustom ? 'none' : 'block' })
|
7723
|
|
- $(`#${enumActionEl.WAY_SELECT}`).css({ display: isCustom ? 'block' : 'none' })
|
|
7723
|
+ $(`#${enumActionEl.WAY_SELECT}`).css({ display: !isTCP && isCustom ? 'block' : 'none' })
|
7724
|
7724
|
$(`#${enumActionEl.SERVICE_EL}`).css({ display: isCustom ? 'none' : 'block' })
|
7725
|
|
- $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCP && isCustom ? 'block' : 'none' })
|
|
7725
|
+ // $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCP && isCustom ? 'block' : 'none' })
|
7726
|
7726
|
$(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCP && isCustom ? 'flex' : 'none' })
|
7727
|
7727
|
}
|
7728
|
7728
|
}
|
...
|
...
|
@@ -7737,6 +7737,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7737
|
7737
|
const { COMPONENT_TYPE } = Sidebar.prototype.enumCellBasicAttribute
|
7738
|
7738
|
const { SWITCH } = Sidebar.prototype.enumComponentType
|
7739
|
7739
|
const isSwitchComponent = vertices[0].getAttribute(COMPONENT_TYPE) === SWITCH
|
|
7740
|
+ const isTCPTransportType = formVal[enumConst.TRANSPORTTYPE] === 'TCP'
|
7740
|
7741
|
|
7741
|
7742
|
if (isParamsSetting && isSwitchComponent && (!currentNodeData.act || !currentNodeData.act.find(item => item.type === enumDynamicEffectType.SWITCH))) {
|
7742
|
7743
|
UseLayUi.topErrorMsg('请先配置数据动效中的状态设置')
|
...
|
...
|
@@ -7744,17 +7745,24 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7744
|
7745
|
}
|
7745
|
7746
|
|
7746
|
7747
|
if (isParamsSetting) {
|
7747
|
|
- const isTCPTransportType = formVal[enumConst.TRANSPORTTYPE] === 'TCP'
|
7748
|
7748
|
const isCustom = formVal[enumConst.COMMAND_TYPE] === COMMAND_TYPE_ENUM.CUSTOM
|
7749
|
7749
|
let inputData = form.val(enumActionEl.INPUT_DATA_FORM_FILTER)
|
7750
|
7750
|
|
7751
|
7751
|
const validateParamsSetting = () => {
|
7752
|
7752
|
if (isCustom) {
|
7753
|
7753
|
if (isTCPTransportType) {
|
7754
|
|
- if (!formVal[enumConst.TCP_COMMAND]) {
|
7755
|
|
- UseLayUi.topErrorMsg('请输入自定义下发指令')
|
7756
|
|
- return false
|
|
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
|
+ }
|
7757
|
7761
|
}
|
|
7762
|
+ // if (!formVal[enumConst.TCP_COMMAND]) {
|
|
7763
|
+ // UseLayUi.topErrorMsg('请输入自定义下发指令')
|
|
7764
|
+ // return false
|
|
7765
|
+ // }
|
7758
|
7766
|
} else {
|
7759
|
7767
|
if (!isJson(formVal[enumConst.JSON_COMMAND])) {
|
7760
|
7768
|
UseLayUi.topErrorMsg('命令配置存在错误')
|
...
|
...
|
@@ -7796,7 +7804,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7796
|
7804
|
[enumConst.CALL_TYPE]: formVal[enumConst.CALL_TYPE],
|
7797
|
7805
|
[enumConst.IDENTIFIER]: formVal[enumConst.IDENTIFIER],
|
7798
|
7806
|
[enumConst.JSON_COMMAND]: formVal[enumConst.JSON_COMMAND],
|
7799
|
|
- [enumConst.WAY]: formVal[enumConst.WAY],
|
|
7807
|
+ [enumConst.WAY]: isTCPTransportType ? 'oneway' : formVal[enumConst.WAY],
|
7800
|
7808
|
[enumConst.COMMAND_TYPE]: formVal[enumConst.COMMAND_TYPE],
|
7801
|
7809
|
[enumConst.TCP_COMMAND]: formVal[enumConst.TCP_COMMAND],
|
7802
|
7810
|
[enumConst.TRANSPORTTYPE]: formVal[enumConst.TRANSPORTTYPE],
|
...
|
...
|
@@ -7866,8 +7874,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7866
|
7874
|
return
|
7867
|
7875
|
}
|
7868
|
7876
|
originType = value
|
7869
|
|
- const isCustom = form.val(enumActionEl.ACTION_SELECT_FILTER)[enumConst.COMMAND_TYPE] === COMMAND_TYPE_ENUM.CUSTOM
|
7870
|
|
- controlFormDisplay(value, transportType, isCustom)
|
|
7877
|
+ form.val(enumActionEl.FORM_FILTER, {
|
|
7878
|
+ [enumConst.COMMAND_TYPE]: COMMAND_TYPE_ENUM.CUSTOM
|
|
7879
|
+ })
|
|
7880
|
+ const isCustom = form.val(enumActionEl.FORM_FILTER)[enumConst.COMMAND_TYPE] === COMMAND_TYPE_ENUM.CUSTOM
|
|
7881
|
+
|
|
7882
|
+ controlFormDisplay(value, transportType === 'TCP', isCustom)
|
7871
|
7883
|
})
|
7872
|
7884
|
|
7873
|
7885
|
/**
|
...
|
...
|
@@ -7878,9 +7890,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
7878
|
7890
|
const flag = value === COMMAND_TYPE_ENUM.CUSTOM
|
7879
|
7891
|
const isTCPTransportType = transportType === 'TCP'
|
7880
|
7892
|
$(`#${enumActionEl.INPUT_DATA_FORM}`).css({ display: flag ? 'none' : 'block' })
|
7881
|
|
- $(`#${enumActionEl.WAY_SELECT}`).css({ display: flag ? 'block' : 'none' })
|
|
7893
|
+ $(`#${enumActionEl.WAY_SELECT}`).css({ display: !isTCPTransportType && flag ? 'block' : 'none' })
|
7882
|
7894
|
$(`#${enumActionEl.SERVICE_EL}`).css({ display: flag ? 'none' : 'block' })
|
7883
|
|
- $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: isTCPTransportType && flag ? 'block' : 'none' })
|
|
7895
|
+ // $(`#${enumActionEl.TCP_COMMAND_INPUT}`).css({ display: !isTCPTransportType && flag ? 'block' : 'none' })
|
7884
|
7896
|
$(`#${enumActionEl.EDITOR_CONTAINER}`).css({ display: !isTCPTransportType && flag ? 'flex' : 'none' })
|
7885
|
7897
|
form.val(enumActionEl.FORM_FILTER, { [enumConst.TCP_COMMAND]: '', [enumConst.SERVICE]: '', [enumConst.COMMAND]: '', [enumConst.IDENTIFIER]: '' })
|
7886
|
7898
|
$(`#${enumActionEl.INPUT_DATA_FORM}`).html('')
|
...
|
...
|
@@ -8057,12 +8069,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8057
|
8069
|
<div id="${enumActionEl.EDITOR}" style="width: 100%; height: 100%;border: 2px solid #eee;"></div>
|
8058
|
8070
|
<textarea name="${enumConst.JSON_COMMAND}" class="layui-textarea" style="display: none;" />
|
8059
|
8071
|
</div>
|
8060
|
|
- <div id="${enumActionEl.TCP_COMMAND_INPUT}" style="display: none;">
|
|
8072
|
+ <!-- <div id="${enumActionEl.TCP_COMMAND_INPUT}" style="display: none;">
|
8061
|
8073
|
<label class="layui-form-label" style="width: 120px;">命令 ${createHelpMessage('用户预览模式下,点击参数设置后。输入的变量值将作为"attrPlaceholder"的值,并以JSON格式下发给服务器。', 'command')}</label>
|
8062
|
8074
|
<div class="layui-input-block" style="margin-left: 150px;">
|
8063
|
8075
|
<input type="text" lay-verType="tips" name="${enumConst.TCP_COMMAND}" placeholder="请输入自定义下发命令" class="layui-input">
|
8064
|
8076
|
</div>
|
8065
|
|
- </div>
|
|
8077
|
+ </div> -->
|
8066
|
8078
|
<div style="display: none;">
|
8067
|
8079
|
<input type="text" lay-verType="tips" name="${enumConst.TRANSPORTTYPE}" placeholder="请输入自定义下发命令" class="layui-input">
|
8068
|
8080
|
</div>
|
...
|
...
|
@@ -8685,7 +8697,11 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8685
|
8697
|
GATEWAY: 'GATEWAY',
|
8686
|
8698
|
ORG_NAME: 'orgName',
|
8687
|
8699
|
DEVICE_NAME: 'deviceName',
|
8688
|
|
- ATTR_NAME: 'attrName'
|
|
8700
|
+ ATTR_NAME: 'attrName',
|
|
8701
|
+ METHOD: 'method',
|
|
8702
|
+ DEVICE_COED: 'deviceCode',
|
|
8703
|
+ REGISTER_ADDRESS: 'registerAddress',
|
|
8704
|
+ DATA_TYPE: 'dataType'
|
8689
|
8705
|
}
|
8690
|
8706
|
|
8691
|
8707
|
/**
|
...
|
...
|
@@ -8700,6 +8716,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8700
|
8716
|
*/
|
8701
|
8717
|
let currentDataSource = {}
|
8702
|
8718
|
|
|
8719
|
+ let thingsModel = []
|
|
8720
|
+
|
8703
|
8721
|
const component = document.createElement('div')
|
8704
|
8722
|
|
8705
|
8723
|
$(component)
|
...
|
...
|
@@ -8738,6 +8756,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8738
|
8756
|
[enumDataSourceConst.DEVICE_ID]: null,
|
8739
|
8757
|
[enumDataSourceConst.ATTR]: null,
|
8740
|
8758
|
[enumDataSourceConst.ATTR_NAME]: null,
|
|
8759
|
+ [enumDataSourceConst.DEVICE_COED]: null,
|
|
8760
|
+ [enumDataSourceConst.METHOD]: null,
|
|
8761
|
+ [enumDataSourceConst.REGISTER_ADDRESS]: null,
|
|
8762
|
+ [enumDataSourceConst.DATA_TYPE]: null,
|
8741
|
8763
|
})
|
8742
|
8764
|
|
8743
|
8765
|
currentDataSource[enumDataSourceConst.DEVICE_TYPE] = value
|
...
|
...
|
@@ -8762,6 +8784,11 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8762
|
8784
|
[enumDataSourceConst.DEVICE_ID]: null,
|
8763
|
8785
|
[enumDataSourceConst.ATTR]: null,
|
8764
|
8786
|
[enumDataSourceConst.ATTR_NAME]: null,
|
|
8787
|
+ [enumDataSourceConst.DEVICE_COED]: null,
|
|
8788
|
+ [enumDataSourceConst.METHOD]: null,
|
|
8789
|
+ [enumDataSourceConst.REGISTER_ADDRESS]: null,
|
|
8790
|
+ [enumDataSourceConst.DATA_TYPE]: null,
|
|
8791
|
+
|
8765
|
8792
|
})
|
8766
|
8793
|
currentDataSource[enumDataSourceConst.DEVICE_PROFILE_ID] = value
|
8767
|
8794
|
getMeetConditionsDevice(currentDataSource)
|
...
|
...
|
@@ -8782,6 +8809,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8782
|
8809
|
<div class="layui-form-item" style="margin-bottom: 0">
|
8783
|
8810
|
<input style="display: none" type="text" name="${enumDataSourceConst.ATTR_NAME}" class="layui-input">
|
8784
|
8811
|
</div>
|
|
8812
|
+ <div class="layui-form-item" style="margin-bottom: 0; display: none;">
|
|
8813
|
+ <input style="display: none" type="text" name="${enumDataSourceConst.DEVICE_COED}" class="layui-input">
|
|
8814
|
+ </div>
|
|
8815
|
+ <div class="layui-form-item" style="margin-bottom: 0; display: none;">
|
|
8816
|
+ <input style="display: none" type="text" name="${enumDataSourceConst.METHOD}" class="layui-input">
|
|
8817
|
+ </div>
|
|
8818
|
+ <div class="layui-form-item" style="margin-bottom: 0; display: none;">
|
|
8819
|
+ <input style="display: none" type="text" name="${enumDataSourceConst.REGISTER_ADDRESS}" class="layui-input">
|
|
8820
|
+ </div>
|
|
8821
|
+ <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">
|
|
8823
|
+ </div>
|
8785
|
8824
|
`
|
8786
|
8825
|
$(component).append(template)
|
8787
|
8826
|
}
|
...
|
...
|
@@ -8804,6 +8843,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8804
|
8843
|
async function getMeetConditionsDevice(params) {
|
8805
|
8844
|
if (!params.organizationId) return
|
8806
|
8845
|
const items = await ConfigurationNodeApi.getMeetConditionsDevice(params);
|
|
8846
|
+ deviceList = items
|
8807
|
8847
|
$(`#${componentId} `).find(`select[name="${enumDataSourceConst.DEVICE_ID}"]`).html(UseLayUi.generateOptionTemplate({ dataSource: items, valueField: 'tbDeviceId', labelField: 'name', alias: 'alias' }))
|
8808
|
8848
|
form.render('select', componentFilter)
|
8809
|
8849
|
}
|
...
|
...
|
@@ -8815,6 +8855,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8815
|
8855
|
async function getAttrByDeviceId(deviceProfileId) {
|
8816
|
8856
|
if (deviceProfileId) {
|
8817
|
8857
|
const [err, res] = await to(ConfigurationNodeApi.getDeviceAttribute(deviceProfileId))
|
|
8858
|
+ thingsModel = res
|
8818
|
8859
|
$(`#${componentId} `).find(`select[name="${enumDataSourceConst.ATTR}"]`).html(UseLayUi.generateOptionTemplate({ dataSource: Array.isArray(res) ? res : [], labelField: 'name', valueField: 'identifier' }))
|
8819
|
8860
|
form.render('select', componentFilter)
|
8820
|
8861
|
}
|
...
|
...
|
@@ -8847,6 +8888,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8847
|
8888
|
click(node) {
|
8848
|
8889
|
form.val(componentFilter, {
|
8849
|
8890
|
[enumDataSourceConst.ORG_NAME]: node?.data?.title,
|
|
8891
|
+ [enumDataSourceConst.DEVICE_COED]: null,
|
8850
|
8892
|
[enumDataSourceConst.DEVICE_ID]: null,
|
8851
|
8893
|
[enumDataSourceConst.DEVICE_NAME]: null,
|
8852
|
8894
|
})
|
...
|
...
|
@@ -8869,10 +8911,12 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8869
|
8911
|
...validateRule,
|
8870
|
8912
|
onClick(data) {
|
8871
|
8913
|
const { value } = data
|
8872
|
|
- const selected = deviceList.find(item => item.id === value)
|
|
8914
|
+ const selected = deviceList.find(item => item.tbDeviceId === value)
|
|
8915
|
+
|
8873
|
8916
|
if (!selected) return
|
8874
|
8917
|
form.val(componentFilter, {
|
8875
|
8918
|
[enumDataSourceConst.DEVICE_NAME]: selected?.name,
|
|
8919
|
+ [enumDataSourceConst.DEVICE_COED]: selected?.code,
|
8876
|
8920
|
[enumDataSourceConst.ATTR]: null,
|
8877
|
8921
|
[enumDataSourceConst.ATTR_NAME]: null,
|
8878
|
8922
|
})
|
...
|
...
|
@@ -8895,9 +8939,31 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8895
|
8939
|
...validateRule,
|
8896
|
8940
|
onClick(data) {
|
8897
|
8941
|
const { value } = data
|
|
8942
|
+
|
8898
|
8943
|
form.val(componentFilter, {
|
8899
|
8944
|
[enumDataSourceConst.ATTR_NAME]: value,
|
8900
|
8945
|
})
|
|
8946
|
+
|
|
8947
|
+ const selected = thingsModel.find(item => item.identifier === value)
|
|
8948
|
+
|
|
8949
|
+ if (!selected) return
|
|
8950
|
+ const type = selected?.extensionDesc?.dataType
|
|
8951
|
+
|
|
8952
|
+ let method
|
|
8953
|
+
|
|
8954
|
+ if (type === 'short' || type === 'unshort') {
|
|
8955
|
+ method = '06'
|
|
8956
|
+ } else if (type === 'bit') {
|
|
8957
|
+ method = '05'
|
|
8958
|
+ } else {
|
|
8959
|
+ method = '10'
|
|
8960
|
+ }
|
|
8961
|
+
|
|
8962
|
+ form.val(componentFilter, {
|
|
8963
|
+ [enumDataSourceConst.METHOD]: method,
|
|
8964
|
+ [enumDataSourceConst.REGISTER_ADDRESS]: selected?.extensionDesc?.registerAddress,
|
|
8965
|
+ [enumDataSourceConst.DATA_TYPE]: selected?.extensionDesc?.dataType,
|
|
8966
|
+ })
|
8901
|
8967
|
}
|
8902
|
8968
|
})
|
8903
|
8969
|
$(component).append(attrsSelect)
|
...
|
...
|
@@ -8908,7 +8974,7 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8908
|
8974
|
* @param {{orgId: string, deviceId: string, slaveDeviceId?: string, attr: string}} dataSource
|
8909
|
8975
|
*/
|
8910
|
8976
|
function echoDataSource(dataSource = {}) {
|
8911
|
|
- const { orgId, deviceId, deviceProfileId, deviceType, attr } = dataSource
|
|
8977
|
+ const { orgId, deviceId, deviceProfileId, deviceType, attr, method, deviceCode, registerAddress, dataType } = dataSource
|
8912
|
8978
|
const queue = []
|
8913
|
8979
|
currentDataSource = { organizationId: orgId, deviceProfileId, deviceType }
|
8914
|
8980
|
queue.push(getProduct(deviceType))
|
...
|
...
|
@@ -8926,6 +8992,10 @@ DataFormatPanel.prototype.addDataFont = function (container) { |
8926
|
8992
|
deviceProfileId,
|
8927
|
8993
|
deviceType,
|
8928
|
8994
|
attr,
|
|
8995
|
+ method,
|
|
8996
|
+ deviceCode,
|
|
8997
|
+ registerAddress,
|
|
8998
|
+ dataType
|
8929
|
8999
|
})
|
8930
|
9000
|
|
8931
|
9001
|
})
|
...
|
...
|
@@ -14626,7 +14696,7 @@ class DispatchCenter { |
14626
|
14696
|
...(dataType === HandleDataSource.enumDataBindType.REAL ? {} : { endTs: Date.now() })
|
14627
|
14697
|
})
|
14628
|
14698
|
setSubscribeMapping(cmdId, [item])
|
14629
|
|
- messageList[dataType].push(message)
|
|
14699
|
+ messageList[dataType]?.push(message)
|
14630
|
14700
|
cmdId++
|
14631
|
14701
|
})
|
14632
|
14702
|
|
...
|
...
|
@@ -15803,7 +15873,7 @@ class HandleDataInteraction { |
15803
|
15873
|
<div class="layui-form-item">
|
15804
|
15874
|
<label class="layui-form-label" style="width: 120px;">自定义下发值</label>
|
15805
|
15875
|
<div class="layui-input-block" style="margin-left: 150px;">
|
15806
|
|
- <input type="text" name="${enumActionEl.CUSTOM_TCP_COMMAND}" lay-verify="required" autocomplete="off" placeholder="请输入下发值" class="layui-input">
|
|
15876
|
+ <input type="number" name="${enumActionEl.CUSTOM_TCP_COMMAND}" lay-verify="required" autocomplete="off" placeholder="请输入下发值" class="layui-input">
|
15807
|
15877
|
</div>
|
15808
|
15878
|
</div>
|
15809
|
15879
|
</div>
|
...
|
...
|
@@ -15982,7 +16052,8 @@ class HandleDataInteraction { |
15982
|
16052
|
|
15983
|
16053
|
const validate = (data) => {
|
15984
|
16054
|
const { commandType, transportType } = content
|
15985
|
|
- let { attr } = contentData.dataSources.find(item => item.nodeId === nodeId) || {}
|
|
16055
|
+ let dataSource = contentData.dataSources.find(item => item.nodeId === nodeId) || {}
|
|
16056
|
+ const { attr, additional } = dataSource
|
15986
|
16057
|
let flag = false
|
15987
|
16058
|
let value
|
15988
|
16059
|
|
...
|
...
|
@@ -15993,8 +16064,11 @@ class HandleDataInteraction { |
15993
|
16064
|
if (isCustom) {
|
15994
|
16065
|
if (isTCP) {
|
15995
|
16066
|
value = data[enumActionEl.CUSTOM_TCP_COMMAND]
|
|
16067
|
+ const { dataType } = additional
|
15996
|
16068
|
const validate = new Validate([
|
15997
|
16069
|
{ 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) } }] : [])
|
15998
|
16072
|
])
|
15999
|
16073
|
if (validate.begin()) flag = true
|
16000
|
16074
|
} else {
|
...
|
...
|
@@ -16039,16 +16113,34 @@ class HandleDataInteraction { |
16039
|
16113
|
defaultHandler(result, callback)
|
16040
|
16114
|
}
|
16041
|
16115
|
|
|
16116
|
+ async function getTCPCommand(registerValue, dataSource) {
|
|
16117
|
+ const { additional } = dataSource || {}
|
|
16118
|
+ const { method, deviceCode, registerAddress } = additional || {}
|
|
16119
|
+
|
|
16120
|
+ const params = {
|
|
16121
|
+ crc: 'CRC_16_LOWER',
|
|
16122
|
+ deviceCode,
|
|
16123
|
+ method,
|
|
16124
|
+ registerAddr: Number(registerAddress),
|
|
16125
|
+ registerNumber: 1,
|
|
16126
|
+ registerValues: [Number(registerValue)]
|
|
16127
|
+ }
|
|
16128
|
+
|
|
16129
|
+ const command = await ConfigurationNodeApi.getModbusCommand(params)
|
|
16130
|
+
|
|
16131
|
+ return command
|
|
16132
|
+ }
|
|
16133
|
+
|
16042
|
16134
|
async function defaultHandler(value, callback) {
|
16043
|
|
- let { deviceId, attr } = contentData.dataSources.find(item => item.nodeId === nodeId) || {}
|
16044
|
|
- console.log(content)
|
|
16135
|
+ let dataSource = contentData.dataSources.find(item => item.nodeId === nodeId) || {}
|
|
16136
|
+ const { deviceId, attr, deviceProfileId } = dataSource
|
16045
|
16137
|
/**
|
16046
|
16138
|
* @type {command: string , commandType: string, service: string, wary: string, tcpCommand: string}
|
16047
|
16139
|
*/
|
16048
|
16140
|
let { command, way, service, callType } = content
|
16049
|
16141
|
const identifier = content?.identifier
|
16050
|
16142
|
const params = content?.transportType === 'TCP'
|
16051
|
|
- ? value
|
|
16143
|
+ ? await getTCPCommand(value, dataSource)
|
16052
|
16144
|
: identifier
|
16053
|
16145
|
? { [identifier]: value }
|
16054
|
16146
|
: value
|
...
|
...
|
|