Advanced programming


As you have already learned, the properties of ACComponent classes are the IACPropertyBase implementations. IACPropertyBase has the property PropertyLogListInfo LiveLog. PropertyLogListInfo, in turn, is a property that can store a series of property values.

The first time you access LiveLog, a property logging mechanism is automatically activated. Every time the property value changes, the new value is written to a ring buffer. You access the values ​​of this ring buffer using the LiveLogList property. The standard capacity of the ring buffer is 500 values. However, you can change this value in the iPlus development environment in the "Log buffer size" field:

 

The values ​​saved in the ring buffer is of type PropertyLogItem.

public class PropertyLogItem
{
  public DateTime Time { get; set; }
  public object Value { get; set; }
}

The LiveLogList property is of type PropertyLogRing:

public class PropertyLogRing : PropertyLogRing<PropertyLogItem>
{
public PropertyLogRing() : this(500) { }
}

The ring buffer implements the INotifyCollectionChanged interface so that value changes can be transferred to other classes via event:

public class PropertyLogRing<T> : INotifyCollectionChanged, IList<T>
{
}

The control element VBChartControl , for example, is such a class that reacts to value changes and displays the logged values ​​on the GUI as a line chart.

Here again the class  PropertyLogListInfo:

public class PropertyLogListInfo : INotifyPropertyChanged
{
public PropertyLogRing LiveLogList {get;}
public IList<PropertyLogItem> PropertyLogList {get;}
}

PropertyLogListInfo can not only save live values, but also provide archived values ​​from a long-term archive. Use the PropertyLogList property to read the property values ​​because PropertyLogListInfo makes either live values ​​or archived values ​​accessible via it.


Property values ​​can also be stored in long-term archives. To do this, the update rate must be set in the iPlus development environment (see picture above). Set a threshold value in the "Log Filter" field so that not every marginal change in value is persisted. This is particularly useful for double and float values.

Archived property values ​​are queried using method

PropertyLogListInfo GetArchiveLog(DateTime from, DateTime to)

which is defined in the IACPropertyNetBase interface. The return value is an instance of PropertyLogListInfo that you have already seen in the previous section.

Long-term archives are implemented using PersistentDictionary, which in turn uses the high-performance ESENT database engine. The PersistentDictionary is basically a binary file. That is why it must be specified for each application project in which directory the ESENT files are to be stored or saved. Enter the path in the iPlus development environment for the root element in the "ArchivePath" property:

Archives are kept for three months. Older months are automatically deleted so that the hard drive usage remains constant. If you require longer archiving periods, you can set this using the "DeletePropLogAfterXMonths" property in the "LoggingConfiguration" section in the configuration file.

Long-term archives can be displayed  as a line diagram using the VBChartControl control element  .