Difference between revisions of "GSD - Ruby codes"

From LinuxMCE
Jump to: navigation, search
m (Added category: GSD)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<table width="100%"> <tr><td bgcolor="#FFCFCF">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.</td></tr> </table>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.
+
[[Category: Programmer's Guide]]
 +
[[Category: GSD]]
  
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:
+
== GSD ==
 +
Generic Serial Device is a module that offers basic functionality for accessing devices via the serial port (mostly through the RS232 interface). The project sources are located in pluto/src/Generic_Serial_Devices.
  
 +
== Command implementation in Ruby ==
 +
For Generic Serial Devices the architecture allows implementing the commands directly from the LinuxMCE 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 (should be supported by the devices for which you want to create the template)
  
    cmd = Command.new( <device from>, <device to>, <???>, <command type>, <command id>)
+
The framework offers an Ruby ''Command'' object that actually behaves as a container for data also found in the C++ class Command from DCE. In order to create an instance of the ruby command use:
  
  
There is a hashmap associated with the comand object that allows setting values for the command parameters:
+
    cmd = Command.new( <device from>, <device to>, <priority>, <type>, <id>)
 +
 
 +
 
 +
There is a hash map associated with the command object that allows setting values for the command parameters:
  
  
Line 19: Line 26:
  
  
Directly implementing commands this way may prove un-conveninet. You can use the Private Method dummy commadn for writing helper functions.
+
Directly implementing each command this way may prove inconvenient. You can use the Private Method dummy command 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 access to what a command really is in the DCE Framework, but, of course, it can be extended to allow more by adding members to the RubyCommandWrapper C++ class. All that's implemented here gets translated to Ruby.
 
+
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.
+
The actual forwarding to the DCE framework is done in the Generic_Serial_Device project, in classes implementing RubyDCEConnector (ex: RubyIOManager). These are used at their turn from the RubySerialWrapper, witch offers the actual context where the Ruby code runs (Ruby twin classes are generated for each device at runtime). The SendCommand used above is a method of the RubySerialWrapper class.

Latest revision as of 15:56, 11 July 2016


GSD

Generic Serial Device is a module that offers basic functionality for accessing devices via the serial port (mostly through the RS232 interface). The project sources are located in pluto/src/Generic_Serial_Devices.

Command implementation in Ruby

For Generic Serial Devices the architecture allows implementing the commands directly from the LinuxMCE 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 (should be supported by the devices for which you want to create the template)

The framework offers an Ruby Command object that actually behaves as a container for data also found in the C++ class Command from DCE. In order to create an instance of the ruby command use:


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


There is a hash map associated with the command 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 each command this way may prove inconvenient. You can use the Private Method dummy command 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 access to what a command really is in the DCE Framework, but, of course, it can be extended to allow more by adding members to the RubyCommandWrapper C++ class. All that's implemented here gets translated to Ruby.

The actual forwarding to the DCE framework is done in the Generic_Serial_Device project, in classes implementing RubyDCEConnector (ex: RubyIOManager). These are used at their turn from the RubySerialWrapper, witch offers the actual context where the Ruby code runs (Ruby twin classes are generated for each device at runtime). The SendCommand used above is a method of the RubySerialWrapper class.