Revision 68 hci/trunk/eneraptor-web-app/grails-app/controllers/com/eneraptor/hci/SysLogController.groovy

View differences:

SysLogController.groovy
332 332
		redirect(action:'clear')
333 333
		
334 334
	}
335
	
336
	def live = {
337
	
338
		List devices = new ArrayList()
339
		
340
		def crit1 = DeviceInfo.createCriteria()
341
		devices = crit1 {
342
			and {
343
				eq("inputDevice",true)
344
				eq("hwSet",session.hwSet)
345
			}
346
			order("friendlyName","asc")
347
		}
348
		
349
		[devices: devices]
350
		
351
	}
352
	
353
	def liveGraph = {
354
		
355
		List data = new ArrayList()
356
		java.util.Date now = new java.util.Date()
357
		
358
		if(params['deviceId'] && params['timeSpan']) {
359
			
360
			System.out.println("[LiveGraph] Getting for " + params.deviceId + ", time span " + params.timeSpan);
361
			
362
			java.util.Date beforeNMinutes = new java.util.Date(
363
				now.time - (60000 * (params.timeSpan as int))
364
			)
365
			
366
			def c = LoggedData.createCriteria()
367
			def results = c {
368
				and {
369
					eq("deviceId",params['deviceId'])
370
					between("dateRecieved",beforeNMinutes,now)
371
				}
372
				order("dateRecieved","asc")
373
			}
374
			
375
			results.each {
376
				data << [it.dateRecieved.getTime(),it.reportedData]
377
			}
378
			
379
			System.out.println(data);
380
			
381
		}
382
		
383
		[params:params, data:data]
384
			
385
	}
335 386
	
336 387
}

Also available in: Unified diff