Refactor and simplify package structure and interfaces.

Reorganize code by removing unused files, restructuring package organization, and updating import references to new paths. This simplifies handling of smart and protocol-related operations, improves maintainability, and eliminates redundancy.
This commit is contained in:
2025-04-27 17:05:45 +03:00
parent 51308a2395
commit eaaa634558
24 changed files with 565 additions and 416 deletions

83
pkg/models/configmodel.go Normal file
View File

@ -0,0 +1,83 @@
package models
import (
"gitea.unprism.ru/KRBL/n9m/v2/pkg/parameters"
)
/*
// request reqistration parameters (directly to register)
func (e *Package) RequestParameters(params map[string]any, serial int, session string) {
e.Payload = map[string]any{
"MODULE": "CONFIGMODEL",
"OPERATION": "GET",
"PARAMETER": map[string]any{
"MDVR": params["MDVR"],
"SERIAL": serial,
},
"SESSION": session,
}
} // end of 'RequestParameters' function
// set reigeter parameters (directly to register)
func (e *Package) SetParameters(params map[string]any, serial int, session string) {
e.Payload = map[string]any{
"MODULE": "CONFIGMODEL",
"OPERATION": "SET",
"PARAMETER": map[string]any{
"MDVR": params["MDVR"],
"SERIAL": serial,
},
"SESSION": session,
}
// log.Println(e.Payload)
} // end of 'SetParameters' function
*/
type ConfigModelSetRequest struct {
MDVR parameters.Setting `json:"MDVR"`
}
type ConfigModelGetRequest struct {
MDVR interface{} `json:"MDVR"`
}
type ConfigModelSetResponse struct {
MDVR parameters.Setting `json:"MDVR"`
}
func InitialConfig() ConfigModelSetRequest {
return ConfigModelSetRequest{
MDVR: parameters.Setting{
KEYS: parameters.KEYS{
GV: 1, // GPS version
},
PGDSM: parameters.PGDSM{
PGPS: parameters.PGPS{
EN: 1, // Real-time position monitoring
MODE: 0b10, // Enable timer
TM: 10, // Time interval
},
},
SUBSTRNET: parameters.SUBSTRNET{
SM: 1,
},
},
}
}
/*
func (e *Package) ResponseConfigModelSet(Sid string) {
e.Payload = map[string]any{
"MODULE": "CONFIGMODUL", // it's not error
"OPERATION": "SET",
"RESPONSE": map[string]any{
"ERRORCODE": 0,
"ERRORCAUSE": "None",
"ERRORDESCRIPTION": "None",
},
"SESSION": Sid,
}
}
*/