Changeset 558


Ignore:
Timestamp:
Feb 9, 2015, 3:36:46 PM (10 years ago)
Author:
djay
Message:

Add OTB Application Observer.

Location:
trunk/zoo-project
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/HISTORY.txt

    r550 r558  
    22  * Add Orfeo Toolbox support for applications as a service
    33  * Add the otb2zcfg utility to produce zcfg for otb applications
     4  * Add OTB Application Observer to have progress status updates
    45  * Fix maxOccurs handling
    56  * Fix gesture of downloaded inputs when multiple values are given
  • trunk/zoo-project/LICENSE

    r476 r558  
    99------------------
    1010
    11 Copyright (c) 2009-2013 GeoLabs SARL
     11Copyright (c) 2009-2015 GeoLabs SARL
    1212Copyright 2010-2011 Fondazione Edmund Mach. All rights reserved.
    1313
     
    2929OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    3030SOFTWARE.
     31
     32ZOO-Kernel OTB Support
     33----------------------
     34
     35Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
     36See OTBCopyright.txt for details.
     37
     38Some parts of this code are derived from ITK. See ITKCopyright.txt
     39for details.
     40
     41 This software is distributed WITHOUT ANY WARRANTY; without even
     42 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     43 PURPOSE.  See the above copyright notices for more information.
     44
     45See Ref: http://hg.orfeo-toolbox.org/OTB/ Copyright
    3146
    3247ZOO-API License
  • trunk/zoo-project/zoo-kernel/service_internal_otb.c

    r555 r558  
    2121 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    2222 * THE SOFTWARE.
     23 *
     24 * See Ref: http://hg.orfeo-toolbox.org/OTB/ Copyright
     25 * Some parts of this code are derived from ITK. See ITKCopyright.txt for
     26 * details.
    2327 */
    2428
    2529#include "service_internal_otb.h"
    26 #include <vector>
    27 #include <string>
    2830
    2931using namespace otb::Wrapper;
     32
     33class MyCommand : public itk::Command
     34{
     35 public:
     36  itkNewMacro( MyCommand );
     37 public:
     38
     39  void Execute(itk::Object *caller, const itk::EventObject & event)
     40  {
     41    Execute( (const itk::Object *)caller, event);
     42  }
     43 
     44  void Execute(const itk::Object * object, const itk::EventObject & event)
     45  {
     46    const AddProcessToWatchEvent* eventToWatch = dynamic_cast< const AddProcessToWatchEvent*> ( &event );
     47    std::string m_CurrentDescription = eventToWatch->GetProcessDescription();
     48    std::cerr << "err_service_zooo start ccalled." << m_CurrentDescription << std::endl;
     49    ZooWatcher * watch = new ZooWatcher(eventToWatch->GetProcess(),
     50                                        eventToWatch->GetProcessDescription());
     51    watch->SetConf(&m_Conf);
     52    m_WatcherList.push_back(watch);
     53  }
     54
     55
     56
     57};
     58
    3059
    3160std::string ReplaceAll(std::string str, const std::string& from, const std::string& to) {
     
    4271  maps* inputs=*real_inputs;
    4372  maps* outputs=*real_outputs;
     73  map* tmp0=getMapFromMaps(*main_conf,"lenv","cwd");
     74  char *ntmp=tmp0->value;
    4475  map* tmp=NULL;
    4576  int res=-1;
     
    6899          res=-1;
    69100        }else{
     101          // Create Observer on AddProcessToWatchEvent
     102          m_Conf=m;
     103          MyCommand::Pointer myCommand = MyCommand::New();
     104          m_Application->AddObserver(AddProcessToWatchEvent(), myCommand);
    70105          char tmpS[1024];
    71           sprintf(tmpS, "The OTB Application %s was loaded correctly.", (*it).c_str());
    72106          const std::vector<std::string> appKeyList = m_Application->GetParametersKeys(true);
    73107          for (unsigned int i = 0; i < appKeyList.size(); i++){
     
    80114              if(test==NULL){
    81115                test=getMapFromMaps(inputs,paramKey.c_str(),"inRequest");
     116                map* tmpPath=getMapFromMaps(m,"main","tmpPath");
     117                map* tmpSid=getMapFromMaps(m,"lenv","usid");
     118                char tmp[1024];
     119                map* tmpVal=getMapFromMaps(outputs,paramKey.c_str(),"mimeType");
    82120                if(test!=NULL && test->value!=NULL && strncasecmp(test->value,"true",4)==0){
    83121                  test=getMapFromMaps(inputs,paramKey.c_str(),"value");
     
    96134                    else if (strncasecmp(test->value,"double",6)==0)
    97135                      outPixType = ImagePixelType_double;
    98                     map* tmpPath=getMapFromMaps(m,"main","tmpPath");
    99                     map* tmpSid=getMapFromMaps(m,"lenv","sid");
    100                     char tmp[1024];
    101                     map* tmpVal=getMapFromMaps(outputs,paramKey.c_str(),"mimeType");
    102136                    char* ext="tiff";
    103137                    if(tmpVal!=NULL){
     
    122156                }else{
    123157                  if(type == ParameterType_OutputVectorData){
    124                       map* tmpPath=getMapFromMaps(m,"main","tmpPath");
    125                       map* tmpSid=getMapFromMaps(m,"lenv","sid");
    126                       char tmp[1024];
    127                       map* tmpVal=getMapFromMaps(outputs,paramKey.c_str(),"mimeType");
    128158                      char* ext="json";
    129159                      if(tmpVal!=NULL){
     
    146176                  else
    147177                    if(type == ParameterType_OutputFilename){
    148                       map* tmpPath=getMapFromMaps(m,"main","tmpPath");
    149                       map* tmpSid=getMapFromMaps(m,"lenv","sid");
    150                       char tmp[1024];
    151                       map* tmpVal=getMapFromMaps(outputs,paramKey.c_str(),"mimeType");
    152178                      char* ext="txt";
    153179                      if(tmpVal!=NULL){
     
    355381    }
    356382  }
     383
     384  for (unsigned int i = 0; i < m_WatcherList.size(); i++){
     385    m_WatcherList[i]->FreeConf();
     386    delete m_WatcherList[i];
     387    m_WatcherList[i] = NULL;
     388  }
     389  m_WatcherList.clear();
     390
    357391  return res;
    358392}
  • trunk/zoo-project/zoo-kernel/service_internal_otb.h

    r555 r558  
    3131#include "otbWrapperApplicationRegistry.h"
    3232#include "otbWrapperInputImageListParameter.h"
     33#include "otbWrapperAddProcessToWatchEvent.h"
     34#include "otbZooWatcher.h"
    3335#include "service_internal.h"
    3436#include "service.h"
     
    3840#include <direct.h>
    3941#endif
     42#include <vector>
     43#include <string>
    4044
     45typedef std::vector<ZooWatcher *> WatcherListType;
     46WatcherListType m_WatcherList;
     47maps* m_Conf;
    4148int zoo_otb_support(maps**,map*,service*,maps**,maps**);
    4249
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png