- @override
Callback used to notify a node that it was created. This is called after a node is deserialized as well.
Source
@override onCreated() async { String rp = configs[r"$path"]; if (rp == null) { rp = configs[r"$value_path"]; } if (configs[r"$publish"] == true) { isPublishOnly = true; } valuePath = rp; group = _link[new Path(path).parentPath]; String groupName = group._watchName; _link.addNode("${path}/lwv", { r"$name": "Last Written Value", r"$type": "dynamic" }); _link.addNode("${path}/startDate", { r"$name": "Start Date", r"$type": "string" }); _link.addNode("${path}/endDate", { r"$name": "End Date", r"$type": "string" }); if (children["enabled"] == null) { _link.addNode("${path}/enabled", { r"$name": "Enabled", r"$type": "bool", "?value": true, r"$writable": "write" }); } if (group.db.database == null) { Completer c = new Completer(); group.db.onDatabaseReady.add(c.complete); await c.future; } HistorySummary summary = await group.db.database.getSummary( groupName, valuePath ); if (summary.first != null) { _link.updateValue("${path}/startDate", summary.first.timestamp); isStartDateFilled = true; } if (summary.last != null) { ValueUpdate update = new ValueUpdate( summary.last.value, ts: summary.last.timestamp ); _link.updateValue("${path}/lwv", update); updateValue(update); } timer = Scheduler.safeEvery(const Duration(seconds: 1), () async { await storeBuffer(); }); var ghn = new GetHistoryNode("${path}/getHistory"); addChild("getHistory", ghn); (_link.provider as SimpleNodeProvider).setNode(ghn.path, ghn); updateList("getHistory"); _link.addNode("${path}/purge", { r"$name": "Purge", r"$invokable": "write", r"$params": [ { "name": "timeRange", "type": "string", "editor": "daterange" } ], r"$is": "purgePath" }); _link.addNode("${path}/delete", { r"$name": "Delete", r"$invokable": "write", r"$is": "delete" }); _link.onValueChange("${path}/enabled").listen((ValueUpdate update) { if (update.value == true) { sub(); } else { if (valueSub != null) { valueSub.cancel(); valueSub = null; } } }); if (_link.val("${path}/enabled") == true) { sub(); } group.db.database.addWatchPathExtensions(this); }