/adei/ui

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/ui
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<?php
    error_reporting(E_ALL ^ E_NOTICE);

    $SETUP_MULTI_MODE = true;
    
    $ADEI_RELEASE = false;

    $TITLE = "ADEI";

    $DEFAULT_MODULE = "graph";
    
    $MODULES = array("config", "graph", "alarms", "logs", "help");
    $POPUPS = array("source", "controls");
    $CONTROLS = array("export", "aggregator", "searchtab", false, "virtual"); // false/null indicates line break

	/* more specific configs should go after less specific ones */
    $OPTIONS = array (
	"default" => array( 
	    "min_resolution" => 600, 		// in db config could be array by id
//	    "cache_config" => $ADEI_CACHE	// alter default cache timing configuration
	    "ignore_subseconds" => true,	// Timestamps with second precision
	    "omit_raw_cache" => false,		// Use data source instead of cache0 tables
	    "fill_raw_first" => false,		// Fill RAW cache table completely prior to processing agregating cache tables
	    "optimize_empty_cache" => false,	// Do not fill lower resolution cache intervals if encompassing one is empty
	    "use_cache_timewindow" => true,	// Shrink time window to currently cached data
	    "use_cache_reader" => false,	// Do not access data source while reading cache
	    "overcome_reader_faults" => false,	// Use CACHE if connection to reader is failed
	    "optimize_time_axes" => true,	// Limit window size by available data (temporary change)
	    "use_md5_postfix" => false,		// Use md5 for table name postfixes
	    "null_value" => 0,			// The numeric value to use instead of NULL (missing data) when needed
	    "disable_caching" => false,		// The CACHE should not be generated, Item for RT display only
	    "channel_uids" => false,		// If channels have unique identifactors within ADEI setup
	)
    );
    

    $ADEI_DB = array (
	"host" => "localhost",
	"port" => 0,
	"database" => "adei",
	"user" => "adei",
	"password" => "adei"
    );

/*
    The TSQLFile support in ROOT is not mature enough    
    $ROOT_DB = array (
	"driver" => "mysql",
	"host" => "localhost",
	"port" => 0,
	"user" => "zeus",
	"password" => "zeus"
    );
*/
    
    $BACKUP_DB = array (
	"driver" => "mysql",
	"host" => "localhost",
	"port" => 0,
	"user" => "zeus",
	"password" => "zeus"
    );

    $ADEI_TIMINGS = array (
	_("1 Year") => 31536000,
	_("1 Month") => 2592000,
	_("1 Week") => 604800,
	_("1 Day") => 86400,
	_("6 Hours") => 21600,
	_("1 Hour") => 3600,
	_("15 Min") => 900,
	_("5 Min") => 300
    );
    
    
    $ADEI_CACHE = array (
	array("min" => 31536000, "res" => 43200), /* year - 12 hour data, 730 points min */
	array("min" => 2592000, "res" => 3600), /* month - 1 hour data, 720 - 8760 data points */
	array("min" => 604800, "res" => 600), /* week - 10 min data, 1008 - 4320 data points */
	array("min" => 86400, "res" => 60), /* day - 1 min data, 1440 - 10080 data points */
	array("min" => 7200, "res" => 10), /* 2 hours - 10 s, 720 - 8640 data points */
	/* 1 - 7200 data points */
    );
    
    
    $ADEI_VIRTUAL_READERS = array(
	"virtual_vg" => array(
	    "title" => _("User Groups"),
	    "reader"=> "VGReader"
	),
	"virtual" => array(
	    "title" => _("Virtual"),
	    "reader" => "VIRTUALReader"
	)
    );

    $ADEI_AXES = array(
	"temperature" => array(
	    "axis_units" => _("C"),
	    "axis_name" => _("Temperature"),
	    "axis_mode" => "STANDARD",
	    "axis_range" => false
	),
	"voltage" => array(
	    "axis_units" => _("V"),
	    "axis_name" => _("Voltage"),
	    "axis_mode" => "STANDARD",
	    "axis_range" => false
	)
    );

    $DEFAULT_MISSING_VALUE = NULL;	/* Value to use instead of NULL values */

    $EXPORT_DEFAULT_FORMAT = "csv";
    
    /* Joiner/Filter: Joiner is a filter supporting multiple groups. From the
    software point of view there is no difference and both are implemented 
    using the same base class. It is possible to have arbitrary sequence of
    enclosed filters/joiners within format configuration.
    Only joiner or filter should be specified on the one level, if both
    are specified the filter will be used.
    
	@PROP@ 			- replaced by passed value
	?{@PROP@?@PROP@:nothing}

      Default:
	@TMPFILE@
	@BLOCK_TITLE@
	@EXPECTED_BLOCKS@
	@BLOCK_NUMBER@


	@ROOT__COMBHIST@	
    */
    
    $ADEI_SYSTEM_FORMATS = array (
	"labview32" => array(
	    'title' => "LabVIEW array",
	    'handler' => "LABVIEW",
	    'hidden' => true,
	    'type' => "streamarray"
	)
    );
    
    $EXPORT_FORMATS = array (
	"csv" => array(
	    'title' => "CSV",
	    'accept_null_values' => true
	),
	"xls" => array(
	    'title' => "Excel",
	    'handler' => "EXCEL",
//	    subsec_format => "DD.MM.YYYY hh:mm:ss.000;@"
//	    subsec_format => "text()" /* Use text (CSV) */
//	    subsec_format => "text(format)" /* Use text (format) */
//	    subsec_format => "DD.MM.YYYY hh:mm:ss.000000;@" /* HP, OpenOffice */
//	    subsec_width => 26
//	    date_format => "DD.MM.YYYY hh:mm:ss"
//	    date_width => 20
//	    value_format => "0.0000E+##"
//	    value_width => 12
/*	    filter => array (
		"type" => "ZIP"
	    )*/
	),
	"root" => array(
	    'title' => "ROOT",
	    'filter' => array (
		'app' => "csv2root",
		'opts' => "--file @TMPFILE@ ?{@BLOCK_NUMBER@===0?--overwrite} ?{@EXPECTED_BLOCKS@!=1?--group @BLOCK_TITLE@}",
		'joiner' => true,
		'groupmode' => true,	/* Run filter app for each group */
	        'extension' => "root"
	    )
	),
	"root_hist" => array(
	    'title' => "ROOT+Hist",
	    'filter' => array(
		'app' => "csv2root",
		'opts' => "--file @TMPFILE@ ?{@BLOCK_NUMBER@===0?--overwrite} ?{@EXPECTED_BLOCKS@!=1?--group @BLOCK_TITLE@} --save-histograms ?{@ROOT__COMBHIST@?--combined-histogram}",
		'joiner' => true,
		'groupmode' => true,	/* Run filter app for each block */
		'extension' => "root"
	    )
	),
	"tdms" => array(
	    'title' => "TDMS",
	    'handler' => "LABVIEW",
	    'type' => "tdms"
	)
    );
    
    $EXPORT_SAMPLING_RATES = array (
	_("Hourly") => 3600,
	_("Minutely") => 60,
	_("1 Hz") => 1,
	_("1000 Hz") => 0.001
    );
    
    $SEARCH_ENGINES = array (
	"ITEMSearch" => array()
    );
    
    
    $ADEI_ID_DELIMITER = "__";
    
    $LOGGER_LOG_REQUESTS = false;	/* Log all ADEI requests */
    $LOGGER_LOG_OUTPUT = false;		/* Log output of ADEI requests */

/* This forces MySQL to use INDEXes while SELECT queries returning huge 
rowsets are executed. After certain threshold, MySQL optimizator stops
using INDEXes what bringing to huge slowdown. This option is intended
to fix this behaviour. */
    $MYSQL_FORCE_INDEXES = true;	
    
    $CACHE_PRECISE_GAPS = false;	/* Enables more precise maxgap calculation in DATAInterval */
    
    $AJAX_UPDATE_RATE = 60; 		/* in seconds */
    $AJAX_WINDOW_BORDER = 10; 		/* in pixels */
    $AJAX_PARSE_DELAY = 100; 		/* html, in milliseconds */

    $SOURCE_KEEP_WINDOW = false;	/* Preserve time range when group is changed */
    

    $DHTMLX_SKIN = "standard";
//    $DHTMLX_SKIN="dhx_blue";
    $DHTMLX_ICONSET = "csh_bluefolders";
    $MENU_SHOW_ITEMS = false;		/* Show separate items in popup menu */
    $MENU_SCROLL_LIMIT = 10;		/* Add scrolling if more than that items present */
    
    $JPGRAPH_PATH="/usr/share/php5/jpgraph";
    $EXCEL_WRITER_PATH ="";
    $TMP_PATH=$ADEI_ROOTDIR . "tmp";

    $ADEI_ROOT_STORAGE = "$ADEI_ROOTDIR/storage/";
    
    $ADEI_APP_PATH = array (
	"default" => "/usr/bin/"
    );
    
    $CSV_SEPARATOR = ",";
    $CSV_DATE_FORMAT = "d-M-y H:i:s";
    $EXCEL_DATE_FORMAT = "DD.MM.YYYY hh:mm:ss";
    $EXCEL_SUBSEC_FORMAT = "DD.MM.YYYY hh:mm:ss.000;@"; /* 
	    Unfortunately Excel doesn't support more than 3 digits,
	    OpenOffice does */
    $ROOT_COMBIHIST_LIMIT = 604800; /* No more, than 1 week */


    $STATUS_DEFAULT_DURATION = 2000;	/* in milliseconds */


    $GRAPH_DEFAULT_HEIGHT = 768; /* in pixels */
    $GRAPH_DEFAULT_WIDTH = 1024; /* in pixels */
/* Maximal number of points (all plots) on Graph, this allows us to produce 
rough multiplots to sustain high update rate (most of resources are used to 
graph->Stroke()) */
    $GRAPH_MAX_POINTS_PER_GRAPH = 5000;
/* Maximal approximation interval (in pixels). I.e. maximal distance between
to approximation points. This option have a priority over MAX_POINTS_PER_GRAPH
option. */
    $GRAPH_MAX_APPROXIMATION_INTERVAL = 10; /* in pixels */

    $GRAPH_AUTOAGGREGATION_MINMAX_THRESHOLD = 10; /* in precision, approx. px/2 */

    $GRAPH_INTERPOLATE_DATA_GAPS = false; /* Do not indicate missing data */

/* Maximal distance between currently CACHEd data and the data available in the
data source, measured in seconds. 0 means - unlimited */
    $GRAPH_MAX_CACHE_GAP = 0;

    
    $GRAPH_ZOOM_RATIO = 2.;	// This coeficent defines product of division of original window by zoomed window
    $GRAPH_DEEPZOOM_AREA = 10;	// In pixels (actual interval is 2x)
    $GRAPH_STEP_RATIO = 5.;	// This coeficent defines product of division of original window by step
    $GRAPH_EDGE_RATIO = 6;	// Product of division of while window by edge size

    $GRAPH_DELTA_SIZE = 10; /* delta neighborhood size, in pixels */
    $GRAPH_MARGINS = array (
	"left" => 50,
	"top" => 20,
	"right" => 220,
	"bottom" => 30
    );
    $GRAPH_SELECTION = array (
	"min_width" => 20,
	"min_height" => 20
    );


    $GRAPH_LINE_WEIGHT = 2;
/* Enables approximation point marks starting with accuracy greater than the
specified number of pixels. 0 - to disable. Significatly degradate performance
if used */
    $GRAPH_ACCURACY_MARKS_OUTSET = 14;
    $GRAPH_ACCURACY_MARKS_MULTIOUTSET = 49;
    $GRAPH_ACCURACY_MARKS_IF_GAPS = false;	// Force if data gaps are found
    $GRAPH_ACCURACY_MARKS_COLOR = "blue";
#   $GRAPH_ACCURACY_MARKS_TYPE = MARK_FILLEDCIRCLE;
    $GRAPH_ACCURACY_MARKS_SIZE = 3;
    
/* Display a bar on top of the graph, indicating the density of the data. The
four modes are supported:
    SHOW_NONE: do not show
    SHOW_EMPTY: show only if missing (due to inavalability of the data) points 
    are available on the graph
    SHOW_POINTS: Indicate all set points on the graph (somehow duplicates 
    'GRAPH_ACCURACY_MARKS' functionality, but displayed even if precision is 
    high and GRAP_ACCURACY_MARKS are disable by OUTSET
    SHOW_GAPS: Will display information on data gaps. Even if point placed on
    the graph, but there is less data than expected, all such points will be
    indicated on the bar 
*/

    $GRAPH_INDICATE_DATA_DENSITY = 'SHOW_NONE';
//    $GRAPH_INDICATE_DATA_DENSITY = SHOW_POINTS;//SHOW_GAPS;

    $GRAPH_DENSITY_PLOT_INVALID_SIZE = 3;
    $GRAPH_DENSITY_PLOT_INVALID_COLOR = 'red';

    $GRAPH_DENSITY_PLOT_VALID_SIZE = 0;
    $GRAPH_DENSITY_PLOT_VALID_COLOR = 'green';
    
    $GRAPH_DENSITY_POINTS_TYPE = 'MARK_FILLEDCIRCLE';
    $GRAPH_DENSITY_POINTS_SIZE = 1;
    $GRAPH_DENSITY_POINTS_COLOR = 'green';
    $GRAPH_DENSITY_POINTS_OUTLINE = 'black';
    
    
    
    $GRAPH_SUBSECOND_THRESHOLD = 5;	/* in seconds, for shorter intervals the subsecond handling is performed */

/* This option defines a plot colors (used sequently), comment out to use black
only */
    $GRAPH_COLORS =  array("#000000","#006400","#000080","#0B0000","#00008B","#8B0000","#8B008B","#8B8B00","#0F0F0F","#F0F0F0");
/*
    $GRAPH_COLORS =  array("black", "#483D8B","#2F4F4F","#00CED1","#9400D3","#FF1493","#00BFFF","#696969","#1E90FF","#D19275","#B22222","#FFFAF0","#228B22","#FF00FF","#DCDCDC",
	    "#808080","#008000","#ADFF2F","#F0FFF0","#FF69B4","#CD5C5C","#4B0082","#FFFFF0","#F0E68C","#E6E6FA","#FFF0F5","#7CFC00","#FFFACD","#ADD8E6",
	    "#D3D3D3","#90EE90","#FFB6C1","#FFA07A","#20B2AA","#87CEFA","#8470FF","#778899","#B0C4DE","#FFFFE0","#00FF00","#32CD32","#FAF0E6","#FF00FF",
	    "#BA55D3","#9370D8","#3CB371","#7B68EE","#00FA9A","#48D1CC","#C71585","#191970","#F5FFFA","#FFE4E1","#FFE4B5","#FFDEAD","#000080","#FDF5E6",
	    "#FF4500","#DA70D6","#EEE8AA","#98FB98","#AFEEEE","#D87093","#FFEFD5","#FFDAB9","#CD853F","#FFC0CB","#DDA0DD","#B0E0E6","#800080","#FF0000",
	    "#FA8072","#F4A460","#2E8B57","#FFF5EE","#A0522D","#C0C0C0","#87CEEB","#6A5ACD","#708090","#FFFAFA","#00FF7F","#4682B4","#D2B48C","#008080");
*/

    if (file_exists("config.actual.php")) {
	require("config.actual.php");
    } else {
	$ADEI_SETUP = "all";
    }


    if ($SETUP_MULTI_MODE) {
	if ($_GET['setup']) {
	    $ADEI_SETUP = $_GET['setup'];
	    unset($_GET['setup']);
	} else {
	    $params = sizeof($_SERVER['argv']);
    	    if ($params>1) {
		$pos = array_search("-setup", $_SERVER['argv']);
		if (($pos)&&(($pos + 1) < $params)) $ADEI_SETUP =  $_SERVER['argv'][$pos + 1];
		else $SETUP_MULTI_MODE = 0;
	    } else $SETUP_MULTI_MODE = 0;
	}
    }

    $SETUP_CONFIG = "setups/$ADEI_SETUP/config.php";
    $SETUP_CSS = "setups/$ADEI_SETUP/$ADEI_SETUP.css";
    
    if (!file_exists("config.php")) {
        $curdir = getcwd();
	if (preg_match("/(services|admin|system|test)$/", $curdir)) chdir("..");
	if (!file_exists("config.php")) {
	    if (preg_match("/tmp\/admin$/", $curdir)) chdir("..");
	}
    }
    
    if (file_exists($SETUP_CONFIG)) require($SETUP_CONFIG);
    
    if (file_exists("config.override.php")) require("config.override.php");
?>