DiamondLightSource / coniql

Control system interface in GraphQL
Apache License 2.0
6 stars 4 forks source link

Meta values in subscriptions only appear once #89

Closed AlexanderWells-diamond closed 1 year ago

AlexanderWells-diamond commented 1 year ago

If you subscribe to any of the "meta" information for a PV, it will only be returned on the first update and then it will only return nulls.

For example the following subscription:

subscription {
  subscribeChannel(id: "SV15I-BM-IP1C-01:ELECTMON:PDU1:UPSEM:KW") {
    status {
      quality
      message
      mutable
    }
    display {
      units
      form
      controlRange {
        max
        min
      }
      choices
      precision
    }
  }
}

Will return this data on the first update:

{
  "data": {
    "subscribeChannel": {
      "status": {
        "quality": "VALID",
        "message": "",
        "mutable": false
      },
      "display": {
        "units": "Kwatts",
        "form": null,
        "controlRange": {
          "max": 0,
          "min": 0
        },
        "choices": null,
        "precision": 3
      }
    }
  }
}

And then a moment later, when the value of the PV updates, the data returned is:

{
  "data": {
    "subscribeChannel": {
      "status": null,
      "display": null
    }
  }
}

The issue is that the subscribe_channel function in caplugin.py will yield only the value at times:

if value_signal.is_armed():
    yield await self.__signal_single_channel(
        value_signal, values, maker, value_lock
    )

This has the effect of returning no meta information, so those parameters are returned as null.

AlexanderWells-diamond commented 1 year ago

After discussion with @coretl , it seems I misunderstood the intention of the subscription - we are deliberately only returning values that have changed (after initially returning everything requested). Hence, there is no need for every subscription to return the unchanging meta values.