数据上报
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

262 lines
7.9 KiB

package consumers
import (
"fmt"
"goUpload/config"
"log"
"testing"
"time"
)
// 广州高支模 测点注册 --> 直接从config配置中读取数据,运行前执行一次 测试用例 即可全部注册
func Test_GzGZM_register(t *testing.T) {
log.Printf("广州高支模注册")
myConfigs := config.LoadConfigJsonByPath("../configFiles")
configBody := myConfigs["consumerGZGZM"]
_consumerGZGZM := new(consumerGZGZM)
_consumerGZGZM.Initial(configBody)
go _consumerGZGZM.RefreshTask()
time.Sleep(2 * time.Second)
sensorInfoMaps := _consumerGZGZM.ConfigInfo.SensorInfoMap
for s, info := range sensorInfoMaps {
log.Println(s, info)
_consumerGZGZM.RegisterPoint(s, info)
}
log.Println(_consumerGZGZM)
}
func Test_TYCJ_YB(t *testing.T) {
Msg := `{
"dtuInfo": {
"id": 0,
"code": "COM3"
},
"sensorData": {
"id": 24,
"name": "LHTDQ-RSG-L07-001-03",
"module": "2942",
"channel": "7",
"factorType": 23,
"productCode": "MD-BM15",
"structId": 0,
"data": {
"RawValues": [
880.98736572265625,
16.775247573852539,
784.51312255859375
],
"ThemeValues": [
-14.017531612697216
]
},
"time": "2023-11-27T14:32:44.355"
}
}`
topic := "upload/uds/23"
consumerCQZG := new(consumerCQZG)
consumerCQZG.onData(topic, Msg)
log.Println("===========")
}
func Test_CZ(t *testing.T) {
Msg := `
{
"roadno": 1,
"speed": 110,
"AxisCount": 2,
"AxleGrpNum": 2,
"AxieWeight1": 950,
"AxieWeight2": 640,
"AxieWeight3": 0,
"AxieWeight4": 0,
"AxieWeight5": 0,
"AxieWeight6": 0,
"AxieWeight7": 0,
"AxieWeight8": 0,
"AxieWeight9": 0,
"AxieWeight10": 0,
"GrossWeight": 1590,
"operDirec": 0,
"strTimeYear": "",
"carmodel": "A",
"carlen": 4.2,
"license": "",
"LimitWeight": 0,
"IP": "10.27.171.207",
"DataState": 0,
"atime": "2023-11-25 10:43:16"
}
`
topic := "upload/CZ/LHTDQ-HSD-L09-001-02"
consumerCQZG := new(consumerCQZG)
consumerCQZG.onData(topic, Msg)
}
func Test_ZD(t *testing.T) {
Msg := `
{
"Sensorid": 0,
"Module": "LHTDQ-VIB-L03-001-01",
"Channel": 0,
"ThemeValue": [
999.44390869140625
],
"RawValues": [
],
"AccValues": [
815.57,
454.898,
250.659,
656.155,
906.561,
764.857
],
"Ticks": 1700918326490
}
`
topic := "upload/ZD/LHTDQ-VIB-L03-001-01"
consumerCQZG := new(consumerCQZG)
consumerCQZG.onData(topic, Msg)
}
func Test_HTJCZD(t *testing.T) {
Msg := `{
"Sensorid":0,
"Module":"228-8",
"Channel":0,
"Frequency":32.0,
"ThemeValue":[1277.327880859375],
"RawValues":[],
"AccValues":[1274.202,1272.588,1274.735,1273.694,1273.741,1274.081,1272.76,1275.333,1274.674,1275.618,1274.765,1273.846,1273.83,1271.781,1271.843,1272.96,1272.593,1272.876,1271.364,1271.847,1270.14,1272.254,1270.792,1274.724,1273.793,1275.681,1274.63,1276.474,1273.812,1273.385,1274.161,1272.629,1275.019,1273.262,1273.861,1273.441,1273.591,1273.455,1273.573,1274.292,1274.525,1275.452,1275.644,1275.143,1274.517,1273.508,1272.987,1272.33,1274.151,1273.31,1274.475,1274.396,1274.982,1274.563,1273.806,1275.359,1273.595,1274.654,1274.842,1274.204,1273.618,1274.899,1272.473,1275.206,1273.523,1272.707,1274.964,1272.47,1276.61,1273.99,1275.635,1275.174,1273.962,1274.056,1274.415,1274.031,1274.727,1274.735,1274.71,1275.372,1273.487,1275.045,1271.584,1274.041,1273.093,1275.185,1275.094,1276.431,1274.467,1275.284,1272.375,1273.716,1272.426,1274.458,1274.489,1274.455,1274.188,1275.364,1272.934,1274.977,1272.731,1275.349,1275.43,1274.325,1275.898,1273.545,1275.811,1273.226,1273.627,1273.545,1271.535,1274.143,1274.231,1273.455,1277.328,1274.296,1275.641,1274.933,1273.315,1274.427,1273.6,1273.817,1275.024,1272.811,1276.174,1273.104,0.427,0.592,-2.423,1.284,0.393,0.879,2.123,-0.66,-0.298,0.232,-3.45,2.859,-2.743,1.91,0.237,-0.397,0.21,0.571,-1.613,1.649,-0.882,-0.604,1.622,-1.364,2.522,-0.627,1.355,-0.377,-1.372,0.501,-1.248,0.326,0.338,-0.228,0.823,-0.286,1.777,-1.052,1.214,-0.349,1.492,-1.053,1.208,-0.982,-1.017,0.332,-1.798,1.091,-0.956,2.485,0.427,0.859,2.411,-1.664,0.927,-0.616,-1.226,-0.475,-1.42,0.898,-0.562,0.331,0.444,0.292,-0.362,3.704,-2.178,2.721,-0.411,-2.145,-0.106,-1.515,1.028,-0.694,1.248,0.218,-0.999,-0.082,0.078,-1.325,2.022,0.124,-0.189,0.218,-0.417,-0.252,-0.081,1.39,-0.389,-0.264,0.732,-0.91,0.15,0.202,-1.423,-0.006,0.133,0.505,1.383,0.786,2.051,-0.872,0.108,-0.198,-2.258,0.431,-1.086,-0.829,-0.096,-0.321,1.506,0.884,2.05,0.451,-0.383,0.122,-1.149,-0.363,0.557,-1.259,0.013,-1.308,-0.316,0.302,0.922,2.34,0.229,1.074,-0.144,-1.089,-0.342,-1.129,-0.993,0.593,-0.322,0.978,-0.356,0.619,-0.438,-0.251,0.356,0.031,0.175,1.056,-0.624,-0.369,-0.244,-0.04,1.088,-0.45,0.801,-0.767,-0.595,-0.334,-0.689,-0.045,-0.254,0.082,0.763,0.773,0.714,1.03,0.732,0.486,-0.352,-1.01,-0.33,-1.051,-0.029,-0.328,0.719,0.667,1.02,1.493,0.328,0.752,-0.372,-0.524,-0.385,-0.375,-0.221,0.052,-0.965,0.326,0.368,1.273,1.314,0.702,0.856,-0.107,0.109,0.243,-0.896,-0.207],
"Ticks":1711335436533,
"ThemeItems":null}`
topic := "upload/ZD/228-8"
consumerCQZG := new(consumerHTJC)
consumerCQZG.onData(topic, Msg)
}
func Test_MYX_GDGS(t *testing.T) {
//初始化读取配置
myxConfig := `
{
"consumer": "consumerMYX",
"config": {
"inMqtt": {
"host": "10.8.30.160",
"port": 30883,
"userName": "xtjc-in",
"password": "123456",
"clientId": "xtjc-in-123",
"Topics": [
"upload/uds/+","upload/ZD/+"
]
},
"inFile": {
"directory": "G:\\工作记录\\每月任务需求\\202312需求\\明月峡数据接入influxDB\\光电光栅数据文件CSV",
"filenameExtension": "*.csv",
"cronStr": "0/1 * * * *"
},
"outHttp": {
"url": "http://127.0.0.1:4009/write?u=mingyuexia_wkd&p=mingyuexia_wkd&db=MingYueXia_Bridge&rp=autogen",
"method": "post"
}
},
"sensors": {
"TYCJsensorNameMap": {
"小里程-塔顶倾斜": "ZTWJC001",
"小里程-桥头测斜": "LDZJJC001",
"小里程-桥头伸缩缝磁滞位移": "SSFJC001",
"小里程-二层桥面中间温湿度": "WSDJC001",
"小里程-二层桥面中间风速风向": "FSFXJC001",
"大里程-塔顶倾斜": "ZTWJC002",
"大里程-桥头测斜": "LDZJJC002",
"大里程-桥头伸缩缝磁滞位移": "SSFJC002",
"大里程-塔顶风速风向": "FSFXJC002"
},
"ZDsensorM-CMap": {
"小里程船撞ZD0001": "CZDZJC001",
"小里程船撞ZD0002": "CZDZJC002",
"大里程船撞ZD0003": "CZDZJC003",
"大里程船撞ZD0004": "CZDZJC004",
"小里程主梁ZD0001": "ZLZDJC001",
"大里程主梁ZD0001": "ZLZDJC002"
},
"GDGSsensorNameMap": [
{
"type": "QLDYBJC",
"map": {
"CH0-1": {
"Label":"QLDYBJC001",
"params": {
"k":1.1
}
},
"CH0-2": {
"Label":"QLDYBJC002",
"params": {
"k":1.2
}
},
"CH0-3": {
"Label":"QLDYBJC003",
"params": {
"k":1.3
}
}
},
"formula": "v=( {{.phy}} +0.1 ) * {{.k}} + 2"
},
{
"type": "QLJYBJC",
"map": {
"CH3-1": {
"Label":"QLJYBJC001",
"params": {
"k":1.4
}
},
"CH3-2": {
"Label":"QLJYBJC002",
"params": {
"k":1.5
}
},
"CH3-3": {
"Label":"QLJYBJC003",
"params": {
"k":1.6
}
}
},
"formula": "v=( {{.phy}} +1000.1 )"
},
{
"type": "ZLWDJC",
"map": {
"CH4-1": {
"Label":"ZLWDJC001"
},
"CH4-2": {
"Label":"ZLWDJC002"
}
}
}
]
}
}`
consumerMyx := new(consumerMYX)
err := consumerMyx.Initial(myxConfig)
if err != nil {
log.Panic(fmt.Sprintf("[%s]初始化失败:%s", "consumerMyx", err.Error()))
}
consumerMyx.onFileData()
}