GRIFFINCollaboration / griffin-dashboard

MIT License
3 stars 3 forks source link

griffin-dashboard

GRIFFIN's dashboard provides a visual user interface for GRIFFIN, its ancillary detectors, data acquisition system, and supporting infrastructure.

Maintenance Requirements

MIDAS

The Dashboard uses MIDAS and the ODB as its backend. A number of configuration steps and frontends are required for the Dashboard to function correctly:

MIDAS Installation

Note that these need to be followed for every MIDAS installation the Dashboard depends on, which is nominally two: the actual experiment, and the state of health machine.

Frontends

State of Health Experiment

An independent MIDAS experiment running nominally on grifsoh00. Set up Agilent, Epics and VME frontends as per the documentation in the SOH repo.

ODB Structures

The Dashboard makes use of a number of ODB structures that must be adhered to. They are fully specified in the relevant documentation:

Whenever an ODB directory is pulled in, the Dashboard will go looking for its contents at dataStore.ODB.<dir name>. In other words, dataStore.ODB is structured exactly like the ODB's directories (though it will only have the necessary subset of information available on it). When pulling in new ODB information, please follow this pattern.

APIs

The Dashboard relies on communication with GRIFFIN's digitizers both directly and through the ODB; see the ADC docs for a detailed discussion of the GRIF-16 API that must be in place.

Developer Notes

Start here if you're planning on doing major development on the Dashboard - below, we walk through the project's dependencies, a simple demonstration of the infrastructure, and go through code contribution guidelines.

Dependencies

Basic fluency with these dependencies will help in understanding and extending the Dashboard codebase. Taking some time to explore each of them on their own will make Dashboard maintenance much easier!

Simplest Example

demo.html is a minimal working example of the engineering techniques that underlie all Dashboard pages. The files relevant to this example are (where indented bullet points indicate subdirectories):

Plus a bunch of boilerplate helpers and frameworks you can see listed in the <head> of demo.html (see list above) - but you should never need to touch most of these.

Key points in demo.html:

dataStore.heartbeat.scriptQueries = ['http://'+dataStore.host+'/?cmd=jcopy&odb0=Experiment&encoding=json-p-nokeys&callback=ODBfetchCallback'] heartbeat();


 Here we:
   - set `dataStore.heartbeat.callback` to `dataUpdate`, or the name of whatever function we want to run after every heartbeat is complete.
   - make sure `dataStore.hearbeat.scriptQueries` has something to go looking for; these queries will circumvent cross origin restrictions, most notably useful for pulling stuff out of the ODB.
   - kick things off with a call to `heartbeat()`.

Also have a look at `templates/demo/demo-template.html`. Key points:

 - CSS (or other scripts) that pertain only to this template should live alongside the template html in the same directory, and be pulled in with the usual `<link>` and `<script>` tags here, like the very first line in this file.
 - Wrap all your html in a template tag that looks like `<template id='template-name'>`
 - Any javascript specific to this template can be included in `<script>` tags at the end, and will be available at global scope.

That's it! Fire up `demo.html` in Chrome or Firefox, and don't forget to open the console to see the callbacks at work. The actual Dashboard pages provide more sophisticated examples, but they all follow this basic structure.

### Contributing Guidelines

Contributions to the Dashboard are very welcome! Please follow the guidelines below:

 - Start by opening an issue in the [main repo](https://github.com/GRIFFINCollaboration/griffin-dashboard) to discuss your proposed changes.
 - Fork the [main repo](https://github.com/GRIFFINCollaboration/griffin-dashboard) and send your changes in a pull request to the gh-pages branch (which is the default). If you've never worked with git or GitHub before, [start with Software Carpentry](http://swcarpentry.github.io/git-novice/).
 - Please write some unit tests to examine as much of your code as possible; see examples in the `/tests` directory. Good candidates for unit testing are any physics calculations, data manipulations, or any other function that returns a result. Functions that affect the DOM are more complicated to test, to be expanded on in future - for now, try and separate calculations from DOM manipulations for ease of testing.
 - Please limit individual functions to 50 lines or less - functions longer than this can probably be re-written as several simpler functions, making them easier to test, debug and reuse.
 - Please limit pull requests to less than 500 lines at a time. (Why? See figure 1 [here](https://smartbear.com/SmartBear/media/pdfs/11_Best_Practices_for_Peer_Code_Review.pdf)).