Understanding Plugins






Doctor Aquarium Plugins
The Doctor Aquarium application was designed to be made of many modular pieces, called plugins. A plugin is a packaged set of computer instructions, that is embeded inside the main Doctor Aquarium application. Each plugin implements a set of interfaces. An interface determines how you can interact with the plugin. For example The SunMoon plugin supports the following interfaces : Monitor,Configure,Log,Trigger,Webpage,Help,Script. The SunMoon Plugin calculates Moon and Sun Events, based on a geographic location. On the right you can see the Monitor interface of the SunMoon Plugin.
  1. A Monitor Interface allows the user to monitor in real time, the state of the SunMoon plugin.
  2. The Configure Interface allows the user to configure the plugin, in this case to set the local Latitude and Longitude.
  3. The Log interface lets you see the plugin's log file.
  4. The Webpage interface allows you to interact with the plugin through a web browser.
  5. Finally the plugin supports the Script Interface, allowing the plugin to act as a trigger inside condition statement. For example:
      if isNow(SunMoon.Sunrise)
        then PlaySound.Play('C:\Good Morning.wav');   
    
    The above script will play a greeting message, at sunrise. Inside scripts, plugins are objects with methods that can be called to either determine the state of the plugin, or cause some type of plugin action to happen. In this example, we have two objects; SunMoon, and PlaySound. The SunMoon object has a method called Sunrise, which returns the date/time of the next sunrise. And the PlaySound object has a method called Play, which will play the a sound file.


Internal Representation


All plugin information is kept in it's own folder named after the plugin's name, int the plugins directory [appdir]/data/plugins/. A plugin folder holds the plugin dll, log files, icon, datafiles, and an info.ini file containing plugin specific properties. Each plugin needs follows naming convantions, as follows :
  1. The plugin Folder name, and the plugins dll name must be the same.
  2. The plugin must contain an info.ini file. (See below for an explanation)
  3. The plugin needs to contain an icon file called named 'icon.ico' and a bitmap file called icon.bmp. The two files are used to visually identify the plugin.
  4. Each plugin needs a help file, with it's first index page called help.html
  5. If the plugin implements a Webpage interface, it must contain an index file called index.html. Thiw will be the file that is shown in the web browser for this plugn
Below, you can see the listing of all the files in the SunMoon plugin folder.



Installing/Unistalling Plugins

The Doctor Aquarium application modular design, allows new plugins to be installed, and old/unused plugins to be uninstalled. The process can be performed manually. Doctor Aquarium tries to load every plugin (folder) that is places in the [appdir]/data/plugins/ directory. To add a new plugin, you simply need place it's folder in the [appdir]/data/plugins/ directory and register the plugins dll, with the regsvr32 command. To uninstall a plugin, reverse the above steps. The Doctor Aquarium application must be shut off when you do this.

Info.ini File


Each plugin must have an info.ini file, inside its folder. The Doctor Aquarium reads the info.ini file at startup to determine how to load the plugin and embed it in the main application. The info.ini file is a simple text file, which lists common properties, including a listing of the interfaces the plugin supports, and a listing of all the methods the plugin implements. (for scripting)


Developing new plugins

Each plugin is a COM object, written in Delphi version 7. The file AquaPlug.tlb contains all the interface definitions. Each plugin needs to implement the IPlugGlobal interface, and then can choose weather to implement the other interfaces. It should be possible to do this in any language that you can work with COM. See the developer section of the Doctor Aquarium website for more information.


SunMoon Info.ini
[Plugin]
Name=SunMoon
FileName=sunMoon
Category=sunMoon
WebPageName=SunMoon.html
Description=SunMoon Plugin: Provides timing events based on the Solar and Lunar Cycles
Version=1.0
Author=SeaApple Software
ReleaseDate=06/21/2004
HomeURL=
UpdateURL=
HelpURL=
Interfaces=Monitor,Configure,Log,Trigger,Webpage,Help,Script
GUID={747DEED4-BB99-4EB1-AD5F-FFE52E29A530}



[Function1]
Name=Sunrise
Comment=Returns the datetime of the next sunrise 
ReturnType=DateTime

[Function2]
Name=Sunset
Comment=Returns the datetime of the next sunset. 
ReturnType=DateTime


[Function3]
Name=SunTransit
Comment=Returns the datetime of the next sun transit. 
ReturnType=DateTime


[Function4]
Name=MoonRise
Comment= Returns the datetime of the next moonrise. 
ReturnType=DateTime

[Function5]
Name=MoonSet
Comment=Returns the datetime of the next moon set. 
ReturnType=DateTime

[Function6]
Name=MoonTransit
Comment=Returns the datetime of the next moon transit
ReturnType=DateTime

[Function7]
Name=MoonPhase
Comment=Returns the current phase as % of full moon from 0 to 100
ReturnType=Integer


[Function8]
Name=isSpring
Comment=Returns True if its spring 
ReturnType=Boolean

[Function9]
Name=isSummer
Comment=Returns True if its summer
ReturnType=Boolean

[Function10]
Name=isAutumn
Comment=Returns True if its autumn 
ReturnType=Boolean

[Function11]
Name=isWinter
Comment=Returns True if its winter 
ReturnType=Boolean