This project has moved and is read-only. For the latest updates, please go here.

Is there an example of the Time Series Framework running as a service?

Mar 29, 2011 at 4:42 PM

I downloaded the openPDC source and have been trying to find an example of using the ServiceHostBase classes to contain an instance of the TimeSeriesFramework architecture.

Although the historian project has services, these are not Windows services, and do not use the base class.

I've tried some "exploratory" coding but keep hitting walls (indicating my understanding is flawed).

E.g. The ServiceHostBase has three collection class members for Input, Action and Output adapters. These are read only references, and are null. So something must trigger the creation of the collections and allow for adapters to be installed. So far, I've not been able to work out what that is.

Additionally my earlier post regarding the connection of adapters - I still don't know how this is implemented - the ConnectionString property looks promising, but I don't know how to use it.

I might well be missing some documentation somewhere - the tab on codeplex is empty, as is the /documentation folder in the download.
Is the documentation available?



Mar 29, 2011 at 8:26 PM

The example that uses the class can be found in the openPDC:

      <openPDC root source folder>\Synchrophasor\Current Version\Source\Applications\openPDC\openPDC\ServiceHost.cs

This class inherits the base class for hosting a service or an application (if running in Debug mode).

You may be a little disappointed by the lack of code here though, not much to see as all the real work is done in the time-series library.

The openPDC is simply a "shell" hosting the framework as a service or application.

The code you are looking for can be found here:

      <TSF root source folder>\Main\Source\Libraries\TimeSeriesFramework\Adapters\AdapterCollectionBase.cs

In this code look at the TryCreateAdapter - this is where the magic of all "adapter creation" happens.

The place where all this gets kick started is in the InitializeSystem method found in:

      <TSF root source folder>\Main\Source\Libraries\TimeSeriesFramework\ServiceHostBase.cs

 In the InitializeSystem method you will find the following steps:

   if (LoadSystemConfiguration())

The LoadSystemConfiguration method loads a DataSet from a database, XML file or web service. This DataSet can be any serialized set of data tables for use by the adapters. When loaded from a database the DataSet is created from a root table called ConfigurationEntity. This defines the tables of the DataSet, three of which are required: InputAdapters, ActionAdapters and OutputAdapters. Any other defined tables are optional from the Time-series Framework perspective but can be required by certain adapters being loaded.

The DataSet is where the "definition" of which adapters to load is defined - that is, the adapters that need to be load are defined in the DataSet (see C:\Program Files\openPDC\ConfigurationCache\SystemConfiguration.xml for an example of a serialized XML DataSet).

Look at the Initialize method in the AdapterCollectionBase.cs, this is where the DataSet (referenced as the "DataSource" property in the code) is "inspected" to see which adapters should be loaded - in this method you will see the aforementioned "TryCreateAdapter" being called for every adapter defined in the data table associated with this collection (i.e., input, action or output).

This is bascially how all adapters are "birthed".

Mar 30, 2011 at 2:47 PM

Thanks very much - I will take a look.

After thinking about it last night I came to the conclusion that the adapters must be loaded from configuration somewhere, this helps a lot.

(I actually did a "find in files" on the openPDC looking for the ServiceHostBase - but it only turned up XML files.)