This first part I was able to figure out with help from community members, in resources listed at the bottom of this post, to get this far. I anticipate that I will need help though, and I will want to reference this later.
First a bunch of reads
The machines are numbered 1-18 and sometimes 15th is just null or not connected, no 13, and 1-9 written as 01-09
example of what was Machine1gross=system.tag.read("[Facility]folder/subgroup/M01/M01Production/M01Gross")
So I think this becomes like:
numMachinesWith0=9
pathGross=
["Facility]folder/subgroup/M0{}/M0{}Production/M0{}Gross".format(nineSet,nineSet,nineSet) for nineSet in range(1,numMachinesWith0+1)]
numMachines = 18
exclusions = [13,15]
pathsGross = ['[Facility]folder/subgroup/M{0:02d}/M{0:02d}Production/M{0:02d}Gross'.format(nineSet) for nineSet in range(1,numMachines + 1) if nineSet not in exclusions]
On a side note because it has helped me a lot check out Catalog Home | Codecademy they have a decent amount of free lessons, editor + console to test and see live results. You learn by doing which I really like. they have tips and good instructions.
I edited above with poor timing. Sorry.
I was trying to get a new line incorrectly.
Thanks for your example
Your example gave me the idea
input
numMachinesWith0=18
test=["[this]M{0:02d}/M{0:02d}Production/M{0:02d}Gross".format(nineSet)
for nineSet in range(0,numMachinesWith0+1)]
test[0]
test[1]
test[18]
This is why I recommend looking at the tag quality.
In my example I have three tags, ‘Tag 01, Tag 02, and Tag 04’. The processing portion only pays attention to those qualities that are good.
numberOfTags = 4
baseTagPath = '[Test]Tag {0:02d}'
tagPaths = [baseTagPath.format(i) for i in xrange(1, numberOfTags+1)]
valuesIn = system.tag.readBlocking(tagPaths)
print 'Tags In'
for tag, qVal in zip(tagPaths, valuesIn):
print tag, ':', qVal
# Processing
tagsOut = []
valuesOut = []
for tag, qValue in zip(tagPaths, valuesIn):
if 'Good' in str(qValue.quality):
tagsOut.append(tag)
valuesOut.append(qValue.value + 5)
print 'Tags Out'
for tag, val in zip(tagsOut, valuesOut):
print tag, ':', val
numberOfTags = 4
baseTagPath = '[Test]Tag {0:02d}'
tagPaths = [baseTagPath.format(i) for i in xrange(1, numberOfTags+1)]
valuesIn = system.tag.readBlocking(tagPaths)
print 'Tags In'
for tag, qVal in zip(tagPaths, valuesIn):
print tag, ':', qVal
# Processing
tagsOut = []
valuesOut = []
for tag, qValue in zip(tagPaths, valuesIn):
if 'Good' in str(qValue.quality):
tagsOut.append(tag)
valuesOut.append(qValue.value + 5)
print '\n-----------\n\nTags Out'
for tag, val in zip(tagsOut, valuesOut):
print tag, ':', val
Output
>>>
Tags In
[Test]Tag 01 : [10, Good, Mon Feb 28 15:11:26 EST 2022 (1646079086152)]
[Test]Tag 02 : [20, Good, Mon Feb 28 15:11:28 EST 2022 (1646079088784)]
[Test]Tag 03 : [null, Bad_NotFound("Path '[Test]Tag 03' not found."), Wed Feb 16 12:47:37 EST 2022 (1645033657329)]
[Test]Tag 04 : [40, Good, Mon Feb 28 16:05:57 EST 2022 (1646082357934)]
-----------
Tags Out
[Test]Tag 01 : 15
[Test]Tag 02 : 25
[Test]Tag 04 : 45
>>>
Should note, that you don't need the 0 in range(). The start parameter is 0 by default.
#range(start,stop,step)
# start - An integer number specifying at which position to start. Default is 0 (optional)
# stop - An integer runber specifying at which position to stop. Stop is not included in the returned set.
# step - An integer number specifying the incrementation. Default is 1 (optional)
print range(10)
print range(1,11)
print range(1,20,2)
Thanks
I like to say (0,variable+1) for the moment.
I am reading again about the tag provider and tag browser too.
I am building a ship in a bottle without the config access so that nothing I do impacts other hubs.
I really appreciate the tag provider made in the example.
I have a silly question that I am not sure how to look up.
If a script runs once very 50 seconds as a gateway timer script, what is the best way to instead just run it at certain times like at the end of a shift and an hour after the end of a shift?