How Do I Add a Method to PlotMS?

This howto explains, in bare bones terms, how to add a method to the plotms dbus interface. It assumes you want to ultimately call this method from the casapy pm tool.

1. Add the interface description to the pm tool xml file, code/xmlcasa/implement/plotms/plotms.xml
<method type="function" name="save">

  <shortdescription>save plot to file</shortdescription>
  <description>Save the plot to a file</description>
    <param type="string" name="plotfile">
      <description>name of plot file</description>
    <param type="string" name="format">
        <description>Format type, if not provided, attempt will be made to guess from plotfile extension</description>
  <example />
  <returns />

2. Define and implement the call in code/xmlcasa/implement/plotms/plotms_cmpt.{h,cc}
 void save(const string& filename, const string& format);
 void plotms::save(const string& filename, const string& format)   {
    Record params, retValue;
    params.define(PlotMSDBusApp::PARAM_EXPORT_FILENAME, filename);
    params.define(PlotMSDBusApp::PARAM_EXPORT_FORMAT, format);

    QtDBusXmlApp::dbusXmlCall(dbus::FROM_NAME, app.dbusName( ),
            PlotMSDBusApp::METHOD_SAVE, params, retValue);
    //return fromRecord(retValue);

3. Add new constants to code/plotms/implement/PlotMS/PlotMSDBusApp.{h,cc}
    static const String PARAM_EXPORT_FILENAME; // String
    static const String PARAM_EXPORT_FORMAT; //String
 const String PlotMSDBusApp::PARAM_EXPORT_FILENAME = "exportfilename";
const String PlotMSDBusApp::PARAM_EXPORT_FORMAT = "exportformat";

4. Add support for new method to code/plotms/implement/PlotMS/ method dbusRunXmlMethod():
     else if(methodName == METHOD_SAVE) {
        PlotMSAction action(PlotMSAction::PLOT_EXPORT);
        if(parameters.isDefined(PARAM_EXPORT_FILENAME)) {
            String filename = parameters.asString(PARAM_EXPORT_FILENAME);
            String format;
            if(parameters.isDefined(PARAM_EXPORT_FORMAT)) {
                format = parameters.asString(PARAM_EXPORT_FORMAT);
            if (!, format)) {
                log("Method " + methodName + ": failed to save plot to file ");
        else {
            callError = true;


-- DaveMehringer - 2010-02-12
Topic revision: r2 - 2010-04-02, DarrellSchiebel
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding NRAO Public Wiki? Send feedback