Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3ccec25

Browse files
OPC-UA-Server: fix server timestamps where creating OPC variables.
1 parent b30cddc commit 3ccec25

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

‎src/OPC-UA-Server/index.js‎

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const {
2323
OPCUAServer,
2424
Variant,
2525
DataType,
26+
DataValue,
2627
StatusCodes,
2728
VariantArrayType,
2829
AccessLevelFlag,
@@ -657,21 +658,42 @@ process.on('uncaughtException', (err) =>
657658
? AccessLevelFlag.CurrentWrite
658659
: writeFlag),
659660
...cmdWriteProp,
661+
value: {
662+
timestamped_get: () =>
663+
new DataValue({
664+
statusCode: element.invalid
665+
? StatusCodes.Bad
666+
: StatusCodes.Good,
667+
sourceTimestamp:
668+
!('timeTagAtSource' in element) ||
669+
element.timeTagAtSource === null
670+
? new Date(0)
671+
: element.timeTagAtSource,
672+
serverTimestamp: element.timeTag,
673+
value: new Variant({
674+
dataType: v.dataType,
675+
...(v.arrayType ? { arrayType: v.arrayType } : {}),
676+
value: v.value,
677+
}),
678+
}),
679+
},
660680
})
661-
if (element.origin !== 'command') {
662-
server._metrics[element.tag].setValueFromSource(
663-
{
664-
dataType: v.dataType,
665-
...(v.arrayType ? { arrayType: v.arrayType } : {}),
666-
value: v.value,
667-
},
668-
element.invalid ? StatusCodes.Bad : StatusCodes.Good,
669-
!('timeTagAtSource' in element) ||
670-
element.timeTagAtSource === null
671-
? new Date(1970, 0, 1)
672-
: element.timeTagAtSource
673-
)
674-
}
681+
//if (element.origin !== 'command') {
682+
// server._metrics[element.tag].serverTimestamp =
683+
// element.timeTag
684+
// server._metrics[element.tag].setValueFromSource(
685+
// {
686+
// dataType: v.dataType,
687+
// ...(v.arrayType ? { arrayType: v.arrayType } : {}),
688+
// value: v.value,
689+
// },
690+
// element.invalid ? StatusCodes.Bad : StatusCodes.Good,
691+
// !('timeTagAtSource' in element) ||
692+
// element.timeTagAtSource === null
693+
// ? new Date(0)
694+
// : element.timeTagAtSource
695+
// )
696+
//}
675697
}
676698
} catch (e) {
677699
Log.log(
@@ -760,7 +782,7 @@ process.on('uncaughtException', (err) =>
760782
: StatusCodes.Good,
761783
!('timeTagAtSource' in change.fullDocument) ||
762784
change.fullDocument.timeTagAtSource === null
763-
? new Date(1970,0,1)
785+
? new Date(0)
764786
: change.fullDocument.timeTagAtSource
765787
)
766788

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /