diff --git a/device/commInterface/commIoOut.go b/device/commInterface/commIoOut.go index 31ed654..8827c56 100644 --- a/device/commInterface/commIoOut.go +++ b/device/commInterface/commIoOut.go @@ -106,7 +106,7 @@ func ReadCommIoOutInterfaceListFromJson() bool { } return true } else { - log.Println("commIoOutInterface.json is not exist") + setting.Logger.Info("commIoOutInterface.json is not exist") return false } diff --git a/httpServer/routerWeb.go b/httpServer/routerWeb.go index 919e7ec..e2e12fd 100644 --- a/httpServer/routerWeb.go +++ b/httpServer/routerWeb.go @@ -28,228 +28,228 @@ func RouterWeb() { loginRouter.POST("/login", apiLogin) } - //router.Use(JWTAuth()) - //{ - systemRouter := router.Group("/api/v1/system") + router.Use(JWTAuth()) { - systemRouter.POST("/reboot", apiSystemReboot) + systemRouter := router.Group("/api/v1/system") + { + systemRouter.POST("/reboot", apiSystemReboot) - systemRouter.GET("/status", apiGetSystemStatus) + systemRouter.GET("/status", apiGetSystemStatus) - systemRouter.GET("/backup", apiBackupFiles) + systemRouter.GET("/backup", apiBackupFiles) - systemRouter.POST("/recover", apiRecoverFiles) + systemRouter.POST("/recover", apiRecoverFiles) - systemRouter.POST("/update", apiSystemUpdate) + systemRouter.POST("/update", apiSystemUpdate) - systemRouter.GET("/loginParam", apiSystemLoginParam) + systemRouter.GET("/loginParam", apiSystemLoginParam) - systemRouter.GET("/MemUseList", apiSystemMemoryUseList) + systemRouter.GET("/MemUseList", apiSystemMemoryUseList) - systemRouter.GET("/DiskUseList", apiSystemDiskUseList) + systemRouter.GET("/DiskUseList", apiSystemDiskUseList) - systemRouter.GET("/DeviceOnlineList", apiSystemDeviceOnlineList) + systemRouter.GET("/DeviceOnlineList", apiSystemDeviceOnlineList) - systemRouter.GET("/DevicePacketLossList", apiSystemDevicePacketLossList) + systemRouter.GET("/DevicePacketLossList", apiSystemDevicePacketLossList) - systemRouter.POST("/systemRTC", apiSystemSetSystemRTC) + systemRouter.POST("/systemRTC", apiSystemSetSystemRTC) + } + + logRouter := router.Group("/api/v1/log") + { + logRouter.GET("/param", apiGetLogParam) + + logRouter.POST("/param", apiSetLogParam) + + logRouter.GET("/filesInfo", apiGetLogFilesInfo) + + logRouter.DELETE("/files", apiDeleteLogFile) + + logRouter.GET("/file", apiGetLogFile) + } + + ntpRouter := router.Group("/api/v1/system/ntp") + { + ntpRouter.POST("/hostAddr", apiSystemSetNTPHost) + + ntpRouter.GET("/hostAddr", apiSystemGetNTPHost) + } + + networkRouter := router.Group("/api/v1/network") + { + networkRouter.POST("/param", apiAddNetwork) + + networkRouter.PUT("/param", apiModifyNetwork) + + networkRouter.DELETE("/param", apiDeleteNetwork) + + networkRouter.GET("/param", apiGetNetwork) + + networkRouter.GET("/linkstate", apiGetNetworkLinkState) + + } + + serialRouter := router.Group("/api/v1/serial") + { + + serialRouter.GET("/param", apiGetSerial) + } + + deviceRouter := router.Group("/api/v1/device") + { + //增加采集接口 + deviceRouter.POST("/interface", apiAddInterface) + + //修改采集接口 + deviceRouter.PUT("/interface", apiModifyInterface) + + //删除采集接口 + deviceRouter.DELETE("/interface", apiDeleteInterface) + + //获取接口信息 + deviceRouter.GET("/interface", apiGetInterfaceInfo) + + //获取所有接口信息 + deviceRouter.GET("/allInterface", apiGetAllInterfaceInfo) + + //增加节点 + deviceRouter.POST("/node", apiAddNode) + + //修改单个节点 + deviceRouter.PUT("/node", apiModifyNode) + + //修改多个节点 + deviceRouter.PUT("/nodes", apiModifyNodes) + + //查看节点 + deviceRouter.GET("/node", apiGetNode) + + //查看节点变量 + deviceRouter.GET("/nodeVariable", apiGetNodeVariableFromCache) + + //查看节点历史变量 + deviceRouter.GET("/nodeHistoryVariable", apiGetNodeHistoryVariableFromCache) + + //查看节点变量实时值 + deviceRouter.GET("/nodeRealVariable", apiGetNodeReadVariable) + + //删除节点 + deviceRouter.DELETE("/node", apiDeleteNode) + + //增加设备模板 + //deviceRouter.POST("/template", apiAddTemplate) + + //获取设备模板 + //deviceRouter.GET("/template", apiGetTemplate) + + //增加设备物模型 + deviceRouter.POST("/tsl", apiAddDeviceTSL) + + //删除设备物模型 + deviceRouter.DELETE("/tsl", apiDeleteDeviceTSL) + + //修改设备物模型 + deviceRouter.PUT("/tsl", apiModifyDeviceTSL) + + //查看设备物模型 + deviceRouter.GET("/tsl", apiGetDeviceTSL) + + //查看设备物模型内容 + deviceRouter.GET("/tsl/contents", apiGetDeviceTSLContents) + + //批量导入设备物模型内容 + deviceRouter.POST("/tsl/contents/csv", apiImportDeviceTSLContents) + + //批量导出设备物模型内容 + deviceRouter.GET("/tsl/contents/csv", apiExportDeviceTSLContents) + + //导出设备物模型内容模板 + deviceRouter.GET("/tsl/contents/template", apiExportDeviceTSLContentsTemplate) + + //导入设备物模型插件 + deviceRouter.POST("/tsl/plugin", apiImportDeviceTSLPlugin) + + //导出设备物模型插件 + deviceRouter.GET("/tsl/plugin", apiExportDeviceTSLPlugin) + + //增加设备物模型属性 + deviceRouter.POST("/tsl/property", apiAddDeviceTSLProperty) + + //修改设备物模型属性 + deviceRouter.PUT("/tsl/property", apiModifyDeviceTSLProperty) + + //删除设备物模型属性 + deviceRouter.DELETE("/tsl/properties", apiDeleteDeviceTSLProperties) + + //查看设备物模型属性 + deviceRouter.GET("/tsl/properties", apiGetDeviceTSLProperties) + + //增加设备物模型服务 + deviceRouter.POST("/tsl/service", apiAddDeviceTSLService) + + //修改设备物模型服务 + deviceRouter.PUT("/tsl/service", apiModifyDeviceTSLService) + + //删除设备物模型服务 + deviceRouter.DELETE("/tsl/services", apiDeleteDeviceTSLServices) + + //获取通信接口 + deviceRouter.GET("/commInterface", apiGetCommInterface) + + //增加通信接口 + deviceRouter.POST("/commInterface", apiAddCommInterface) + + //修改通信接口 + deviceRouter.PUT("/commInterface", apiModifyCommInterface) + + //删除通信接口 + deviceRouter.DELETE("/commInterface", apiDeleteCommInterface) + + //增加串口通信接口 + deviceRouter.POST("/commSerialInterface", apiAddCommSerialInterface) + + //修改串口通信接口 + deviceRouter.PUT("/commSerialInterface", apiModifyCommSerialInterface) + + //删除串口通信接口 + deviceRouter.DELETE("/commSerialInterface", apiDeleteCommSerialInterface) + + //调用设备服务 + deviceRouter.POST("/service", apiInvokeService) + + //向采集接口发送透传数据 + deviceRouter.POST("/interface/directData", apiSendDirectDataToCollInterface) + } + + toolRouter := router.Group("/api/v1/tool") + { + //获取通信报文 + toolRouter.POST("/commMessage", apiGetCommMessage) + } + + pluginRouter := router.Group("/api/v1/update") + { + pluginRouter.POST("/plugin", apiUpdatePlugin) + } + + reportRouter := router.Group("/api/v1/report") + { + reportRouter.POST("/param", apiSetReportGWParam) + + reportRouter.GET("/param", apiGetReportGWParam) + + reportRouter.DELETE("/param", apiDeleteReportGWParam) + + reportRouter.POST("/node/param", apiSetReportNodeWParam) + + reportRouter.POST("/nodes/param", apiBatchAddReportNodeParam) + + reportRouter.GET("/node/param", apiGetReportNodeWParam) + + reportRouter.DELETE("/node/param", apiDeleteReportNodeWParam) + } } - logRouter := router.Group("/api/v1/log") - { - logRouter.GET("/param", apiGetLogParam) - - logRouter.POST("/param", apiSetLogParam) - - logRouter.GET("/filesInfo", apiGetLogFilesInfo) - - logRouter.DELETE("/files", apiDeleteLogFile) - - logRouter.GET("/file", apiGetLogFile) - } - - ntpRouter := router.Group("/api/v1/system/ntp") - { - ntpRouter.POST("/hostAddr", apiSystemSetNTPHost) - - ntpRouter.GET("/hostAddr", apiSystemGetNTPHost) - } - - networkRouter := router.Group("/api/v1/network") - { - networkRouter.POST("/param", apiAddNetwork) - - networkRouter.PUT("/param", apiModifyNetwork) - - networkRouter.DELETE("/param", apiDeleteNetwork) - - networkRouter.GET("/param", apiGetNetwork) - - networkRouter.GET("/linkstate", apiGetNetworkLinkState) - - } - - serialRouter := router.Group("/api/v1/serial") - { - - serialRouter.GET("/param", apiGetSerial) - } - - deviceRouter := router.Group("/api/v1/device") - { - //增加采集接口 - deviceRouter.POST("/interface", apiAddInterface) - - //修改采集接口 - deviceRouter.PUT("/interface", apiModifyInterface) - - //删除采集接口 - deviceRouter.DELETE("/interface", apiDeleteInterface) - - //获取接口信息 - deviceRouter.GET("/interface", apiGetInterfaceInfo) - - //获取所有接口信息 - deviceRouter.GET("/allInterface", apiGetAllInterfaceInfo) - - //增加节点 - deviceRouter.POST("/node", apiAddNode) - - //修改单个节点 - deviceRouter.PUT("/node", apiModifyNode) - - //修改多个节点 - deviceRouter.PUT("/nodes", apiModifyNodes) - - //查看节点 - deviceRouter.GET("/node", apiGetNode) - - //查看节点变量 - deviceRouter.GET("/nodeVariable", apiGetNodeVariableFromCache) - - //查看节点历史变量 - deviceRouter.GET("/nodeHistoryVariable", apiGetNodeHistoryVariableFromCache) - - //查看节点变量实时值 - deviceRouter.GET("/nodeRealVariable", apiGetNodeReadVariable) - - //删除节点 - deviceRouter.DELETE("/node", apiDeleteNode) - - //增加设备模板 - //deviceRouter.POST("/template", apiAddTemplate) - - //获取设备模板 - //deviceRouter.GET("/template", apiGetTemplate) - - //增加设备物模型 - deviceRouter.POST("/tsl", apiAddDeviceTSL) - - //删除设备物模型 - deviceRouter.DELETE("/tsl", apiDeleteDeviceTSL) - - //修改设备物模型 - deviceRouter.PUT("/tsl", apiModifyDeviceTSL) - - //查看设备物模型 - deviceRouter.GET("/tsl", apiGetDeviceTSL) - - //查看设备物模型内容 - deviceRouter.GET("/tsl/contents", apiGetDeviceTSLContents) - - //批量导入设备物模型内容 - deviceRouter.POST("/tsl/contents/csv", apiImportDeviceTSLContents) - - //批量导出设备物模型内容 - deviceRouter.GET("/tsl/contents/csv", apiExportDeviceTSLContents) - - //导出设备物模型内容模板 - deviceRouter.GET("/tsl/contents/template", apiExportDeviceTSLContentsTemplate) - - //导入设备物模型插件 - deviceRouter.POST("/tsl/plugin", apiImportDeviceTSLPlugin) - - //导出设备物模型插件 - deviceRouter.GET("/tsl/plugin", apiExportDeviceTSLPlugin) - - //增加设备物模型属性 - deviceRouter.POST("/tsl/property", apiAddDeviceTSLProperty) - - //修改设备物模型属性 - deviceRouter.PUT("/tsl/property", apiModifyDeviceTSLProperty) - - //删除设备物模型属性 - deviceRouter.DELETE("/tsl/properties", apiDeleteDeviceTSLProperties) - - //查看设备物模型属性 - deviceRouter.GET("/tsl/properties", apiGetDeviceTSLProperties) - - //增加设备物模型服务 - deviceRouter.POST("/tsl/service", apiAddDeviceTSLService) - - //修改设备物模型服务 - deviceRouter.PUT("/tsl/service", apiModifyDeviceTSLService) - - //删除设备物模型服务 - deviceRouter.DELETE("/tsl/services", apiDeleteDeviceTSLServices) - - //获取通信接口 - deviceRouter.GET("/commInterface", apiGetCommInterface) - - //增加通信接口 - deviceRouter.POST("/commInterface", apiAddCommInterface) - - //修改通信接口 - deviceRouter.PUT("/commInterface", apiModifyCommInterface) - - //删除通信接口 - deviceRouter.DELETE("/commInterface", apiDeleteCommInterface) - - //增加串口通信接口 - deviceRouter.POST("/commSerialInterface", apiAddCommSerialInterface) - - //修改串口通信接口 - deviceRouter.PUT("/commSerialInterface", apiModifyCommSerialInterface) - - //删除串口通信接口 - deviceRouter.DELETE("/commSerialInterface", apiDeleteCommSerialInterface) - - //调用设备服务 - deviceRouter.POST("/service", apiInvokeService) - - //向采集接口发送透传数据 - deviceRouter.POST("/interface/directData", apiSendDirectDataToCollInterface) - } - - toolRouter := router.Group("/api/v1/tool") - { - //获取通信报文 - toolRouter.POST("/commMessage", apiGetCommMessage) - } - - pluginRouter := router.Group("/api/v1/update") - { - pluginRouter.POST("/plugin", apiUpdatePlugin) - } - - reportRouter := router.Group("/api/v1/report") - { - reportRouter.POST("/param", apiSetReportGWParam) - - reportRouter.GET("/param", apiGetReportGWParam) - - reportRouter.DELETE("/param", apiDeleteReportGWParam) - - reportRouter.POST("/node/param", apiSetReportNodeWParam) - - reportRouter.POST("/nodes/param", apiBatchAddReportNodeParam) - - reportRouter.GET("/node/param", apiGetReportNodeWParam) - - reportRouter.DELETE("/node/param", apiDeleteReportNodeWParam) - } - //} - if err := router.Run(":8080"); err != nil { setting.Logger.Errorf("gin run err,%v", err) } diff --git a/releaseAll.sh b/releaseAll.sh deleted file mode 100755 index e720e9d..0000000 --- a/releaseAll.sh +++ /dev/null @@ -1,8 +0,0 @@ -make linux-armv5 -cp openGW_armV5 ../Release/ -make linux-arm64 -cp openGW_arm64 ../Release/ -make linux-amd64 -cp openGW_linux64 ../Release/ -make windows-amd64 -cp openGW_win64.exe ../Release/ \ No newline at end of file diff --git a/report/mqttEMQX/mqttEmqxReport.go b/report/mqttEMQX/mqttEmqxReport.go index 9d81527..ef2f3d1 100644 --- a/report/mqttEMQX/mqttEmqxReport.go +++ b/report/mqttEMQX/mqttEmqxReport.go @@ -222,132 +222,3 @@ func (r *ReportServiceParamEmqxTemplate) NodePropertyPost(name []string) { } } } - -//func (r *ReportServiceParamEmqxTemplate) NodePropertyPost(name []string) { -// -// nodeList := make([]ReportServiceNodeParamEmqxTemplate, 0) -// for _, n := range name { -// for k, v := range r.NodeList { -// if n == v.Name { -// nodeList = append(nodeList, v) -// //上报故障计数值先加,收到正确回应后清0 -// r.NodeList[k].ReportErrCnt++ -// } -// } -// } -// -// pageCnt := len(nodeList) / 20 //单包最大发送20个设备 -// if len(nodeList)%20 != 0 { -// pageCnt += 1 -// } -// -// for pageIndex := 0; pageIndex < pageCnt; pageIndex++ { -// if pageIndex != (pageCnt - 1) { -// propertyPost := MQTTPropertyPostTemplate{ -// ID: strconv.Itoa(MsgID), -// Version: "V1.0", -// Ack: 1, -// } -// node := nodeList[20*pageIndex : 20*pageIndex+20] -// for _, n := range node { -// for _, c := range device.CollectInterfaceMap { -// if c.CollInterfaceName == n.CollInterfaceName { -// for _, d := range c.DeviceNodeMap { -// if d.Name == n.Name { -// propertyPostParam := MQTTPropertyPostParamTemplate{ -// ClientID: n -// } -// for _, v := range d.VariableMap { -// if len(v.Value) >= 1 { -// index := len(v.Value) - 1 -// property := propertyTemplate{} -// property.Name = v.Name -// property.Value = v.Value[index].Value -// valueMap = append(valueMap, property) -// } -// } -// NodeValue := MQTTEmqxNodeValueTemplate{} -// NodeValue.ValueMap = valueMap -// NodeValue.ProductKey = n.Param.ProductKey -// NodeValue.DeviceName = n.Param.DeviceName -// NodeValueMap = append(NodeValueMap, NodeValue) -// } -// } -// } -// } -// } -// -// -// MsgID++ -// MQTTEmqxPropertyPost(r.GWParam, NodeValueMap) -// select { -// case frame := <-r.ReceiveReportPropertyAckFrameChan: -// { -// if frame.Code == 200 { -// setting.Logger.Debugf("%s MQTTEmqxNodePropertyPost OK", r.GWParam.ServiceName) -// } else { -// setting.Logger.Debugf("%s MQTTEmqxNodePropertyPost Err", r.GWParam.ServiceName) -// } -// } -// case <-time.After(time.Millisecond * 2000): -// { -// setting.Logger.Debugf("%s MQTTEmqxNodePropertyPost Err", r.GWParam.ServiceName) -// } -// } -// } else { //最后一页 -// NodeValueMap := make([]MQTTEmqxNodeValueTemplate, 0) -// valueMap := make([]propertyTemplate, 0) -// node := nodeList[20*pageIndex : len(nodeList)] -// //log.Printf("nodeList %v\n", node) -// for _, n := range node { -// for _, c := range device.CollectInterfaceMap { -// if c.CollInterfaceName == n.CollInterfaceName { -// for _, d := range c.DeviceNodeMap { -// if d.Name == n.Name { -// for _, v := range d.VariableMap { -// if len(v.Value) >= 1 { -// index := len(v.Value) - 1 -// property := propertyTemplate{} -// property.Name = v.Name -// property.Value = v.Value[index].Value -// valueMap = append(valueMap, property) -// } -// } -// NodeValue := MQTTEmqxNodeValueTemplate{} -// NodeValue.ValueMap = valueMap -// NodeValue.ProductKey = n.Param.ProductKey -// NodeValue.DeviceName = n.Param.DeviceName -// NodeValueMap = append(NodeValueMap, NodeValue) -// } -// } -// } -// } -// } -// -// mqttEmqxRegister := MQTTEmqxRegisterTemplate{ -// RemoteIP: r.GWParam.IP, -// RemotePort: r.GWParam.Port, -// ProductKey: r.GWParam.Param.ProductKey, -// DeviceName: r.GWParam.Param.DeviceName, -// DeviceSecret: r.GWParam.Param.DeviceSecret, -// } -// //setting.Logger.Debugf("NodeValueMap %v", NodeValueMap) -// MQTTEmqxNodePropertyPost(r.GWParam.MQTTClient, mqttEmqxRegister, NodeValueMap) -// -// select { -// case frame := <-r.ReceiveReportPropertyAckFrameChan: -// { -// if frame.Code == 200 { -// setting.Logger.Debugf("%s MQTTEmqxNodePropertyPost OK", r.GWParam.ServiceName) -// } else { -// setting.Logger.Debugf("%s MQTTEmqxNodePropertyPost Err", r.GWParam.ServiceName) -// } -// } -// case <-time.After(time.Millisecond * 2000): -// { -// setting.Logger.Debugf("%s MQTTEmqxNodePropertyPost Err", r.GWParam.ServiceName) -// } -// } -// } -// } -//}