A toolkit for filtering and data processing in WinCC OA Oliver Holme
Filtering needs Current filtering possibilities Simple procedures provided by WinCC OA Smoothing (time, deadband, old/new comparison) Available only in drivers and archiver Custom code with dpConnect() of timedFunc() More filtering can be useful sometimes Smoothing noisy data, reducing update rate Avoid further load downstream (FSM, dpConnects, alarms) Beyond filtering - analysis and characterisation of a signal e.g. RMS calculation or value change detection/counting Oliver Holme 10/06/2014
Toolkit concept Avoid duplicated implementations doing similar things Eliminate the need to write any filtering code for most cases Only configuration required (setting up a config DP) Write and test filters once, then use many times Hopefully reduce errors Provide facilities to extend the set of filters if required Central place for data processing – fewer obscure CTRL scripts Oliver Holme 10/06/2014
Default filter set Provides a standard set of configurable filters Spike filter(min_spike_size, spike_length) Low pass filter(time_constant) Mean(window_length) – sliding window Median(window_length) – sliding window Kalman filter(q, r) Also some examples of analysis and rate reduction RMS(window_length) Sample and hold() – to sample a data stream Value change detection() – can act as a simple watchdog Limitations: Single input and single output DPE But either or both can be dyn_... types Oliver Holme 10/06/2014
Chains can contain any number of filters How it works Defining a “filter chain”: Filter definitions are saved into one or more filter config DPs A CTRL manager runs a script to perform the filtering One manager can handle one (-filter_dp_config <DP>) or all config DPs Load can be shared across many managers Input DPE Filter 1 Filter N Output DPE Choose polling or “on change” Chains can contain any number of filters Oliver Holme 10/06/2014
What exists now The filtering script The default filter set (See slide 4) Functions to configure the config DPs: CMS_ECALfw_Filtering_createFilterDetailString() CMS_ECALfw_Filtering_createFilterChainObject() CMS_ECALfw_Filtering_saveFilterChain() CMS_ECALfw_Filtering_removeFilterChain() Visualisation panel Shows configuration (no editing) Live input/output view with plot Oliver Holme 10/06/2014
Oliver Holme 10/06/2014
Adding new filters First three arguments must be: key – a unique identifier of “this” step in a filter chain value – the new value of the process variable timestamp – the timestamp that the value was read* Additional arguments for filter configuration Persistent information can be saved for next iteration: CMS_ECALfw_Filtering_setVariable(key, variable, value) CMS_ECALfw_Filtering_getVariable(key, variable, value) Persistent value is of type mixed Return value is the output of the filter step (type: mixed) To return “nothing”, return CMS_ECALfw_Filtering_NONE * time of polling for polled values or DPE timestamp in case of “on change” Oliver Holme 10/06/2014
Example – Sliding Mean Get previous state Manipulate Save state mixed CMS_ECALfw_Filtering_SlidingMean( string key, mixed value, time timestamp, int window, bool outputAtStartup = false) { mixed output = CMS_ECALfw_Filtering_NONE; //load previous sliding window contents dyn_mixed buffer; CMS_ECALfw_Filtering_getVariable(key, "buffer", buffer); //append latest value and remove the first dynAppend(buffer, value); if(dynlen(buffer) > window) dynRemove(buffer, 1); //save the sliding window contents for next time CMS_ECALfw_Filtering_setVariable(key, "buffer", buffer); //determine and return mean value if(outputAtStartup || (dynlen(buffer) == window)) output = dynAvg((dyn_float)buffer); return output; } Get previous state Manipulate Save state Generate output Oliver Holme 10/06/2014
Average CPU thread load Average CPU thread load Performance Simple filter chain 1 filter, on change, 1Hz input values Sliding mean (window = 5 samples) Complex filter chain 3 filters, on change, 1Hz input values Spike filter -> low pass -> RMS (win = 5) Filter chains Peak RAM consumption Average CPU thread load 500 55 MB 22 % 1000 66 MB 44 % 1500 78 MB 67 % 2000 88 MB 75 % 2500 100 MB 87 % 3000 110 MB 93 % Filter chains Peak RAM consumption Average CPU thread load 500 56 MB 52 % 1000 69 MB 80 % 1500 83 MB 95 % 2000 - 2500 3000 Test computer DELL Blade PowerEdge M610 with Windows 7 SP1 and WinCC OA 3.11 SP1 Dual Intel Xeon X5660 2.8 GHz (6 cores / 12 threads per CPU) Oliver Holme 10/06/2014
Current Status Used in production in CMS ECAL DCS Median and value change detection (watchdog) Studies ongoing for further applications Spike filter and mean No further development anticipated at the moment Any interest? Oliver Holme 10/06/2014