-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
automata.yaml missing? #9
Comments
Hi, thanks for looking at my project! There's a couple of examples of config here, though may be slight out of date: Line 4 in c491aeb
Line 6 in c491aeb
|
You need to upload the config to a topic on the mqtt server - there's a command: |
Hey Barnaby Gray,
I've put a few things together however I think I've missed something? I'm
new to Go coming from Python. Go is Great!
I'm coding up a repeater which is like a TV transmitter. number of states
with transitions.Thought using fsm is a better approach than a bunch of
nested if else's?
*My Go code main.go*
package main
import (
"fmt"
"github.com/barnybug/gofsm"
"os"
)
func main() {
data, err := os.ReadFile("fsm_config.yaml")
if err != nil {
panic(err)
}
// Initialize the FSM from YAML
fsm, err := gofsm.FromYaml(data)
if err != nil {
panic(err)
}
// Subscribe to state changes
fsm.OnChange(func(e *gofsm.Event) {
fmt.Printf("transitioned from %v -> %v by %v\n", e.Src(), e.Dst(),
e.Event())
})
// Simulate events
fsm.Event("EvtStartupDone")
fsm.Event("EvtGoOnAir")
fsm.Event("EvtEndTransmission")
fsm.Event("EvtSleep")
fsm.Event("EvtWakeup")
fsm.Event("EvtShutdown")
}
*My fsm_config.yaml fil*e
initial: STARTUP
states:
- STARTUP
- IDLE
- ONAIR
- SHUTDOWN
- SLEEP
events:
- EvtStartupDone
- EvtGoOnAir
- EvtEndTransmission
- EvtShutdown
- EvtSleep
- EvtWakeup
transitions:
STARTUP:
EvtStartupDone: IDLE
IDLE:
EvtGoOnAir: ONAIR
EvtShutdown: SHUTDOWN
EvtSleep: SLEEP
ONAIR:
EvtEndTransmission: IDLE
SLEEP:
EvtWakeup: IDLE
Any quick clue on how to use it?
Regards
Rob
…On Thu, 31 Aug 2023 at 23:16, Barnaby Gray ***@***.***> wrote:
You need to upload the config to a topic on the mqtt server - there's a
command:
gohome config config config.yml
But I've not tested starting a 'greenfield' installation from nothing, so
YMMV!
—
Reply to this email directly, view it on GitHub
<#9 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM4O2SZ6RTJLPLQ3PST3F4DXYCFETANCNFSM6AAAAAA4A2Z5HU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hello @barnybug,
I'm looking on how to implement a repeater controller using gofsm and having states and transition in automata.yml file. Finding hard to understand how gohome uses it. great work on gohome btw.
// The automata are configured via yaml configuration format configured under:
//
// http://localhost:8723/config?path=gohome/config/automata
The text was updated successfully, but these errors were encountered: