From bbfdd2b16f7d825f439183f48a5adc7f58cc97da Mon Sep 17 00:00:00 2001 From: pengwang <969753572@qq.com> Date: Mon, 13 Sep 2021 22:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A1=E3=80=81=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E8=8A=82=E7=82=B9=E7=B1=BB=E5=9E=8B=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E4=BB=8E=E7=89=A9=E6=A8=A1=E5=9E=8B=E4=B8=AD=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=202=E3=80=81=E5=8E=BB=E6=8E=89=E4=B9=8B=E5=89=8D=E4=BB=8Elua?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=B8=AD=E8=8E=B7=E5=8F=96=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E7=9A=84=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- device/collectInterface.go | 2 +- device/deviceType.go | 76 ------------------------------------- httpServer/routerDevice.go | 29 -------------- httpServer/routerWeb.go | 3 -- webroot/.DS_Store | Bin 8196 -> 0 bytes 5 files changed, 1 insertion(+), 109 deletions(-) delete mode 100644 webroot/.DS_Store diff --git a/device/collectInterface.go b/device/collectInterface.go index bdadbe7..2f9c641 100644 --- a/device/collectInterface.go +++ b/device/collectInterface.go @@ -151,7 +151,7 @@ func ReadCollectInterfaceManageFromJson() bool { return false } - setting.Logger.Debugf("CollectInterfaceParamMap %+v\n", CollectInterfaceParamMap) + setting.Logger.Debugf("CollectInterfaceParamMap %+v", CollectInterfaceParamMap) for k, v := range CollectInterfaceParamMap.CollectInterfaceParam { //创建接口实例 CollectInterfaceMap = append(CollectInterfaceMap, NewCollectInterface(v.CollInterfaceName, diff --git a/device/deviceType.go b/device/deviceType.go index a71778f..4954b21 100644 --- a/device/deviceType.go +++ b/device/deviceType.go @@ -9,8 +9,6 @@ import ( "path/filepath" "strings" - "github.com/yuin/gluamapper" - lua "github.com/yuin/gopher-lua" ) @@ -26,29 +24,10 @@ type DeviceNodeTypeMapStruct struct { DeviceNodeType []DeviceNodeTypeTemplate } -type DeviceNodeTypeLuaState struct { - LuaState *lua.LState - TypeName string - CollName string -} - -type DeviceNodeTypeVariableTemplate struct { - Index int - Name string - Label string - Type string -} - -type DeviceNodeTypeVariableMapTemplate struct { - TemplateType string - Variable []DeviceNodeTypeVariableTemplate -} - var DeviceNodeTypeMap = DeviceNodeTypeMapStruct{ DeviceNodeType: make([]DeviceNodeTypeTemplate, 0), } var DeviceTypePluginMap = make(map[int]*lua.LState) -var DeviceNodeTypeVariableMap = make([]DeviceNodeTypeVariableMapTemplate, 0) func ReadDeviceNodeTypeMap() bool { @@ -151,63 +130,8 @@ func ReadDeviceNodeTypeMap() bool { } } } - - for _, f := range fileMap { - if strings.Contains(f.Name(), ".lua") { - if strings.Contains(f.Name(), v.Name()) == false { //lua文件和设备模版名字不一样 - //获取设备模板中的变量 - ReadDeviceNodeTypeVariableMap(v.Name(), DeviceTypePluginMap[index]) - } - } - } } } return true } - -func ReadDeviceNodeTypeVariableMap(templateType string, l *lua.LState) { - - type LuaVariableTemplate struct { - Index int - Name string - Label string - Type string - } - - type LuaVariableMapTemplate struct { - Variable []*LuaVariableTemplate - } - - //调用NewVariables - err := l.CallByParam(lua.P{ - Fn: l.GetGlobal("NewVariables"), - NRet: 1, - Protect: true, - }) - if err != nil { - setting.Logger.Warning("NewVariables err,", err) - } - - //获取返回结果 - ret := l.Get(-1) - l.Pop(1) - - LuaVariableMap := DeviceNodeTypeVariableMapTemplate{} - - if err := gluamapper.Map(ret.(*lua.LTable), &LuaVariableMap); err != nil { - setting.Logger.Warning("NewVariables gluamapper.Map err,", err) - } - - TypeVariableMap := DeviceNodeTypeVariableMapTemplate{} - TypeVariableMap.TemplateType = templateType - for _, v := range LuaVariableMap.Variable { - variable := DeviceNodeTypeVariableTemplate{} - variable.Index = v.Index - variable.Name = v.Name - variable.Label = v.Label - variable.Type = v.Type - TypeVariableMap.Variable = append(TypeVariableMap.Variable, variable) - } - DeviceNodeTypeVariableMap = append(DeviceNodeTypeVariableMap, TypeVariableMap) -} diff --git a/httpServer/routerDevice.go b/httpServer/routerDevice.go index 18f698e..ec37b1f 100644 --- a/httpServer/routerDevice.go +++ b/httpServer/routerDevice.go @@ -859,35 +859,6 @@ func apiGetTemplate(context *gin.Context) { context.String(http.StatusOK, string(sJson)) } -func apiGetTemplateVariable(context *gin.Context) { - - templateType := context.Query("TemplateType") - - aParam := &struct { - Code string - Message string - Data device.DeviceNodeTypeVariableMapTemplate - }{} - - for _, v := range device.DeviceNodeTypeVariableMap { - if v.TemplateType == templateType { - aParam.Code = "0" - aParam.Message = "" - aParam.Data = v - - sJson, _ := json.Marshal(aParam) - context.String(http.StatusOK, string(sJson)) - return - } - } - - aParam.Code = "1" - aParam.Message = "TemplateType is not exist" - aParam.Data = device.DeviceNodeTypeVariableMapTemplate{} - sJson, _ := json.Marshal(aParam) - context.String(http.StatusOK, string(sJson)) -} - func apiAddDeviceTSL(context *gin.Context) { aParam := struct { diff --git a/httpServer/routerWeb.go b/httpServer/routerWeb.go index 121cb06..f645ea5 100644 --- a/httpServer/routerWeb.go +++ b/httpServer/routerWeb.go @@ -187,9 +187,6 @@ func RouterWeb() { //删除设备物模型服务 deviceRouter.DELETE("/tsl/services", apiDeleteDeviceTSLServices) - //获取设备模板变量 - deviceRouter.GET("/templateVariable", apiGetTemplateVariable) - //获取通信接口 deviceRouter.GET("/commInterface", apiGetCommInterface) diff --git a/webroot/.DS_Store b/webroot/.DS_Store deleted file mode 100644 index f50ba5de28cfa15090634f68e75d22e929e7d05f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHM&2G~`5T5O?n+j2+3R+ISAaO`hoTe=iLZoSsC?`-5900XRoF+z&H%gp_VuEtv z4Y=_00=xqk#0j{=m3Khm3NyRg)^_W1qp01HcE9!RjMwvx$Idtaz=}QF0+<5;0~_JY zG zIF$_0^TEVMSWq~WC>|Zyi4p*D45x+Q80!FGV=62t97+_XcurY8FlEYAiNT~fuA8Ke zSWq~WD9wRMb6{#`rYaOBc1Jr?r~@lV)V*dvGjNars@^L~-{Ji9B-QO?>3q zLb4io<3GVQOq%G8&tBqo;bfUWEgx@vpOP%5`|~K>P%u6pcQEFHAeUQ7n^`M=WRko_ zhfoq@L9vPu63K_$w^#A?a7Oe$e7vnPB65xv-_MC8ok&(J|G;gc*AWXlt!vQ?oKyxz zrDJnc|KCjh{(n;4*M4aRGy}*08!MGdMH(c~LAADtZ4(;_=?x_c6YNAejws4;#JxWZ gacrV0*%TBGCE^UqKmQQ0`@37e{{{cLJDm*t0sVVpMgRZ+