PDA

View Full Version : Working with CelItems issue



stolyarov_as
15th March 2012, 14:20
Hello!

I try to use CelItems() function of Cel to create alternative CEL Export function (for example export to excel).
with code like
public void Macro_ExportCelToCsv()
{
try
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
Trace.WriteLine("Count = " + this.Cel().CelItems("*").Count);
int count = this.Cel().CelItems("*").Count;
using (StreamWriter sw = new StreamWriter(saveFileDialog.FileName))
{
for (int i = 0; i < count; i++)
{
sw.WriteLine(this.Cel().CelItems("*").Item(i).Class.ToString() + ";" +
this.Cel().CelItems("*").Item(i).Time.ToString() + ";" +
this.Cel().CelItems("*").Item(i).VariableName + ";" +
this.Cel().CelItems("*").Item(i).Tagname + ";" +
this.Cel().CelItems("*").Item(i).User + ";" +
this.Cel().CelItems("*").Item(i).Value.ToString());
}
}
}
}
catch (Exception ex)
{
Trace.WriteLine(ex.Message);
}
}


we get only todays lines of CEL in result report.
How to get CEL lines from preceding days?

markclemens
16th March 2012, 02:30
Hi,

From the online help, see below. It should work when you create a function with a CEL filter, that shows CEL items from the historical files instead of the ringbuffer.

I hope this is helpful :)

You may also want to consider having a look at the built-in CEL export to SQL feature, which may be easier to generate an Excel report from ;) (requires a zenon license for the SQL export module)

Regards,
Mark



Cel.CelItems


CelItems(strFilter As String) As CelItems



Parameters
strFilter As String
A Filter is not implemented yet. To avoid problems in future use always the asterisk...

Example:



Debug.Print zCelItems("*").Count




ED not used
RT read only

Remarks

Object to get all Items are actually in memory...


Filter String:
If the string is not "*", then the string should represent the name (case sensitive) of a zenon function.
If a function with the given name exists, the filter settings within this function will be used.
--> only version 6.51 and above

Sample:

'################################################# #########
'### Get all CEL Items of the project ###
'################################################# #########
Public Sub GetAllItems()
Dim i As Integer
'get all items in memory...
For i = 0 To thisProject.Cel.CelItems("*").Count - 1
'print text of item to outputwindow
Debug.Print thisProject.Cel.CelItems("*").Item(i).Text
Next i
End Sub