diff options
author | xengineering <mail2xengineering@protonmail.com> | 2021-06-15 15:51:38 +0200 |
---|---|---|
committer | xengineering <mail2xengineering@protonmail.com> | 2021-06-15 15:58:23 +0200 |
commit | 4a01c8e94921d9ddcaf6d6dee0feca4d9c3655a2 (patch) | |
tree | 634a3d6e380079d0da5e8fafaf866a33a63fb4bc /src/camera.go | |
parent | 2269cc653577dffc58dba4ad5534583f28f224de (diff) | |
download | birdscan-4a01c8e94921d9ddcaf6d6dee0feca4d9c3655a2.tar birdscan-4a01c8e94921d9ddcaf6d6dee0feca4d9c3655a2.tar.zst birdscan-4a01c8e94921d9ddcaf6d6dee0feca4d9c3655a2.zip |
Refactoring: Camera has Statemachine and not is Statemachine
Diffstat (limited to 'src/camera.go')
-rw-r--r-- | src/camera.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/camera.go b/src/camera.go new file mode 100644 index 0000000..12a9d54 --- /dev/null +++ b/src/camera.go @@ -0,0 +1,38 @@ +// vim: shiftwidth=4 tabstop=4 noexpandtab + +package main + +type Camera struct { + statemachine Machine +} + +func NewCamera() Camera { + return Camera{ + statemachine: Machine{ + name: "camera", + initial: "idle", + states: StateMap{ + "idle": MachineState{ + on: TransitionMap{ + "take_single_picture": MachineTransition{ + to: "single_picture", + }, + }, + }, + "single_picture": MachineState{ + on: TransitionMap{ + "single_picture_taken": MachineTransition{ + to: "idle", + }, + }, + }, + }, + api: make(chan string), + state_listeners: make([]*(chan string), 0), + }, + } +} + +func (cam *Camera) run() { + cam.statemachine.Run() +} |