Class: X10::Cm17a::Controller
- Inherits:
-
Object
- Object
- X10::Cm17a::Controller
- Defined in:
- lib/x10/cm17a.rb,
ext/cm17a_api/cm17a_api.c
Overview
The Controller object is the low level interface to the CM17A Firecracker controller. Client software generally uses the device level interface rather than the controller directly.
Class Method Summary collapse
-
.x10_controller? ⇒ Boolean
Yes, this class represents a X10 controller.
Instance Method Summary collapse
-
#close ⇒ Object
Close the controller device.
-
#command(house, unit, command_code, steps) ⇒ Object
Send a command to the CM17A controller.
-
#device(house, unit) ⇒ Object
Create an X10::Cm17a::Device on this controller at the given X10 house and unit address.
-
#initialize(*args) ⇒ Object
constructor
Create a new CM17A controller on the serial device named
device_name
.
Constructor Details
#X10::Cm17a::Controller.new ⇒ Object #X10::Cm17a::Controller.new(device_name) ⇒ Object
Create a new CM17A controller on the serial device named device_name
. If no device name is given, then a default device will be selected (/dev/ttyS0
for linux and COM1
for windows).
50 51 52 53 54 55 56 57 58 59 |
# File 'ext/cm17a_api/cm17a_api.c', line 50
static VALUE cm17a_init(int argc, VALUE *argv, VALUE self)
{
const char * device_name = DEFAULT_SERIAL_DEVICE;
if (argc > 0)
device_name = STR2CSTR(argv[0]);
fd = cm17a_open_device(device_name);
if (fd == INVALID_X10_DEVICE)
rb_raise(eX10Error, "Unable to open cm17a device '%s'", device_name);
return self;
}
|
Class Method Details
.x10_controller? ⇒ Boolean
Yes, this class represents a X10 controller.
23 24 25 |
# File 'lib/x10/cm17a.rb', line 23 def self.x10_controller? true end |
Instance Method Details
#close ⇒ Object
Close the controller device.
108 109 110 111 112 |
# File 'ext/cm17a_api/cm17a_api.c', line 108
static VALUE cm17a_close(VALUE self)
{
cm17a_close_device(fd);
return Qnil;
}
|
#command(house, unit, command_code, steps) ⇒ Object
Send a command to the CM17A controller. The X10 unit to get the address is given by the house
code (0-15) and the unit
code (0-15). The command must be one of the following constants:
-
:on
– Turn the device on. -
:off
– Turn the device off. -
:dim
– Dim the device bysteps
steps. -
:brighten
– Brighten the device bysteps
steps.
Note that the unit code is ignored for the :brighten
and :dim
commands. The bright/dim commands will effect the last addressed unit.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'ext/cm17a_api/cm17a_api.c', line 78
static VALUE cm17a_ruby_command(
VALUE self,
VALUE rhouse,
VALUE rdevice,
VALUE rcommand,
VALUE rsteps)
{
int house = NUM2INT(rhouse);
int device = NUM2INT(rdevice);
int steps = NUM2INT(rsteps);
int command;
if (rcommand == symON)
command = CM17A_ON;
else if (rcommand == symOFF)
command = CM17A_OFF;
else if (rcommand == symDIM)
command = CM17A_DIM;
else if (rcommand == symBRIGHTEN)
command = CM17A_BRIGHTEN;
else
command = NUM2INT(rcommand);
cm17a_command(fd, house, device, command, steps);
return Qnil;
}
|