#include <time.h>
Go to the source code of this file.
Compounds | |
struct | rwil_device |
Typedefs | |
typedef void * | rwil_handle |
typedef void(* | rwil_success_callback_t )(rwil_device) |
The type used for success callbacks. More... | |
typedef void(* | rwil_failure_callback_t )(rwil_device, const char *) |
The type used for failure callbacks. More... | |
typedef void(* | rwil_x10_listener_t )(char, int, const char *) |
The type used for the X10 listener. More... | |
Functions | |
rwil_handle | rwil_init () |
Initialize the Real World Interface Library. More... | |
rwil_device | rwil_create (rwil_handle rwilhandle, char house, int num) |
Create a device in the RWIL with the specified attributes. More... | |
void | rwil_destroy (rwil_device handle) |
Destroy a device from the RWIL with the specified handle. More... | |
void | rwil_on (rwil_device handle, time_t when) |
Turn a device on to full power. More... | |
void | rwil_off (rwil_device handle, time_t when) |
Turn a device off. More... | |
void | rwil_setbright (rwil_device handle, int brightness, time_t when) |
Set the brightness of a device. More... | |
void | rwil_interpolatebright (rwil_device handle, int startbrightness, int endbrightness, time_t startwhen, time_t endwhen, int steps) |
Interpolate brightness between two values over a time interval. More... | |
int | rwil_getbright (rwil_device handle) |
Get the brightness of a device now. More... | |
int | rwil_ison (rwil_device handle) |
Determine whether the device is on now. More... | |
void | rwil_success_callback (rwil_success_callback_t callback) |
Set the success callback. More... | |
void | rwil_failure_callback (rwil_failure_callback_t callback) |
Set the failure callback. More... | |
void | rwil_set_x10_listener (rwil_x10_listener_t callback) |
Set the X10 listener. More... | |
void | rwil_shutdown (rwil_handle rwilhandle) |
Shutdown the RWIL. More... |
|
The type used for failure callbacks. This function takes as a parameter the device handle of the device that unsuccesfully executed, and a textual error message. Definition at line 103 of file procrwil.h. Referenced by rwil_failure_callback(). |
|
Definition at line 15 of file procrwil.h. Referenced by main(), rwil_create(), rwil_init(), and rwil_shutdown(). |
|
The type used for success callbacks. This function takes as a parameter the device handle of the device that succesfully executed. Definition at line 90 of file procrwil.h. Referenced by rwil_success_callback(). |
|
The type used for the X10 listener. This function takes a parameter for the house letter, the unit number and the textual messagetype house letters are uppercase in the range [A,P], the unit numbers are in the range [1,16] and the various message-types are:
Definition at line 133 of file procrwil.h. Referenced by rwil_set_x10_listener(). |
|
Create a device in the RWIL with the specified attributes.
Definition at line 26 of file procrwil.cpp. Referenced by main().
00027 { 00028 char buf[20]; 00029 int val; 00030 RWIL *rwil = (RWIL*)rwilhandle; 00031 rwil_device device; 00032 val = (house << 16) + num; 00033 sprintf(buf, "%d", val); 00034 X10Device *dev = new X10Device(buf, rwil->output, house, num); 00035 rwil->AddDevice(dev); 00036 device.handle = rwilhandle; 00037 device.dev_handle = val; 00038 return device; 00039 } |
|
Destroy a device from the RWIL with the specified handle.
Definition at line 42 of file procrwil.cpp. Referenced by main().
00043 { 00044 RWIL *rwil = (RWIL*)handle.handle; 00045 char buf[20]; 00046 sprintf(buf, "%d", handle.dev_handle); 00047 rwil->RemoveDevice(buf); 00048 } |
|
Set the failure callback. Set the global failure callback.
Definition at line 126 of file procrwil.cpp. Referenced by main().
00127 { 00128 failure_call = callback; 00129 } |
|
Get the brightness of a device now. Get the current brightness of a device.
Definition at line 98 of file procrwil.cpp. Referenced by rwil_ison().
00099 { 00100 RWIL *rwil = (RWIL*)handle.handle; 00101 char buf[20]; 00102 sprintf(buf, "%d", handle.dev_handle); 00103 00104 X10Device* dev = (X10Device *)rwil->GetDevice(buf); 00105 return StringToInt(dev->GetStatus()); 00106 } |
|
Initialize the Real World Interface Library. Call this before any other functions. Definition at line 14 of file procrwil.cpp.
00015 { 00016 RWIL *ptr = new RWIL; 00017 rwil_handle handle; 00018 ptr->Start(); 00019 ptr->AddDevice(new X10Recv("rwil_x10_listener", ptr->output)); 00020 handle = ptr; 00021 ptr->output.SetAddCallback(rwil_callback); 00022 return handle; 00023 } |
|
Interpolate brightness between two values over a time interval. Callback is only called at completion or failure of last event.
Definition at line 75 of file procrwil.cpp. Referenced by main().
00076 { 00077 RWIL *rwil = (RWIL*)handle.handle; 00078 char buf[20]; 00079 00080 time_t timedif = endwhen - startwhen; 00081 int brightdif = endbrightness - startbrightness; 00082 00083 sprintf(buf, "%d", handle.dev_handle); 00084 00085 int count = 0; 00086 for(count = 0; count < steps; count++) 00087 { 00088 Message msg(buf, "dim", startwhen + timedif * count / steps); 00089 msg.SetParam("percent", IntToString(startbrightness + brightdif * count / steps)); 00090 00091 //Ensure that the callback is only called by the last change in brightness 00092 if((count + 1)== steps)msg.SetParam("rwilhandle", IntToString((int)rwil)); 00093 rwil->input.Add(msg); 00094 } 00095 } |
|
Determine whether the device is on now.
Definition at line 109 of file procrwil.cpp.
00110 { 00111 if(rwil_getbright(handle)) return 1; 00112 return 0; 00113 } |
|
Turn a device off.
Definition at line 56 of file procrwil.cpp. Referenced by main().
00057 { 00058 rwil_setbright(handle, 0, when); 00059 } |
|
Turn a device on to full power.
Definition at line 51 of file procrwil.cpp. Referenced by main().
00052 { 00053 rwil_setbright(handle, 100, when); 00054 } |
|
Set the X10 listener. Use this function to activate and set up the x10 listener. If you pass a null value as a listener then the function will deactivate listening.
Definition at line 131 of file procrwil.cpp.
00132 { 00133 listener_call = callback; 00134 } |
|
Set the brightness of a device.
Definition at line 62 of file procrwil.cpp. Referenced by rwil_off(), and rwil_on().
00063 { 00064 RWIL *rwil = (RWIL*)handle.handle; 00065 char buf[20]; 00066 sprintf(buf, "%d", handle.dev_handle); 00067 00068 Message msg(buf, "dim", when); 00069 msg.SetParam("percent", IntToString(brightness)); 00070 msg.SetParam("rwilhandle", IntToString((int)rwil)); 00071 rwil->input.Add(msg); 00072 } |
|
Shutdown the RWIL. This function shuts down the rwil system, and waits for the shutdown to complete. This could take several seconds.
Definition at line 137 of file procrwil.cpp. Referenced by main().
00138 { 00139 RWIL *rwil = (RWIL*)rwilhandle; 00140 rwil->Kill(); 00141 rwil->Join(); 00142 delete rwil; 00143 } |
|
Set the success callback. Set the global success callback.
Definition at line 120 of file procrwil.cpp. Referenced by main().
00121 { 00122 success_call = callback; 00123 } |