def live_monitor(request, instrument): """ Display the list of current DASMON status @param instrument: instrument name """ instrument_id = get_object_or_404(Instrument, name=instrument.lower()) # Update URL update_url = reverse('dasmon:get_update', args=[instrument]) pv_url = reverse('pvmon:get_update', args=[instrument]) breadcrumbs = view_util.get_monitor_breadcrumbs(instrument_id) template_values = {'instrument': instrument.upper(), 'breadcrumbs':breadcrumbs, 'update_url': update_url, 'pv_url': pv_url, 'key_value_pairs': view_util.get_cached_variables(instrument_id, monitored_only=True), } template_values = report.view_util.fill_template_values(request, **template_values) template_values = users.view_util.fill_template_values(request, **template_values) template_values = view_util.fill_template_values(request, **template_values) template_values['signals_url'] = reverse('dasmon:get_signal_table', args=[instrument]) return render(request, 'dasmon/live_monitor.html', template_values)
def get_update(request, instrument): """ Ajax call to get updates behind the scenes @param instrument: instrument name """ # Get instrument instrument_id = get_object_or_404(Instrument, name=instrument.lower()) # Get last experiment and last run data_dict = report.view_util.get_current_status(instrument_id) data_dict['variables'] = view_util.get_cached_variables(instrument_id, monitored_only=False) localtime = timezone.now() df = dateformat.DateFormat(localtime) recording_status = {"key": "recording_status", "value": view_util.is_running(instrument_id), "timestamp": df.format(settings.DATETIME_FORMAT), } data_dict['variables'].append(recording_status) # Get current DAS health status das_status = view_util.get_system_health(instrument_id) data_dict['das_status'] = das_status data_dict['live_plot_data'] = view_util.get_live_variables(request, instrument_id) # Recent run info data_dict = view_util.get_live_runs_update(request, instrument_id, None, **data_dict) response = HttpResponse(json.dumps(data_dict), content_type="application/json") response['Connection'] = 'close' response['Content-Length'] = len(response.content) return response
def pv_monitor(request, instrument): """ Display the list of latest PV values @param request: HTTP request object @param instrument: instrument name """ instrument_id = get_object_or_404(Instrument, name=instrument.lower()) # DASMON Breadcrumbs breadcrumbs = "<a href='%s'>home</a> › <a href='%s'>%s</a> › %s" % (reverse(settings.LANDING_VIEW), reverse('report:instrument_summary', args=[instrument]), instrument.lower(), "monitor") template_values = {'instrument':instrument.upper(), 'breadcrumbs': breadcrumbs, 'update_url':reverse('pvmon:get_update', args=[instrument]), 'key_value_pairs':view_util.get_cached_variables(instrument_id, True), } template_values = report.view_util.fill_template_values(request, **template_values) template_values = users.view_util.fill_template_values(request, **template_values) template_values = dasmon.view_util.fill_template_values(request, **template_values) return render_to_response('pvmon/pv_monitor.html', template_values)