summaryrefslogtreecommitdiff
path: root/src/camera.go
blob: 12a9d54fd1b76109355e5a0f8b1dbabf5af78ce1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()
}