Script in Alarms to stop and pause TOOL

Hi guys,

Is it possible to create a script in alarms that will send a stop command to the tool(secs/gem) when an alarm gets active?

Thanks!

Yes, sure.

In the “Alarm Active” script use the system.secsgem.sendRequest function to send the command to the tool.

Refer to the SECS/GEM Module User Manual to learn about this and other SECS/GEM Module scripting functions.

Best,

[quote=“nmudge”]Yes, sure.

In the “Alarm Active” script use the system.secsgem.sendRequest function to send the command to the tool.

Refer to the SECS/GEM Module User Manual to learn about this and other SECS/GEM Module scripting functions.

Best,[/quote]

Do i just replace the entire function with this?

(sample command to tool)
command = system.secsgem.sendRequest(“S2F41”,True,body,datasource,equipment,prefix)

Thank you for the response!

Correct, although this call still needs to be inside the alarm function. You get back a transaction id, which allows you to check the response sent back from the tool using system.secsgem.getResponse.

Edit- clarification

No, the alarmActive function cannot be replaced. What you do is put your script inside the alarmActive function. When the alarm becomes active the alarmActive function gets called, so anything you put in the alarmActive function will run when alarmActive is called.

alright thanks guys! will try it out :slight_smile:

I was having this error on the alarm after setting up a stop command on the alarmActive script

Error:

Code:

When I looked at the documentation for system.secsgem.sendRequest it takes 5 arguments. In your code you are passing 6 arguments. My version of the SECS/GEM Module is 2.7.3. Try getting rid of the “prefix” argument.

system.secsgem.sendRequest(streamFunction, reply, body, datasource, equipment)

[quote=“nmudge”]When I looked at the documentation for system.secsgem.sendRequest it takes 5 arguments. In your code you are passing 6 arguments. My version of the SECS/GEM Module is 2.7.3. Try getting rid of the “prefix” argument.

system.secsgem.sendRequest(streamFunction, reply, body, datasource, equipment) [/quote]

Hello Nic,

SECS/GEM module is working perfectly because i can start and select recipe on the tool,
but i cannot seem to make the stop command work.
Every time the condition on the alarm is satisfied and it should be executing the stop command,
that is when the error will occur on the tag

Thanks!

Does the stop command work if you put the script on an actionPerformed event of a button?

Yes, the stop command works when i tried it with a button.
but with alarm script its not working.

Okay, one thing I noticed in your earlier code is that you are trying to access client tags in your script, like this one “[Client]ToolID”. That is not going to work in a tag script because client tags don’t exist for non-client tag scripts.

Client tags exist in the runtime client, but other kinds of tags exist in the Ignition gateway and cannot access client tags.

I think this is the problem because system.tag.read("[Client]ToolID").value == None, so the script throws an error because no value is provided for the equipment parameter.

What happens if you replace your client tag reads with hard coded values in your activeAlarm script?

[quote=“nmudge”]Okay, one thing I noticed in your earlier code is that you are trying to access client tags in your script, like this one “[Client]ToolID”. That is not going to work in a tag script because client tags don’t exist for non-client tag scripts.

Client tags exist in the runtime client, but other kinds of tags exist in the Ignition gateway and cannot access client tags.

I think this is the problem because system.tag.read("[Client]ToolID").value == None, so the script throws an error because no value is provided for the equipment parameter.

What happens if you replace your client tag reads with hard coded values in your activeAlarm script?[/quote]

Hard coding the values for the client tags made the stop command work without an error.

any suggestions where i should place the tags?

Thank you for the help!