From adf59e8c6cdaf050ef9cf09301111e7429ec0c37 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Thu, 13 Oct 2022 08:23:01 +0200 Subject: Client + Config + FSM: Simplify file names --- client.go | 4 ++-- fsm.go | 3 +-- internal/config/config.go | 6 +++--- internal/fsm/fsm.go | 4 +--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/client.go b/client.go index 6aa9a3a..ffa8802 100644 --- a/client.go +++ b/client.go @@ -90,11 +90,11 @@ func (client *Client) Register( } // Initialize the FSM - client.FSM = newFSM(name, stateCallback, directory, debug) + client.FSM = newFSM(stateCallback, directory, debug) client.Debug = debug // Initialize the Config - client.Config.Init(name, directory) + client.Config.Init(directory, "state") // Try to load the previous configuration if client.Config.Load(&client) != nil { diff --git a/fsm.go b/fsm.go index ae5bfdc..25d3e79 100644 --- a/fsm.go +++ b/fsm.go @@ -95,7 +95,6 @@ func GetStateName(s FSMStateID) string { } func newFSM( - name string, callback func(FSMStateID, FSMStateID, interface{}), directory string, debug bool, @@ -201,7 +200,7 @@ func newFSM( }, } returnedFSM := fsm.FSM{} - returnedFSM.Init(name, STATE_DEREGISTERED, states, callback, directory, GetStateName, debug) + returnedFSM.Init(STATE_DEREGISTERED, states, callback, directory, GetStateName, debug) return returnedFSM } diff --git a/internal/config/config.go b/internal/config/config.go index 0965998..ec9afa2 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -11,13 +11,13 @@ import ( ) type Config struct { - Name string Directory string + Name string } -func (config *Config) Init(name string, directory string) { - config.Name = name +func (config *Config) Init(directory string, name string) { config.Directory = directory + config.Name = name } func (config *Config) GetFilename() string { diff --git a/internal/fsm/fsm.go b/internal/fsm/fsm.go index 4fc647e..d5957b0 100644 --- a/internal/fsm/fsm.go +++ b/internal/fsm/fsm.go @@ -54,7 +54,6 @@ type FSM struct { } func (fsm *FSM) Init( - name string, current FSMStateID, states map[FSMStateID]FSMState, callback func(FSMStateID, FSMStateID, interface{}), @@ -64,7 +63,6 @@ func (fsm *FSM) Init( ) { fsm.States = states fsm.Current = current - fsm.Name = name fsm.StateCallback = callback fsm.Directory = directory fsm.GetName = nameGen @@ -86,7 +84,7 @@ func (fsm *FSM) HasTransition(check FSMStateID) bool { } func (fsm *FSM) getGraphFilename(extension string) string { - debugPath := path.Join(fsm.Directory, fsm.Name) + debugPath := path.Join(fsm.Directory, "graph") return fmt.Sprintf("%s%s", debugPath, extension) } -- cgit v1.2.3