Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

Historian SDK

Storing Events

After you have created either a separate or combined historian connection proxy object, you can start sending events to the historian using HistorianAccess.AddStreamedValue() method.

This method adds a new event into the event data stream for delivery to the historian server. If the connection proxy object was created with store-and-forward support, the caller of this method should not be concerned about whether a live physical connection to the historian is present. The underlying HCAL infrastructure transparently redirects the data flow either to the historian server or to the store-and-forward engine.

The following code snippet illustrates sending 1,000 events.

Example

HistorianAccessError error;
HistorianEvent myEvent = new HistorianEvent();

int events = 0;
for(int i = 0; i < 1000; i++)
{
    myEvent.EventTime = DateTime.Now;
    myEvent.ID = Guid.NewGuid();
    myEvent.Type = "SDKEvent";
    if (!myEvent.AddProperty("Priority", 10, out error))
        break;
    if (!myEvent.AddProperty("IsAlarm", false, out error))
        break;
    if (!myEvent.AddProperty("ValueString", i.ToString(), out error))
        break;
    // ... set other properties here
    if (!historian.AddStreamedValue(myEvent, out error))
        break;
    events++;
}

if (events != 1000)
    Console.WriteLine("Error occured: {0}", error.ErrorDescription);

Every HistorianEvent object can have up to 50 properties settable by the AddProperty() method. The names and types of event properties can be found in the AVEVA Historian Database Reference.