open-ephys / bonsai-onix1

Bonsai library for the Open Ephys Onix Acquisition System
https://open-ephys.github.io/bonsai-onix1-docs/
MIT License
4 stars 3 forks source link

Strategy for read-only register logging #31

Open jonnew opened 10 months ago

jonnew commented 10 months ago

Some ONI device registers are used to inform the user about the state of the hardware, and are useful metadata. They should probably be log-able in some way. It would be nice if they could be exposed via Externalize Property in the workflow editor and saved in a text file, for instance. Here is an example of some read-only registers in ConfigureTest0 which targets the Test0 ONIX device (https://open-ephys.github.io/onix-docs/Hardware%20Guide/Datasheets/test-0.html).

        [XmlIgnore]
        [Category(ConfigurationCategory)]
        [Description("Indicates the number of 16-bit numbers, 0 to PayloadWords - 1, that follow Message in each frame.")]
        public uint DummyCount { get; private set; }

        [XmlIgnore]
        [Category(ConfigurationCategory)]
        [Description("Indicates the rate at which frames are produced. 0 indicates that the frame rate is unspecified (variable or upstream controlled).")]
        public uint FrameRateHz { get; private set; }

        public override IObservable<ContextTask> Process(IObservable<ContextTask> source)
        {
            var deviceName = DeviceName;
            var deviceAddress = DeviceAddress;
            return source.ConfigureDevice(context =>
            {
                var device = context.GetDevice(deviceAddress, Test0.ID);
                context.WriteRegister(deviceAddress, Test0.ENABLE, Enable ? 1u : 0);
                FrameRateHz = context.ReadRegister(deviceAddress, Test0.FRAMERATE);
                DummyCount = context.ReadRegister(deviceAddress, Test0.NUMTESTWORDS);

                var deviceInfo = new DeviceInfo(context, DeviceType, deviceAddress);
                var disposable = DeviceManager.RegisterDevice(deviceName, deviceInfo);
                return disposable;
            });
        }

However, in the workflow, their values appear as default initialized through the UI (0 in this case) and they are not exposable though the Expose Property functionality.

image

The first is fine because they are updated during the call to Process when the workflow is started and seems to be a necessary consequence of the new architecture. However, I think that we should be able to see them at runtime for logging. Maybe I'm missing an obvious way to do this e.g. by changing their accessibility level or via an attribute.

jonnew commented 2 months ago

Revisiting this, I don't know why i would expect these properties to be available via the Externalize Property function. However, the point stands that it would be useful to be able log read-only hardware information in some way.