This example shows how to use Bulkmode with C#
private void ThisProject_Startup(object sender, EventArgs e)
{
try
{
Array.Resize(ref strVariables, this.Variables().Count);
//File Array with Variables
for (int i = 0; i < strVariables.Length; i++)
{
if (this.Variables().Item(i).Name.Equals("Intern_Variable_UINT_1")) {}
else
{
strVariables[i] = this.Variables().Item(i).Name;
}
}
///Create OnlineContainer
zOLV = this.OnlineVariables().Item("myOLV");
if (zOLV == null)
{
zOLV = this.OnlineVariables().CreateOnlineVariables("myOLV");
}
///Add Array to Bulk Container
zOLV.AddBulk(ref strVariables);
zOLV.ActivateBulkMode();
zOLV.Define();
zOLV.VariableBulkChange += new zenOn.VariableBulkChangeEventHandler(zOLV_VariableBulkChange);
}
catch (Exception ex)
{
System.Diagnostics.Debug.Print("ERROR ThisProject_Startup:" + ex.Message + " " + ex.Source);
}
}
private void ThisProject_Shutdown(object sender, EventArgs e)
{
try
{
zOLV.VariableBulkChange -= new zenOn.VariableBulkChangeEventHandler(zOLV_VariableBulkChange);
zOLV.Undefine();
this.OnlineVariables().DeleteOnlineVariables("myOLV");
}
catch (Exception ex)
{
System.Diagnostics.Debug.Print("ERROR ThisProject_Startup:" + ex.Message + " " + ex.Source);
}
}
///
///
///
/// Object Array with zenonVariable Types
/// Double Array Variable ID
/// Double Array Variable Value
/// State Low as Double Array
/// Stat High as Double Array
/// Timestampe of the Variable as Double Array
void zOLV_VariableBulkChange(ref object pvVars,
ref object pvPvIDs,
ref object pvValues,
ref object pvStatesLo,
ref object pvStatesHi,
ref object pvTimes)
{
try
{
Object[] zpvVars = (Object[])pvVars;
double[] zpvPvIDs = (double[])pvPvIDs;
Object[] zpvValues = (Object[])pvValues;
double[] zpvStatesLo = (double[])pvStatesLo;
double[] zpvStatesHi = (double[])pvStatesHi;
DateTime[] zpvTimes = (DateTime[])pvTimes;
for (int i = 0; i <= zpvVars.GetUpperBound(0); i++)
{
//Cast Object of the Array to zenon Variable Type
Object ix = zpvVars[i];
zenOn.IVariable myTest = (zenOn.IVariable)zpvVars[i];
///Get Type
System.Diagnostics.Debug.Print(myTest.GetType().ToString());
System.Diagnostics.Debug.Print(zpvPvIDs[i].GetType().ToString());
System.Diagnostics.Debug.Print(zpvValues[i].GetType().ToString());
System.Diagnostics.Debug.Print(zpvStatesLo[i].GetType().ToString());
System.Diagnostics.Debug.Print(zpvStatesHi[i].GetType().ToString());
System.Diagnostics.Debug.Print(zpvTimes[i].GetType().ToString());
///Get Values
System.Diagnostics.Debug.Print("Variable name: " + myTest.Name);
System.Diagnostics.Debug.Print("Variable ID: " + zpvPvIDs[i].ToString());
System.Diagnostics.Debug.Print("Variable Value: " + zpvValues[i].ToString());
System.Diagnostics.Debug.Print("State Low: " +zpvStatesLo[i].ToString());
System.Diagnostics.Debug.Print("State High: " + zpvStatesHi[i].ToString());
System.Diagnostics.Debug.Print("Timestampe: " + zpvTimes[i].ToString());
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.Print("ERROR zOLV_VariableBulkChange:" + ex.Message + " "+ ex.Source);
}
}
If you add the EventHandler before you call the Define will not make sence. Because without OnlineContainer the EventHandler will not triggert. The EventHandler will triggert after the call of Define.

Originally Posted by
mvj
Hi
Do you have an example using Bulk mode?
What happens if you add the EventHandler before the call to Define? Will the event automatically be called when/after Define is called? It should since it changes from "nothing" to a value, right?
Best regards
Michael