Check-in [15e21d4fcc]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:update topcua for some open62541 1.x diffs in type handling etc.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 15e21d4fcc6ddfc0f510c5aa4effb86cc3f1aaad
User & Date: chw 2020-07-28 04:39:37
Context
2020-07-30
04:58
more changes in topcua for type handling check-in: 416a0ae7c1 user: chw tags: trunk
2020-07-28
04:57
merge with trunk check-in: ac0d74ae78 user: chw tags: wtf-8-experiment
04:39
update topcua for some open62541 1.x diffs in type handling etc. check-in: 15e21d4fcc user: chw tags: trunk
2020-07-27
03:46
add selected tcl upstream changes check-in: 88b5277aad user: chw tags: trunk
Changes

Changes to jni/topcua/doc/opcua.n.

1
2
3
4
5
6
7
8
9
10
11
...
706
707
708
709
710
711
712
713









714
715
716
717
718
719
720



721
722
723
724
725
726
727
'\"
'\" Copyright (c) 1993 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\" Copyright (c) 2018/19 Christian Werner <chw at ch minus werner dot de>
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.TH opcua n 8.6 Tcl "Tcl Extension Commands"
.\" ---- man.macros begin ----
.\" The -*- nroff -*- definitions below are for supplemental macros used
................................................................................
\fBopcua type\fR \fIhandle nodeid\fR ?\fIattr\fR?
.
Performs a read operation on the client or server object \fIhandle\fR
like \fBopcua read\fR but instead of the attribute's value returns the
type name of attribute \fIattr\fR of the node identifier \fInodeid\fR. If
\fIattr\fR is omitted, it defaults to the \fIValue\fR attribute.
.TP
\fBopcua types basic|empty|list|nodeid\fR ?\fIname\fR?









.
Returns a list of OPC/UA type names for the \fIbasic\fR and \fIlist\fR
subcommands. Basic types are primitives (e.g. integer numbers) for which
a mapping to Tcl objects is provided. The \fIempty\fR subcommand requires
\fIname\fR to be a known OPC/UA type name and produces and returns an
empty value of this type, e.g. 0.0 for a floating point type. The \fInodeid\fR
subcommand returns the node identifier for the type \fIname\fR.



.TP
\fBopcua write\fR \fIhandle nodeid\fR ?\fIattr\fR? \fItype value\fR
.
Performs a write operation on the client or server object \fIhandle\fR
writing \fIvalue\fR with type \fItype\fR into the attribute \fIattr\fR of
the node identifier \fInodeid\fR. If \fIattr\fR is omitted, it defaults
to \fIValue\fR.



|







 







|
>
>
>
>
>
>
>
>
>







>
>
>







1
2
3
4
5
6
7
8
9
10
11
...
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
'\"
'\" Copyright (c) 1993 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\" Copyright (c) 2018-20 Christian Werner <chw at ch minus werner dot de>
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.TH opcua n 8.6 Tcl "Tcl Extension Commands"
.\" ---- man.macros begin ----
.\" The -*- nroff -*- definitions below are for supplemental macros used
................................................................................
\fBopcua type\fR \fIhandle nodeid\fR ?\fIattr\fR?
.
Performs a read operation on the client or server object \fIhandle\fR
like \fBopcua read\fR but instead of the attribute's value returns the
type name of attribute \fIattr\fR of the node identifier \fInodeid\fR. If
\fIattr\fR is omitted, it defaults to the \fIValue\fR attribute.
.TP
\fBopcua types basic\fR
.
.TP
\fBopcua types empty\fR ?\fIhandle\fR? \fIname\fR
.
.TP
\fBopcua types list\fR ?\fIhandle\fR?\fR
.
.TP
\fBopcua types nodeid\fR ?\fIhandle\fR? \fIname\fR
.
Returns a list of OPC/UA type names for the \fIbasic\fR and \fIlist\fR
subcommands. Basic types are primitives (e.g. integer numbers) for which
a mapping to Tcl objects is provided. The \fIempty\fR subcommand requires
\fIname\fR to be a known OPC/UA type name and produces and returns an
empty value of this type, e.g. 0.0 for a floating point type. The \fInodeid\fR
subcommand returns the node identifier for the type \fIname\fR.
For the command forms where a \fIhandle\fR can be specified, this allows
to deal with additional custom data types (see e.g. \fBopcua deftypes\fR)
which where loaded into the client or server object \fIhandle\fR.
.TP
\fBopcua write\fR \fIhandle nodeid\fR ?\fIattr\fR? \fItype value\fR
.
Performs a write operation on the client or server object \fIhandle\fR
writing \fIvalue\fR with type \fItype\fR into the attribute \fIattr\fR of
the node identifier \fInodeid\fR. If \fIattr\fR is omitted, it defaults
to \fIValue\fR.

Changes to jni/topcua/topcua.c.

1178
1179
1180
1181
1182
1183
1184


























1185
1186
1187
1188
1189
1190
1191
....
2432
2433
2434
2435
2436
2437
2438








2439
2440
2441
2442
2443
2444
2445
....
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936



2937
2938
2939
2940

2941
2942
2943
2944
2945
2946
2947
		    (strcmp(types[j].typeName, name) == 0)) {
		    type = &types[j];
		    break;
		}
	    }
	}
    }


























    return type;
}
 
/*
 *-------------------------------------------------------------------------
 *
 * ParseNodeId --
................................................................................
	    }
	    return list;
	}
    }
    if (data == NULL) {
	return Tcl_NewObj();
    }








    if (type == &UA_TYPES[UA_TYPES_BOOLEAN]) {
	int *v = (int *) data;

	return Tcl_NewIntObj(*v ? 1 : 0);
    }
    if (type == &UA_TYPES[UA_TYPES_SBYTE]) {
	return Tcl_NewIntObj(((signed char *) data)[0]);
................................................................................
	    UA_delete(value, type);
	    value = NULL;
	    goto error;
	}
    } else if (type == &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]) {
	int n;
	Tcl_Obj **elem;
	UA_String s;

	if (Tcl_ListObjGetElements(interp, obj, &n, &elem) != TCL_OK) {
	    goto error;
	}
	if (n != 2) {
	    Tcl_SetResult(interp, "two elements required", TCL_STATIC);
	    goto error;
	}
	value = UA_new(type);



	s = UA_String_fromChars(Tcl_GetString(elem[0]));
	UA_String_copy(&s, &((UA_LocalizedText *) value)->locale);
	s = UA_String_fromChars(Tcl_GetString(elem[1]));
	UA_String_copy(&s, &((UA_LocalizedText *) value)->text);

    } else if (type == &UA_TYPES[UA_TYPES_VARIANT]) {
	int n, j;
	Tcl_Obj **elem;
	const UA_DataType *vtype = NULL;
	void *vdata = NULL;

	if (Tcl_ListObjGetElements(interp, obj, &n, &elem) != TCL_OK) {







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>







 







<




|
|



>
>
>
|
|
|
|
>







1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
....
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
....
2954
2955
2956
2957
2958
2959
2960

2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
		    (strcmp(types[j].typeName, name) == 0)) {
		    type = &types[j];
		    break;
		}
	    }
	}
    }
#if (UA_OPEN62541_VER_MAJOR >= 1)
    if (type == NULL) {
	UA_NodeId nodeid;

	if (ParseNodeId(NULL, &nodeid, name) != NULL) {
	    for (j = 0; j < UA_TYPES_COUNT; j++) {
		if (UA_NodeId_equal(&UA_TYPES[j].typeId, &nodeid)) {
		    type = &UA_TYPES[j];
		    break;
		}
	    }
	    if ((type == NULL) && (uah != NULL)) {
		size_t typesSize = uah->typesArray.typesSize;
		UA_DataType *types = (UA_DataType *) uah->typesArray.types;

		for (j = 0; j < typesSize; j++) {
		    if (UA_NodeId_equal(&types[j].typeId, &nodeid)) {
			type = &types[j];
			break;
		    }
		}
	    }
	    UA_NodeId_deleteMembers(&nodeid);
	}
    }
#endif
    return type;
}
 
/*
 *-------------------------------------------------------------------------
 *
 * ParseNodeId --
................................................................................
	    }
	    return list;
	}
    }
    if (data == NULL) {
	return Tcl_NewObj();
    }
#if (UA_OPEN62541_VER_MAJOR >= 1)
    /* Map scalar enum types to wide integer. */
    if ((type->membersSize == 0) &&
	(type->typeKind == UA_DATATYPEKIND_ENUM) &&
	(type->typeIndex == UA_TYPES_INT32)) {
	return Tcl_NewWideIntObj(((unsigned int *) data)[0]);
    }
#endif
    if (type == &UA_TYPES[UA_TYPES_BOOLEAN]) {
	int *v = (int *) data;

	return Tcl_NewIntObj(*v ? 1 : 0);
    }
    if (type == &UA_TYPES[UA_TYPES_SBYTE]) {
	return Tcl_NewIntObj(((signed char *) data)[0]);
................................................................................
	    UA_delete(value, type);
	    value = NULL;
	    goto error;
	}
    } else if (type == &UA_TYPES[UA_TYPES_LOCALIZEDTEXT]) {
	int n;
	Tcl_Obj **elem;


	if (Tcl_ListObjGetElements(interp, obj, &n, &elem) != TCL_OK) {
	    goto error;
	}
	if ((n != 0) && (n != 2)) {
	    Tcl_SetResult(interp, "zero or two elements required", TCL_STATIC);
	    goto error;
	}
	value = UA_new(type);
	if (n > 0) {
	    UA_String s;

	    s = UA_String_fromChars(Tcl_GetString(elem[0]));
	    UA_String_copy(&s, &((UA_LocalizedText *) value)->locale);
	    s = UA_String_fromChars(Tcl_GetString(elem[1]));
	    UA_String_copy(&s, &((UA_LocalizedText *) value)->text);
	}
    } else if (type == &UA_TYPES[UA_TYPES_VARIANT]) {
	int n, j;
	Tcl_Obj **elem;
	const UA_DataType *vtype = NULL;
	void *vdata = NULL;

	if (Tcl_ListObjGetElements(interp, obj, &n, &elem) != TCL_OK) {