diff --git a/lib/after_setup_pages/userspace_page.dart b/lib/after_setup_pages/userspace_page.dart index 7726f2d..274c5cf 100644 --- a/lib/after_setup_pages/userspace_page.dart +++ b/lib/after_setup_pages/userspace_page.dart @@ -78,7 +78,7 @@ class _UserspacePageState extends State { // print(message.toString()); // pza/*/atts/info - print(c[0].topic); + // print(c[0].topic); if (c![0].topic.startsWith("pza") & c![0].topic.endsWith("atts/info")) { final recMess = c![0].payload as MqttPublishMessage; @@ -96,7 +96,16 @@ class _UserspacePageState extends State { if (!interfaceAlreadyRegistered(ic)) { if (ic.getType() != "device") { setState(() { - interfaces = [...interfaces, ic]; + // sort interface by device name and + interfaces.add(ic); + interfaces.sort((a, b) { + var compareResult = a.getDeviceName().compareTo(b.getDeviceName()); + if (compareResult == 0) { + compareResult = a .getInterfaceName().compareTo(b.getInterfaceName()); + } + return compareResult; + }); + // interfaces = [...interfaces, ic]; }); } } @@ -138,7 +147,7 @@ class _UserspacePageState extends State { final ic = interfaces[index]; final type = ic.info["type"]; - + switch (type) { case "blc": return IcBlc(ic); diff --git a/lib/userspace_widgets/ic_bpc.dart b/lib/userspace_widgets/ic_bpc.dart index aeabef8..0b8b6f6 100644 --- a/lib/userspace_widgets/ic_bpc.dart +++ b/lib/userspace_widgets/ic_bpc.dart @@ -29,12 +29,12 @@ class _IcBpcState extends State { /// /// void onMqttMessage(List> c) { - print("============"); - print('Received ${c[0].topic} from ${widget._interfaceConnection.topic} '); + // print("============"); + // print('Received ${c[0].topic} from ${widget._interfaceConnection.topic} '); // if (c[0].topic.startsWith(widget._interfaceConnection.topic)) { - print(c[0].topic); + // print(c[0].topic); if (!c[0].topic.endsWith('/info')) { final recMess = c![0].payload as MqttPublishMessage; @@ -43,14 +43,14 @@ class _IcBpcState extends State { var jsonObject = json.decode(pt); - print(jsonObject); + // print(jsonObject); // Map updateAtts = Map.from(_attsEffective); setState(() { for (MapEntry atts in jsonObject.entries) { for (MapEntry field in atts.value.entries) { - print('${atts.key} ${field.key} => ${field.value}'); + // print('${atts.key} ${field.key} => ${field.value}'); switch (atts.key) { case "enable": if (field.key == "value") { diff --git a/lib/userspace_widgets/ic_platform.dart b/lib/userspace_widgets/ic_platform.dart index fd38f8c..927ddae 100644 --- a/lib/userspace_widgets/ic_platform.dart +++ b/lib/userspace_widgets/ic_platform.dart @@ -25,10 +25,10 @@ class _IcPlatformState extends State { } void _handleButtonPress() { - print(_value); + // print(_value); if (_value == 'fake psu') { - print(widget._interfaceConnection.topic); + // print(widget._interfaceConnection.topic); // /cmds/set Map content = { diff --git a/lib/userspace_widgets/ic_relay.dart b/lib/userspace_widgets/ic_relay.dart index 5b0b66f..f61a3e1 100644 --- a/lib/userspace_widgets/ic_relay.dart +++ b/lib/userspace_widgets/ic_relay.dart @@ -26,15 +26,15 @@ class _IcRelayState extends State { /// /// void onMqttMessage(List> c) { - print("============"); - print('Received ${c[0].topic} from ${widget._interfaceConnection.topic} '); + // print("============"); + // print('Received ${c[0].topic} from ${widget._interfaceConnection.topic} '); - print(widget._interfaceConnection.topic); + // print(widget._interfaceConnection.topic); if (c[0].topic.startsWith(widget._interfaceConnection.topic)) { - print("test = ${c[0].topic}"); + // print("test = ${c[0].topic}"); if (!c[0].topic.endsWith('/info')) { - print("success = ${c[0].topic}"); + // print("success = ${c[0].topic}"); final recMess = c![0].payload as MqttPublishMessage; final pt = @@ -42,7 +42,7 @@ class _IcRelayState extends State { var jsonObject = json.decode(pt); - print(jsonObject); + // print(jsonObject); // Map updateAtts = Map.from(_attsEffective);