Tag properties

how do I reference a memory tag in a gateway script and can I create a user defined tag that will function as a display stack to keep track of my tag changes? I am trying to avoid using a database or historian function since resolution is important to me.
I would like to know if using a list with a fixed length and appending my tag changes as strings will be a good idea for my application.

You can store tag changes in a string tag. First you need to create a Gateway Tag Change script that listens on any tag you want to track changes on. The script would get the value and store it in the tag. You can read memory tags in gateway scripts like this:value = system.tag.getTagValue("Path/To/MemoryTag")You can write to memory tags in gateway scripts like this:system.tag.writeToTag("Path/To/MemoryTag", "SomeValue")Your tag change script will be something like:[code]value = newValue.value
tagPath = str(event.tagPath)
timestamp = newValue.timestamp

currentTrack = system.tag.getTagValue(“MemoryTagString”)
currentTrack += “%s;%s;%s\n” % (tagPath, timestamp, value)
system.tag.writeToTag(“MemoryTagString”, currentTrack)[/code]You may have to change it a bit but hopefully you see the idea.

thanks. I will give this a try and see how things go.

I did some looking around and I hope I am not missing something but could you give an example of what you mean by Path/to/Memorytag? When you create a memorytag there is no path. How do you determine a path when you reference it?

This is my playground code:
import app
app.Winchester.Logger.post(‘oopsie’)

here is the function within my module:

def post(Message):
import system, datetime
now = datetime.datetime.now()
timeStamp = str(now)
nameDateFile = now.strftime("%Y%m%d")
filename = “c://Users//AJ//%s.txt”%(nameDateFile)
system.file.writeFile(filename, ‘\r\nIT’S %s %s’ %(timeStamp[0:23], str(Message)), 1)
#tagPath = str(event.tagPath)
#timestamp = newValue.timestamp
currentTrack = system.tag.getTagValue(“MemoryTagString”)
currentTrack += “;%s;%s\n” % (timeStamp[0:23], str(Message))
system.tag.writeToTag(“MemoryTagString”, currentTrack)

The script prints 1 to my screen.
I get an error saying:
Error writing to tag.
Gateway comm is not read/write.

I’ve created the tag “MemoryTagString” to be a memory type and string type.
The value is 0 and it is READ/Write.

That means that you are trying to run the script in the designer and the designer is in read-only mode. In the toolbar you will see three buttons where the middle one is selected right now. Select the third one labeled “Read/Write” and try the script again.

for i in range(4):
Tag[i] = Tag[i+1]
Tag[4] = Message
system.tag.writeToTag("Tag…
Can I do something like this to quickly modify the number of tags i keep track of…
how can I adapt string arrays here? Is there a better way to do this?

now I am struggling to understand if I will be able to use datasets as string arrays like so…
def post(Message):
import system, datetime
now = datetime.datetime.now()
timeStamp = str(now)
nameDateFile = now.strftime("%Y%m%d")
filename = “c://Users//AJ//%s.txt”%(nameDateFile)
system.file.writeFile(filename, ‘\r\nIT’S %s %s’ %(timeStamp[0:23], str(Message)), 1)
#tagPath = str(event.tagPath)
#timestamp = newValue.timestamp
currentTrack = system.tag.getTagValue(“MemoryTagString”)
currentTrack += " %s %s" % (timeStamp[0:23], str(Message))
system.tag.writeToTag(“MemoryTagString”, currentTrack)
data = []
data.append(currentTrack)
newstringset= dataset.dataset(data)

What am I missing here?
The documentation I’ve read on datasets does not seem to link the scripting to the datasets I see in the designer. I just need one column that can display string variables from most recent to 50 changes old with an easy way to scale the number that I store.

In order to create a dataset do the following:data = [] data.append([currentTrack]) newdataset = system.dataset.toDataSet(["Current Track"], data)