Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
sort interface widget with device name and interface name + remove so…
Browse files Browse the repository at this point in the history
…me log (#32)

Co-authored-by: Damien Albisson <[email protected]>
  • Loading branch information
Darcraytore1 and Damien Albisson authored May 23, 2024
1 parent 317ad37 commit 542a67e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
15 changes: 12 additions & 3 deletions lib/after_setup_pages/userspace_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class _UserspacePageState extends State<UserspacePage> {
// 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;

Expand All @@ -96,7 +96,16 @@ class _UserspacePageState extends State<UserspacePage> {
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];
});
}
}
Expand Down Expand Up @@ -138,7 +147,7 @@ class _UserspacePageState extends State<UserspacePage> {

final ic = interfaces[index];
final type = ic.info["type"];

switch (type) {
case "blc":
return IcBlc(ic);
Expand Down
10 changes: 5 additions & 5 deletions lib/userspace_widgets/ic_bpc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class _IcBpcState extends State<IcBpc> {
///
///
void onMqttMessage(List<MqttReceivedMessage<MqttMessage>> 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;

Expand All @@ -43,14 +43,14 @@ class _IcBpcState extends State<IcBpc> {

var jsonObject = json.decode(pt);

print(jsonObject);
// print(jsonObject);

// Map<String, dynamic> updateAtts = Map.from(_attsEffective);

setState(() {
for (MapEntry<String, dynamic> atts in jsonObject.entries) {
for (MapEntry<String, dynamic> 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") {
Expand Down
4 changes: 2 additions & 2 deletions lib/userspace_widgets/ic_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class _IcPlatformState extends State<IcPlatform> {
}

void _handleButtonPress() {
print(_value);
// print(_value);

if (_value == 'fake psu') {
print(widget._interfaceConnection.topic);
// print(widget._interfaceConnection.topic);

// /cmds/set
Map<String, dynamic> content = {
Expand Down
12 changes: 6 additions & 6 deletions lib/userspace_widgets/ic_relay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ class _IcRelayState extends State<IcRelay> {
///
///
void onMqttMessage(List<MqttReceivedMessage<MqttMessage>> 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 =
MqttPublishPayload.bytesToStringAsString(recMess.payload.message);

var jsonObject = json.decode(pt);

print(jsonObject);
// print(jsonObject);

// Map<String, dynamic> updateAtts = Map.from(_attsEffective);

Expand Down

0 comments on commit 542a67e

Please sign in to comment.