addObject method
FakeBacnetObject
addObject(
- BacnetObjectType type,
- int instance, {
- String? name,
- BacnetValue? presentValue,
- BacnetEngineeringUnits? units,
- bool? commandable,
- Map<
BacnetPropertyId, BacnetValue> properties = const {},
Adds an object. Outputs are commandable unless commandable says
otherwise; their presentValue becomes the relinquish default. Without
presentValue the object starts at 0, inactive or state 1.
Implementation
FakeBacnetObject addObject(
BacnetObjectType type,
int instance, {
String? name,
BacnetValue? presentValue,
BacnetEngineeringUnits? units,
bool? commandable,
Map<BacnetPropertyId, BacnetValue> properties = const {},
}) {
final object = FakeBacnetObject._(
this,
type,
instance,
commandable ??
(type == BacnetObjectType.analogOutput ||
type == BacnetObjectType.binaryOutput ||
type == BacnetObjectType.multiStateOutput),
);
object.properties.addAll({
BacnetPropertyId.objectIdentifier: object.identifier,
BacnetPropertyId.objectName: BacnetCharacterString(
name ?? '${type.label} $instance',
),
BacnetPropertyId.objectType: BacnetEnumerated(type),
if (units != null) BacnetPropertyId.units: BacnetEnumerated(units),
...properties,
});
if (type != BacnetObjectType.device) {
final value = presentValue ?? FakeBacnetObject._defaultPresentValue(type);
object.properties[BacnetPropertyId.presentValue] = value;
if (object.commandable) {
object.properties[BacnetPropertyId.relinquishDefault] = value;
object._publishPriorityArray();
}
}
_objects[(type, instance)] = object;
return object;
}