Skip to content

Mishandling of a non-update event that presents a value as well as a message #11

@apcarp

Description

@apcarp

One of the non-update event types in jmyapi (CHANNELS_PRIOR_DATA_DISCARDED, https://github.com/JeffersonLab/jmyapi/blob/main/src/main/java/org/jlab/mya/event/EventCode.java), can actually present a value that should be displayed. The current practice is to show either the value for update events or a message for non-update events.

Here is a query and response for the currently deployed myquery.

https://epicsweb.jlab.org/myquery/interval?c=R2O1KMAS&b=2023-03-20&e=2023-03-22&l=&t=graphical&m=ops&f=&v=&p=on
{
  "datatype": "DBR_DOUBLE",
  "datasize": 1,
  "datahost": "opsmya6",
  "ioc": "iocsl24rfhpa",
  "active": true,
  "sampled": false,
  "data": [
    {
      "d": "2023-03-20T00:00:00",
      "t": "CHANNELS_PRIOR_DATA_DISCARDED"
    },
    {
      "d": "2023-03-22T00:00:00",
      "t": "CHANNELS_PRIOR_DATA_DISCARDED"
    }
  ],
  "returnCount": 2
}

Here is the command and response for the currently deployed cli myget. Notice the 0 value and the message.

[56] 15:43:29 adamc@devl21 > myget -m ops -p -b 2023-02-01 -e 2023-04-01 -c R2O1KMAS
2022-05-20 08:12:08 0 << Channel's prior data discarded >>

Here is a code snippet from https://github.com/JeffersonLab/myquery/blob/main/src/main/java/org/jlab/myquery/QueryController.java that shows how this is being handled.

    public void writeFloatEvent(String name, JsonGenerator gen, FloatEvent event, boolean formatAsMillisSinceEpoch, boolean adjustMillisWithServerOffset, DateTimeFormatter timestampFormatter, DecimalFormat decimalFormatter) {
        if (name != null) {
            gen.writeStartObject(name);
        } else {
            gen.writeStartObject();
        }

        FormatUtil.writeTimestampJSON(gen, "d", event.getTimestampAsInstant(), formatAsMillisSinceEpoch, adjustMillisWithServerOffset, timestampFormatter);

        **if (event.getCode() == EventCode.UPDATE) {
            // Round number (banker's rounding) and create String then create new BigDecimal to ensure no quotes are used in JSON
            gen.write("v", new BigDecimal(decimalFormatter.format(event.getValue())));
        } else {
            writeInformationalEvent(gen, event);
        }**

        gen.writeEnd();
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions