IP based autologin -Vision

My Home Page:

My Machineboard:

I would like to have the below functionality-

When a person from Buffering-01 area launches the application, machineboard for this machine should display directly with 6 menus above. he should not be able to navigate to other icons.

Similarly when a person from Buffering-02 launches, same applies and he will not be able to view other machine details.

This user login information can be distinguished with their login IP. for eg :if is for Buffering-01, is for buffering-02.

Client event script Used:

ipAddress = system.tag.read("[System]Client/Network/IPAddress").value 
query = """SELECT Process as Process , MachineID as MachineID FROM cdcms.tbl_ip_details where IP_Address=?""" 
userInfo = system.db.runPrepQuery(query,[ipAddress])[0]
window1="Main Windows/Machine/Machine Board"
window2="Main Windows/Machine/Machine Board-East Dock"
window3="Main Windows/Machine/Machine Board-West Dock"
system.nav.openWindow("window1",{"Process":Process},{"MachineID":MachineID} )
system.nav.openWindow("window2",{"Process":Process},{"MachineNo":MachineID} )

I am getting below error:

In your code sample, I don't see a definition for Process or MachineID.

How to assign the results from below query to a variable.

query = """SELECT Process as Process , MachineID as MachineID FROM cdcms.tbl_ip_details where IP_Address=?""" 

Remove the """ from the query. runPrepQuery will pass the data as a string.

query = "SELECT Process, MachineID 
         FROM cdcms.tbl_ip_details WHERE IP_Address = ?"
userInfo = system.db.runPrepQuery(query, [ipAddress])[0]

Process AS Process, etc. is redundant so I've removed the AS parts.

Still i am getting the same error

You will need to create variables and assign the values from userInfo to them.
I'm not where I can test code, but it should look something like this:

Process = userInfo.getValueAt(0,"Process")
MachineID = userInfo.getValueAt(0,"MachineID")
1 Like

The user manual says the syntax is
system.nav.openWindow(path, [params])


    {"Process": Process, "MachineID": MachineID})

Mind your spacing in your code. Standard is no space before punctuation and one space after punctuation. It will improve legibility.

1 Like

It is working now.
What i endup was, writing to the vision tag.

ipAddress = system.tag.read("[System]Client/Network/IPAddress").value 
query = "SELECT Process, MachineID, IP_Address FROM cdcms.tbl_ip_details WHERE IP_Address = ?"
userInfo = system.db.runPrepQuery(query, [ipAddress])
Process = userInfo.getValueAt(0,"Process")
MachineID = userInfo.getValueAt(0,"MachineID")
getIP = userInfo.getValueAt(0,"IP_Address")

if Process == 1:
	vProcess = "Colouring"
	system.tag.write("[client]Screen No", 5)
elif Process == 2:
	vProcess = "Ribboning"
	system.tag.write("[client]Screen No", 7)
elif Process == 3:
	vProcess = "Buffering"
	system.tag.write("[client]Screen No", 2)
vHeader = "Machine Board: " + vProcess+" - "+str(MachineID)

vMachine = vProcess + "-"+ MachineID


if ipAddress == getIP:
	system.nav.openWindow("Main Windows/Machine/Machine Board")
	system.nav.openWindow("Main Windows/Machine/Machine Board-East Dock")
	system.nav.openWindow("Main Windows/Machine/Machine Board-West Dock")
	system.nav.openWindow("Main Windows/Home")
1 Like