update emulator

This commit is contained in:
2026-02-19 11:43:40 +01:00
parent 27517bd2ea
commit 5e448a14e2
7 changed files with 109 additions and 22 deletions

View File

@@ -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)