Musson Industrial's Embr-Periscope Module

Release Notice

Embr v8.1 - 2026.3.3
Embr v8.3 - 2026.3.3

This release includes a scripting function for submitting functions to a Perspective session's queue:

system.perspective.invokeOnQueue(function, [delay], [scope], [sessionId], [pageId])

Parameters

  • function (required)
    A function that will be called with a single parameter:

    • The parameter is the requested scope.
    • This allows access to the view, page, or session if it cannot be captured via a closure.
  • delay (optional)
    Time in milliseconds to wait before invoking the function.

    • Allows scheduling functions to run later.
  • scope (optional)
    Controls the lifecycle of the function relative to Perspective objects. Default is 'view'.

    • 'view': Function runs only if the view is still active after the delay.
    • 'page': Function runs only if the page is still active after the delay.
    • 'session': Function runs only if the session is still active after the delay.
  • sessionId (optional)
    The target session ID.

  • pageId (optional)
    The target page ID.

Examples

Delayed Execution

def myFunction(scope):
    system.perspective.print("Running after 5 seconds. Neat.")

system.perspective.invokeOnQueue(myFunction, 5000) # default scope='view'

Incrementing Counter

This example counts to 50 using view custom properties.

def doThing(scope):
	if self.view.custom.count < 50:
		self.view.custom.count += 1
		self.view.custom.text = 'Counting: %d'  % self.view.custom.count
		system.perspective.invokeOnQueue(doThing, 100)
	else:
		self.view.custom.text = "Done!"
	
self.view.custom.count = 0
self.view.custom.text = "Waiting to start...."
system.perspective.invokeOnQueue(doThing, 1000)

Incrementing Counters (across all sessions)

This example counts to 50 using session custom properties. The functions will be run across all client sessions using scope='session' and sessionId parameters.

def makeHandlers(sessionId):
    def doThing(scope):
        if scope.custom.count < 50:
            scope.custom.count += 1
            scope.custom.text = scope.custom.count
            system.perspective.invokeOnQueue(doThing, 100, scope='session', sessionId=sessionId)
        else:
            scope.custom.text = "Done!"
	
    def setup(scope):
        scope.custom.count = 0
        scope.custom.text = "Waiting to start...."
        system.perspective.invokeOnQueue(doThing, scope='session', sessionId=sessionId)
	
    return setup
	
	
sessions = system.perspective.getSessionInfo()
	
for session in sessions:
	# Simple way to filter out designer sessions
    if len(session.id) < 36:
        continue
	
    setup = makeHandlers(session.id)
    system.perspective.invokeOnQueue(setup, 1000, scope='session', sessionId=session.id)

New Sponsors

Big thanks to both @David_Stone and @andrew.budaiev for sponsoring this project!
If you're interested in contributing, check us out on GitHub Sponsors.

8 Likes