Hi,
I cannot get the progress bar applet to work. I'm keeping it open in the dashboard while I run an experiment and I'm trying to update the value that it displays during the experiment. The problem is that the value immediately jumps to the highest value (87 in the following example) when starting the experiment although there are delays in the code before the progress bar dataset is updated. Here's some dummy code corresponding to my experiment file:

from artiq.experiment import *
import numpy as np
import Rb_only_3D_MOT

class Master_sequence(EnvExperiment):
	"""MAIN Sequence"""
	def build(self):
		Rb_only_3D_MOT.MOT.build(self)
		
	def run(self):
		self.core.reset()
		msm = MultiScanManager(
			("Rb_load_time_3D", self.Rb_load_time_3D_Scan),
			("Rb_hold_time_3D", self.Rb_hold_time_3D_Scan))
		for point in msm:
			self.Assign_scan_run_values(point)
			self.run_seq()

	def Assign_scan_run_values(self, point):
		for key in [*point.__dict__]:
			if key != 'attr':
				setattr(self, key, getattr(point, key))	

	@kernel
	def run_seq(self):
		self.set_dataset("progress", 0, broadcast=True)	

		self.core.break_realtime()

		Rb_only_3D_MOT.MOT.load_mot(self) # in here is delay(1*s)
		Rb_only_3D_MOT.MOT.hold_mot(self) # in here is delay(1*s)
		
		self.set_dataset("progress", 87, broadcast=True)

I've unsuccessfully tried using mutate_dataset (only for arrays I believe) and I've tried making "progress" an array.

I'm calling the applet via
${artiq_applet}progress_bar progress

Would like any help to make the progress bar work. Any example code of a working dummy progress bar would be appreciated.

Thanks,
Malte

You can use RPC and time.sleep() instead to emulate those delays in the applet side (host environment).

The delay() method in the kernels is only for adjusting RTIO time cursor. You can check it on https://m-labs.hk/artiq/manual-beta/rtio.html

Also you can use the ccb.issue method to initialize creation of applet from the experiment code.

Here's a sample template:

from artiq.experiment import *
import time                             # for time.sleep()


class ProgressBarTest(EnvExperiment):
    """Progress bar test"""
    def build(self):
        ...
        self.setattr_device("ccb")      # access controller for applets

    def run(self):
        # Issue the applet command
        self.ccb.issue("create_applet", "progress_bar", 
                       "${artiq_applet}progress_bar progress")
        ...

        self.run_seq()

        ...

    # @kernel                           # not neccessary for testing the applet alone                                               
    def run_seq(self):
        self.set_progress(0)

        # self.mock_load_mot()              
        # self.mock_hold_mot()

        self.set_progress(87)

    @rpc(flags={"async"})
    def set_progress(self, value):
        self.set_dataset("progress", value, broadcast=True)
        # Introduce a delay in the host environment to mimic device delays.
        time.sleep(1)

Awesome, this seems to be exactly what I was looking for!