Event for the change of the selectino in the Batch Control Master recipe list and Control recipe list

Event for the change of the selectino in the Batch Control Master recipe list and Control recipe list

Summary

In earlier versions of zenon it was not possible to evaluate the selected master recipes or control recipes via the API. This is, however, important for some applications.

Description

In earlier versions of zenon it was not possible to evaluate the selected master recipes or control recipes via the API. This is, however, important for some applications.

Solution

New API events have been introduced to allow to react on selection changes in the two recipe lists.

Information

Here's some sample code to show how to use the new event:

MRSelectionChanged:

VSTA:

// local variable for the batchManager to register the events
private IBatchManager batchManager = null;

void ThisProject_Active()
{
// Register event
batchManager.MRSelectionChanged += new MRSelectionChangedEventHandler(ThisProject_MRSelectionChanged);
}

void ThisProject_Inactive()
{
// unregister Event
batchManager.MRSelectionChanged -= new MRSelectionChangedEventHandler(ThisProject_MRSelectionChanged);
}

void ThisProject_MRSelectionChanged(IBatchMRSelectionChangedEventData eventData)
{
// Get master recipe selection for the screen in which the selection has changed
int[] selectedMRIds = (int[])batchManager.SelectedMRIds(eventData.ScreenName);

// Build an output string
string selectedMRIdsInfo = "Selected MRIds: ";
foreach (int selectedMRId in selectedMRIds)
selectedMRIdsInfo += selectedMRId + "; ";

// Write an output message
System.Diagnostics.Debug.Print("\n" + selectedMRIdsInfo);
}


VBA:

Dim WithEvents zBatchManager As BatchManager

Private Sub Project_Active()
'Register events
Set zBatchManager = thisProject.BatchManager
End Sub

Private Sub Project_Inactive()
'Unregister events
Set zBatchManager = Nothing
End Sub

Private Sub zBatchManager_MRSelectionChanged(ByVal eventData As IBatchMRSelectionChangedEventData)
'Get the MRs of the calling screen
Dim selectedMRIds() As Long
selectedMRIds = zBatchManager.selectedMRIds(eventData.ScreenName)

Dim selectedMRIdsInfo As String
selectedMRIdsInfo = "Selected MRIds: "

'Get the MR Ids data
For i = 0 To UBound(selectedMRIds)
selectedMRIdsInfo = selectedMRIdsInfo & selectedMRIds(i) & "; "
Next i

'Show messagebox with recipe Ids
MsgBox (selectedMRIdsInfo)
End Sub

CRSelectionChanged:

VSTA:

// local variable for the batchManager to register the events
private IBatchManager batchManager = null;

void ThisProject_Active()
{
// Register event
batchManager.CRSelectionChanged += new CRSelectionChangedEventHandler(ThisProject_CRSelectionChanged);
}

void ThisProject_Inactive()
{
// unregister Event
batchManager.CRSelectionChanged -= new CRSelectionChangedEventHandler(ThisProject_CRSelectionChanged);
}

void ThisProject_CRSelectionChanged(IBatchCRSelectionChangedEventData eventData)
{
// Get control recipe selection for the screen in which the selection has changed
object[] selectedCRIds = (object[])batchManager.SelectedCRIds(eventData.ScreenName);

// Build an output string
string selectedCRIdsInfo = "Selected CRIds[CRId | MRId): ";
foreach (object selectedCRId in selectedCRIds)
{
IBatchRecipeId crId = (IBatchRecipeId)selectedCRId;
selectedCRIdsInfo += crId.CRId + " | " + crId.MRId + "; ";
}

// Write an output message
System.Diagnostics.Debug.Print("\n" + selectedCRIdsInfo);
}

VBA:

Dim WithEvents zBatchManager As BatchManager

Private Sub Project_Active()
'Register events
Set zBatchManager = thisProject.BatchManager
End Sub

Private Sub Project_Inactive()
'Unregister events
Set zBatchManager = Nothing
End Sub

Private Sub zBatchManager_CRSelectionChanged(ByVal eventData As IBatchCRSelectionChangedEventData)
'Get the CRs of the calling screen
Dim selectedCRIds() As BatchRecipeId
selectedCRIds = zBatchManager.selectedCRIds(eventData.ScreenName)

Dim selectedCRIdsInfo As String
selectedCRIdsInfo = "Selected CRIds[CRId | MRId): "

'Get the CR Ids data
For i = 0 To UBound(selectedCRIds)
selectedCRIdsInfo = selectedCRIdsInfo & selectedCRIds(i).CRId & " | " & selectedCRIds(i).MRId & "; "
Next i

'Show messagebox with recipe Id
MsgBox (selectedCRIdsInfo)
End Sub



Issue Number: 31958
Fixed on Date: 27.5.2014
Versions: 7.11 0 BUILD 12493 | 7.20 0 BUILD 17768