Skip to content

Commit

Permalink
Fixed a bug in the processing of Property's type and Action's input/o…
Browse files Browse the repository at this point in the history
…utput type when null was specified
  • Loading branch information
hidetak committed Jul 20, 2024
1 parent 021da87 commit ae300d4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
7 changes: 4 additions & 3 deletions node-red-node-wot/plugin-resources-src/node-wot-plugin-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,13 @@ export const createClientFlowUsingDashboard = (tdString: string, existedNodes: a
actionGenIds.push(generateId())
}
const tdAction = td.actions[actionName]
let actionInputType = tdAction.input?.type || "actionInputTypeNull"
const actionParams = {
...commonParams,
actionName,
actionDescription: tdAction.description,
inputMode: DATATYPES[tdAction.input?.type || "actionInputTypeNull"].inputMode,
convert: DATATYPES[tdAction.input?.type || "actionInputTypeNull"].typeConvert,
inputMode: DATATYPES[actionInputType].inputMode,
convert: DATATYPES[actionInputType].typeConvert,
}
flowAndOffsetY = makeActionFlow(commonGenIds, actionGenIds, actionParams, tdAction, flowAndOffsetY.offsetY)
flow = flow.concat(flowAndOffsetY.flow)
Expand Down Expand Up @@ -264,7 +265,7 @@ const makeActionFlow = (commonGenIds, actionGenIds, params, tdAction, offsetY) =
offsetY
)
flow = flow.concat(flowAndOffsetY.flow)
if (tdAction.input?.type) {
if (params.inputMode) {
flowAndOffsetY = replaceParamsAndIds(
ACTION_ARGS_TEMP,
params,
Expand Down
1 change: 1 addition & 0 deletions node-red-node-wot/src/wot-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module.exports = function (RED) {
shape: "ring",
text: err.message,
})
console.error(err)
done(err)
})
})
Expand Down
2 changes: 2 additions & 0 deletions node-red-node-wot/src/wot-property.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ module.exports = function (RED) {
shape: "ring",
text: "Response error",
})
console.error(err)
done(err)
})
})
Expand Down Expand Up @@ -189,6 +190,7 @@ module.exports = function (RED) {
shape: "ring",
text: err.message,
})
console.error(err)
done(err)
})
})
Expand Down
15 changes: 9 additions & 6 deletions node-red-node-wot/src/wot-server-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ module.exports = function (RED) {

// for wot-server-config
node.getProps = () => {
const input = config.actionInputDataType === "null" ? undefined : { type: config.actionInputDataType }
const output =
config.actionOutputDataType === "null"
? undefined
: {
type: config.actionOutputDataType,
}
return {
attrType: "actions",
name: config.actionName,
outputArgs: config.outParams1_actionArgsConstValue,
content: {
description: config.actionDescription,
input: {
type: config.actionInputDataType,
},
output: {
type: config.actionOutputDataType,
},
input,
output,
},
}
}
Expand Down
3 changes: 2 additions & 1 deletion node-red-node-wot/src/wot-server-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ module.exports = function (RED) {

// for wot-server-config
node.getProps = () => {
const type = config.propertyDataType === "null" ? undefined : config.propertyDataType
return {
attrType: "properties",
name: config.propertyName,
outputAttr: config.outParams2_writingValueConstValue,
content: {
description: config.propertyDescription,
type: config.propertyDataType,
type,
readOnly: config.propertyReadOnlyFlag,
observable: config.propertyObservableFlag,
},
Expand Down

0 comments on commit ae300d4

Please sign in to comment.