|
@@ -9,14 +9,26 @@ import (
|
|
|
)
|
|
|
|
|
|
func TestEnvItem_GetCurrentData(t *testing.T) {
|
|
|
- SetOptions(Options{GtServerIp: "120.55.44.4:8900"})
|
|
|
+ SetOptions(Options{GtServerIp: "120.55.44.4:8900", PlcItemSecret: "237c92d2-8795-1094-11ef-00e2e48fce4a"})
|
|
|
e := EnvItem{
|
|
|
ProjectId: 92,
|
|
|
- Item: "C.M.UF1_DB@press_PV",
|
|
|
+ Item: "C5.M5.RO1_SJSCXS",
|
|
|
}
|
|
|
|
|
|
- v, ht, err := e.getCurrentValue()
|
|
|
+ gk := EnvItem{
|
|
|
+ ProjectId: 92,
|
|
|
+ Item: "C5.M5.RO1_SJJSKG",
|
|
|
+ }
|
|
|
+ gk.SetValue("1", "0")
|
|
|
+
|
|
|
+ v, ht, err := gk.getCurrentValue()
|
|
|
+ t.Log(v, ht, err)
|
|
|
+ //
|
|
|
+ //t.Log(e.SetValue("0", "1"))
|
|
|
|
|
|
+ //b := <-e.WaitValue("0", 0, 3*time.Second, 0)
|
|
|
+ //t.Log(b)
|
|
|
+ v, ht, err = e.getCurrentValue()
|
|
|
t.Log(v, ht, err)
|
|
|
|
|
|
}
|
|
@@ -172,3 +184,22 @@ func ToString(data interface{}) string {
|
|
|
bs, _ := json.Marshal(data)
|
|
|
return string(bs)
|
|
|
}
|
|
|
+
|
|
|
+func TestEnvItem_WaitNotValue(t *testing.T) {
|
|
|
+ SetOptions(Options{GtServerIp: "47.96.12.136:8788", PlcItemSecret: "237c92d2-8795-1094-11ef-00e2e48fce4a"})
|
|
|
+ e := &EnvItem{
|
|
|
+ ProjectId: 92,
|
|
|
+ Item: "C.M.RO1_DB@control_word",
|
|
|
+ }
|
|
|
+
|
|
|
+ t.Log(e.GetItemInt64Val())
|
|
|
+
|
|
|
+ err := e.SetValue(fmt.Sprintf("%d", e.Value), "72")
|
|
|
+ if err != nil {
|
|
|
+ t.Log(err)
|
|
|
+ } else {
|
|
|
+ c := e.WaitNotValue([]string{"24"}, 3*time.Second, 20)
|
|
|
+
|
|
|
+ t.Log(<-c)
|
|
|
+ }
|
|
|
+}
|