changeDeviceAssignment method

void changeDeviceAssignment(
  1. PrimaryDeviceConfiguration<DeviceRegistration> device,
  2. AssignedTo assignedTo
)

Change who the primary device is assignedTo.

By default, primary devices are all roles so using this method is only needed if you want to change this default assignment.

Requires that device is part of this protocol and assignedTo contains participant roles which are part of this protocol.

Implementation

void changeDeviceAssignment(
  PrimaryDeviceConfiguration device,
  AssignedTo assignedTo,
) {
  assignedDevices ??= {};
  assert(primaryDevices.contains(device),
      "The device configuration is not part of this protocol.");
  assert(isValidAssignment(assignedTo),
      "One of the assigned participant roles is not part of this protocol.");
  assert(
      !assignedTo.isAssignedToAll,
      "Do not use this method to assign a device to all participants. "
      "This is done per default.");

  assignedDevices![device.roleName] = assignedTo.roleNames!;
}