update emulator
This commit is contained in:
@@ -56,6 +56,17 @@ func (s *DeviceState) handleWriteCommand(cmd string) string {
|
||||
return "ERRORE: I comandi 'W' sono accettati solo in modalità programmazione."
|
||||
}
|
||||
|
||||
// Handle special WNC command
|
||||
if strings.HasPrefix(cmd, "WNC=") {
|
||||
valueStr := strings.TrimPrefix(cmd, "WNC=")
|
||||
value, err := strconv.Atoi(valueStr)
|
||||
if err != nil || (value != 0 && value != 1) {
|
||||
return "ERRORE: Valore fuori range per WNC"
|
||||
}
|
||||
s.SetNCParam(value == 1)
|
||||
return fmt.Sprintf("OK: Parametro WNC impostato e salvato: %d", value)
|
||||
}
|
||||
|
||||
// Parse command format: "W<id>=<value>"
|
||||
parts := strings.SplitN(cmd, "=", 2)
|
||||
if len(parts) != 2 {
|
||||
@@ -97,6 +108,15 @@ func (s *DeviceState) handleReadCommand(cmd string) string {
|
||||
return "ERRORE: I comandi 'W' sono accettati solo in modalità programmazione."
|
||||
}
|
||||
|
||||
// Handle special RNC command
|
||||
if cmd == "RNC" {
|
||||
value := 0
|
||||
if s.GetNCParam() {
|
||||
value = 1
|
||||
}
|
||||
return fmt.Sprintf("PARAM: WNC=%d", value)
|
||||
}
|
||||
|
||||
// Extract parameter ID
|
||||
idStr := strings.TrimPrefix(cmd, "R")
|
||||
id, err := strconv.Atoi(idStr)
|
||||
|
||||
Reference in New Issue
Block a user