# First user-based control locking mechanism \[Ignition 8\]

**URL:** <https://forum.inductiveautomation.com/t/first-user-based-control-locking-mechanism-ignition-8/97025>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 9, 2024, 2:52pm UTC](https://forum.inductiveautomation.com/t/first-user-based-control-locking-mechanism-ignition-8/97025 "2024-10-09T14:52:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Clark](https://avatars.discourse-cdn.com/v4/letter/j/43a26b/32.png) [@Jacob\_Clark](https://forum.inductiveautomation.com/u/Jacob_Clark)\
**Post date:** [October 9, 2024, 2:52pm UTC](https://forum.inductiveautomation.com/t/first-user-based-control-locking-mechanism-ignition-8/97025/1 "2024-10-09T14:52:46Z")

</div>

Hello I have hydraulic controls I am implementing and was hoping to setup some kind of control locking mechanism

For example if a perspective user turns on the hydraulic motor, they are the only ones who can control the hydraulics, on every other perspective session that is not that user the controls for the hydraulics will be disabled

I am doing this because the hydraulics should only be controlled by one person at a time and interference may cause damage and unexpected input (Yes if I can get this working there will be an emergency shut off that any session can use to cut the hydraulics off and release control)

There are 2 ways I have thought about going to solve this problem:

1. Use a while loop to check if the controls are in use and flag a property on the session that is controlling the hydraulics (Would rather avoid this route)
2. Sending a message from a tag change script attached to the hydraulic motor which will trigger a message handler in session events which will send a message to the control components

I have tried 2, I'm not sure if there is an issue with my setup because nothing seems to be happening when I update the tag

Tag Change Script:

```python
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	system.util.sendMessage('plant-fredonia', 'hydraulics')

```

Session Events message handler named hydraulics:

```python
def handleMessage(session, payload):
	system.perspective.sendMessage('hydraulic', {})

```

Component message handler named hydraulic:

```python
def onMessageReceived(self, payload):
	# implement your handler here
	system.perspective.print("Hello World")

```

When the tag value changes:

- I check the browser console I see nothing
- the gateway scripts start up logger is displaying this error: Gateway script MessageHandlerException, project 'plant-fredonia', message handler 'hydraulics': com.inductiveautomation.ignition.common.script.message.MessageHandlerException: The message handler "hydraulics" could not be found! Check your event script message handlers.

Any help or advice would be appreciated!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 9, 2024, 3:18pm UTC](https://forum.inductiveautomation.com/t/first-user-based-control-locking-mechanism-ignition-8/97025/2 "2024-10-09T15:18:25Z")

</div>

See this similar recent discussion:

> [@Closing Vision Window instance on separate clients](https://forum.inductiveautomation.com/t/closing-vision-window-instance-on-separate-clients/96905/2):
>
> This is extremely difficult and fragile, as described. Instead, consider allowing the window to always be opened, but all of its features disabled by default. Then, set up a couple memory tags. One to hold the client ID of the client "in control", and a second to contain a datetime timeout value. Enable the controls on the window while the particular client's ID matches and the timeout timestamp is greater than now(). Use a button on the window to "claim" control by writing the current clie…

That one is for Vision, but a similar technique would be reasonable for Perspective (using session ID instead of client ID).

One big caveat:

If your application needs any kind of jog functionality, **Perspective** cannot do it. (It cannot ensure a jog command turns off when a button is released.) It is non-trivial to make reliable in **Vision** , but is at least _ **possible** _. Search this forum for "Momentary" for detailed discussions of **why**. (Some quite heated.)
