system.opc.setServerEnabled of a remote OPC Server

Have an instance where I need to disable/enable an opc connection on a remote gateway, I assume I'd need to do something other than use the system.opc.setServerEnabled() system function? The remote gateway is back end only, opcua, tag historian and alarm notification.

Set up a message handler on the remote server and then use system.util.sendMessage to send it a message telling it to enable or disable the connection.

1 Like

Thanks Kevin, works great.

For those playing at home, even though it's quite trivial:

Gateway Event Script - Message - "ResetOpcConnection":

def handleMessage(payload):
	bExecute = payload['Execute']
	sOpcConnection = payload['OpcConnection']
	if bExecute:
		system.opc.setServerEnabled(sOpcConnection, False)
		system.opc.setServerEnabled(sOpcConnection, True)

Then running, in my case, on a change script on a one shot button value, so I can include the ever impotant "Are You Sure?":

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if currentValue.value == 1:
		project = self.view.params.opcReset.ignitionProject
		messageHandler = 'ResetOpcConnection'
		payload = { 'Execute': True,
					'OpcConnection': self.view.params.opcReset.opcConnection }
		scope = 'G' #gateway
		remoteServers = [self.view.params.opcReset.ignitionServer]
		system.util.sendMessage(project, messageHandler, payload, scope = scope, remoteServers = remoteServers )
	self.props.value = 0