PG2: read the computer name on which the PG2 is displayed
Can I read in a PG2 the computer name of the computer on which the PG2 is displayed? With this information I want enable/disable Buttons computer dependent.
Voted best answer
Don't think this is possible.
But with Security Definition aspects you can control a property to be readable/writeable only on certain nodes.
I also think PG2 can evaluate if a property is writeable using a subproperty (type hash "#" after the property name) and I suppose "IsWritable" or something similar appears.
Don't hesitate to ask your sales representative to forward a request for what you need; eg reading the hostname (which I believe exists as a environment variable in Windows).
It worked for me this way: (Tested on Server2008R2 64 bit, 5.1FP4 but I believe it will work on all)
1. Create an Aspect "simple scripting aspect" on the object where you have Graphic Display aspect.
2. Write following VBscript:
Set objNet = CreateObject("WScript.Network")
ComputerName = objNet.ComputerName
3.Expose this property as OPC Read on Presentation tab.
4. This property is available in the Graphics builder as a property of the Object.
$'pr::.:Simple Scripting Aspect:ComputerName'
"I want enable/disable Buttons computer dependent."
This is the wrong approach. And if you try to make it work this way it will break when one of your computers fails and you have to replace it with another workstation. Security in an 800xA system is done by User, not by computer. You need to ...
- Create separate operator accounts based on the priveledges you require in each area of the plant
- Create Security Definition Aspects that define which users can do a particular operation
- Create "Property Attribute overide" aspects if required to change the default AC800M object security.
- Use the "write enabled" property of an OPC value to enable or disable functions.
- If absolutely required you can also restrict which users can log onto a workstation using a windows security policy, but really, having separate operator accounts should be all that you need.
Because your security is based on the user identity, if there is a problem with your workstation at 2am, the operator can simply use another worksation somewhere else in the plant.
Finally, using "pushbuttons" directly on an operator screen is something you should really avoid. It is far too easy for page links and pushbuttons to become confused. Any push button operation like this should always open a pop up confirm / cancel dialog. There are details on how to do this in the Graphics builder manuals.
I think I must describe the goal better:
We want in the workplace a possibility to logoff the windows user.This should be for all 800xA clients possible, but not for aspect/connectivity servers.
Our concept is:
In a Windows Application Aspect, we reference to a Batch-File, which logoff the windows user. The Windows Application aspect is calling from a PG2 verb button.For the aspect/connectivity servers should be the button disabled (Whatever user is logged in).
The method from elemravi works well, but we would prefer a solution without VB-script.