Difference between revisions of "GSD - Ruby codes"

From LinuxMCE
Jump to: navigation, search
 
Line 2: Line 2:
  
 
The framework offers an Ruby ''Command'' object that is actually a wrapper around the C++ class Command. In order to create an instance of the ruby ocommand use:
 
The framework offers an Ruby ''Command'' object that is actually a wrapper around the C++ class Command. In order to create an instance of the ruby ocommand use:
 +
  
 
cmd = Command.new( <device from>, <device to>, <???>, <command type>, <command id>)
 
cmd = Command.new( <device from>, <device to>, <???>, <command type>, <command id>)
 +
  
 
There is a hashmap associated with the comand object that allows setting values for the command parameters:
 
There is a hashmap associated with the comand object that allows setting values for the command parameters:
 +
  
 
cmd.params_[<parameter id>] = <string value for command parameter>
 
cmd.params_[<parameter id>] = <string value for command parameter>
 +
  
 
And for sending the command you should use the SendCommand function:
 
And for sending the command you should use the SendCommand function:
 +
  
 
SendCommand(cmd)
 
SendCommand(cmd)

Revision as of 06:26, 25 September 2006

This page was written by Pluto and imported with their permission when LinuxMCE branched off in February, 2007. In general any information should apply to LinuxMCE. However, this page should be edited to reflect changes to LinuxMCE and remove old references to Pluto.
For Generic Serial Devices the architecture allows implementing the commands directly from the Pluto Admin Web Page, using Advanced/Device Templates. After picking the device template, select ruby codes and add the command groups that you want to implement.

The framework offers an Ruby Command object that is actually a wrapper around the C++ class Command. In order to create an instance of the ruby ocommand use:


cmd = Command.new( <device from>, <device to>, <???>, <command type>, <command id>)


There is a hashmap associated with the comand object that allows setting values for the command parameters:


cmd.params_[<parameter id>] = <string value for command parameter>


And for sending the command you should use the SendCommand function:


SendCommand(cmd)


Directly implementing commands this way may prove un-conveninet. You can use the Private Method dummy commadn for writing helper functions.

Besides from the params_ member, the ruby Command object has members for all the parameters from the constructor. Still, the wrapper offers only simple acces to what a commad really is in the DCE Framework.

The actual translation level is done in the Generic_Serial_Device project, in the RubyCommandWrapper class. Whatever methods, parameters etc this class offers will be found in the Ruby Command class after compilation. This allows easily extending the acces the ruby code has to the framework.