Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
z2m
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xAAL
Code
Go
z2m
Commits
676a6407
Commit
676a6407
authored
8 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Update display
parent
44b546c8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
devices.go
+1
-1
1 addition, 1 deletion
devices.go
z2m.go
+14
-17
14 additions, 17 deletions
z2m.go
with
15 additions
and
18 deletions
devices.go
+
1
−
1
View file @
676a6407
...
...
@@ -14,7 +14,7 @@ func setupDevice(dev *xaal.Device, bDevice *BridgeDevice) {
dev
.
ProductID
=
bDevice
.
Definition
.
Model
dev
.
HWID
=
bDevice
.
IeeeAddress
dev
.
Version
=
bDevice
.
SwBuildID
dev
.
Info
=
"z2m:
"
+
bDevice
.
FriendlyName
dev
.
Info
=
"z2m:
"
+
bDevice
.
Type
+
":
"
+
bDevice
.
FriendlyName
}
func
newDevices
(
gw
*
gateway
,
bDevice
*
BridgeDevice
)
{
...
...
This diff is collapsed.
Click to expand it.
z2m.go
+
14
−
17
View file @
676a6407
...
...
@@ -6,6 +6,7 @@ import (
"log/slog"
"slices"
"sort"
"strings"
MQTT
"github.com/eclipse/paho.mqtt.golang"
"github.com/jedib0t/go-pretty/v6/table"
...
...
@@ -74,9 +75,20 @@ func (bDevices *BridgeDevice) dump() {
expTab
:=
table
.
NewWriter
()
expTab
.
SetTitle
(
"Exp:"
+
bDevices
.
FriendlyName
)
expTab
.
SetStyle
(
table
.
StyleRounded
)
expTab
.
AppendHeader
(
table
.
Row
{
"Name"
,
"Type"
,
"Unit"
})
expTab
.
AppendHeader
(
table
.
Row
{
"Name"
,
"Type"
,
"Unit"
,
"Values"
,
"Features: Name[Type](Unit){Property}"
})
for
_
,
expose
:=
range
bDevices
.
Definition
.
Exposes
{
expTab
.
AppendRow
(
table
.
Row
{
expose
.
Name
,
expose
.
Type
,
expose
.
Unit
})
values
:=
""
if
len
(
expose
.
Values
)
>
0
{
values
=
strings
.
Join
(
expose
.
Values
,
"
\n
"
)
}
features
:=
""
if
len
(
expose
.
Features
)
>
0
{
for
_
,
feature
:=
range
expose
.
Features
{
features
+=
fmt
.
Sprintf
(
"- %s[%s](%s){%s}
\n
"
,
feature
.
Name
,
feature
.
Type
,
feature
.
Unit
,
feature
.
Property
)
}
features
=
strings
.
TrimSuffix
(
features
,
"
\n
"
)
}
expTab
.
AppendRow
(
table
.
Row
{
expose
.
Name
,
expose
.
Type
,
expose
.
Unit
,
values
,
features
})
}
fmt
.
Println
(
expTab
.
Render
())
}
...
...
@@ -102,22 +114,7 @@ func parseDeviceJSON(jsonData []byte) {
if
!
newFlag
{
continue
}
device
.
dump
()
for
_
,
expose
:=
range
device
.
Definition
.
Exposes
{
fmt
.
Printf
(
"- Expose: %s[%s](%s)
\n
"
,
expose
.
Name
,
expose
.
Type
,
expose
.
Unit
)
if
len
(
expose
.
Features
)
>
0
{
for
_
,
feature
:=
range
expose
.
Features
{
fmt
.
Printf
(
" - Feature: %s[%s](%s){%s}
\n
"
,
feature
.
Name
,
feature
.
Type
,
feature
.
Unit
,
feature
.
Property
)
}
}
if
len
(
expose
.
Values
)
>
0
{
fmt
.
Printf
(
" - Values: %v
\n
"
,
expose
.
Values
)
}
}
fmt
.
Printf
(
"------------------
\n\n
"
)
// spew.Dump(device)
newDevices
(
gw
,
&
device
)
// TODO: filter if device already exists
gw
.
devices
=
append
(
gw
.
devices
,
&
device
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment