完成了设备模版的修改

This commit is contained in:
969753572 2020-07-06 21:58:21 +08:00
parent 41365b7391
commit a00b8aec08
6 changed files with 21 additions and 27 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -158,15 +158,15 @@ func CommunicationManageAddEmergencyTest(){
func CommunicationManagePoll(){
cmd := CommunicationCmd{}
for i:=0;i<DeviceInterfaceMap[InterFaceID0].DeviceNodeCnt;i++{
cmd.interfaceID = InterFaceID0
cmd.deviceAddr = DeviceInterfaceMap[InterFaceID0].DeviceNodeAddrMap[i]
cmd.deviceType = DeviceInterfaceMap[InterFaceID0].DeviceNodeTypeMap[i]
cmd.funName = "GetDeviceRealVariables"
CommunicationManageAdd(cmd)
}
//cmd := CommunicationCmd{}
//
//for i:=0;i<DeviceInterfaceMap[InterFaceID0].DeviceNodeCnt;i++{
//
// cmd.interfaceID = InterFaceID0
// cmd.deviceAddr = DeviceInterfaceMap[InterFaceID0].DeviceNodeAddrMap[i]
// cmd.deviceType = DeviceInterfaceMap[InterFaceID0].DeviceNodeTypeMap[i]
// cmd.funName = "GetDeviceRealVariables"
//
// CommunicationManageAdd(cmd)
//}
}

View File

@ -35,8 +35,6 @@ type DeviceNodeInterface interface {
ProcessRx(rxChan chan bool,rxBuf []byte,rxBufCnt int) chan bool
//获取设备变量值
GetDeviceVariablesValue() []VariableTemplate
//New(index int,dType string,dAddr string)DeviceNodeInterface
}
type Build interface{
@ -104,7 +102,9 @@ const (
//var DeviceNodeTypeMap [MaxDeviceNodeTypeCnt]DeviceNodeTypeTemplate
var DeviceInterfaceMap [MaxDeviceInterfaceManage]*DeviceInterfaceTemplate
var DeviceInterfaceParamMap DeviceInterfaceParamMapTemplate
var DeviceTemplateMap = map[string]Build{
"modbus":&DeviceNodeModbusTemplate{},
}
func WriteDeviceInterfaceManageToJson(){
@ -127,8 +127,6 @@ func WriteDeviceInterfaceManageToJson(){
DeviceInterfaceParamMap.DeviceInterfaceParam[k].DeviceNodeCnt = v.DeviceNodeCnt
DeviceInterfaceParamMap.DeviceInterfaceParam[k].DeviceNodeAddrMap = v.DeviceNodeAddrMap
DeviceInterfaceParamMap.DeviceInterfaceParam[k].DeviceNodeTypeMap = v.DeviceNodeTypeMap
}
sJson,_ := json.Marshal(DeviceInterfaceParamMap)
@ -199,8 +197,8 @@ func DeviceNodeManageInit(){
//创建设备实例
for i:=0;i<v.DeviceNodeCnt;i++{
DeviceInterfaceMap[k].NewDeviceNode(
v.DeviceNodeAddrMap[i],
v.DeviceNodeTypeMap[i])
v.DeviceNodeTypeMap[i],
v.DeviceNodeAddrMap[i])
}
}
}else{
@ -261,12 +259,6 @@ func (d *DeviceInterfaceTemplate)ModifyDeviceInterface(pollPeriod,offlinePeriod
d.OfflinePeriod = offlinePeriod
}
var DeviceTemplateMap = map[string]Build{
"modbus": &DeviceNodeModbusTemplate{},
}
DeviceTemplateMap
/********************************************************
功能描述 增加单个节点
参数说明
@ -281,7 +273,7 @@ func (d *DeviceInterfaceTemplate)NewDeviceNode(dType string,dAddr string){
builder,ok := DeviceTemplateMap[dType]
if !ok{
log.Println("deviceNodeType is not exist")
panic("deviceNodeType is not exist")
}
index := len(d.DeviceNodeMap)
@ -312,9 +304,10 @@ func (d *DeviceInterfaceTemplate)AddDeviceNode(dType string,dAddr string) (bool,
//
//}
log.Printf("dType is %s\n",dType)
builder,ok := DeviceTemplateMap[dType]
if !ok{
log.Println("deviceNodeType is not exist")
panic("deviceNodeType is not exist")
}
index := len(d.DeviceNodeMap)

BIN
goAdapter

Binary file not shown.

View File

@ -183,7 +183,7 @@ func apiAddNode(context *gin.Context){
}
var status bool
status,aParam.Message = device.DeviceInterfaceMap[nodeInfo.InterfaceID].AddDeviceNode(nodeInfo.DAddr,nodeInfo.DType)
status,aParam.Message = device.DeviceInterfaceMap[nodeInfo.InterfaceID].AddDeviceNode(nodeInfo.DType,nodeInfo.DAddr)
if status == true{
device.WriteDeviceInterfaceManageToJson()

1
selfpara/deviceNodeManage.json Executable file
View File

@ -0,0 +1 @@
{"DeviceInterfaceParam":[{"InterfaceID":0,"PollPeriod":60,"OfflinePeriod":180,"DeviceNodeCnt":1,"DeviceAddrMap":["1"],"DeviceTypeMap":["modbus"]},{"InterfaceID":1,"PollPeriod":60,"OfflinePeriod":180,"DeviceNodeCnt":0,"DeviceAddrMap":[],"DeviceTypeMap":[]}],"DeviceNodeTypeMap":[],"DeviceTemplateMap":{"modbus":{"Index":0,"Addr":"","Type":"","LastCommRTC":"","CommTotalCnt":0,"CommSuccessCnt":0,"CommStatus":"","TemplateName":"","TemplateType":"","TemplateID":"","TemplateMessage":""}}}