Coder Social home page Coder Social logo

jeffersonlab / wedm Goto Github PK

View Code? Open in Web Editor NEW
7.0 9.0 2.0 4.73 MB

Web Extensible Display Manager

Home Page: https://epicsweb.jlab.org/wedm

License: MIT License

Java 68.26% CSS 1.65% JavaScript 29.33% HTML 0.17% Dockerfile 0.58%
epics ace container-workflows java-workflows

wedm's Introduction

wedm Java CI with Gradle Docker

The Web Extensible Display Manager leverages epics2web to view EDM screens on the web.

Example



Overview

Quick Start with Compose

  1. Grab project
git clone https://github.com/JeffersonLab/wedm
cd wedm
  1. Launch Compose
docker compose up
  1. Navigate to example displays via web browser

http://localhost:8080/wedm

See: Docker Compose Strategy

Install

  1. Install epics2web
  2. Download wedm.war and drop it into the Tomcat webapps directory
  3. Start Tomcat and navigate your web browser to localhost:8080/wedm

Configure

Web Socket Gateway

Use the environment varaible EPICS_2_WEB_HOST to specify the hostname (and optionally :port) of the epics2web server. If undefined, the same host as WEDM is assumed.

Screen Files Path

The environment variable EDL_DIR must be set to the canonical path to the directory containing your EDL files. This directory (and subdirectories) will be browsable in WEDM. If you want the demo EDL files on the overview page to work you need to download the demo files and place them inside your EDL_DIR directory at the subdirectory wedm. Demo files which require an EPICS monitor will need those PVs to exist (LOC PVs are used as much as possible to limit this). The demo files are intended to be used with the JLab colors.list.

Colors File Path

The color palette file is located by searching the following locations in order:

  1. EDMCOLORFILE environment variable with an absolute path to a file
  2. EDMFILES environment variable with an absolute path to a directory containing the file "colors.list"
  3. Finally the default location of /etc/edm/colors.list

Screen File Search Path

Similar to EDM, the environment variable EDMDATAFILES may be set to a colon-separated list of search paths. For example, setting EDMDATAFILES=/main/sub1:/main/sub2 will result in searches for display files in the two provided folders. When relative paths are encountered in an EDL file, the EDL_DIR path is searched first, then any additional paths specified in EDMDATAFILES are searched.

Accessing Screen Files on Web Server

Some EDM installations share files across a site via a web server. That way, clients running EDM do not need local or NFS-based file access, but can access all *.edl files from a web server. WEDM will fetch edl files specified with an absolute HTTP or HTTPS URL, and alternatively can search for files specified with a relative path to a remote server. Similar to EDM, the environment variable EDMHTTPDOCROOT allows WEDM to locate relatively-specified remote files via a web address. It has to be used in combination with an EDMDATAFILES search path, which might have only one / entry.

For example, assume EDMHTTPDOCROOT=http://www.webserver.com/edlfiles and EDMDATAFILES=/main/sub1:/main/sub2. Whenever WEDM is now trying to open a file x.edl, it will attempt to open
http://www.webserver.com/edlfiles/main/sub1/x.edl followed by http://www.webserver.com/edlfiles/main/sub2/x.edl, using the order provided in the search path, until it succeeds to find the file.

When EDMHTTPDOCROOT is defined, all complete URLs passed to WEDM via ...?edl=http:/... must in fact start with the EDMHTTPDOCROOT. Other URLs will be rejected to prevent network attacks which try to use the WEDM host to probe URL access.

Often it is convenient to ignore self-signed certificates. This can be done by defining the environment variable WEDM_DISABLE_CERTIFICATE_CHECK to any value.

Relative path support

EDM versions from 1-12-105J on (ca. June 2021) use this environment variable to enable support for relative path names:

EDMRELATIVEPATHS=yes

When relative paths are enabled, the names of embedded displays, images and links to related displays can be resolved relative to the display which contains them.

By default, WEDM will test access to each relative path and otherwise fall back to the search path. These access checks take considerable time. If a site uses relative path names and no longer relies on a search path, these checks can be disabled via

WEDM_DISABLE_RELATIVEPATHS_CHECK=yes

When both EDMRELATIVEPATHS and WEDM_DISABLE_RELATIVEPATHS_CHECK are set to yes, all file references are assumed to be relative without checking access.

Context Prefix

When proxying WEDM it is sometimes useful to have multiple instances accessible via the same host via separate context paths. In order to return correct links to resources an instance proxied with a namespacing prefix needs to be aware of the prefix. The environment variable CONTEXT_PREFIX does this. For example at Jefferson Lab we use a single proxy server for multiple departments each with their own instance of WEDM, and each configured with a prefix such as "/fel", "/chl", "/itf", and "/srf" ("/ops" uses default/empty prefix).

OTF Screens

If the optional environment variable OTF_DIR is defined, then ShellCommand widgets with OTFLauncher commands will be honored if possible via a pregenerated screen cache found at the path indicated by the variable. The cache directory is expected to contain a file named edl.json which maps OTF shell commands to .edl files. The JLab On-The-Fly (OTF) EDM screens are used to automatically keep screens in sync with the accelerator configuration database and are usually generated dynamically at the time of invocation. A cache reduces latency when opening screens and a separate app invokes the generation commands such that WEDM continues to interface solely with EDM files on a filesystem.

Build

This project is built with Java 17 (compiled to Java 8 bytecode), and uses the Gradle 7 build tool to automatically download dependencies and build the project from source:

git clone https://github.com/JeffersonLab/wedm
cd wedm
gradlew build

Note: If you do not already have Gradle installed, it will be installed automatically by the wrapper script included in the source

Note for JLab On-Site Users: Jefferson Lab has an intercepting proxy

See: Docker Development Quick Reference

Release

  1. Bump the version number in the VERSION file and commit and push to GitHub (using Semantic Versioning).
  2. The CD GitHub Action should run automatically invoking:
    • The Create release GitHub Action to tag the source and create release notes summarizing any pull requests. Edit the release notes to add any missing details. A war file artifact is attached to the release.
    • The Publish docker image GitHub Action to create a new demo Docker image, and bump the compose.override.yaml to use the new image.

Deploy

At JLab this app is found at epicsweb.jlab.org/wedm, plus other fiefdom specific subpaths, and internally at epicswebtest.acc.jlab.org/wedm. However, the epicsweb server is a proxy for epicswebops.acc.jlab.org, epicswebops2.acc.jlab.org, epicswebchl.acc.jlab.org, epicswebfel.acc.jlab.org, epicswebsrf.acc.jlab.org and epicswebitf.acc.jlab.org. Additionally, the context root for each is adjusted with a prefix such that all servers can be reached from a single namespace. The context root prefixes are /, /ops2, /chl, /fel, /srf, and /itf respectively. Tomcat interprets context roots from war file name unless overridden elsewhere. Therefore each war must be prefixed with <prefix>#. Use wget or the like to grab the release war file. Don't download directly into webapps dir as file scanner may attempt to deploy before fully downloaded. Be careful of previous war file as by default wget won't overrwite. The war file should be attached to each release, so right click it and copy location (or just update version in path provided in the example below). Example for chl fiefdom:

cd /tmp
rm wedm.war
wget https://github.com/JeffersonLab/wmenu/releases/download/v1.2.3/wedm.war
mv wedm.war chl#wedm.war
mv  chl#wedm.war /usr/share/tomcat/webapps

See Also

wedm's People

Contributors

es-sns121 avatar github-actions[bot] avatar kasemir avatar slominskir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

es-sns121 kasemir

wedm's Issues

Color PV not working as expected on meters screen

The meters substationSummary.edl works fine in EDM, but in WEDM the color PV CALC expressions don't appear to be working correctly as the text widgets displaying power using the color PV expression are all white (on a white background, so invisible).

A debug version substationSummary-debug.edl has been created to help isolate the issue.

The Color PV CALC expression is:

CALC\\{(A>D)||(B>F)||(C>H)?2:(A>E)||(B>G)||(C>I)?1:0}(40MVA_North_West_Loop:aAmps,40MVA_North_West_Loop:bAmps,40MVA_North_West_Loop:cAmps,40MVA_North_West_Loop:aAmps.HIHI,40MVA_North_West_Loop:aAmps.HIGH,40MVA_North_West_Loop:bAmps.HIHI,40MVA_North_West_Loop:bAmps.HIGH,40MVA_North_West_Loop:cAmps.HIHI,40MVA_North_West_Loop:cAmps.HIGH)

Initial triage:
The CALC expression may be working OK as using the expression for a text widget value appears to get the correct result (0). The problem widgets are actually being assigned color white, which corresponds to CALC expression result of 4+ according to color rule 113, which translated to the web (JavaScript) looks like:

jlab.wedm.colorRules[113] = "switch(true) {case (A <0): B = 'gray-9'; break;case (A ==0): B = 'green-1'; break;case (A >=1 && A <2): B = 'yellow-1'; break;case (A >=2 && A <3): B = 'red-1'; break;case (A >=4): B = 'white'; break;}";
...
jlab.wedm.colors['white'] = 'rgb(255, 255, 255)';

See Also:

CAMAC Status Summary Alarm isn't triggering as expected

Problem:

The CAMAC status screen is indicating that iocctf crate-1 and crate-2, and iocch2a crate-18 are in alarm in EDM, but not in WEDM.

EDM
thumbnail_Screenshot from 2024-04-03 10-41-40

WEDM
thumbnail_epicsweb

WEDM Link to Screen

Triage:
Alarm PV CALC expressions:

crate-18

CALC\\{max(A,B,C,D,E,F,G,H)}(analog_Temp_ch2a_18.STAT,analog_P24v_ch2a_18.STAT,analog_P12v_ch2a_18.STAT,analog_P6v_ch2a_18.STAT,analog_Ground_ch2a_18.STAT,analog_N6v_ch2a_18.STAT,analog_N12v_ch2a_18.STAT,analog_N24v_ch2a_18.STAT)

crate-1

CALC\\{max(A,B,C,D,E,F,G,H)}(analog_Temp_ctf_1.STAT,analog_P24v_ctf_1.STAT,analog_P12v_ctf_1.STAT,analog_P6v_ctf_1.STAT,analog_Ground_ctf_1.STAT,analog_N6v_ctf_1.STAT,analog_N12v_ctf_1.STAT,analog_N24v_ctf_1.STAT)

crate-2

CALC\\{max(A,B,C,D,E,F,G,H)}(analog_Temp_ctf_2.STAT,analog_P24v_ctf_2.STAT,analog_P12v_ctf_2.STAT,analog_P6v_ctf_2.STAT,analog_Ground_ctf_2.STAT,analog_N6v_ctf_2.STAT,analog_N12v_ctf_2.STAT,analog_N24v_ctf_2.STAT)

Reported by:

Joseph Sawyer

Support OTF Screen Commands

It would be nice if we supported JLab On-The-Fly (OTF) generated EDM screens launched from a Command Widget. We have a server-side OTF Generator cache already for screens launched from WMenu. The OTF cached screen names will soon map to a file on the filesystem that can be obtained by base64 encoding the OTF command. We should create a new environment variable named something like OTF_DIR, and if configured, attempt to convert OTF commands to related display links in the OTF_DIR.

See: https://developer.mozilla.org/en-US/docs/Web/API/btoa

Related: #27

Symbol widget value ranges not properly parsed?

Assume this in the display file:

# (Symbol)
object activeSymbolClass
beginObjectProperties
major 4
minor 0
release 0
x 690
y 408
w 82
h 67
file "PumpSymbols.edl"
numStates 3
minValues {
  0 -100
  2 0.5
}
maxValues {
  1 0.5
  2 9999
}
controlPvs {
  0 "CF_RS:DIWS_PDIS4800A:Sts"
}
numPvs 1

When entries are missing in the minValues and maxValues arrays, the default should be zero.
So the above defines value ranges
State 0: min -100, max 0
State 1: min 0, max 0.5
State 2: min 0.5, max 999

In the WEDM display, however, the widget ends up with
data-min-values="-100 0 0" and data-max-values="0 0 0", as if only the value range for state 0 is used, the rest defaults to 0.

Screen Shot 2021-06-08 at 11 33 22 AM

EDM object TextupdateClass units not displayed

Given a an EDL file containing:

# (Text Update)
object TextupdateClass
beginObjectProperties
major 10
minor 0
release 0
x 273
y 457
w 113
h 29
controlPv "REDACTED"
fgColor index 14
bgColor index 70
font "helvetica-bold-r-16.0"
fontAlign "right"
endObjectProperties

The expected widget display should include units. This may depend on the "Mode" attribute, which by default (missing) apparently means show units:

thumbnail_Screenshot from 2024-02-28 14-26-33

Reported by Brad Webb (ORNL).

Note: WEDM does support units on the EDM object activeXTextDspClass, Example. That works differently apparently though:

  1. EDL file contains showUnits
  2. Server-side widget parser marks the output HTML with flag data-show-units
  3. Client-side browser code looks for flag
  4. Then knows to register for .EGU
  5. Then sets .EGU updates to HTML data-units
  6. Then widget client-side code handles

Auto Font Sizing Sometimes Breaks on Firefox

Sometimes the auto font sizing feature breaks on Firefox. It seems to be affected by zoom settings, but can occur even with zoom reset. It is likely due to the jQuery outerHeight(true) and outerWidth(true) methods sometimes returning inaccurate element dimensions, which are expected to do so during zoom (and with hidden elements). Inaccurate dimensions can also be due to rendering race conditions (sometimes element sizes are changed dynamically as a page loads and sometimes coded delays with setTimeout() can help), though EDM elements are absolutely positioned and fixed sized. Alternative APIs could be investigated. See:

Support widget TextEntry

There are a few widgets not supported that are very similar to the already supported TextControl widget (activeXTextDspClass and activeXTextDspClass:noedit). These widgets include:

  1. TextEntry (TextentryClass)
  2. RegTextUpdate (RegTextupdateClass) #8
  3. TextUpdate (TextupdateClass)*

*This class will render, but doesn't handle scientific notation formatting

Support blinking static colors

Currently WEDM doesn't know what to do with static color definitions which define more than one color. Example from ORNL colors.list:

static 136 "blinking red" { 65535 0 0 0 0 0 } #

Pulling up a related display has wrong path

Ryan et al,

Amazing job! I can't believe how well this works out of the box. Our colors.list file doesn't quite work with your parsing, but that's probably something we should fix locally.

One issue: when clicking on a related display that opens in a new window, the wrong path is appended to the URL.
Instead of pulling up /wedm/screen/...
it pulls up /wedm/undefined/wedm/screen/...

I think the problem may lie in line 52 of wedm/web/resources/widgets/relatedDisplayClass/widget.js

where it tries to append jlab.conxtextprefix and the path again.

Note that embedded screens do work perfectly.

Not sure if this is unintended behavior, or we need to define jlab.contextprefix ENV, or it is something also to be changed on a separate branch for SNS if we pursue this further. I don't want to break your stuff!

Thanks,
Geoff

Related Display Help Command Not Implemented

If a Related Display has a help command configured it is ignored by WEDM. Further, if the configured help command index is not the last menu item configured then menu items after it are ignored.

Nested macros not propogated

A related display opened from a screen that is embedded in another screen that is supposed to inherit macros from the top most screen does not inherit them (only inherits macros from it's immediate parent screen).

Support widget RegTextupdate

Need to add support for RegTextupdate, which is used by ORNL. An example EDL markup for this widget would be useful. More investigation is needed, but this might be an ORNL site-specific widget and might be related to the EDM core activeXRegTextClass.

ActiveMotifSlider widget limitsFromDb attribute not working with .BDL

The limitsFromDb attribute in an EDL file indicates that an ActiveMotifSlider widget should obtain min and max scale bounds from EPICS. This is an alternative to explicit scaleMin and scaleMax attributes. Support for limitsFromDb is provided, but does not work if the channel field contains .BDL. This issue may result in the "knob" on the slider appearing in unexpected locations on the display, outside of the widget itself.

Rendering isn't always pixel perfect match to EDM

More investigation is needed, but if you examine enough screens you'll find examples where WEDM and EDM are not a pixel perfect match. This is generally most evident on screens with lots of grouping and stacking. This may have to do with the "box model", in other words questions such as is the border included in the widget dimensions? Anti-aliasing and other "shape-rendering" SVG properties can make a difference here too. When SVG lines are drawn at a particular coordinate they don't always overlay pixels exactly and even a 1 pixel line may be rendered as 50% at one pixel and 50% at the one beside it. There are also peculiarities with EDM rendering such as a zero width widget with zero width border rendering as non-zero.

EDM colors.list file location inflexible

Currently the software assumes the colors.list file is in the same location as the EDL files. Instead the software should honor the environment variables EDMCOLORFILE or EDMFILES or the fallback location /etc/edm.

Support web-friendly command: open URL

Currently the (shell) command button isn't supported at all (it renders, but nothing happens when you click it). It would be useful to allow opening web URLs by inspecting the command. Perhaps support command line syntax for launching a few browsers at a given URL such as Chrome, Chromium, and Firefox. Note: it wouldn't actually launch the specified browser, it would just confirm that the URL should be opened in the existing WEDM browser (probably in a new tab).

ActiveSymbol Demo no longer resolves screen file relative paths

Regardless of the new EDMRELATIVEPATHS environment setting screen file relative paths are no longer resolved in the ActiveSymbol widget. The work around is to update the path to be either an EDM root relative path or an absolute path.

It seems EDM ActiveSymbol originally supported screen relative paths in WEDM. Still need to verify what EDM does.

Brought about by #22

Color PV not working as expected on SUPERBIGBITE screen

The Hall A SUPERBIGBITE Combo Screen has a Circle widget (shape) that is used to indicate power on/off via a CALC expression color rule and it isn't displaying in WEDM the same as in EDM.

Initial investigation determined that shapes currently do not support CALC expressions. CALC color rule support was added to text widgets in #28.

Logic for shapes is consolidated in RectangleClass:

jlab.wedm.ShapePvObserver.prototype.handleColorUpdate = function (update) {
var $obj = $("#" + this.id),
$shape = $obj.find("rect, ellipse, path"),
color,
stmt,
lineRuleIndex = $obj.attr("data-line-color-rule"),
fillRuleIndex = $obj.attr("data-fill-color-rule");
$obj[0].classList.remove("waiting-for-state");
if (lineRuleIndex !== undefined) {
stmt = jlab.wedm.colorRules[lineRuleIndex];
color = jlab.wedm.evalColorExpr.call(this, stmt, update.value);
$shape.attr("stroke", color);
}
if (fillRuleIndex !== undefined) {
stmt = jlab.wedm.colorRules[fillRuleIndex];
color = jlab.wedm.evalColorExpr.call(this, stmt, update.value);
$shape.attr("fill", color);
}
};
};

The CALC expression in question is:

CALC\\{A||B}(MSUPERBIGBITEr.B4,MSUPERBIGBITER.B1)

Note: The expression is using a logical OR on numeric values. JavaScript logical OR on numbers differs from logical OR on Strings so explicit type conversion is critical and required here. Here is hoping that JavaScript handling of numeric logical OR matches what EPICS / EDM expects.

Aside: EPICS probe command reports the PVs used in the expression are of type CHAR and Java CAJ reports type BYTE. Sigh.

EDM object TextupdateClass PV without EGU results in CAException

This is a regression from #33. Now, we sorta have the opposite problem. It turns out EPICS PVs often do not have an EGU field. The recent enhancement aggressively looks for the EGU field though, resulting in CAExceptions, which manifest on WEDM screens as white text / white backgrounds.

WEDM does not monitor complex CA Types, only primitive types. If monitoring a GR or CTRL complex type struct we could potentially just check if the units field was present client-side. However, with the a-la-carte monitoring approach it appears we need to catch ChannelNotFoundException instead. Else figure out a way to determine ahead of time if a PV actually has an EGU field.

WEDM does not allow space in CALC expression

According to the docs an inline CALC expression in EDM is defined like:

CALC\{A+B}(pv1, pv2)

However, EDM actually is fairly forgiving and will work even with a space between the expression and variable list like so:

CALC\{A+B} (pv1, pv2)

WEDM is currently not so forgiving and will mark the CALC item as invalid. It would be nice if WEDM matched EDM more closely.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.