Centrafuse Logo Flux Logo


Plugin Communication

Overview

This page provides a description of plugin-to-plugin communication and how to obtain and set data in other plugins.


Communication API

CFPlugin provides 2 functions for plugin-to-plugin communication, CF_pluginData() and CF_pluginCommand().


The CF_pluginData() and CF_getPluginData() Functions

Your plugin dll can pass internal data to other plugins using the CF_pluginData() override. The plugin creator shall define the commands and parameters available. The caller shall use CF_getPluginData() to request this data from the plugin.

The following example is taken from the OBDII Plugin.

 public override string CF_pluginData(string command, string param1)
 {
     string retvalue = "";
     switch (command)
     {
         case "SENSOR1": retvalue = sensordata[0, 0]; break;
         case "SENSOR2": retvalue = sensordata[0, 1]; break;
         case "SENSOR3": retvalue = sensordata[0, 2]; break;
         case "SENSOR4": retvalue = sensordata[0, 3]; break;
         case "SENSOR5": retvalue = sensordata[0, 4]; break;
         case "SENSOR6": retvalue = sensordata[0, 5]; break;
         case "SENSOR7": retvalue = sensordata[0, 6]; break;
         case "SENSOR8": retvalue = sensordata[0, 7]; break;
         case "SENSOR9": retvalue = sensordata[1, 0]; break;
         case "SENSOR10": retvalue = sensordata[1, 1]; break;
         case "SENSOR11": retvalue = sensordata[1, 2]; break;
         case "SENSOR12": retvalue = sensordata[1, 3]; break;
         case "SENSOR13": retvalue = sensordata[1, 4]; break;
         case "SENSOR14": retvalue = sensordata[1, 5]; break;
         case "SENSOR15": retvalue = sensordata[1, 6]; break;
         case "SENSOR16": retvalue = sensordata[1, 7]; break;
      }
      return retvalue;
 }

The following shows how the above CF_pluginData() function would be invoked by the caller using CF_getPluginData().

 // Get the current speed of vehicle
 string speed = CF_getPluginData("OBDII", "SENSOR1", "");

 // Get the current rpm of vehicle
 string rpm = CF_getPluginData("OBDII", "SENSOR2", "");


The CF_pluginCommand() and CF_systemCommand() Functions

Your plugin dll can execute commands from other plugins using the CF_pluginCommand() override. The plugin creator shall define the commands and parameters available. The caller shall use CF_systemCommand() to request this data from the plugin.

The following example is taken from the Web Plugin.

 public override void CF_pluginCommand(string command, string param1, string param2)
 {
     try
     {
         // Make sure plugin has been loaded, if not, load
         if(firstshow)
         {
             this.loadWeb();
             firstshow = false;
         }
 
         switch(command.ToUpper())
         {
             case "BROWSE":
                 // ...................
                 // ...................
                 // web plugin code runs here to browse to url passed in by param1
                 // ...................
                 // ...................
                 break;
         }
     }s
     catch(Exception errmsg) { CFTools.writeError(errmsg.Message, errmsg.StackTrace); }
 }

The following shows how the above CF_pluginCommand() function would be invoked by the caller using CF_systemCommand().

 // Open browser screen in fullscreen mode
 CF_systemCommand(CF_Actions.PLUGIN, "WEB", "BROWSE", "http://www.fluxmedia.net", "FULLSCREEN");

 // Open browser screen in normal mode
 CF_systemCommand(CF_Actions.PLUGIN, "WEB", "BROWSE", "http://www.fluxmedia.net");


Communicating with the Centrafuse Email Plugin

Email can be composed and sent via the Email Plugin using the following syntax:

 CF_systemCommand(CF_Actions.PLUGIN, "EMAIL", "COMPOSE", [REPLYTO], [SUBJECT]);

where [REPLYTO] and [SUBJECT] refer to the email address that should be sent in the the headers as the reply-to email address, and the subject line of the email. The email body is entered dynamically by the user using quick-reply messages, voice recording as an attachment, or a normal reply using the OSK.


Communicating with the Web Plugin

A web page can be displayed via the Web Plugin using the following syntax:

 // Open browser screen in fullscreen mode
 CF_systemCommand(CF_Actions.PLUGIN, "WEB", "BROWSE", "http://www.fluxmedia.net", "FULLSCREEN");

 // Open browser screen in normal mode
 CF_systemCommand(CF_Actions.PLUGIN, "WEB", "BROWSE", "http://www.fluxmedia.net");


Communicating with the WiFi Plugin

A web page can be displayed via the Web Plugin using the following syntax:

 // Connect to WiFi network specified by SSID
 CF_systemCommand(CF_Actions.PLUGIN, "WIFI", "CONNECT", [NETWORKSSID]);

where [NETWORKSSID] refers to the Wifi SSID associated with the access point / network that is being connected to.

 // Disconnect current wifi connection
 CF_systemCommand(CF_Actions.PLUGIN, "WIFI", "DISCONNECT");


Communicating with the OBDII Plugin

Data can be retrieved from the OBDII Plugin using the following syntax:

 string data = CF_getPluginData("OBDII", [SENSORNUMBER], "");

where [SENSORNUMBER] is equal to one of the following strings:

[SENSORNUMBER] Returned Value
"SENSOR1" Speed
"SENSOR2" RPM
"SENSOR3" Air Intake
"SENSOR4" Coolant Temperature
"SENSOR5" Engine Load
"SENSOR6" Air Flow Rate
"SENSOR7" Fuel Pressure
"SENSOR8" Intake Pressure
"SENSOR9" Timing Advance
"SENSOR10" Throttle Position
"SENSOR11" Short Term Fuel Trim
"SENSOR12" Fuel System Status
"SENSOR13" PTO Status
"SENSOR14" Long Term Fuel Trim
"SENSOR15" Engine Run Time
"SENSOR16" OBD Requirements





Copyright © 2008 Flux Media, Inc. (U.S. Copyright Registration Number: TXu-1-239-794) Flux Logo