Working with Devices & HardwareSetting(s)

Discuss macros to control the hardware functions of your ZEISS microscope
Post Reply
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Working with Devices & HardwareSetting(s)

Post by user-4 »

If you intend to set the status of your hardware via OAD the first step is to have a look at

Zen.Devices.

so that IntelliSense of the Python Editor gives you an idea what is accessible directly.

You will discover that only very view devices are listed. This is because there is a huge list of devices that are available ‘in principle’ but on the other side only a very special amount of devices is combined with your microscope.

To bridge this gab we decided to introduce the HardwareSetting which can be read by

Code: Select all

hardwareSetting= Zen.Devices.ReadHardwareSetting()
The HardwareSetting can be e.g. saved

Code: Select all

hardwareSetting.SaveAs(filename)
and loaded

Code: Select all

hardwareSetting = ZenHardwareSetting()
hardwareSetting.Load(filename)
To get an idea what is in the Setting use something like

Code: Select all

componentIds = hardwareSetting.GetAllComponentIds()

for componentId in componentIds:
    print componentId
    
    parameterNames = hardwareSetting.GetAllParameterNames(componentId)
    
    for parameterName in parameterNames:
        print parameterName
        
        parameterValue = hardwareSetting.GetParameter(componentId, parameterName)
        print parameterValue
To set a paremeter use

Code: Select all

hardwareSetting.SetParameter(componentId, parameterName, parameterValue)
The final step usually is to apply the HardwareSetting with

Code: Select all

Zen.Devices.ApplyHardwareSetting(hardwareSetting)


Please keep in mind, that when you work with

hardwareSetting= Zen.Devices.ReadHardwareSetting()

you will obtain the full set of all devices plus its status.

This might be very correct in certain situations but can also be sort of an overkill when you just intend to modify the status of some selected devices.



There are two main ways to limit your apply to the view devices you want to change.

First of all use

Code: Select all

hardwareSetting = ZenHardwareSetting()
hw.SetParameter('MTBDiracLaser1','IsEnabled', False / Tue)
ZenHardwareSetting() returns an empty container and SetParameter just adds the device plus its status to the HardwareSetting.
Please be aware, that this procedure only works with version 2.6 and later.

Therefore

Code: Select all

Zen.Devices.ApplyHardwareSetting(hardwareSetting)
will just modify the devices you have set.

An alternative is to save a ‘full-blown’ HardwareSetting with

Code: Select all

hardwareSetting= Zen.Devices.ReadHardwareSetting()
hardwareSetting.SaveAs(filename)
and then open the XML-File with an editor and delete all the parts that are not necessary in your case. Please keep in mind that the XML-File must remain valid.

Using the file like

Code: Select all

hardwareSetting = ZenHardwareSetting()
hardwareSetting.Load(filename)
Zen.Devices.ApplyHardwareSetting(hardwareSetting)
also just sets the devices that you have defined.
Alexis Touchet
Posts: 1
Joined: Wed Apr 12, 2023 3:40 am

Re: Working with Devices & HardwareSetting(s)

Post by Alexis Touchet »

Thank you for sharing this workaround.
User avatar
Vlad Veridictovich
Posts: 2
Joined: Tue Jul 11, 2023 11:33 am

Re: Working with Devices & HardwareSetting(s)

Post by Vlad Veridictovich »

tHANKS FOR IT!
Hillary Hillary
Posts: 1
Joined: Wed Sep 27, 2023 5:40 am

Re: Working with Devices & HardwareSetting(s)

Post by Hillary Hillary »

Your information was extremely helpful and solved my problem.
Post Reply