sendWhoHas method
Future<void>
sendWhoHas({
- BacnetObject? object,
- String? objectName,
- int lowLimit = -1,
- int highLimit = -1,
- int network = 0xFFFF,
override
Sends a Who-Has for object or for the object named objectName
(exactly one of them). Devices hosting it answer with an
IHaveEvent (see events).
lowLimit and highLimit limit the device instance range (-1 for no
limit); network selects the broadcast as for sendWhoIs.
Implementation
@override
Future<void> sendWhoHas({
BacnetObject? object,
String? objectName,
int lowLimit = -1,
int highLimit = -1,
int network = 0xFFFF,
}) async {
_checkStarted();
if ((object == null) == (objectName == null)) {
throw ArgumentError('give either object or objectName');
}
requests.add(
FakeBacnetRequest('sendWhoHas', object: object, objectName: objectName),
);
for (final device in _devices.values) {
final id = device.deviceId;
if (!device.online ||
(lowLimit >= 0 && id < lowLimit) ||
(highLimit >= 0 && id > highLimit)) {
continue;
}
for (final candidate in device.objects) {
final name =
candidate.properties[BacnetPropertyId.objectName]?.asString ?? '';
if (candidate.identifier != object && name != objectName) continue;
unawaited(
Future<void>.delayed(latency + device.latency, () {
if (_events.isClosed) return;
_events.add(
IHaveEvent(
deviceId: id,
object: candidate.identifier,
objectName: name,
),
);
}),
);
}
}
}