Change workbench by means of OAD

In this subforum specific Topics concerning ZEN Core, e.g workbenches, are discussed
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Change workbench by means of OAD

Post by user-6033 »

Hi,
If I use macro as a step in the workflow created in a template then I can use stepback to reach the precedent workbench. Can I change workbench anyhow in Free Mode? For example If I setup a workflow in freemode and would like the user to manually do something in a workbench different from the OAD module. I have tried different options. A running macro stops if one manullay changes workbench while macro is in pause-mode and I have not found any way to change workbench programmatically.

I have one short other question as well. When aquiring an image is it automatically added to the Documents collection? If I check Documents.Count before and after acquiring an image I get 0 and 1, respectively. And if I use Documents.Add(image) and check Documents.Count I get 2.

Best regards
Fredrik Olsson
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

I have not found any way to change workbench programmatically
This would be a nice OAD-feature in the future but I'm sorry, this is not possible at the moment in ZEN core.


Please do not use the documents collection in ZEN core.
This is a vital part from ZEN blue which is not supported in ZEN core.
Thus the docuents collection will 'disappear' in future versions of ZEN core.
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Hi

Trying a changed macro in the job is a little slow since removing the OAD task, re- adding a new OAD task and choosing the same macro tend to reload the old macro version instead of the new one. To empty the memory I restart the software or load another macro before re-loading my target macro. So developing in freemode is for me faster but then I can not make use of other workbenches.

I use the document collection for one task and it is for showgrid(). If I only make use of ActiveDocument and then either prior to that, or subsequenly use image.Graphics.Showgrid() nothing appears, but if I first add the image to the Documents, then it works. So please do not remove the Document collection before letting us know how to show the grid. :)

I use interactive measurement workbench in my workflow with OAD support in the next step. I would prefer to use Markers in the interactive workbench but I am stuck at when running the job then the user can not freely add as many markers as the user want in a quick way. One is limited to the number which is set for the job setup. One may add unlimited markers but have to first add the marker workbench, put the marker on the image and repeat these two steps until all markers are added, which of course is very slow... Any suggestion? I might use events as a workaround but then need to extract each point info from the measurementtext in several steps with OAD.

Best regards
Fredrik Olsson
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Trying a changed macro in the job ...
As far as I understand your requirement, the idea is to change the behavior of an OAD workbench within a workflow. Although a real exchange of the macro is not possible programmatically, it might be a solution to change the behavior by parameter.

Code: Select all

def macro0():
  …
def macro1():
  …
def macro2():
  …

if parameter == 0:
    macro0()
elif parameter == 1:
    macro1()
else:
    macro2()
To create a workflow that supports this ‘switching between macros’ the parameter can be set in a previous workbench like

Code: Select all

Zen.Application.ActiveWorkbench.SetOutputValue(1,"parameter")
and in the macro workbench the parameter is read by

Code: Select all

parameter = Zen.Application.GetLastOutputParameterValue("parameter")
An alternative could be to save the parameter in a textfile and read the parameter from the textfile when the macro starts.
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

interactive measurement workbench the user can not freely add as many markers as the user want in a quick way
This is only possible in 'Free Examination'.

If this is no alternative to you please have a look at 'events' instead of 'markers'.

For configuration of events (and markers) see 'Manage Features for Graphical Elements'.
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Showgrid()
Please have a look at the two code-examples:

Code: Select all

## show grid works with live image
image = Zen.Acquisition.StartLive()
Zen.Application.ActiveDocument = image
image.Graphics.ShowGrid()
snap = Zen.Acquisition.AcquireImage()
Zen.Application.ActiveDocument = snap
#image.Graphics.HideGrid()
image = Zen.Acquisition.StopLive()

Code: Select all

## show grid works with continous image
image = Zen.Acquisition.StartContinuous()
Zen.Application.ActiveDocument = image
image.Graphics.ShowGrid()
#image.Graphics.HideGrid()
image = Zen.Acquisition.StopContinuous()

I hope this shows alternative ways with ShowGrid().
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Hi,

This is related to the Events and markers in interactive workbench:

I can use Events instead. However, there seems to be an issue with "Events" and using MeasureToTable. Markers, Lines and Events shows up perfectly in the Result Table in the Interactive Workbench. If I have the OAD workbench after the interactive workbench in my flow then lines and markers also shows up in the OAD workbench when getting the image from the Zen.Application.Get... , using Table1 = Zen.Measure.MeasureToTable(image) and setting activedocument = Table1. Events behaves differently. Most of the times it does not reach the table in the OAD. Occasionally it shows up when Events is not the last measurement in the interactive workbench, other measurements like marker or lines have been added after events. This means I am not able to easily get the event parameters from the table, but I can reach them directly from the graphics in the image and extact the different parameters from the multiline textfield.


Best regards
Fredrik Olsson
user-6033
Posts: 89
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6033 »

Hi,

This is related to Showgrid():

I was able to have the grid visible in the acquired image but it was not obvious... See below. But the next problem is that I do not see any way to transfer the acquired image directly to the next workbench which can be the interactive workbench. I have tried with setting the image as output value, I have it as the active document, but when the OAD script is finished and I change to next step in my workflow the active document area clears and there is not workspace area such as the output area in the free examination mode. I can pass an image to another macro but how to pass it to another ordinary workbench? When going from a workbench such as Aquire image then the image stays in the active document workspace so then there is no problem.


Three attempts to have the grid visible after aquiring the image.

1.
image = Zen.Acquisition.StartLive()
Zen.Application.ActiveDocument = image
image.Graphics.ShowGrid()
snap = Zen.Acquisition.AcquireImage()
Zen.Application.ActiveDocument = snap
#snap.Graphics.ShowGrid()
Zen.Application.Pause('Wait')
Zen.Application.ActiveWorkbench.SetOutputValue(snap, 'S1')
Zen.Acquisition.StopLive()

Result
Apply in Free Examination: Grid is not visible
Workflow: Grid is not visible

2.
image = Zen.Acquisition.StartLive()
Zen.Application.ActiveDocument = image
image.Graphics.ShowGrid()
snap = Zen.Acquisition.AcquireImage()
Zen.Application.ActiveDocument = snap
snap.Graphics.ShowGrid()
Zen.Application.Pause('Wait')
Zen.Application.ActiveWorkbench.SetOutputValue(snap, 'S1')
Zen.Acquisition.StopLive()


Apply in Free examination: Grid is visible
Workflow: Grid is visible


3.
image = Zen.Acquisition.StartLive()
Zen.Application.ActiveDocument = image
#image.Graphics.ShowGrid()
snap = Zen.Acquisition.AcquireImage()
Zen.Application.ActiveDocument = snap
snap.Graphics.ShowGrid()
Zen.Application.Pause('Wait')
Zen.Application.ActiveWorkbench.SetOutputValue(snap, 'S1')
Zen.Acquisition.StopLive()

Result
Apply in Free examination: Grid is not visible
Workflow: Grid is not visible
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

any way to transfer the acquired image directly to the next workbench
Hello Fredrik Olsson,

did you try (to the next workbench)

Code: Select all

Zen.Application.ActiveWorkbench.SetDefaultOutputValue(Image)
or (from the previous workbench)

Code: Select all

Zen.Application.ActiveWorkbench.GetDefaultInputValue()
user-4
Posts: 397
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

there seems to be an issue with "Events" and using MeasureToTable
Hello Fredrik Olsson,

sorry, but we cannot reproduce your case. We used ZEN 2 Core 2.5 HF4.

Our workflow consists of the following workbenches:

1 Load Image
2 Interactive Measurement (Line, Line, Events, Marker)
3 Macro (MeasureToTable, SetDefaultOutputValue(table))


Everything worked fine ...
Post Reply