This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(code_lock). | |
-behaviour(gen_statem). | |
-define(NAME, code_lock). | |
-export([down/1,up/1,code_length/0]). % API | |
-export([start_link/1,stop/0]). % Server | |
-export([init/1,callback_mode/0,terminate/3]). % Behaviour | |
-export([locked/3,open/3]). % States |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule CodeLock do | |
@name :code_lock | |
## Start and stop | |
def start_link(code) do | |
:gen_statem.start_link({:local,@name}, __MODULE__, code, []) | |
end | |
def stop, do: :gen_statem.stop @name | |
def callback_mode, do: [:state_functions,:state_enter] |