@@ 297-370 (lines=74) @@ | ||
294 | ||
295 | ||
296 | class AttributeWriteMask(IntEnum): |
|
297 | ''' |
|
298 | Define bits used to indicate which attributes are writable. |
|
299 | ||
300 | :ivar None_: |
|
301 | :vartype None_: 0 |
|
302 | :ivar AccessLevel: |
|
303 | :vartype AccessLevel: 1 |
|
304 | :ivar ArrayDimensions: |
|
305 | :vartype ArrayDimensions: 2 |
|
306 | :ivar BrowseName: |
|
307 | :vartype BrowseName: 4 |
|
308 | :ivar ContainsNoLoops: |
|
309 | :vartype ContainsNoLoops: 8 |
|
310 | :ivar DataType: |
|
311 | :vartype DataType: 16 |
|
312 | :ivar Description: |
|
313 | :vartype Description: 32 |
|
314 | :ivar DisplayName: |
|
315 | :vartype DisplayName: 64 |
|
316 | :ivar EventNotifier: |
|
317 | :vartype EventNotifier: 128 |
|
318 | :ivar Executable: |
|
319 | :vartype Executable: 256 |
|
320 | :ivar Historizing: |
|
321 | :vartype Historizing: 512 |
|
322 | :ivar InverseName: |
|
323 | :vartype InverseName: 1024 |
|
324 | :ivar IsAbstract: |
|
325 | :vartype IsAbstract: 2048 |
|
326 | :ivar MinimumSamplingInterval: |
|
327 | :vartype MinimumSamplingInterval: 4096 |
|
328 | :ivar NodeClass: |
|
329 | :vartype NodeClass: 8192 |
|
330 | :ivar NodeId: |
|
331 | :vartype NodeId: 16384 |
|
332 | :ivar Symmetric: |
|
333 | :vartype Symmetric: 32768 |
|
334 | :ivar UserAccessLevel: |
|
335 | :vartype UserAccessLevel: 65536 |
|
336 | :ivar UserExecutable: |
|
337 | :vartype UserExecutable: 131072 |
|
338 | :ivar UserWriteMask: |
|
339 | :vartype UserWriteMask: 262144 |
|
340 | :ivar ValueRank: |
|
341 | :vartype ValueRank: 524288 |
|
342 | :ivar WriteMask: |
|
343 | :vartype WriteMask: 1048576 |
|
344 | :ivar ValueForVariableType: |
|
345 | :vartype ValueForVariableType: 2097152 |
|
346 | ''' |
|
347 | None_ = 0 |
|
348 | AccessLevel = 1 |
|
349 | ArrayDimensions = 2 |
|
350 | BrowseName = 4 |
|
351 | ContainsNoLoops = 8 |
|
352 | DataType = 16 |
|
353 | Description = 32 |
|
354 | DisplayName = 64 |
|
355 | EventNotifier = 128 |
|
356 | Executable = 256 |
|
357 | Historizing = 512 |
|
358 | InverseName = 1024 |
|
359 | IsAbstract = 2048 |
|
360 | MinimumSamplingInterval = 4096 |
|
361 | NodeClass = 8192 |
|
362 | NodeId = 16384 |
|
363 | Symmetric = 32768 |
|
364 | UserAccessLevel = 65536 |
|
365 | UserExecutable = 131072 |
|
366 | UserWriteMask = 262144 |
|
367 | ValueRank = 524288 |
|
368 | WriteMask = 1048576 |
|
369 | ValueForVariableType = 2097152 |
|
370 | ||
371 | ||
372 | class BrowseDirection(IntEnum): |
|
373 | ''' |
@@ 805-865 (lines=61) @@ | ||
802 | 'SourceTimestamp': ('Encoding', 2), |
|
803 | 'ServerTimestamp': ('Encoding', 3), |
|
804 | 'SourcePicoseconds': ('Encoding', 4), |
|
805 | 'ServerPicoseconds': ('Encoding', 5), |
|
806 | } |
|
807 | ||
808 | ua_types = ( |
|
809 | ('Encoding', 'Byte'), |
|
810 | ('Value', 'Variant'), |
|
811 | ('StatusCode', 'StatusCode'), |
|
812 | ('SourceTimestamp', 'DateTime'), |
|
813 | ('SourcePicoseconds', 'UInt16'), |
|
814 | ('ServerTimestamp', 'DateTime'), |
|
815 | ('ServerPicoseconds', 'UInt16'), |
|
816 | ) |
|
817 | ||
818 | def __init__(self, variant=None, status=None): |
|
819 | self.Encoding = 0 |
|
820 | if not isinstance(variant, Variant): |
|
821 | variant = Variant(variant) |
|
822 | self.Value = variant |
|
823 | if status is None: |
|
824 | self.StatusCode = StatusCode() |
|
825 | else: |
|
826 | self.StatusCode = status |
|
827 | self.SourceTimestamp = None # DateTime() |
|
828 | self.SourcePicoseconds = None |
|
829 | self.ServerTimestamp = None # DateTime() |
|
830 | self.ServerPicoseconds = None |
|
831 | self._freeze = True |
|
832 | ||
833 | def __str__(self): |
|
834 | s = 'DataValue(Value:{0}'.format(self.Value) |
|
835 | if self.StatusCode is not None: |
|
836 | s += ', StatusCode:{0}'.format(self.StatusCode) |
|
837 | if self.SourceTimestamp is not None: |
|
838 | s += ', SourceTimestamp:{0}'.format(self.SourceTimestamp) |
|
839 | if self.ServerTimestamp is not None: |
|
840 | s += ', ServerTimestamp:{0}'.format(self.ServerTimestamp) |
|
841 | if self.SourcePicoseconds is not None: |
|
842 | s += ', SourcePicoseconds:{0}'.format(self.SourcePicoseconds) |
|
843 | if self.ServerPicoseconds is not None: |
|
844 | s += ', ServerPicoseconds:{0}'.format(self.ServerPicoseconds) |
|
845 | s += ')' |
|
846 | return s |
|
847 | ||
848 | __repr__ = __str__ |
|
849 | ||
850 | ||
851 | def datatype_to_varianttype(int_type): |
|
852 | """ |
|
853 | Takes a NodeId or int and return a VariantType |
|
854 | This is only supported if int_type < 63 due to VariantType encoding |
|
855 | At low level we do not have access to address space thus decoding is limited |
|
856 | a better version of this method can be find in ua_utils.py |
|
857 | """ |
|
858 | if isinstance(int_type, NodeId): |
|
859 | int_type = int_type.Identifier |
|
860 | ||
861 | if int_type <= 25: |
|
862 | return VariantType(int_type) |
|
863 | else: |
|
864 | return VariantTypeCustom(int_type) |
|
865 | ||
866 | ||
867 | def get_default_value(vtype): |
|
868 | """ |