From da5eafd2ec666d12ba5f53e64ff7591b8b291363 Mon Sep 17 00:00:00 2001 From: lucas Date: Thu, 10 Apr 2025 13:20:14 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=9B=B4=E6=96=B0=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...¯åЍto江è‹çœå†œæ‘公路桥æ¢ç›‘测.go | 4 +- consumers/consumerJSNCGLQL.go | 6 ++- testUnit/æ±Ÿè‹æ™ºæ„Ÿæµ‹è¯•_test.go | 44 +++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/adaptors/振动to江è‹çœå†œæ‘公路桥æ¢ç›‘测.go b/adaptors/振动to江è‹çœå†œæ‘公路桥æ¢ç›‘测.go index 25f9fad..a3e14e8 100644 --- a/adaptors/振动to江è‹çœå†œæ‘公路桥æ¢ç›‘测.go +++ b/adaptors/振动to江è‹çœå†œæ‘公路桥æ¢ç›‘测.go @@ -42,11 +42,13 @@ func (the Adaptor_ZD_JSNCGLQL) ZDtoJSNCGLQL(zd models.ZDnew) (result []NeedPush) sourceId := fmt.Sprintf("%d_%d", zd.SensorId, zd.Channel) sensorCode := the.getSensorCode(sourceId) if sensorCode == "" { - log.Printf("振动 设备[%s] 无匹é…çš„ 江è‹å†œæ‘公路桥æ¢ç›‘测系统 测点id,请检查é…置文件", zd.Module) + log.Printf("振动 设备[%s] 无匹é…çš„ 江è‹å†œæ‘公路桥æ¢ç›‘测系统 sourceId=[%s],请检查é…置文件", zd.Module, sourceId) return } topic := fmt.Sprintf("data/%s/%s", the.BridgeCode, sensorCode) + //江è‹ä¸œäº¤ 固定 128HZ 16个采样点 作为 1ç§’16HZ + zd.Frequency = float32(len(zd.AccValues) * 1.0) //æ•°æ®ç§’æ•° seconds := len(zd.AccValues) / int(zd.Frequency) diff --git a/consumers/consumerJSNCGLQL.go b/consumers/consumerJSNCGLQL.go index e14b653..4058b4e 100644 --- a/consumers/consumerJSNCGLQL.go +++ b/consumers/consumerJSNCGLQL.go @@ -38,7 +38,7 @@ func (the *consumerJSNCGLQL) Initial(cfg string) error { return err } func (the *consumerJSNCGLQL) InputInitial() error { - the.ch = make(chan []adaptors.NeedPush, 200) + the.ch = make(chan []adaptors.NeedPush, 500) //æ•°æ®å…¥å£ the.InMqtt = dbOperate.MqttInitial( the.Info.IoConfig.In.Mqtt.Host, @@ -78,11 +78,13 @@ func (the *consumerJSNCGLQL) Work() { if push.Topic != "" { outTopic = push.Topic } + the.outMqtt.Publish(outTopic, push.Payload) + } } - time.Sleep(100 * time.Millisecond) + time.Sleep(5 * time.Millisecond) } }() } diff --git a/testUnit/æ±Ÿè‹æ™ºæ„Ÿæµ‹è¯•_test.go b/testUnit/æ±Ÿè‹æ™ºæ„Ÿæµ‹è¯•_test.go index ce3cd3c..38fe81a 100644 --- a/testUnit/æ±Ÿè‹æ™ºæ„Ÿæµ‹è¯•_test.go +++ b/testUnit/æ±Ÿè‹æ™ºæ„Ÿæµ‹è¯•_test.go @@ -64,7 +64,51 @@ func Test_æ±Ÿè‹æ™ºæ„Ÿ_加速度(t *testing.T) { bytes := adp.Transform(matchTopic, Msg) log.Println(bytes) } +func Test_江è‹ä¸œäº¤_加速度(t *testing.T) { + Msg := ` +{ + "Ticks": 1744259211391, + "Sensorid": 64085, + "Module": "1", + "Channel": 1, + "Frequency": 128, + "ThemeValue": [ + 190.05810893173759 + ], + "RawValues": [], + "AccValues": [ + -178.44, + -180.421, + -188.563, + -172.968, + -187.81, + -179.353, + -178.915, + -188.968, + -174.02, + -186.831, + -182.622, + -176.204, + -190.058, + -173.708, + -183.312, + -183.576 + ], + "ThemeItems": null +} +` + adp := adaptors.Adaptor_ZD_JSNCGLQL{ + IdMap: map[string]string{ + "64085_1": "LHTDQ-JSD-C08-001-01", + "m1c2": "LHTDQ-JSD-L03-001-01", + }, + BridgeCode: "G2320281L0012", + } + matchTopic := "upload/ZD" + bytes := adp.Transform(matchTopic, Msg) + log.Println(bytes) +} func Test_æ±Ÿè‹æ™ºæ„Ÿ_光电挠度(t *testing.T) { Msg := `