Creating New Datagrid

From LinuxMCE
Revision as of 20:10, 27 July 2009 by Chriss (Talk | contribs)

Jump to: navigation, search

How do I create a new games plugin that generates a datagrid showing games on the screen?

Here is how I would do it:

  • Add a device template for the 'Games Plugin'. Use Climate Plugin as the template; it's the simplest of the plugins.
  • Do an apt-get install pluto-dcegen, and run: /usr/pluto/bin/DCEGen -d [device template] from the bin directory where your sources are (cd /home/sources/trunk/src/bin for example).
  • In Games_Plugin.h add an ! after the //<-dceag-decl-b-> line so that block of auto-gen'd code won't get overriden, and co-derive teh class from , public DataGridGeneratorPlugIn like climate plugin.
  • Add the member:
    class Datagrid_Plugin *m_pDatagrid_Plugin;
    and a function for your data grid:
    class DataGridTable *ClimateScenariosGrid(string GridID,string Parms,void *ExtraData,int *iPK_Variable,string *sValue_To_Assign,class Message *pMessage);
  • Add the code that initializes the datagrid engine like in climate plugin:
m_pDatagrid_Plugin=( Datagrid_Plugin * ) m_pRouter->FindPluginByTemplate(DEVICETEMPLATE_Datagrid_Plugin_CONST);
if( !m_pDatagrid_Plugin )
{
	LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"Cannot find sister plugins to climate plugin");
	return false;
}

m_pDatagrid_Plugin->RegisterDatagridGenerator(
	new DataGridGeneratorCallBack(this,(DCEDataGridGeneratorFn)(&Climate_Plugin::ClimateScenariosGrid))
	,DATAGRID_Climate_Scenarios_CONST,PK_DeviceTemplate_get());
  • Add a record in teh pluto_main.DataGrid table for your new datagrid, and edit pluto_main/Define_DataGrid.h to add your new record, and change the RegisterDataGrid to use your function for the datagrid and your DATAGRID_X_CONST.
  • In Designer add a new DesignObj for the screen that will display your datagrid. Use one of the other screens as a template. To see what screens are being used, edit /etc/pluto.conf, comment out the LogLevels line, do:
    /usr/pluto/bin/MessageSend dcerouter 0 -1000 7 11
    to force all devices to recheck the log levels and start logging verbosely. Tail the
    /var/log/pluto/20_LaunchOrbiter.log | grep Goto_DesignObj
    Then as you change screens in Orbiter you can see what designobj's are being used. Note that Designer is nasty, unfriendly, finicky, and only runs on Windows. Sorry, this really needs work, but has been neglected since it's an in-house tool.
  • When you add the new design obj of type datagrid, add your new data grid id.
  • Add to the pluto_main.Screen table a record for this new screen and set the 'autoinclude' field to 1 for now so that screen will be generated even though nothing calls it. Then add to Screen_DesignObj a record associating this screen with your new DesignObj.
  • In the admin site, add an instance of your game plugin under DCERouter (next to the other plugins).
  • Go into the admin site and under Advanced, Configuration, Scenarios, add a scenario with a command going to "the local orbiter" "Goto Screen" with our new screen as teh parameter for PK_Screen.

Now, after you reload the router and regen the Orbiter's UI, then when the user navigates to your screen by choosing the scenario you created, it will call that data grid generator function, and you can populate the grid with data like in Climate_Plugin::ClimateScenariosGrid and it will appear.

Designer is in trunk/src/designer. It's a c# app requiring vs.net to compile. You can get a zip file at: http://linuxmce.org/HADesigner.zip with them already compiled so you should be able to run it on any windows box. first on your core's console run: mysql grant all on *.* to 'root'@'%.%.%.%' (or use an ip mask) so designer can access the mysql databases.

Install the Mysql ODBC client for windows, and the attached Microsoft ODBC for .NET: http://linuxmce.org/odbc_net.msi

Also, what I do is: ln -sf /usr/pluto/orbiter/ /home/orbiter

and then from windows, start, run: \\192.168.80.1

and in the /home/orbiter folder, copy the skins directory to c:\[whatever]\skins.

When Designer runs give it the login information for accessing the database on the core, and the path to the skins directory.