How to use the template for variable initialization?


#1

Hi,

I have another question about the openECA template created by openECA client.
I am trying to initialize some variables when the Algorithm class is started. For example, deserialize multiple variables from XML file. Currently the only way to initialize it is to create a static constructor.

I remembered in OpenPDC we can override the Initialize() function so I would like to know if the openECA template will also have something similar.

Regards,
Tong


#2

Hi Tong,

I’m assuming you are using a C# template, but the information should be similar regardless. There is a method in Algorithm.cs, the file where you write your algorithm code, called UpdateSystemSettings() that can be used in a similar fashion to the Initialize() method of openPDC adapters. Alternatively, you can modify any of the other classes in the generated project to call an appropriate method for doing this work, however note that any file with a warning comment at the top will be regenerated if you generate your project again. Program.cs is the file that calls the UpdateSystemSettings() method.

As for how this code will be written in a deployed version of the product, the architecture for that is still up in the air and will depend on the target language for the analytic. We expect the structure of the Algorithm.cs class to be similar, though the methods will probably not be static so that the algorithm can be unloaded and reloaded by the service or application at runtime. There will also likely be an optional method to allow disposal of system resources when your algorithm module is unloaded at runtime.

Thanks,
Stephen