This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag.py
1066 lines (908 loc) 路 37.1 KB
/
tag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
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
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) 2018-2021
# Author: Cesar Roman
# Contact: cesar@thecesrom.dev
"""Tag Functions
The following functions give you access to interact with Ignition Tags.
"""
__all__ = [
"addTag",
"browseConfiguration",
"browseHistoricalTags",
"browseTags",
"browseTagsSimple",
"editAlarmConfig",
"editTag",
"editTags",
"exists",
"getAlarmStates",
"isOverlaysEnabled",
"loadFromFile",
"queryTagCalculations",
"queryTagDensity",
"queryTagHistory",
"read",
"readAll",
"removeTag",
"removeTags",
"scan",
"setOverlaysEnabled",
"storeTagHistory",
"write",
"writeAll",
"writeAllSynchronous",
"writeSynchronous",
]
import system.date
from java.lang import Object
class BrowseResults(Object):
"""BrowseResults class."""
def getContinuationPoint(self):
pass
def getResultQuality(self):
pass
def getResults(self):
pass
def getReturnedSize(self):
pass
def getTotalAvailableSize(self):
pass
def setContinuationPoint(self, continuationPoint):
pass
def setResultQuality(self, value):
pass
def setResults(self, results):
pass
def setTotalAvailableResults(self, totalAvailableResults):
pass
class QualifiedValue(object):
"""Represents a value with a DataQuality & timestamp attached to
it."""
def __init__(self, value=None, quality=None, timestamp=None):
self._value = value
self._quality = quality
self._timestamp = timestamp
@property
def value(self):
return str(self._value)
def derive(self, diagnosticMessage):
pass
def equals(self, value, includeTimestamp):
pass
def getQuality(self):
pass
def getTimestamp(self):
pass
def getValue(self):
pass
class AlarmProperty(object):
"""AlarmProperty class."""
def __init__(self, property=None, value=None, type=None):
self.property = property
self.type = type
self.value = value
class BrowseTag(Object):
"""BrowseTag class."""
def __init__(
self,
name=None,
path=None,
fullPath=None,
type=None,
valueSource=None,
dataType=None,
):
super(BrowseTag, self).__init__()
self.name = name
self.path = path
self.fullPath = fullPath
self.type = type
self.valueSource = valueSource
self.dataType = dataType
def getDataType(self):
return self.dataType
def getFullPath(self):
return self.fullPath
def getPath(self):
return self.path
def getTagType(self):
return self.type
def getValueSource(self):
return self.valueSource
def isDB(self):
print self
return True
def isExpression(self):
print self
return True
def isFolder(self):
print self
return True
def isMemory(self):
print self
return True
def isOPC(self):
print self
return True
def isQuery(self):
print self
return True
def isUDT(self):
print self
return True
def toString(self):
pass
class Results(object):
"""Results class."""
def getPath(self):
pass
def getType(self):
pass
def hasChildren(self):
pass
class TagAlarmDefinition(object):
"""TagAlarmDefinition class."""
alarm = None
def getAlarmProperties(self):
print self
return AlarmProperty()
class TagConfiguration(object):
"""TagConfiguration class."""
def getAlarms(self):
pass
def getFolderPath(self):
pass
def getFullPath(self):
pass
def getName(self):
pass
def getParameters(self):
pass
def getProperties(self):
pass
def getSubTags(self):
pass
def getTagType(self):
pass
def addTag(
parentPath,
name,
tagType,
dataType,
accessRights,
enabled,
value,
attributes,
parameters,
overrides,
alarmList,
alarmConfig,
):
"""Adds a new tag in Ignition. You can add OPC, memory, expression,
query, folder, and UDT instance tags. You can't add Client Tags,
because those can vary from project to project.
Args:
parentPath (str): The folder to add the tag to. Leave blank for
the root folder.
name (str): The name of the tag.
tagType (str): The type of tag to create. Possible values are
OPC, MEMORY, EXPRESSION, QUERY, Folder, and UDT_INST.
dataType (str): The data type of the tag. Not used for UDT
instances or folders. Possible basic values are Int1, Int2,
Int4, Int8, Float4, Float8, Boolean, String, DataSet, and
DateTime. Possible array values are Int4Array, Int8Array,
Float8Array, BooleanArray, StringArray, DateTimeArray.
accessRights (str): The access rights for a tag. Possible values
are Read_Only, Read_Write, and Custom.
enabled (bool): If True, the tag will be enabled.
value (object): The value of the tag. Used for memory tags.
attributes (dict): The tag's configuration attributes.
parameters (dict): The parameters for a UDT instance tag.
overrides (dict): All of the overrides for a UDT instance tag.
alarmList (str): List of legacy alarms for the tag. The legacy
alarm system was retired in 7.6.0, so the alarmConfig
parameter should be utilized on newer versions.
alarmConfig (dict): The alarm configuration for the tag. See
editAlarmConfig for details on how to use this parameter.
"""
print (
parentPath,
name,
tagType,
dataType,
accessRights,
enabled,
value,
attributes,
parameters,
overrides,
alarmList,
alarmConfig,
)
def browseConfiguration(path, recursive):
"""Browses a folder path or UDT and returns Tag configuration
information for each Tag within the specified path. This can be used
to view event scripts, alarms, as well as any other configurable
attribute on a Tag.
Args:
path (str): The path that will be browsed, typically to a folder
or UDT instance. Leave blank to browse the root folder. A
Tag Provider may be specified as follows: "[TagProvider]".
If the Tag Provider is omitted, client scoped calls will be
made against the project's default provider. Gateway scoped
calls must include a Tag Provider. When browsing UDTs,
specifying the UDT path will browse the Tags inside the UDT.
To browse the UDT instance, specify the parent of the
instance.
recursive (bool): If True, will recursively search for Tags in
folders. Each folder will return a 'tags' property
containing the nested TagConfigurations in another list.
Returns:
list(TagConfiguration): A list of TagConfiguration objects.
Attributes on the object may be read by calling
tag.get(propertyObject). A list of attributes with
configuration information can be obtained by calling
getProperties(). Only attributes with non-default values
will appear in the attribute list.
"""
print (path, recursive)
return [TagConfiguration()]
def browseHistoricalTags(
path, nameFilters=None, maxSize=None, continuationPoint=None
):
"""Will browse for any historical Tags at the provided historical
path. It will only browse for Tags at the path, and will not go down
through any children. Will return with a BrowseResults object.
Args:
path (str): The Historical Tag Path to browse. See the Tag
Export page for a description of how to construct a
historical Tag Path.
nameFilters (list[str]): A list of name filters to be applied to
the result set. Optional.
maxSize (int): The maximum size of the result set. Optional.
continuationPoint (object): Sets the continuation point in order
to continue a browse that was previously started and then
limited. Use .getContinuationPoint() on the BrowseResults
object to get the continuation point. Optional.
Returns:
BrowseResults: An object that contains the results as well as
the Continuation Point. Get the results by calling
.getResults() on the BrowseResults object.
"""
print (path, nameFilters, maxSize, continuationPoint)
return BrowseResults()
def browseTags(
parentPath,
tagPath=None,
tagType=None,
dataType=None,
udtParentType=None,
recursive=False,
sort="ASC",
):
"""Returns an array of tags from a specific folder. The function
supports filtering and recursion. Leave filters blank to return all
tags.
If called in the gateway scope, a Tag Provider must be specified.
Args:
parentPath (str): The parent folder path. Leave blank for the
root folder. Note: you can specify the tag provider name in
square brackets at the beginning of the parentPath string.
Example: "[myTagProvider]MyTagsFolder". If the tag provider
name is left off then the project default provider will be
used.
tagPath (str): Filters on a tag path. Use * as a wildcard for
any number of characters and a ? for a single character.
Optional.
tagType (str): Filters on a tag type. Possible values are OPC,
MEMORY, DB, QUERY, Folder, DERIVED and UDT_INST. Optional.
dataType (str): The data type of the tag. Not used for UDT
instances or folders. Possible values are Int1, Int2, Int4,
Int8, Float4, Float8, Boolean, String, and DateTime.
Optional.
udtParentType (str): The name of the parent UDT. Optional.
recursive (bool): Recursively search for tags inside of folders.
Note: It is highly recommended that recursive is set to
False, as server timeouts are more likely to occur.
Optional.
sort (str): Sets the sort order, possible values are ASC and
DESC. Sorting is done on the full path of the tag. Optional.
Returns:
list[BrowseTag]: An array of BrowseTag. BrowseTag has the
following variables: name, path, fullPath, type, dataType,
and the following functions: isFolder(), isUDT(), isOPC(),
isMemory(), isExpression(), isQuery().
"""
print (
parentPath,
tagPath,
tagType,
dataType,
udtParentType,
recursive,
sort,
)
return [BrowseTag()]
def browseTagsSimple(parentPath, sort):
"""Returns a sorted array of tags from a specific folder.
Args:
parentPath (str): The parent folder path. Leave blank for the
root folder. Note: you can specify the tag provider name in
square brackets at the beginning of the parentPath string.
Example: "[myTagProvider]MyTagsFolder". If the tag provider
name is left off then the project default provider will be
used.
sort (str): Sets the sort order, possible values are ASC and
DESC.
Returns:
list[BrowseTag]: An array of BrowseTag. BrowseTag has the
following variables: name, path, fullPath, type, dataType,
and the following functions: isFolder(), isUDT(), isOPC(),
isMemory(), isExpression(), isQuery().
"""
print (parentPath, sort)
return [BrowseTag()]
def editAlarmConfig(tagPaths, alarmConfig):
"""Edit the alarm configuration of multiple existing tags in
Ignition with a single call.
Args:
tagPaths (list[str]): The full path to the tag you want to edit.
Note: you can specify the tag provider name in square
brackets at the beginning of the parentPath string. Example:
"[myTagProvider]MyTagsFolder". If the tag provider name is
left off then the project default provider will be used.
alarmConfig (dict): A dictionary of multi-dimensional lists
containing the new alarm configuration. The key in the
dictionary will be the name of the alarm being to edit, and
the value is a list of lists. The nested lists use the
format ["name", "Value", "newValue"]. Note that item 1 is
always "Value".
"""
print (tagPaths, alarmConfig)
def editTag(
tagPath,
attributes=None,
parameters=None,
accessRights=None,
overrides=None,
alarmList=None,
alarmConfig=None,
):
"""Edits an existing Tag in Ignition. This will not work on Client
Tags, because there is a Client Provider for each project.
Args:
tagPath (str): The full path to the Tag you want to edit. For
members of UDT instances, the tagPath will be the path to
the UDT instance, with the overrides parameter listing out
the member Tags to edit. Note: you can specify the Tag
provider name in square brackets at the beginning of the
parentPath string. Example: "[myTagProvider]MyTagsFolder".
If the Tag provider name is left off then the project
default provider will be used.
attributes (dict): The Tag's configuration attributes. Optional.
parameters (dict): The parameters for a UDT instance Tag.
Optional.
accessRights (string): The access rights for the Tags. Possible
values are Read_Only, Read_Write, and Custom. Optional.
overrides (dict): All of the overrides for a UDT instance Tag.
The dictionary should be in the form of the names of member
Tags as keys, with the values being a dictionary of
properties/overrides ie. {'memberTagName':{dictionary of
overrides}}. Optional.
alarmList (str): List of legacy alarms for the Tag. The legacy
alarm system was retired in 7.6.0. Newer systems should
utilize the system.tag.editAlarmConfig function instead.
Optional.
alarmConfig (dict): The alarm configuration for the Tag. Note
that this parameter cannot edit alarms on UDTs. Instead, the
system.tag.editAlarmConfig function (which can also edit
alarms on non-UDT Tags) should be used instead. See
editAlarmConfig for details on how to use this parameter.
Optional.
"""
print (
tagPath,
attributes,
parameters,
accessRights,
overrides,
alarmList,
alarmConfig,
)
def editTags(
tagPaths,
attributes,
parameters,
accessRights,
overrides,
alarmList,
alarmConfig,
provider,
json,
):
"""Edit multiple existing Tags in Ignition with a single call. This
will not work on Client Tags, because there is a Client Provider for
each project.
Args:
tagPaths (list[str]): The full path to the Tag you want to edit.
For members of UDT instances, the tagPath will be the path
to the UDT instance, with the overrides parameter listing
out the member Tags to edit. Note: you can specify the Tag
provider name in square brackets at the beginning of the
parentPath string. Example: "[myTagProvider]MyTagsFolder".
If the Tag provider name is left off then the project
default provider will be used.
attributes (dict): The Tag's configuration attributes.
parameters (dict): The parameters for a UDT instance Tag.
accessRights (str): The access rights for a Tag. Possible values
are Read_Only, Read_Write, and Custom.
overrides (dict): All of the overrides for a UDT instance Tag.
alarmList (str): List of legacy alarms for the Tag. The legacy
alarm system was retired in 7.6.0, so the alarmConfig
parameter should be utilized on newer versions.
alarmConfig (dict): The alarm configuration for the Tag.
provider (str): The name of the Tag provider, used in
conjunction with the JSON argument. The default value is the
default Tag provider. Optional.
json (str): The properties to edit on Tags, represented as a
JSON object. When using this, it acts as a replacement for
other parameters. Optional.
"""
print (
tagPaths,
attributes,
parameters,
accessRights,
overrides,
alarmList,
alarmConfig,
provider,
json,
)
def exists(tagPath):
"""Checks whether or not a tag with a given path exists.
Args:
tagPath (str): The path of the tag to look up.
Returns:
bool: True if a tag exists for the given path, False otherwise.
"""
print tagPath
return True
def getAlarmStates(tagPath):
"""Returns an array of alarm definitions for a specific tag.
Args:
tagPath (str): The full path to the tag. Note: you can specify
the tag provider name in square brackets at the beginning of
the parentPath string. Example:
"[myTagProvider]MyTagsFolder". If the tag provider name is
left off then the project default provider will be used.
Returns:
list[TagAlarmDefinition]: An array of TagAlarmDefinition.
"""
print tagPath
return [TagAlarmDefinition()]
def isOverlaysEnabled():
"""Returns whether or not the current client's quality overlay
system is currently enabled.
Returns:
bool: True (1) if overlays are currently enabled.
"""
return False
def loadFromFile(filePath, provider, mode):
"""This function locates an exported tag file and loads the tags
into the specified tag provider.
Args:
filePath (str): The path of the tag file to import from.
provider (str): The name of the provider to import to.
mode (int): Dictates what happens if the tag already exists.
0 = overwrite, 1 = ignore.
"""
print (filePath, provider, mode)
def queryTagCalculations(
paths,
calculations,
startDate=None,
endDate=None,
rangeHours=None,
rangeMinutes=None,
aliases=None,
includeBoundingValues=True,
validatesSCExec=True,
noInterpolation=False,
ignoreBadQuality=False,
):
"""Queries various calculations (aggregations) for a set of tags
over a specified range. Returns a dataset with a row per tag, and a
column per calculation.
This is useful when you wish to aggregate tag history collected over
a period of time into a single value per aggregate. If you want
multiple values aggregated to a single time slice (i.e., hourly
aggregates for the same tag over an 8 hour period) consider using
system.tag.queryTagHistory
Args:
paths (list[str]): An array of tag paths (strings) to query
calculations for. The resulting dataset will have a row for
each tag, and a column for each calculation.
calculations (list[str]): An array of calculations (aggregation
functions) to execute for each tag. Valid values are:
"Average" (time-weighted), "MinMax", "LastValue",
"SimpleAverage", "Sum", "Minimum", "Maximum", "DurationOn",
"DurationOff", "CountOn", "CountOff", "Count", "Range",
"Variance", "StdDev", "PctGood", and "PctBad".
startDate (datetime): The starting point for the calculation
window. If omitted, and range is not used, 8 hours before
the current time is used. Optional.
endDate (datetime): The end of the calculation window. If
omitted, and range is not used, uses the current time.
Optional.
rangeHours (int): Allows you to specify the query range in
hours, instead of using start and end date. Can be positive
or negative, and can be used in conjunction with startDate
or endDate. Optional.
rangeMinutes (int): Same as rangeHours, but in minutes.
Optional.
aliases (list[str]): Aliases that will be used to override the
tag path names in the result dataset. Must be 1-to-1 with
the tag paths. If not specified, the tag paths themselves
will be used. Optional.
includeBoundingValues (bool): A boolean flag indicating that the
system should attempt to load values before and after the
query bounds for the purpose of interpolation. The effect
depends on the aggregates used. The default is "True".
Optional.
validatesSCExec (bool): A boolean flag indicating whether or not
data should be validated against the scan class execution
records. If False, calculations may include data that is
assumed to be good, even though the system may not have been
running. Default is "True". Optional.
noInterpolation (bool): A boolean flag indicating that the
system should not attempt to interpolate values in
situations where it normally would, such as for analog tags.
Default is "False". Optional.
ignoreBadQuality (bool): A boolean flag indicating that bad
quality values should not be used in the query process. If
set, any value with a "bad" quality will be completely
ignored in calculations. Default is "False". Optional.
Returns:
Dataset: A dataset representing the calculations over the
specified range.
"""
endDate = system.date.now() if endDate is None else endDate
startDate = (
system.date.addHours(endDate, -8) if startDate is None else startDate
)
print (
paths,
calculations,
startDate,
endDate,
rangeHours,
rangeMinutes,
aliases,
includeBoundingValues,
validatesSCExec,
noInterpolation,
ignoreBadQuality,
)
def queryTagDensity(paths, startDate, endDate):
"""Queries the Tag history system for information about the density
of data. In other words, how much data is available for a given time
span.
This function is called with a list of Tag paths, and a start and
end date. The result set is a two column dataset specifying the
timestamp, and a relative weight. Each row is valid from the given
time until the next row. Tags are assigned a 1 or a 0 if they are
present or not. All values are then multiplied together to get a
decimal based percentage for the density. Thus, for four Tag paths
passed in, if three Tags were present during the span, the result
would be 0.75.
Args:
paths (list[str]): An array of Tag paths (strings) to query.
startDate (datetime): The start of the range to query.
endDate (datetime): The end of the range to query.
Returns:
Dataset: A 2-column dataset consisting of a timestamp and a
weight. Each row is valid until the next row.
"""
print (paths, startDate, endDate)
return [0, 0]
def queryTagHistory(
paths,
startDate=None,
endDate=None,
returnSize=-1,
aggregationMode="Average",
returnFormat="Wide",
columnNames=None,
intervalHours=None,
intervalMinutes=None,
rangeHours=None,
rangeMinutes=None,
aggregationModes=None,
includeBoundingValues=None,
validateSCExec=None,
noInterpolation=None,
ignoreBadQuality=None,
timeout=None,
):
"""Issues a query to the Tag Historian. Querying tag history
involves specifying the tags and the date range, as well as a few
optional parameters. The Tag historian will find the relevant
history and then interpolate and aggregate it together into a
coherent, tabular result set.
Args:
paths (list[str]): An array of tag paths (strings) to query.
Each tag path specified will be a column in the result
dataset.
startDate (datetime): The earliest value to retrieve. If
omitted, 8 hours before current time is used. Optional.
endDate (datetime): The latest value to retrieve. If omitted,
current time is used. Optional.
returnSize (int): The number of samples to return. -1 will
return values as they changed, and 0 will return the
"natural" number of values based on the logging rates of the
scan class(es) involved. -1 is the default. Optional.
aggregationMode (str): The mode to use when aggregating multiple
samples into one time slice. Valid values are: "Average"
(time-weighted), "MinMax", "LastValue", "SimpleAverage",
"Sum", "Minimum", "Maximum", "DurationOn", "DurationOff",
"CountOn", "CountOff", "Count", "Range", "Variance",
"StdDev", "PctGood", and "PctBad". Optional.
returnFormat (str): Use "Wide" to have a column per tag queried,
or "Tall" to have a fixed-column format. Default is "Wide".
Optional.
columnNames (list[str]): Aliases that will be used to override
the column names in the result dataset. Must be 1-to-1 with
the tag paths. If not specified, the tag paths themselves
will be used as column titles. Optional.
intervalHours (int): Allows you to specify the window interval
in terms of hours, as opposed to using a specific return
size. Optional.
intervalMinutes (int): Same as intervalHours, but in minutes.
Can be used on its own, or in conjunction with
intervalHours. Optional.
rangeHours (int): Allows you to specify the query range in
hours, instead of using start and end date. Can be positive
or negative, and can be used in conjunction with startDate
or endDate. Optional.
rangeMinutes (int): Same as rangeHours, but in minutes.
Optional.
aggregationModes (list[str]): A one-to-one list with paths
specifying an aggregation mode per column. Optional.
includeBoundingValues (bool): A boolean flag indicating that the
system should attempt to include values for the query bound
times if possible. The default for this property depends on
the query mode, so unless a specific behavior is desired, it
is best to not include this parameter. Optional.
validateSCExec (bool): A boolean flag indicating whether or not
data should be validated against the scan class execution
records. If False, data will appear flat (but good quality)
for periods of time in which the system wasn't running. If
True, the same data would be bad quality during downtime
periods. Optional.
noInterpolation (bool): A boolean flag indicating that the
system should not attempt to interpolate values in
situations where it normally would. This will also prevent
the return of rows that are purely interpolated. Optional.
ignoreBadQuality (bool): A boolean flag indicating that bad
quality values should not be used in the query process. If
set, any value with a "bad" quality will be completely
ignored in calculations and in the result set. Optional.
timeout (int): Timeout in milliseconds for Client Scope. This
property is ignored in the Gateway Scope. Optional.
Returns:
Dataset: A dataset representing the historian values for the
specified tag paths. The first column will be the timestamp,
and each column after that represents a tag.
"""
endDate = system.date.now() if endDate is None else endDate
startDate = (
system.date.addHours(endDate, -8) if startDate is None else startDate
)
print (
paths,
startDate,
endDate,
returnSize,
aggregationMode,
returnFormat,
columnNames,
intervalHours,
intervalMinutes,
rangeHours,
rangeMinutes,
aggregationModes,
includeBoundingValues,
validateSCExec,
noInterpolation,
ignoreBadQuality,
timeout,
)
return None
def read(tagPath):
"""Reads the value of the tag at the given tag path. Returns a
qualified value object. You can read the value, quality, and
timestamp from this object. If the tag path does not specify a tag
property, then the Value property is assumed.
You can also read the value of tag attributes by appending the
attribute to the tagPath parameter. See the Tag Attributes page for
a list of available attributes.
Args:
tagPath (str): Reads from the given tag path. If no property is
specified in the path, the Value property is assumed.
Returns:
QualifiedValue: A qualified value. This object has three
sub-members: value, quality, and timestamp.
"""
print tagPath
return QualifiedValue()
def readAll(tagPaths):
"""Reads the values of each tag in the tag path list. Returns a
sequence of qualified value objects. You can read the value,
quality, and timestamp from each object in the return sequence.
Reading in bulk like this is more efficient than calling read() many
times.
Args:
tagPaths (list[str]): A sequence of tag paths to read from.
Returns:
list[QualifiedValue]: A sequence of qualified values
corresponding to each tag path given. Each qualified value
will have three sub-members: value, quality, and timestamp.
"""
print tagPaths
items = []
for _ in range(len(tagPaths)):
items.append(QualifiedValue())
return items
def removeTag(tagPath):
"""Removes a tag from Ignition.
Args:
tagPath (str): The path to the tag you want to remove. You can
specify the tag provider name in square brackets at the
beginning of the parentPath string. Example:
"[myTagProvider]MyTagsFolder". If the tag provider name is
left off, then the project default provider will be used.
Note that an empty path ( '' ) will remove all tags.
"""
print tagPath
def removeTags(tagPaths):
"""Removes multiple tags from Ignition with a single call.
Args:
tagPaths (list[str]): An array of the paths to the tags you want
to remove. You can specify the tag provider name in square
brackets at the beginning of the parentPath string. Example:
"[myTagProvider]MyTagsFolder". If the tag provider name is
left off, then the project default provider will be used.
Note that an empty path (['']) will remove all tags.
"""
print tagPaths
def scan(provider, scname):
"""Forces execution of a scan class. On a leased scan class, if both
the fast and slow rate are set to 0, this will not execute.
Args:
provider (str): The name of the scan class provider. If blank,
it will use the default. Required if used in the gateway
scope.
scname (str): The name of the scan class to execute.
"""
print (provider, scname)
def setOverlaysEnabled(enabled):
"""Enables or disables the component quality overlay system.
Args:
enabled (bool): True (1) to turn on tag overlays, False (0) to
turn them off.
"""
print enabled
def storeTagHistory(
historyprovider,
tagprovider,
paths,
values,
qualities=None,
timestamps=None,
):
"""Inserts data into the tag history system, allowing Tag history to
be recorded via scripting.
The Tag paths are associated with a historical and realtime
provider, but they do not necessarily need to exist in the realtime
provider. This means records from non-existent (virtual) Tags can be
stored in the Tag History system. Because of this, it is imperative
that Tag paths passed to the function are typed precisely, otherwise
the history will be stored at an incorrect path.
Note that the Tag History system does cache tag data. Thus, if this
function is called, the tag path and tag id are cached until the
history provider or gateway are restarted. This means manually
removing the tag from the sqlth_te table, and then calling this
function again with the same path will not re-populate the tag
execution table (especially so when working purely with virtual tag
paths). Instead, the cache must first be cleared, and then a new
entry will be added the next time this function is called.
Args:
historyprovider (str): The historical provider to store to.
tagprovider (str): The name of the realtime tag provider to
associate these tags with. The tag provider does not need to
exist, and the tag paths do not need to exist in it.
paths (list[str]): A list of paths to store. The values,
qualities, and timestamps are one-to-one with the paths. A
single path may be present multiple times in order to store
multiple values.
values (list[object]): A list of values to store.
qualities (list[int]): A list of integer quality codes
corresponding to the values. Quality codes can be found on
the Tag Quality and Overlays page. If omitted, GOOD quality
will be used. Optional.
timestamps (list[Date]): A list of Date timestamps corresponding
to the values. If omitted, the current time will be used. A
java.util.date object may be passed, so the system.date
functions can be used to return a timestamp. Optional.
"""
print (historyprovider, tagprovider, paths, values, qualities, timestamps)
def write(tagPath, value, suppressErrors=False):
"""Writes a value to a tag. Note that this function writes
asynchronously. This means that the function does not wait for the
write to occur before returning - the write occurs sometime later on
a different thread.
Args:
tagPath (str): The path of the tag to write to.
value (object): The value to write.
suppressErrors (bool): A flag indicating whether or not to
suppress errors. Optional.
Returns:
int: 0 if the write failed immediately, 1 if it succeeded
immediately, and 2 if it is pending.
"""
print (tagPath, value, suppressErrors)