Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ The app supports two modes controlled by the `--desktop` flag:
- `cmd/simulator/templates/index.html` - Embedded dashboard UI
- `cmd/simulator/wails.json` - Wails configuration

**Public package:**
- `fuse/` - each phase's fuse as a thermal model (element, body, holder; I² heating), within IEC 60269-1's gates and following ABB's gG curves for 16-63 A; no dependencies, so an EMS's own simulation (FTW's `go/internal/sitesim`) imports the same model

**Internal packages:**
- `internal/modbus/server.go` - Modbus TCP server with register storage and logging
- `internal/modbus/registers.go` - Register definitions, encoding/decoding (U16, I16, U32, I32)
Expand Down
30 changes: 25 additions & 5 deletions cmd/simulator/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math"
"time"

"github.com/srcfl/device-simulator/fuse"
"github.com/srcfl/device-simulator/internal/modbus"
"github.com/srcfl/device-simulator/internal/modbus/devices"
"github.com/srcfl/device-simulator/internal/settings"
Expand Down Expand Up @@ -906,18 +907,37 @@ func (a *App) UpdateSiteConfig(id int, config map[string]interface{}) error {
if baseLoad, ok := config["base_load_w"].(float64); ok {
site.BaseLoadW = baseLoad
}
if fuseSize, ok := config["fuse_size"].(float64); ok {
fuseSize, sizeSet := config["fuse_size"].(float64)
fuseProfile, profileSet := config["fuse_profile"].(string)
if sizeSet || profileSet {
size, profile := site.FuseSize, site.FuseProfile
if sizeSet {
if fuseSize != math.Trunc(fuseSize) {
return fmt.Errorf("fuse size %v A is not whole amperes", fuseSize)
}
size = int(fuseSize)
}
if profileSet {
profile = fuseProfile
}
if err := checkFuse(size, profile); err != nil {
return err
}
}
if sizeSet {
site.FuseSize = int(fuseSize)
site.FuseDamage = PhaseLoads{}
site.FuseHeat = [3]fuse.Phase{}
site.FuseOverload = FuseOverload{}
}
if fuseProfile, ok := config["fuse_profile"].(string); ok {
if profileSet {
if _, exists := fuseProfiles[fuseProfile]; !exists {
return fmt.Errorf("unknown fuse profile")
}
if site.FuseProfile != fuseProfile {
site.FuseProfile = fuseProfile
site.FuseDamage = PhaseLoads{}
site.FuseHeat = [3]fuse.Phase{}
site.FuseOverload = FuseOverload{}
}
}
Expand All @@ -935,19 +955,19 @@ func (a *App) UpdateSiteConfig(id int, config map[string]interface{}) error {
if fb, ok := config["fuse_blown"].(map[string]interface{}); ok {
if l1, ok := parseBool(fb["l1"]); ok {
if site.FuseBlown.L1 && !l1 {
site.FuseDamage.L1 = 0
site.FuseDamage.L1, site.FuseHeat[0] = 0, fuse.Phase{}
}
site.FuseBlown.L1 = l1
}
if l2, ok := parseBool(fb["l2"]); ok {
if site.FuseBlown.L2 && !l2 {
site.FuseDamage.L2 = 0
site.FuseDamage.L2, site.FuseHeat[1] = 0, fuse.Phase{}
}
site.FuseBlown.L2 = l2
}
if l3, ok := parseBool(fb["l3"]); ok {
if site.FuseBlown.L3 && !l3 {
site.FuseDamage.L3 = 0
site.FuseDamage.L3, site.FuseHeat[2] = 0, fuse.Phase{}
}
site.FuseBlown.L3 = l3
}
Expand Down
Loading
Loading