Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Apress - Smart Home Automation with Linux (2010)- P55:Linux users can now control their homes remotely! Are you a Linux user who has ever wanted to turn on the lights in your house, or open and close the curtains, while away on holiday? Want to be able to play the same music in every room, controlled from your laptop or mobile phone? Do you want to do these things without an expensive off-the-shelf kit | CHAPTER 7 CONTROL HUBS In the TODO example your applet should be able to list the to-do list for the current user or the public and optionally be able to sort it alphabetically.5 This will ultimately provide you with five potential parameters Refresh state parameter Which user is visible Refresh state parameter Is the list sorted Command argument Switch to user X. Command argument Sort list. Command argument Unsort list aka show in order . This demonstrates the next point there is redundancy here. It is technically possible to combine the refresh state and command parameter in one since they both control the same data. However when you are building a web page you need to know all the refresh state parameters so that the other links on the page have the correct values. Unfortunately that would require a lot of work to know which state parameter would be overridden later by the command parameters. You can simplify this by writing a refresh function that describes the current state and that every other applet will indirectly call when it requests a URL from the applet manager function getRefreshParams appMan return appMan- getArgument this user this- _viewuser . . appMan- getArgument this sort this- _sortlist You next add links that contain command parameters which are similar to those you ve seen already html Show html. appMan- getAppletLink this dosort 0 Chronologically . html. appMan- getAppletLink this dosort 1 Alphabetically html. For html. appMan- getAppletLink this douser user user . html. appMan- getAppletLink this douser public Public 5 To correctly delete an entry from the TODO list you d need to lock the file in case the file got corrupted when two people tried to delete at the same time. I have a truly marvelous solution to this which this margin is too narrow to contain 253 CHAPTER 7 CONTROL HUBS These parameters by convention are prefixed with do indicating that they should change the refresh state. That is new state old state do changes. The applet .