1. develop controller for smart devices rapidly

  1. load Demo project, if you had opened it, go to next step. do following to load demo :
    1. right click tray icon of HomeCenter server, it display as following :
    2. click "Designer"
    3. click "Demo" button in toolbar, after successful load demo, a message is displayed.

  2. click "Air Ctrler [controller://myctrl]" tree node in left tree panel

  3. the editor of example controller in Demo project looks like following :

    layout area : (in left side)
    • Logical layout : There are five keys in first blue block area, there are six keys in second blue block area. Each block is 240X240。
    • Layout implementation: You do not care about the layout implementation. the physical layout of the mobile according to the phone's size and horizontal, vertical screen.
      • If your mobile (240X480) use the controller above in portrait orientation, the controller looks like the view in editor. If your mobile is in landscape orientation, the keys in second blue block are the right side of the keys in first block, not the bottom.
      • the layout of keys in mobile follows the principles : the key position within same blue block is relatively constant, the relative position between the blocks due to the width of the phone screen from left to right, from top to bottom in order is placed.

    response area : (in right side)

  4. Requirements : if user press OK key of controller on mobile, your HomeCenter server receive it and send a message for response . The initial temperature of air conditioning is 18℃
    just do as following :
    1. find
      elsif keyValue == CtrlKey::KEY_OK
    2. press return key in the line end, input :
      showTip "Press OK"
    3. important : the script will be executed on JRuby engine in JVM of your HomeCenter server, the responsibility of mobile side are presentation and receiving inputs
    4. find
      def onLoad
    5. press return key in the line end, input :
      sendStatus "Temperature", "18℃"
    6. click Test Script button, a green bar will be displayed on the bottom, it means code is OK
    7. click Activate button in toolbar, (if the project is in active status, clicking is still needed for overriding the old deploy), save project, a message (Successful activate project, moble can access this resources now.) will be popped up
    8. start your mobile app, input HomeCenter ID and password, click OK, your demo project looks like these on mobile :
    9. click Air Ctrler icon to enter the controller, click OK key of controller, there is a moving message "Press OK" displayed on mobile. It looks like following :
    10. to view the current temperature, click the left arrow icon on the right side, it looks like the following :


  • return to tutorials of HomeCenter server