-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathclient_read_test.go
58 lines (48 loc) · 1.33 KB
/
client_read_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package client_rw
import (
"encoding/json"
"fmt"
"github.com/wendy512/iec61850"
"github.com/wendy512/iec61850/test"
"testing"
)
const (
AnIn1ObjectRef = "simpleIOGenericIO/GGIO1.AnIn1.mag.f"
Ind1ObjectRef = "simpleIOGenericIO/GGIO1.Ind1.stVal"
)
func TestRead(t *testing.T) {
client := test.CreateClient(t)
defer test.CloseClient(client)
test.DoRead(t, client, AnIn1ObjectRef, iec61850.MX)
test.DoRead(t, client, Ind1ObjectRef, iec61850.ST)
}
func TestReadFloat(t *testing.T) {
client := test.CreateClient(t)
defer test.CloseClient(client)
objectRef := AnIn1ObjectRef
value, err := client.ReadFloat(objectRef, iec61850.MX)
if err != nil {
t.Fatalf("read %s object error %v\n", objectRef, err)
}
t.Logf("read %s float value -> %v\n", objectRef, value)
}
func TestReadBool(t *testing.T) {
client := test.CreateClient(t)
defer test.CloseClient(client)
objectRef := Ind1ObjectRef
value, err := client.ReadBool(objectRef, iec61850.ST)
if err != nil {
t.Fatalf("read %s object error %v\n", objectRef, err)
}
t.Logf("read %s bool value -> %v\n", objectRef, value)
}
func TestGetLogicalDeviceList(t *testing.T) {
client := test.CreateClient(t)
defer test.CloseClient(client)
deviceList := client.GetLogicalDeviceList()
marshal, err := json.Marshal(deviceList)
if err != nil {
t.Fatal(err)
}
fmt.Println(string(marshal))
}