Created
          July 20, 2011 16:24 
        
      - 
      
- 
        Save snay2/1095293 to your computer and use it in GitHub Desktop. 
    KRL for the home automation prototype (incoming call example)
  
        
  
    
      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
    
  
  
    
  | rule incoming_call { | |
| select when phone incoming_call | |
| pre { | |
| media_state = get_media_state(); | |
| new_media_state = (media_state eq "play") => "pause" | media_state; | |
| light_level = get_light_level(); | |
| new_light_level = (light_level <= 8) => 8 | light_level; | |
| } | |
| { | |
| set_media_state(new_media_state); | |
| set_light_level(new_light_level); | |
| } | |
| fired { | |
| set app:prev_media_state media_state; | |
| set app:prev_light_level light_level; | |
| } | |
| } | |
| rule call_finished { | |
| select when phone hung_up | |
| { | |
| set_media_state(app:restore_media_state); | |
| set_light_level(app:prev_light_level); | |
| } | |
| fired { | |
| clear app:prev_media_state; | |
| clear app:prev_light_level; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment