From 4a01c8e94921d9ddcaf6d6dee0feca4d9c3655a2 Mon Sep 17 00:00:00 2001 From: xengineering Date: Tue, 15 Jun 2021 15:51:38 +0200 Subject: Refactoring: Camera has Statemachine and not is Statemachine --- src/camera.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/camera.go (limited to 'src/camera.go') 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() +} -- cgit v1.2.3-70-g09d2