Applies To:
  • CitectSCADA  5.XX
  • CitectHMI  5.XX

Summary:
How long are trend samples held in the trend server's cache before they are written to disk? Sometimes data is lost when Citect shuts down.  

Solution:
The trend server creates a separate cache for each trend tag according to the trend cache parameter(s) in the Citect.ini file. Once the cache fills up the data is written to the trend history files. In Citect 5.31 and later there are 9 possible cache sizes, depending on the sample rate of the trend tag. The sizes are set by the [Trend]CacheSize<x> parameters (where x is 0 to 8). In Citect 5.30 and older there is only one cache size used for all trend tags. Its size is set by the [Trend]TrendBufSize parameter.

For example, if a trend tag's sample rate is 15 minutes its cache size would be 128 samples in Citect 5.31 and higher. This is the default size for [Trend]CacheSize8, which applies to all trends with sample rates of 100 seconds or more. So, this trend tag would take 32 hours to fill the 128 sample cache. It does not matter how many trend tags there are since each one gets its own cache. If the sample rate was 100 seconds it would only take about 4 hours to fill it.

It is possible for samples to be held in the cache longer than expected if some samples were missed. For example, if an event trend was configured with a sample rate of 5 minutes it would have a 128 sample cache which should fill up in 10 hours 40 minutes. But if the trigger event only happened every 15 minutes it would take three times as long to fill the cache as expected. Once the 10h 40m expired, the data would be considered stale. After the data is stale for half of the next cache period it is written to disk--in this case a total of 16 hours from when the first sample was recorded.

If you feel the cache is not the optimal size for your trend tags, you can adjust the cache size parameters mentioned above. Be aware that each CacheSize<x> parameter applies to a range of sample rates (and TrendBufSize in 5.30 and older applies to all trend tags). For example, CacheSize5 is used for all trend tags with sample rates between 10 and 20 seconds.

Trend caches are also written to the trend history files when Citect shuts down. However, if you log off of Windows while Citect is running, data may be lost. Citect will only allow Windows to shut down or log off while Citect is running if you have enabled the [Kernel]WinShutdown parameter. This is meant for use when Citect is running as a Windows service and you want it to continue running after you log off. If you actually shut down the PC or log off while Citect is running normally (not as a service), Citect may not write all data to disk. This has been fixed in Citect 5.50. To take advantage of this you would use mode 2 or 3 (instead of 1) with the WinShutdown parameter.

[KERNEL] WinShutdown Parameter (Citect 5.50 and later)

Allowable Values:

0 - the current default behaviour of citect.

1 - this mode is unchanged to that of previous versions. i.e. it will allow shutdown/logoff/reboot but some loss of data may occur.

2 - Citect will perform a clean shutdown and will reboot by default. Logoff requests will be performed as requested.

3 - Citect will perform a clean shutdown and will powerdown by default. Logoff requests will be performed as requested.

4 - Citect will perform a clean shutdown but Windows will continue running unaffected by any requests to shutdown/reboot. Logoff requests will be performed as requested.

 

Keywords:
 

Attachments