Sample Implementation Guide
This page explains the implementation steps and sample code for the SampleCgiRemoteControl plugin as a concrete example of running a plugin from CgiRemoteControl.
For an overview of CgiRemoteControl.exe and its command-line options, see Command-line usage. For a summary of the plugin-side interface specification, see Plugin-side Implementation.
Plugin class
First, create a class that implements IEventListener.
public class SampleCgiRemoteControl : IEventListener {
}
Implementing IPlugin
Next, implement the members of the IPluginService interface.
public string Description
{
get { return "A plugin running on the CgiRemoteControls"; }
}
public IEnumerable<int> FeatureIds { get { return null; } }
public string Name
{
get { return "Sample CgiRemoteControl plugin"; }
}
public string Version
{
get { return "1.0.0"; }
}
Implementing IEventListener event handlers
Then implement the event-handler methods. When CgiRemoteControl runs, it invokes the OnPluginControl method.
public void Initialize(FTC.SDKInterface.Services.IUnityContainer unityContainer) { }
public void OnSolutionChanged(ISolution solution) { }
public void OnAssetGeneration(string assetFile, bool isTargetAsset, OperationStatus status) { }
public void OnImportFinished() { }
public void OnShutdown() { }
public int OnPluginControl(string command)
{
Logger.Info("This is a sample for calling OnPluginControl() method in a plugin by CgiReomteControl.");
return 0;
}
Specifying the events the plugin handles
Implement the EventsToSubscribe property of the IEventListener interface. This property specifies the set of events to be passed to the plugin. To have CgiRemoteControl call your plugin method, you must include EventId.PluginControlCommand.
public EventId EventsToSubscribe => EventId.PluginControlCommand;
Below are the sample code and an example of the CgiRemoteControl run results.
using Feat.Utils;
using FTC.SDKInterface.Plugins;
using FTC.SDKInterface.Solution;
using System.Collections.Generic;
SampleCgiRemoteControl.cs
namespace SampleCgiRemoteControl
{
public class SampleCgiRemoteControl : IEventListener
{
public EventId EventsToSubscribe => EventId.PluginControlCommand;
public void Initialize(FTC.SDKInterface.Services.IUnityContainer unityContainer) { }
public void OnSolutionChanged(ISolution solution) { }
public void OnAssetGeneration(string assetFile, bool isTargetAsset, OperationStatus status) { }
public void OnImportFinished() { }
public void OnShutdown() { }
//This method is called when launching CgiRemoteControls.
public int OnPluginControl(string command)
{
Logger.Info("This is a sample for calling OnPluginControl() method in a plugin by CgiReomteControl.");
return 0;
}
public string Description
{
get { return "A plugin running on the CgiRemoteControls"; }
}
public IEnumerable<int> FeatureIds { get { return null; } }
public string Name
{
get { return "Sample CgiRemoteControl plugin"; }
}
public string Version
{
get { return "1.0.0"; }
}
}
}