Getting Device Host Names

Anyone know of a way to get the Hostname for a device?

I can set it with system.device.setDeviceHostname. But I don’t see a way to get the Hostname or other configuration information for the OPC devices (other than the bit of information from system.device.listDevices)

Thanks

There’s no corresponding getDeviceHostname or any other easy way to do it that I can think of. I think we need to add it, even though I don’t think either of them should be part of the scripting API.

Begin rant: the fact that setDeviceHostname snuck its way into Ignition in the first place via the now defunct IA Labs scripting module irks me. Devices can in theory be anything, including a thing that doesn’t even have a hostname or anything close. Not only that, it relies on an implementation detail of each device, which is that the device has to call its “Hostname” property “Hostname” and use that column name in the internal DB. It’s bad all the way down.

In 8.0, all devices will fully expose their configuration in the address space, and you’ll be able to read or write those values as you wish to change configuration (assuming the proper access rights from the the write originates from).

edit: Summary: I made a ticket, system.opc.getDeviceHostname might appear in 7.9.2.

Thanks for the quick reply Kevin. I just thought it was odd that you can add a new device or change just one of the configuration parameters for a device (setDeviceHostname) but couldn’t get the configuration from a device.

If I can rant for a second…It would be nice if there was a little more consistency in the implementation of some of these scripting function. For example system.device.listDevices returns a tidy dataset with the device names, enable,state,and driver. To get the same information for the OPC servers you first have to call system.opc.getServers then iterate through the return list and call system.opc.getServerState and system.opc.isServerEnabled to get the equivalent information.

It also seemed odd to me that system.device is it’s own scripting subset. Why not put those function under system.opc for example why not system.opc.listDevices?

Enough ranting, thanks again for your prompt reply.

The system.device functions have origins in the IA Labs module, which was originally kind of a “release valve” for design services when they needed advanced functionality that didn’t exist. There’s no consistency because there was no upfront design or forethought in most of these functions; they sprang to life out of necessity when needed.

There might be something to the idea of a system.opc call that gives you a dataset of information about the connections though… will have to think about that.

Now that we have the ability to get the Device Hostname, is it possible to pull the hostname for all of the configured OPC-UA devices? Or is it possible to add it as a column in the listDevices() scripting function?

UPDATE I should narrow this request to add Hostname to the listDevices() srcipting function, so that it be added as another column:

Name , Enabled , State , Driver & Hostname

Not all devices have a hostname property.

This is understood. Are you saying that because not all devices in the device list may not have a Hostname property, that it cannot be included in the listDevices() script?

That’s probably why it wasn’t included in the results of that function. Right now it returns a few attributes that are universally applicable to all driver instances. Hostname is veering into driver-specific territory.