How can I change an alarm setpoint using a script action?

I am trying to configure a script action on a button so that the following occurs when it is pushed:

  • it gets the current value of a nearby numerical field entry box
  • it writes that value to the setpoint of an alarm on a tag (the tag path will be dynamically selected using a system of parameters)

I know how to bind an alarm’s setpoint to a memory tag, but I don’t want to go that route because then I would have to create a bunch of new individual memory tags for every setpoint of every alarm. I want to be able to call the setpoint of an alarm directly through an address.

I found this post from a few years ago but I think it’s outdated (system.tag.editTag doesn’t seem to exist anymore)

I’ve tried using writeBlocking to do it, like this:

        newvalue = self.getsibling('NumericEntryField').value
	newvalue_as_list = [newvalue]
	setpointPath_as_list = [{self.view.params.tag_alarm_path}.setpointA]
	SP_write = system.tag.writeBlocking(setpointPath_as_list, newvalue_as_list, 5000)

It didn’t throw any debug errors but it didn’t work either.

8.0 has system.tag.configure().

I found it easier to get the tag configuration, modify it, then write the configuration back.

tagName = '[default]path/to/tag'

tagConfig = system.tag.getConfiguration(tagName)

tagConfig[0]['alarms'][0]['setpointA'] = newValue

system.tag.configure('', tagConfig)
2 Likes