diff --git a/CEP/BB/PSS3/Makefile.am b/CEP/BB/PSS3/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..70a18969293affc1978361d0c7a7184264aec83e --- /dev/null +++ b/CEP/BB/PSS3/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS=src + +DOC_SUBDIRS=src + +include $(lofar_sharedir)/Makefile.common diff --git a/CEP/BB/PSS3/bootstrap b/CEP/BB/PSS3/bootstrap new file mode 100755 index 0000000000000000000000000000000000000000..06f18cde1dbfd6912ef7d927c4d35d25c7137a62 --- /dev/null +++ b/CEP/BB/PSS3/bootstrap @@ -0,0 +1,3 @@ +#!/bin/sh + +../../../autoconf_share/bootstrap ../../../autoconf_share diff --git a/CEP/BB/PSS3/configure.in b/CEP/BB/PSS3/configure.in new file mode 100644 index 0000000000000000000000000000000000000000..c4f6e3817b330e78f4c6d6f573a75c5cc8738927 --- /dev/null +++ b/CEP/BB/PSS3/configure.in @@ -0,0 +1,71 @@ +dnl +dnl Process this file with autoconf to produce a configure script. +dnl +AC_INIT(src/BlackBoardDemo.h) +dnl AC_CONFIG_AUX_DIR(config) +dnl AM_CONFIG_HEADER(config/config.h) +AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE(BlackBoardDemo, 0.1) + +dnl Initialize for LOFAR (may set compilers) +lofar_INIT + +dnl Checks for programs. +AC_PROG_AWK +AC_PROG_YACC +AC_PROG_CC +AC_PROG_CXX +AM_PROG_LEX +AC_PROG_INSTALL +AC_PROG_LN_S +AC_DISABLE_SHARED +AC_PROG_LIBTOOL + +dnl Checks for libraries. + +dnl dnl Replace `main' with a function in -lfl: +dnl AC_CHECK_LIB(fl, main) +dnl dnl Replace `main' with a function in -lcosev_r: +dnl AC_CHECK_LIB(cosev_r, main) +dnl dnl Replace `main' with a function in -lcosnm_r: +dnl AC_CHECK_LIB(cosnm_r, main) +dnl dnl Replace `main' with a function in -lorb_r: +dnl AC_CHECK_LIB(orb_r, main) +dnl dnl Replace `main' with a function in -lpthread: +dnl AC_CHECK_LIB(pthread, main) +dnl dnl Replace `main' with a function in -lvport_r: +dnl AC_CHECK_LIB(vport_r, main) + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(unistd.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T + +dnl Checks for library functions. +AC_FUNC_VPRINTF + +dnl +dnl Check for LOFAR specific things +dnl +lofar_DEBUG_OPTIMIZE +lofar_CORBA +lofar_MATLAB +lofar_AIPSPP(1) +lofar_MPI +lofar_QATOOLS +lofar_DOCXX +lofar_PACKAGE(CEP/CPA/PSS3/MNS) +lofar_PACKAGE(CEP/CEPFrame) + +lofar_EXTERNAL(pq,1,libpq-fe.h) + +dnl +dnl Output Makefiles +dnl +AC_OUTPUT( +src/Makefile +Makefile +) diff --git a/CEP/BB/PSS3/src/BlackBoardDemo.cc b/CEP/BB/PSS3/src/BlackBoardDemo.cc new file mode 100644 index 0000000000000000000000000000000000000000..5dcb3954ff1042859201c587f9d60df5f1765920 --- /dev/null +++ b/CEP/BB/PSS3/src/BlackBoardDemo.cc @@ -0,0 +1,179 @@ +// BlackBoardDemo.cc: A blackboard simulator class +// +// Copyright (C) 2000, 2002 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////////// + +#include <stdio.h> +#include <Common/lofar_iostream.h> +#include <stdlib.h> +#include <Common/lofar_string.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <Common/Debug.h> + +#include "CEPFrame/Transport.h" +#include "CEPFrame/Step.h" +#include "CEPFrame/Simul.h" +#include "CEPFrame/WH_Empty.h" +#include "CEPFrame/Profiler.h" +#include "CEPFrame/ParamBlock.h" +#include "CEPFrame/TH_Database.h" +#include "PSS3/BlackBoardDemo.h" +#include "PSS3/WH_Evaluate.h" +#include "PSS3/WH_PSS3.h" +#include "PSS3/WH_Connection.h" +#include TRANSPORTERINCLUDE +#include <aips/Arrays/Vector.h> + + +using namespace LOFAR; + +BlackBoardDemo::BlackBoardDemo() +{ + cout << ">>>>>>>> BlackBoardDemo constructor <<<<<<<<<<" << endl; +} + +BlackBoardDemo::~BlackBoardDemo() +{ + undefine(); +} + +/** + Define function for the BlackBoardDemo simulation. It defines the steps that + process part of the data. + */ +void BlackBoardDemo::define(const ParamBlock& params) +{ + // Free any memory previously allocated + undefine(); + + // Create the top-level Simul + Simul simul(new WH_Empty(), + "BlackBoardDemo", + true, + true, // controllable + true); // monitor + setSimul(simul); + + // Set node and application number of Simul + simul.runOnNode(0,0); + simul.setCurAppl(0); + + // Optional: Get any extra params from input + // Example: noOfSourceSteps = params.getInt("sources",1); + String msName = "demo.MS"; + String meqModel = "demo"; + String skyModel = "demo_gsm"; + String modelType = "LOFAR.RI"; + String dataColName = "MODEL_DATA"; + String residualColName = "CORRECTED_DATA"; + uInt ddID = 0; + Vector<int> ant1(21); + Vector<int> ant2(21); + for (int i=0; i<21; i++) + { + ant1[i]=ant2[i]=4*i; + } + bool calcUVW = false; + + DH_Postgresql::UseDatabase("10.87.2.50", "meijeren", "postgres"); + + // Create the WorkHolder(s) + WH_Evaluate controlWH("control"); + WH_PSS3 ksWH("KS", msName, meqModel, skyModel, ddID, ant1, ant2, modelType, + calcUVW, dataColName, residualColName); + + // Empty workholders necessary for data transport to/from database +// WH_Connection controlInWH("empty", 0, 1, WH_Connection::WorkOrder); + WH_Connection controlOutWH("empty", 1, 0, WH_Connection::WorkOrder); + WH_Connection ksInWH("empty", 0, 1, WH_Connection::WorkOrder); +// WH_Connection ksOutWH("empty", 1, 0, WH_Connection::WorkOrder); + + // Create the Step(s) + Step controlStep(controlWH, "controlStep"); + Step knowledgeSourceStep(ksWH, "knowledgeSource"); + + // Empty steps necessary for data transport to database +// Step controlInStep(controlInWH, "CsourceStub"); + Step controlOutStep(controlOutWH, "CsinkStub"); + Step ksInStep(ksInWH, "KSsourceStub"); +// Step ksOutStep(ksOutWH, "KSsinkStub"); + + // Determine the node and process for each step to run in + controlStep.runOnNode(0,0); + controlOutStep.runOnNode(0,0); + ksInStep.runOnNode(1,0); + knowledgeSourceStep.runOnNode(1,0); + + // Add all Step(s) to Simul + simul.addStep(controlStep); + simul.addStep(controlOutStep); + simul.addStep(ksInStep); + simul.addStep(knowledgeSourceStep); + + // Create the cross connections between Steps + // Connections to the database. The steps are not really connected to + // each other, but to the database +// controlStep.connect(&controlInStep, 0, 0, 1, TH_Database::proto); + controlOutStep.connect(&controlStep, 0, 0, 1, TH_Database::proto); + knowledgeSourceStep.connect(&ksInStep, 0, 0, 1, TH_Database::proto); +// ksOutStep.connect(&knowledgeSourceStep, 0, 0, 1, TH_Database::proto); + +} + + +void BlackBoardDemo::run(int nSteps) { + TRACER1("Call run()"); + Profiler::init(); + Step::clearEventCount(); + + TRACER4("Start Processing simul"); + for (int i=0; i<nSteps; i++) { + if (i==2) Profiler::activate(); + TRACER2("Call simul.process() "); + getSimul().process(); + if (i==5) Profiler::deActivate(); + } + + TRACER4("END OF SIMUL on node " << TRANSPORTER::getCurrentRank () ); + +#if 0 + // close environment + TRANSPORTER::finalize(); +#endif + +} + +void BlackBoardDemo::dump() const { + getSimul().dump(); +} + +void BlackBoardDemo::quit() { +} + +void BlackBoardDemo::undefine() { + // Clean up +} diff --git a/CEP/BB/PSS3/src/BlackBoardDemo.h b/CEP/BB/PSS3/src/BlackBoardDemo.h new file mode 100644 index 0000000000000000000000000000000000000000..14e9da7be2ccfa48b720b5b2ebaf9e316af10c02 --- /dev/null +++ b/CEP/BB/PSS3/src/BlackBoardDemo.h @@ -0,0 +1,62 @@ +// BlackBoardDemo.h: An empty simulator +// +// Copyright (C) 2000, 2002 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +// +////////////////////////////////////////////////////////////////////////// + +#ifndef PSS3_BLACKBOARDDEMO_H +#define PSS3_BLACKBOARDDEMO_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "CEPFrame/Simulator.h" +#include "CEPFrame/ParamBlock.h" + + +/** + This is a Simulator class which demonstrates the use of a blackboard control architecture + in combination with PSS3 calibration software. +*/ + +class BlackBoardDemo: public LOFAR::Simulator +{ +public: + BlackBoardDemo(); + virtual ~BlackBoardDemo(); + + // overloaded methods from the Simulator base class + virtual void define(const LOFAR::ParamBlock& params = LOFAR::ParamBlock()); + virtual void run(int); + virtual void dump() const; + virtual void quit(); + + void undefine(); + +private: + +}; + + +#endif diff --git a/CEP/BB/PSS3/src/Calibrator.cc b/CEP/BB/PSS3/src/Calibrator.cc index a5525f346afeac3387ea62b13b8d6f934f5872d9..7f7be20a021470e9e4c6b7de386fa84415509955 100644 --- a/CEP/BB/PSS3/src/Calibrator.cc +++ b/CEP/BB/PSS3/src/Calibrator.cc @@ -20,9 +20,9 @@ // // $Id: -#include <CAL/MeqCalibraterImpl.h> +#include <PSS3/MeqCalibraterImpl.h> #include <Common/lofar_iostream.h> -#include <Calibrator.h> +#include <PSS3/Calibrator.h> const int DefaultAntennaCount = 21; diff --git a/CEP/BB/PSS3/src/DH_Parms.cc b/CEP/BB/PSS3/src/DH_Parms.cc new file mode 100644 index 0000000000000000000000000000000000000000..a840cff9a9355df7bb8d636cb75c22465ba1fe4d --- /dev/null +++ b/CEP/BB/PSS3/src/DH_Parms.cc @@ -0,0 +1,71 @@ +// DH_Parms.cc: +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + + +#include "DH_Parms.h" + +using namespace LOFAR; + +DH_Parms::DH_Parms (const string& name) +: DH_Postgresql (name, "DH_Parms") +{ + setDataPacket (&itsDataPacket, sizeof(itsDataPacket)); +} + +DH_Parms::DH_Parms(const DH_Parms& that) + : DH_Postgresql(that) +{ + setDataPacket (&itsDataPacket, sizeof(itsDataPacket)); +} + +DH_Parms::~DH_Parms() +{ +} + +DataHolder* DH_Parms::clone() const +{ + return new DH_Parms(*this); +} + +void DH_Parms::preprocess() +{ +} + +void DH_Parms::postprocess() +{ +} + +DH_Parms::DataPacket::DataPacket() + : itsParam1Name("Stokes1.CP"), + itsParam1Value(0), + itsParam2Name("RA.CP"), + itsParam2Value(0), + itsParam3Name("DEC.CP"), + itsParam3Value(0), + itsSrcNo(-1), + itsID(-1) +{ + itsSolution.init(); +} diff --git a/CEP/BB/PSS3/src/DH_Parms.h b/CEP/BB/PSS3/src/DH_Parms.h new file mode 100644 index 0000000000000000000000000000000000000000..5b79e7ca0e4b11ac3aa7057d2a0b05482562d371 --- /dev/null +++ b/CEP/BB/PSS3/src/DH_Parms.h @@ -0,0 +1,119 @@ +// DH_Parms.h: Example DataHolder +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + +#ifndef PSS3_DH_PARMS_H +#define PSS3_DH_PARMS_H + +#include <Common/lofar_complex.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "CEPFrame/DH_Postgresql.h" +#include "PSS3/Solution.h" + +/** + This class is an example DataHolder which is only used in the + Example programs. +*/ + +class DH_Parms: public LOFAR::DH_Postgresql +{ +public: + + explicit DH_Parms (const string& name); + + virtual ~DH_Parms(); + + DataHolder* clone() const; + + /// Aloocate the buffers. + virtual void preprocess(); + + /// Deallocate the buffers. + virtual void postprocess(); + + // Data access methods + const string& getParam1Name(); + float getParam1Value(); + const string& getParam2Name(); + float getParam2Value(); + const string& getParam3Name(); + float getParam3Value(); + int getSourceNo(); + Solution* getSolution(); + +protected: + // Definition of the DataPacket type. + class DataPacket: public DH_Database::DataPacket + { + public: + DataPacket(); + string itsParam1Name; // Names and values of three parameters + float itsParam1Value; + string itsParam2Name; + float itsParam2Value; + string itsParam3Name; + float itsParam3Value; + int itsSrcNo; // Its source number + Solution itsSolution; // Its solution quality + long itsID; // Unique id + }; + +private: + + /// Forbid assignment. + DH_Parms& operator= (const DH_Parms&); + DH_Parms(const DH_Parms&); + DataPacket itsDataPacket; + +}; + +inline const string& DH_Parms::getParam1Name() +{ return itsDataPacket.itsParam1Name;} + +inline float DH_Parms::getParam1Value() +{ return itsDataPacket.itsParam1Value; } + +inline const string& DH_Parms::getParam2Name() +{ return itsDataPacket.itsParam2Name;} + +inline float DH_Parms::getParam2Value() +{ return itsDataPacket.itsParam2Value; } + +inline const string& DH_Parms::getParam3Name() +{ return itsDataPacket.itsParam3Name;} + +inline float DH_Parms::getParam3Value() +{ return itsDataPacket.itsParam3Value; } + +inline int DH_Parms::getSourceNo() +{ return itsDataPacket.itsSrcNo; } + +inline Solution* DH_Parms::getSolution() +{ return &itsDataPacket.itsSolution; } + +#endif diff --git a/CEP/BB/PSS3/src/DH_Status.cc b/CEP/BB/PSS3/src/DH_Status.cc new file mode 100644 index 0000000000000000000000000000000000000000..543c4696a2da1481386c7943af9bdefb69da7e0d --- /dev/null +++ b/CEP/BB/PSS3/src/DH_Status.cc @@ -0,0 +1,65 @@ +// DH_Status.cc: +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + + +#include "DH_Status.h" + +using namespace LOFAR; + +DH_Status::DH_Status (const string& name) +: DataHolder (name, "DH_Status"), + itsDataPacket (0) +{} + +DH_Status::DH_Status(const DH_Status& that) + : DataHolder(that), + itsDataPacket(0) +{ +} + +DH_Status::~DH_Status() +{ + delete [] (char*)(itsDataPacket); +} + +DataHolder* DH_Status::clone() const +{ + return new DH_Status(*this); +} + +void DH_Status::preprocess() +{ + // First delete possible buffers. + postprocess(); + // Initialize base class. + // setDataPacket (itsDataPacket, size); +} + +void DH_Status::postprocess() +{ + delete [] (char*)(itsDataPacket); + itsDataPacket = 0; + setDefaultDataPacket(); +} diff --git a/CEP/BB/PSS3/src/DH_Status.h b/CEP/BB/PSS3/src/DH_Status.h new file mode 100644 index 0000000000000000000000000000000000000000..4054ee9d5da3d487fc4c64647eba4f5ac61972d9 --- /dev/null +++ b/CEP/BB/PSS3/src/DH_Status.h @@ -0,0 +1,80 @@ +// DH_Status.h: Example DataHolder +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + +#ifndef PSS3_DH_STATUS_H +#define PSS3_DH_STATUS_H + +#include <Common/lofar_complex.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "CEPFrame/DataHolder.h" + +/** + This class is an example DataHolder which is only used in the + Example programs. +*/ + +class DH_Status: public LOFAR::DataHolder +{ +public: + + explicit DH_Status (const string& name); + + DH_Status(const DH_Status&); + + virtual ~DH_Status(); + + DataHolder* clone() const; + + /// Aloocate the buffers. + virtual void preprocess(); + + /// Deallocate the buffers. + virtual void postprocess(); + + +protected: + // Definition of the DataPacket type. + class DataPacket: public DataHolder::DataPacket + { + public: + DataPacket(){}; + + }; + +private: + /// Forbid assignment. + DH_Status& operator= (const DH_Status&); + + DataPacket* itsDataPacket; + +}; + + + +#endif diff --git a/CEP/BB/PSS3/src/DH_WorkOrder.cc b/CEP/BB/PSS3/src/DH_WorkOrder.cc new file mode 100644 index 0000000000000000000000000000000000000000..2cdfc9132f94021a85d5bdf43f3351b8d9347f55 --- /dev/null +++ b/CEP/BB/PSS3/src/DH_WorkOrder.cc @@ -0,0 +1,262 @@ +// DH_WorkOrder.cc: +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + + +#include "PSS3/DH_WorkOrder.h" +#include "Common/Debug.h" + +using namespace LOFAR; + +int DH_WorkOrder::theirWriteCount = 0; +int DH_WorkOrder::theirReadCount = 0; + +DH_WorkOrder::DH_WorkOrder (const string& name, const string& type) + : DH_Postgresql(name, "DH_WorkOrder"), + itsType (type) +{ + setDataPacket (&itsDataPacket, sizeof(itsDataPacket)); +} + +DH_WorkOrder::DH_WorkOrder(const DH_WorkOrder& that) + : DH_Postgresql(that), + itsType (that.itsType) +{ + setDataPacket (&itsDataPacket, sizeof(itsDataPacket)); +} + +DH_WorkOrder::~DH_WorkOrder() +{ + TRACER4("DH_WorkOrder destructor"); +} + +DataHolder* DH_WorkOrder::clone() const +{ + return new DH_WorkOrder(*this); +} + +void DH_WorkOrder::preprocess() +{ +} + +void DH_WorkOrder::postprocess() +{ +} + +DH_WorkOrder::DataPacket::DataPacket() + : itsParam1Name("StokesI.CP"), + itsParam1Value(0), + itsParam2Name("RA.CP"), + itsParam2Value(0), + itsParam3Name("DEC.CP"), + itsParam3Value(0), + itsSrcNo(-1), + itsStatus(New), + itsKSType("PSS3"), + itsStrategyNo(0), + itsArgSize(0) +{ +} + +void DH_WorkOrder::setArgSize(int size) +{ + AssertStr(size > 0, "Size is not greater than zero"); + AssertStr(size <= MAX_STRAT_ARGS_SIZE, "Size is greater than buffer size,increase buffer size"); + itsDataPacket.itsArgSize = size; +} + +bool DH_WorkOrder::StoreInDatabase(int, int, char* buf, int) +{ + DataPacket* data = (DataPacket*) buf; // Necessary at the moment, must be changed + // in TH_Database. + + if (itsType == "Control") + { + // First create blob: + int i; + ostringstream ostr; + + // To do: add blob header + + // Put varArgs in blob + char hexrep [data->itsArgSize]; + for (i = 0; i < data->itsArgSize; i ++) { + sprintf (hexrep, "%02X ", (unsigned char) (data->itsVarArgs[i])); + ostr << hexrep; + } + + // Create insertion commands + ostringstream q1; + ostringstream q2; + + q1 << "INSERT INTO BBWorkOrders VALUES (" + << theirWriteCount << ", " + << data->itsStatus << ", " + << "'" << data->itsKSType << "', " + << data->itsStrategyNo << ", " + << data->itsArgSize << ", " + << "'" << ostr.str() << "');"; + + cout << "DH_WorkOrder::StoreInDatabase <<< Insert WorkOrder QUERY: " << q1.str () << endl; + + q2 << "INSERT INTO BBSolutions (id, p1name, p2name, p3name) VALUES (" + << theirWriteCount << ", " + << "'" << data->itsParam1Name << "', " + << "'" << data->itsParam2Name << "', " + << "'" << data->itsParam3Name << "'); "; + + cout << "DH_WorkOrder::StoreInDatabase <<< Insert Solution QUERY: " << q2.str () << endl; + + ExecuteSQLCommand(q1); + ExecuteSQLCommand(q2); + + theirWriteCount ++; + + return true; + } + else if (itsType == "KS") + { + ostringstream q; + q << "UPDATE BBSolutions SET " + << "P1ParamValue = " << "'" << data->itsParam1Value << "', " + << "P2ParamValue = " << "'" << data->itsParam2Value << "', " + << "P3ParamValue = " << "'" << data->itsParam3Value << "', " + << "SrcNo = " << data->itsSolution.itsMu << " " + << "WHERE ID = " << data->itsID << "); "; + + cout << "DH_WorkOrder::StoreInDatabase <<< Update Solution QUERY: " << q.str () << endl; + + + ExecuteSQLCommand(q); + + return true; + } + return false; +} + +bool DH_WorkOrder::RetrieveFromDatabase(int, int, char* buf, int size) +{ + if (itsType == "KS") + { + // Construct workorder query in table BBWorkOrders + ostringstream q1; + + q1 << "SELECT * FROM BBWorkOrders WHERE " + << "id = " << theirReadCount << " AND " + << "status = 0 AND " + << "kstype = 'PSS3' " << ";"; + + cout << "DH_WorkOrder::RetrieveFromDatabase <<< WorkOrder QUERY: " << q1.str () << endl; + + PGresult * res1; + + // Block until a packet appears in the table + do { + cerr << '.'; + res1 = PQexec (DH_Postgresql::theirConnection, (q1.str ()).c_str ()); + + AssertStr (PQresultStatus (res1) == PGRES_TUPLES_OK, + "DH_Postgressql::Retrieve (); Select query failed.") + // TODO: Do a PQclear here? + } while (PQntuples (res1) == 0); + + int nRows; + nRows = PQntuples (res1); + AssertStr (nRows == 1, "DH_Postgresql::Retrieve ();" + << "ERROR: Found less or more than 1 message in database.") + + DataPacket* data = (DataPacket*) buf; // Necessary at the moment, must be changed + // in TH_Database. + + char token[40]; + + istringstream istr (PQgetvalue (res1, 0, 5)); + for (int k = 0; k < size; k ++) { + istr >> token; + data->itsVarArgs[k] = (char) strtoul (token, NULL, 16); + } + + // Construct query for parameter names in table BBSolutions + ostringstream q2; + + q2 << "SELECT * FROM BBSolutions WHERE " + << "id = " << theirReadCount << ";"; + + cout << "DH_WorkOrder::RetrieveFromDatabase <<< Params QUERY: " << q2.str () << endl; + + PGresult * res2; + + // Block until a packet appears in the table + do { + cerr << '.'; + res2 = PQexec (DH_Postgresql::theirConnection, (q2.str ()).c_str ()); + + AssertStr (PQresultStatus (res2) == PGRES_TUPLES_OK, + "DH_Postgressql::Retrieve (); Select query failed.") + // TODO: Do a PQclear here? + } while (PQntuples (res2) == 0); + + nRows = PQntuples (res2); + AssertStr (nRows == 1, "DH_Postgresql::Retrieve ();" + << "ERROR: Found less or more than 1 message in database."); + + + // Update WorkOrder status in table BBWorkOrders + ostringstream q3; + + q3 << "UPDATE BBWorkOrders SET " + << "Status = 1" << " " + << "WHERE id = " << theirReadCount << " AND " + << "Status = 0" << " ;"; + + cout << "DH_WorkOrder::RetrieveFromDatabase <<< UPDATE COMMAND: " << q3.str () << endl; + + ExecuteSQLCommand(q3); + + + // Put results in DataPacket + data->itsStatus = (DH_WorkOrder::woStatus) atoi(PQgetvalue(res1, 0, 1)); + data->itsKSType = PQgetvalue(res1, 0, 2); + data->itsStrategyNo = atoi(PQgetvalue(res1, 0, 3)); + data->itsArgSize = atoi(PQgetvalue(res1, 0, 4)); + + data->itsID = atoi(PQgetvalue(res2, 0, 0)); + data->itsParam1Name = PQgetvalue(res2, 0, 1); + data->itsParam2Name = PQgetvalue(res2, 0, 2); + data->itsParam3Name = PQgetvalue(res2, 0, 3); + + PQclear(res1); + PQclear(res2); + + theirReadCount++; + return true; + } + else if (itsType == "Control") + { + // Code to be added. + return true; + } + + return false; +} diff --git a/CEP/BB/PSS3/src/DH_WorkOrder.h b/CEP/BB/PSS3/src/DH_WorkOrder.h new file mode 100644 index 0000000000000000000000000000000000000000..7b17cda3e9b76fd4d908b5f54d441d415e7c5b3a --- /dev/null +++ b/CEP/BB/PSS3/src/DH_WorkOrder.h @@ -0,0 +1,206 @@ +// DH_WorkOrder.h: Example DataHolder +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + +#ifndef PSS3_DH_WORKORDER_H +#define PSS3_DH_WORKORDER_H + +#include <Common/lofar_complex.h> + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <CEPFrame/DH_Postgresql.h> +#include <PSS3/Solution.h> + +#define MAX_STRAT_ARGS_SIZE 32 // Change this value to the maximum + // argument size of all strategy + // implementations + +/** + This class is an example DataHolder which is only used in the + Example programs. +*/ + +class DH_WorkOrder: public LOFAR::DH_Postgresql +{ +public: + + enum woStatus{New,Assigned,Executed}; + + explicit DH_WorkOrder (const string& name, const string& type); + + DH_WorkOrder(const DH_WorkOrder&); + + virtual ~DH_WorkOrder(); + + DataHolder* clone() const; + + /// Aloocate the buffers. + virtual void preprocess(); + + /// Deallocate the buffers. + virtual void postprocess(); + + /// Database store/retrieve methods + bool StoreInDatabase(int appId, int tag, char* buf, int size); + bool RetrieveFromDatabase(int appId, int tag, char* buf, int size); + + /// Data access functions. + int getID(); + void setID(int id); + const string& getParam1Name(); + float getParam1Value(); + void setParam1Value(float val); + const string& getParam2Name(); + float getParam2Value(); + void setParam2Value(float val); + const string& getParam3Name(); + float getParam3Value(); + void setParam3Value(float val); + + int getSourceNo(); + void setSourceNo(int no); + Solution* getSolution(); + + woStatus getStatus(); + void setStatus(woStatus status); + const string& getKSType(); + void setKSType(const string& ksType); + + unsigned int getStrategyNo(); + void setStrategyNo(unsigned int no); + int getArgSize(); + void setArgSize(int size); + char* getVarArgsPtr(); + + +protected: + // Definition of the DataPacket type. + // N.B.This datapacket can only be correctly transported with TH_Database + class DataPacket: public DH_Database::DataPacket + { + public: + DataPacket(); + ~DataPacket() {}; + int itsID; + string itsParam1Name; // Names and values of three parameters + float itsParam1Value; + string itsParam2Name; + float itsParam2Value; + string itsParam3Name; + float itsParam3Value; + int itsSrcNo; // Its source number + Solution itsSolution; // Its solution quality + + woStatus itsStatus; // WorkOrder status + string itsKSType; // Knowledge source type which is allowed to + // execute the WorkOrder + unsigned int itsStrategyNo; // Strategy number + int itsArgSize; // Size of strategy specific arguments in bytes + char itsVarArgs[MAX_STRAT_ARGS_SIZE]; + // Strategy specific arguments + }; + +private: + /// Forbid assignment. + DH_WorkOrder& operator= (const DH_WorkOrder&); + DataPacket itsDataPacket; + + string itsType; // Its type (Control or KS). This will determine which query + // is executed in StoreInDatabase and RetrieveFromDatabase + + static int theirWriteCount; + static int theirReadCount; + +}; + +inline int DH_WorkOrder::getID() +{ return itsDataPacket.itsID; } + +inline void DH_WorkOrder::setID(int id) +{ itsDataPacket.itsID = id; } + +inline const string& DH_WorkOrder::getParam1Name() +{ return itsDataPacket.itsParam1Name;} + +inline float DH_WorkOrder::getParam1Value() +{ return itsDataPacket.itsParam1Value; } + +inline void DH_WorkOrder::setParam1Value(float val) +{ itsDataPacket.itsParam1Value = val; } + +inline const string& DH_WorkOrder::getParam2Name() +{ return itsDataPacket.itsParam2Name;} + +inline float DH_WorkOrder::getParam2Value() +{ return itsDataPacket.itsParam2Value; } + +inline void DH_WorkOrder::setParam2Value(float val) +{ itsDataPacket.itsParam2Value = val; } + +inline const string& DH_WorkOrder::getParam3Name() +{ return itsDataPacket.itsParam3Name;} + +inline float DH_WorkOrder::getParam3Value() +{ return itsDataPacket.itsParam3Value; } + +inline void DH_WorkOrder::setParam3Value(float val) +{ itsDataPacket.itsParam3Value = val; } + +inline int DH_WorkOrder::getSourceNo() +{ return itsDataPacket.itsSrcNo; } + +inline void DH_WorkOrder::setSourceNo(int no) +{ itsDataPacket.itsSrcNo = no; } + +inline Solution* DH_WorkOrder::getSolution() +{ return &itsDataPacket.itsSolution; } + +inline DH_WorkOrder::woStatus DH_WorkOrder::getStatus() +{ return itsDataPacket.itsStatus; } + +inline void DH_WorkOrder::setStatus(DH_WorkOrder::woStatus status) +{ itsDataPacket.itsStatus = status; } + +inline const string& DH_WorkOrder::getKSType() +{ return itsDataPacket.itsKSType; } + +inline void DH_WorkOrder::setKSType(const string& ksType) +{ itsDataPacket.itsKSType = ksType; } + +inline unsigned int DH_WorkOrder::getStrategyNo() +{ return itsDataPacket.itsStrategyNo; } + +inline void DH_WorkOrder::setStrategyNo(unsigned int no) +{ itsDataPacket.itsStrategyNo = no; } + +inline int DH_WorkOrder::getArgSize() +{ return itsDataPacket.itsArgSize; } + +inline char* DH_WorkOrder::getVarArgsPtr() +{ return itsDataPacket.itsVarArgs; } + +#endif diff --git a/CEP/BB/PSS3/src/Makefile.am b/CEP/BB/PSS3/src/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..1863aa3da92e921f05849ab5e757a04b5669f83b --- /dev/null +++ b/CEP/BB/PSS3/src/Makefile.am @@ -0,0 +1,34 @@ +bin_PROGRAMS = BlackBoardDemo + +DOCHDRS = \ +DH_Parms.h \ +DH_WorkOrder.h \ +WH_Evaluate.h \ +WH_PSS3.h \ +WH_Connection.h \ +BlackBoardDemo.h \ +Solution.h \ +Strategy.h \ +StrategyImpl.h \ +SI_Peeling.h \ +MeqCalibraterImpl.h \ +Calibrator.h + +BlackBoardDemo_SOURCES = $(DOCHDRS) \ +Simulate.cc \ +DH_Parms.cc \ +DH_WorkOrder.cc \ +WH_Evaluate.cc \ +WH_PSS3.cc \ +WH_Connection.cc \ +BlackBoardDemo.cc \ +Solution.cc \ +Strategy.cc \ +StrategyImpl.cc \ +SI_Peeling.cc \ +MeqCalibraterImpl.cc \ +Calibrator.cc + +BlackBoardDemo_DEPENDENCIES = $(LOFAR_DEPEND) + +include $(lofar_sharedir)/Makefile.common diff --git a/CEP/BB/PSS3/src/MeqCalibraterImpl.cc b/CEP/BB/PSS3/src/MeqCalibraterImpl.cc index 7f1a6d7251ff80451a8bd9f284b46e97ba0d7731..2a69e0c15b4102cd3e9679e270739f054889cbab 100644 --- a/CEP/BB/PSS3/src/MeqCalibraterImpl.cc +++ b/CEP/BB/PSS3/src/MeqCalibraterImpl.cc @@ -20,8 +20,8 @@ //# //# $Id$ -#include <CAL/MeqCalibraterImpl.h> -#include <CAL/Solution.h> +#include <PSS3/MeqCalibraterImpl.h> +#include <PSS3/Solution.h> #include <MNS/MeqJonesNode.h> #include <MNS/MeqStatExpr.h> diff --git a/CEP/BB/PSS3/src/MeqCalibraterImpl.h b/CEP/BB/PSS3/src/MeqCalibraterImpl.h index 295a5d0d93903be99bc8fda7453e1978978f4bf4..2eb8379abdf7b8042d5e5298a26a4775efaf019c 100644 --- a/CEP/BB/PSS3/src/MeqCalibraterImpl.h +++ b/CEP/BB/PSS3/src/MeqCalibraterImpl.h @@ -20,8 +20,8 @@ //# //# $Id$ -#ifndef CAL_MEQCALIBRATER_H -#define CAL_MEQCALIBRATER_H +#ifndef PSS3_MEQCALIBRATER_H +#define PSS3_MEQCALIBRATER_H class Solution; #include <aips/Arrays/Matrix.h> @@ -51,7 +51,7 @@ class Solution; #include <MNS/MeqLofarStatSources.h> #include <MNS/MeqStatUVW.h> #include <MNS/ParmTable.h> -#include <CAL/Solution.h> +#include <PSS3/Solution.h> /*! * Class to perform self-calibration on a MeasurementSet using the diff --git a/CEP/BB/PSS3/src/SI_Peeling.cc b/CEP/BB/PSS3/src/SI_Peeling.cc new file mode 100644 index 0000000000000000000000000000000000000000..d5a0e95571e774bb3f9ad90211bfb6e636d10fb1 --- /dev/null +++ b/CEP/BB/PSS3/src/SI_Peeling.cc @@ -0,0 +1,117 @@ +//# SI_Peeling.cc: The peeling calibration strategy +//# +//# Copyright (C) 2002-2003 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#include <PSS3/SI_Peeling.h> +#include <Common/Debug.h> +#include <PSS3/Calibrator.h> + +SI_Peeling::SI_Peeling(Calibrator* cal, int argSize, char* args) + : StrategyImpl(), + itsCal(cal), + itsCurIter(-1), + itsCurSource(1), + itsFirstCall(true) +{ + AssertStr(argSize == sizeof(Peeling_data), "Incorrect argument list"); + SI_Peeling::Peeling_data* pData = (SI_Peeling::Peeling_data*)args; + itsNIter = pData->nIter; + itsNSources = pData->nSources; + itsTimeInterval = pData->timeInterval; + +// mc->setTimeInterval(itsTimeInterval); +// mc->clearSolvableParms(); +} + +SI_Peeling::~SI_Peeling() +{} + +bool SI_Peeling::execute(Vector<String>& paramNames, + Vector<float>& paramValues, + Solution& solutionQuality) +{ + AssertStr(itsCal != 0, + "Calibrator pointer not set for this peeling strategy"); + if (itsCurSource > itsNSources) + { + return false; // Finished with all sources. + } + else + { + itsCal->Initialize(); + itsCal->OptimizeSource(itsCurSource, itsNIter); + itsCurSource++; + return true; + } + +// if (itsFirstCall) +// { +// Vector<String> pp(3); +// Vector<String> ep(3); +// ostringstream oss[3]; +// oss[0] << paramNames[0] << itsCurSource; pp[0] = oss[0].str(); +// oss[1] << paramNames[1] << itsCurSource; pp[1] = oss[1].str(); +// oss[2] << paramNames[2] << itsCurSource; pp[2] = oss[2].str(); +// itsMC->setSolvableParms (pp,ep,true); +// itsMC->resetIterator(); +// itsMC->nextInterval(); +// cout << "Next interval" << endl; +// itsFirstCall = false; +// } + +// // Temporary code to get an idea: +// if (++itsCurIter >= itsNIter) // Peeling strategy: +// { // inner loop over iterations, outer +// cout << "Next interval" << endl; // over sources. +// if (itsMC->nextInterval() == false) +// { +// if (++itsCurSource > itsNSources) +// { +// return false; // Finished with all iterations, +// } // intervals and sources +// else +// { +// cout << "Next source" << endl; +// itsMC->clearSolvableParms(); +// Vector<String> pp(3); +// Vector<String> ep(3); +// ostringstream oss[3]; +// oss[0] << paramNames[0] << itsCurSource; pp[0] = oss[0].str(); +// oss[1] << paramNames[1] << itsCurSource; pp[1] = oss[1].str(); +// oss[2] << paramNames[2] << itsCurSource; pp[2] = oss[2].str(); +// itsMC->setSolvableParms (pp,ep,true); +// itsMC->resetIterator(); +// itsMC->nextInterval(); +// cout << "Next interval" << endl; +// } +// } +// itsCurIter = 0; // Reset iterator +// } +// cout << "Next iteration: " << itsCurIter << endl; +// itsMC->solve(false); +// itsMC->updateParms(); +// itsMC->saveResidualData(); +// itsMC->saveParms(); + +// Vector<String> solution(3*itsNSources + 6); // Output from the solve call + +// return true; +} diff --git a/CEP/BB/PSS3/src/SI_Peeling.h b/CEP/BB/PSS3/src/SI_Peeling.h new file mode 100644 index 0000000000000000000000000000000000000000..4b2c33c006371b7a4eaf22fa08438bd022c224a1 --- /dev/null +++ b/CEP/BB/PSS3/src/SI_Peeling.h @@ -0,0 +1,78 @@ +//# SI_Peeling.h: The peeling calibration strategy +//# +//# Copyright (C) 2002-2003 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#ifndef PSS3_SI_PEELING_H +#define PSS3_SI_PEELING_H + +#if defined(HAVE_CONFIG_H) +#include <config.h> +#endif + +//# Includes +#include <PSS3/StrategyImpl.h> +#include <Common/lofar_string.h> + +//# Forward Declarations + +// This is a class which implements the peeling strategy. + +class SI_Peeling : public StrategyImpl +{ +public: + + typedef struct { // Struct containing data specific for peeling strategy + int nIter; + int nSources; + double timeInterval; + }Peeling_data; + + SI_Peeling(Calibrator* cal, int argSize, char* args); + + virtual ~SI_Peeling(); + + /// Execute the strategy + virtual bool execute(Vector<String>& paramNames, // Parameters for which + // to solve + Vector<float>& paramValues, // Parameter values + Solution& solutionQuality); + + /// Get strategy type + virtual string getType() const; + + private: + SI_Peeling(const SI_Peeling&); + SI_Peeling& operator=(const SI_Peeling&); + + Calibrator* itsCal; // The calibrator + int itsNIter; // Number of iterations + int itsNSources; // Number of sources for which to solve + double itsTimeInterval; // Time interval for which to solve + int itsCurIter; // The current iteration + int itsCurSource; // The current source + bool itsFirstCall; +}; + +inline string SI_Peeling::getType() const +{ return "Peeling"; } + + +#endif diff --git a/CEP/BB/PSS3/src/Simulate.cc b/CEP/BB/PSS3/src/Simulate.cc new file mode 100644 index 0000000000000000000000000000000000000000..846941e65ba76b0534588c6ea01ab07bf1eff7de --- /dev/null +++ b/CEP/BB/PSS3/src/Simulate.cc @@ -0,0 +1,67 @@ +// Simulate.cc: +// +// Copyright (C) 2000-2002 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +///////////////////////////////////////////////////////////////// + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "CEPFrame/SimulatorParseClass.h" +#include <Common/lofar_iostream.h> +#include <Common/Debug.h> +#include "PSS3/BlackBoardDemo.h" +#ifdef HAVE_MPI +#include <mpi.h> +#endif + +#ifdef HAVE_CORBA +int atexit(void (*function)(void)) +{ + return 1; +} +#endif + +int main (int argc, const char** argv) +{ + +#ifdef HAVE_MPI + MPI_Init(&argc, (char ***)&argv); +#endif + try { + BlackBoardDemo simulator; + simulator.setarg (argc, argv); + + // Set trace level. + Debug::initLevels (argc, argv); + try { + LOFAR::SimulatorParse::parse (simulator); + } + catch (LOFAR::SimulatorParseError x) { + + cout << x.what() << endl; + } + } + catch (...) { + cout << "Unexpected exception in Simulate" << endl; + } +} diff --git a/CEP/BB/PSS3/src/Solution.cc b/CEP/BB/PSS3/src/Solution.cc index 701b43d5a47408a900fb2e03d8e13e6ce34509e3..8fc8531416b6282d610ceda2a67bb7734570a7a2 100644 --- a/CEP/BB/PSS3/src/Solution.cc +++ b/CEP/BB/PSS3/src/Solution.cc @@ -20,7 +20,7 @@ //# //# $Id$ -#include <CAL/Solution.h> +#include <PSS3/Solution.h> Solution::Solution(): diff --git a/CEP/BB/PSS3/src/Solution.h b/CEP/BB/PSS3/src/Solution.h index ad6d7371be4706a1569e4f5bd0529e972a9bf451..d8ecf50eeb2e239421e03f1cb0f6f04027375790 100644 --- a/CEP/BB/PSS3/src/Solution.h +++ b/CEP/BB/PSS3/src/Solution.h @@ -20,8 +20,8 @@ //# //# $Id$ -#ifndef CAL_SOLUTION_H -#define CAL_SOLUTION_H +#ifndef PSS3_SOLUTION_H +#define PSS3_SOLUTION_H #if defined(HAVE_CONFIG_H) #include <config.h> diff --git a/CEP/BB/PSS3/src/Strategy.cc b/CEP/BB/PSS3/src/Strategy.cc new file mode 100644 index 0000000000000000000000000000000000000000..4348dcd0f14ade6c25288a881981d1f431963e3f --- /dev/null +++ b/CEP/BB/PSS3/src/Strategy.cc @@ -0,0 +1,73 @@ +//# Strategy.cc: A base class for all calibration strategies +//# +//# Copyright (C) 2002-2003 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#include <PSS3/Strategy.h> +#include <Common/Debug.h> +#include <PSS3/SI_Peeling.h> + +Strategy::Strategy(int strategyNo, Calibrator* cal, + int varArgSize, char* varArgs) +{ + AssertStr(cal!=0, "Calibrator pointer is 0"); + switch (strategyNo) + { + case 1: // Peeling + TRACER3("Creating peeling strategyImpl"); + itsImpl = new SI_Peeling(cal, varArgSize, varArgs); + break; + case 2: // Ripple Tree + TRACER3("Creating ripple tree strategyImpl"); + // Code must be added + break; + case 3: // Classic + TRACER3("Creating classic strategyImpl"); + // Code must be added + break; + default: + itsImpl = 0; + Throw("Unknown strategy number in Strategy construction"); + } + +} + +Strategy::~Strategy() +{ + if (itsImpl != 0) + { + delete itsImpl; + } +} + +bool Strategy::execute(Vector<String>& paramNames, + Vector<float>& paramValues, + Solution& solutionQuality) +{ + if (itsImpl != 0) + { + return itsImpl->execute(paramNames, paramValues, solutionQuality); + } + else + { + TRACER2("No strategy implementation; cannot execute."); + return false; + } +} diff --git a/CEP/BB/PSS3/src/Strategy.h b/CEP/BB/PSS3/src/Strategy.h new file mode 100644 index 0000000000000000000000000000000000000000..a9648244471d696e068c9449c917fed847a39ab9 --- /dev/null +++ b/CEP/BB/PSS3/src/Strategy.h @@ -0,0 +1,60 @@ +//# Strategy.h: A base class for all calibration strategies +//# +//# Copyright (C) 2002-2003 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#ifndef PSS3_STRATEGY_H +#define PSS3_STRATEGY_H + +#if defined(HAVE_CONFIG_H) +#include <config.h> +#endif + +//# Includes +#include <aips/Arrays/Vector.h> +#include <PSS3/Solution.h> + +//# Forward Declarations +class Calibrator; +class StrategyImpl; + +// This class defines the interface to calibration strategies. It creates +// and contains a reference to a concrete calibration strategy implementation +// (StrategyImpl class). (Bridge pattern) + + +class Strategy +{ +public: + Strategy(int strategyNo, Calibrator* cal, int varArgSize, char* varArgs); + + virtual ~Strategy(); + + /// Execute the strategy + bool execute(Vector<String>& paramNames, // Parameters for which to solve + Vector<float>& paramValues, // Parameter values + Solution& solutionQuality); // Solution quality + + private: + StrategyImpl* itsImpl; // The strategy implementation +}; + + +#endif diff --git a/CEP/BB/PSS3/src/StrategyImpl.cc b/CEP/BB/PSS3/src/StrategyImpl.cc new file mode 100644 index 0000000000000000000000000000000000000000..b5e8222e2f62b80d9e20c65d16b59c4beca6b049 --- /dev/null +++ b/CEP/BB/PSS3/src/StrategyImpl.cc @@ -0,0 +1,30 @@ +//# StrategyImpl.cc: A base class for all calibration strategies +//# +//# Copyright (C) 2002-2003 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#include <PSS3/StrategyImpl.h> + +StrategyImpl::StrategyImpl() +{} + +StrategyImpl::~StrategyImpl() +{} + diff --git a/CEP/BB/PSS3/src/StrategyImpl.h b/CEP/BB/PSS3/src/StrategyImpl.h new file mode 100644 index 0000000000000000000000000000000000000000..fce987ee8fa4e851177c113ec3f230f301744e3a --- /dev/null +++ b/CEP/BB/PSS3/src/StrategyImpl.h @@ -0,0 +1,61 @@ +//# StrategyImpl.h: A base class for all calibration strategies +//# +//# Copyright (C) 2002-2003 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#ifndef PSS3_STRATEGYIMPL_H +#define PSS3_STRATEGYIMPL_H + +#if defined(HAVE_CONFIG_H) +#include <config.h> +#endif + +//# Includes +#include <aips/Arrays/Vector.h> +#include <Common/lofar_string.h> +#include <PSS3/Solution.h> + +//# Forward Declarations +class Calibrator; + +// This is a base class for all calibration strategies. + +class StrategyImpl +{ +public: + StrategyImpl(); + + virtual ~StrategyImpl(); + + /// Execute the strategy + virtual bool execute(Vector<String>& paramNames, // Parameters for which + // to solve + Vector<float>& paramValues, // Parameter values + Solution& solutionQuality) = 0; // Solution quality + + /// Get strategy implementation type + virtual string getType() const = 0; + + private: + +}; + + +#endif diff --git a/CEP/BB/PSS3/src/WH_Connection.cc b/CEP/BB/PSS3/src/WH_Connection.cc new file mode 100644 index 0000000000000000000000000000000000000000..4506e839ebf304b01da97236de0510eeaf21288d --- /dev/null +++ b/CEP/BB/PSS3/src/WH_Connection.cc @@ -0,0 +1,114 @@ +// WH_Connection.cc: +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + +#include "PSS3/WH_Connection.h" +#include <math.h> + +using namespace LOFAR; + +WH_Connection::WH_Connection (const string& name, int nInDHs, + int nOutDHs, dhType dh1Type, dhType dh2Type) + : WorkHolder(nInDHs, nOutDHs, name, "WH_Connection"), + itsNInDHs(nInDHs), + itsNOutDHs(nOutDHs), + itsDH1Type(dh1Type), + itsDH2Type(dh2Type) +{ + AssertStr((nInDHs == 0) || (nOutDHs == 0), "Number of inputs or number of outputs should be 0"); + if (nInDHs != 0) + { + AssertStr((nInDHs==1 || nInDHs == 2), "Number of dataholders is not equal to 1 or 2 : " + << nInDHs); + switch (dh1Type) { + case WorkOrder: + getDataManager().addInDataHolder(0, new DH_WorkOrder("in", "Conn"), true); + break; + case Parms: + getDataManager().addInDataHolder(0, new DH_Parms("in"), true); + break; + } + if (nInDHs == 2) + { + switch (dh2Type) { + case WorkOrder: + getDataManager().addInDataHolder(1, new DH_WorkOrder("in", "Conn"), true); + break; + case Parms: + getDataManager().addInDataHolder(1, new DH_Parms("in"), true); + break; + } + } + } + else + { + AssertStr((nOutDHs==1 || nOutDHs == 2), "Number of dataholders is not equal to 1 or 2 : " + << nOutDHs); + switch (dh1Type) { + case WorkOrder: + getDataManager().addOutDataHolder(0, new DH_WorkOrder("in", "Conn"), true); + break; + case Parms: + getDataManager().addOutDataHolder(0, new DH_Parms("in"), true); + break; + } + if (nOutDHs == 2) + { + switch (dh2Type) { + case WorkOrder: + getDataManager().addOutDataHolder(1, new DH_WorkOrder("in", "Conn"), true); + break; + case Parms: + getDataManager().addOutDataHolder(1, new DH_Parms("in"), true); + break; + } + } + } + +} + + + +WH_Connection::~WH_Connection() +{} + +WorkHolder* WH_Connection::construct (const string& name, int, int, + const ParamBlock&) +{ + return new WH_Connection (name, 0, 0, Parms, Parms); +} + +WH_Connection* WH_Connection::make (const string& name) +{ + return new WH_Connection (name, itsNInDHs, itsNOutDHs, itsDH1Type, itsDH2Type); +} + +void WH_Connection::process() +{ +} + +void WH_Connection::dump() +{ +} + diff --git a/CEP/BB/PSS3/src/WH_Connection.h b/CEP/BB/PSS3/src/WH_Connection.h new file mode 100644 index 0000000000000000000000000000000000000000..b0c91dbd56331ce4e42eeb06124415c69d1fc623 --- /dev/null +++ b/CEP/BB/PSS3/src/WH_Connection.h @@ -0,0 +1,83 @@ +// WH_Connection.h: An empty WorkHolder (doing nothing) +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + +#ifndef PSS3_WH_CONNECTION_H +#define PSS3_WH_CONNECTION_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "CEPFrame/WorkHolder.h" +#include "PSS3/DH_WorkOrder.h" +#include "PSS3/DH_Parms.h" + + +/** + This is an empty WorkHolder class. It either has (1 or 2) inputs or outputs of + a specified type. This WorkHolder is used in a 'stub' step */ + +class WH_Connection: public LOFAR::WorkHolder +{ +public: + enum connType{input, output}; + enum dhType{WorkOrder, Parms}; + + /// Construct the work holder. + explicit WH_Connection (const string& name, int NInDHs, + int NOutDHs, dhType dh1Type, dhType dh2Type=Parms); + + virtual ~WH_Connection(); + + /// Static function to create an object. + static WorkHolder* construct (const string& name, int ninput, int noutput, + const LOFAR::ParamBlock&); + + /// Make a fresh copy of the WH object. + virtual WH_Connection* make (const string& name); + + /// Do a process step. + virtual void process(); + + /// Show the work holder on stdout. + virtual void dump(); + +private: + /// Forbid copy constructor. + WH_Connection (const WH_Connection&); + + /// Forbid assignment. + WH_Connection& operator= (const WH_Connection&); + + connType itsType; + int itsNInDHs; + int itsNOutDHs; + dhType itsDH1Type; + dhType itsDH2Type; + +}; + + +#endif diff --git a/CEP/BB/PSS3/src/WH_Evaluate.cc b/CEP/BB/PSS3/src/WH_Evaluate.cc new file mode 100644 index 0000000000000000000000000000000000000000..0da625b9e6201855873eff4f8a04e73637c2d33d --- /dev/null +++ b/CEP/BB/PSS3/src/WH_Evaluate.cc @@ -0,0 +1,78 @@ +// WH_Evaluate.cc: +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + +#include <stdio.h> // for sprintf + +#include "PSS3/WH_Evaluate.h" +#include "CEPFrame/Step.h" +#include "CEPFrame/ParamBlock.h" +#include "Common/Debug.h" +#include "PSS3/DH_WorkOrder.h" +#include "PSS3/SI_Peeling.h" + +using namespace LOFAR; + +WH_Evaluate::WH_Evaluate (const string& name) +: WorkHolder (0, 1, name,"WH_Evaluate") +{ +// getDataManager().addInDataHolder(0, new DH_WorkOrder("in_0", "Control"), +// true); // + getDataManager().addOutDataHolder(0, new DH_WorkOrder("out_0", "Control"), + true); +} + +WH_Evaluate::~WH_Evaluate() +{ +} + +WH_Evaluate* WH_Evaluate::make (const string& name) +{ + return new WH_Evaluate(name); +} + +void WH_Evaluate::process() +{ + TRACER3("WH_Evaluate process()"); + // DH_WorkOrder* inp = (DH_WorkOrder*)getDataManager().getInHolder(0); + DH_WorkOrder* outp = (DH_WorkOrder*)getDataManager().getOutHolder(0); + // Define new work order + outp->setStatus(DH_WorkOrder::New); + outp->setKSType("PSS3"); + outp->setStrategyNo(1); + // Set arguments for peeling + int size = sizeof(SI_Peeling::Peeling_data); + outp->setArgSize(size); + SI_Peeling::Peeling_data* data = + (SI_Peeling::Peeling_data*)outp->getVarArgsPtr(); + data->nIter = 20; + data->nSources = 3; + data->timeInterval = 3600.; + // Set parameter names +} + +void WH_Evaluate::dump() +{ +} + diff --git a/CEP/BB/PSS3/src/WH_Evaluate.h b/CEP/BB/PSS3/src/WH_Evaluate.h new file mode 100644 index 0000000000000000000000000000000000000000..1bc686cb3bbaff4f094652e608a0c8cc404bdd0d --- /dev/null +++ b/CEP/BB/PSS3/src/WH_Evaluate.h @@ -0,0 +1,70 @@ +// WH_Evaluate.h: This class implements the controller of the blackboard. +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + +#ifndef PSS3_WH_EVALUATE_H +#define PSS3_WH_EVALUATE_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "CEPFrame/WorkHolder.h" + + +/** + This class implements the controller of the blackboard +*/ + +class WH_Evaluate: public LOFAR::WorkHolder +{ +public: + /// Construct the work holder and give it a name. + /// It is possible to specify how many input and output data holders + /// are created and how many elements there are in the buffer. + /// The first WorkHolder should have nin=0. + explicit WH_Evaluate (const string& name="aWH_Evaluate"); + + virtual ~WH_Evaluate(); + + /// Make a fresh copy of the WH object. + virtual WH_Evaluate* make (const string& name); + + /// Do a process step. + virtual void process(); + + /// Show the work holder on stdout. + virtual void dump(); + +private: + /// Forbid copy constructor. + WH_Evaluate (const WH_Evaluate&); + + /// Forbid assignment. + WH_Evaluate& operator= (const WH_Evaluate&); + +}; + + +#endif diff --git a/CEP/BB/PSS3/src/WH_PSS3.cc b/CEP/BB/PSS3/src/WH_PSS3.cc new file mode 100644 index 0000000000000000000000000000000000000000..62b20fd7d3896a2f467438488e7dc705e2d51c69 --- /dev/null +++ b/CEP/BB/PSS3/src/WH_PSS3.cc @@ -0,0 +1,127 @@ +// WH_PSS3.cc: +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + +#include <stdio.h> // for sprintf + +#include "PSS3/WH_PSS3.h" +#include "CEPFrame/Step.h" +#include "CEPFrame/ParamBlock.h" +#include "Common/Debug.h" +#include "PSS3/DH_WorkOrder.h" +#include "PSS3/DH_Parms.h" +#include "PSS3/Calibrator.h" +#include "PSS3/Strategy.h" + +using namespace LOFAR; + +WH_PSS3::WH_PSS3 (const string& name, const String & msName, + const String& meqModel, const String& skyModel, + uInt ddid, const Vector<int>& ant1, + const Vector<int>& ant2, const String& modelType, + bool calcUVW, const String& dataColName, + const String& residualColName) + : WorkHolder (1, 0, name, "WH_PSS3"), + itsCal (0), + itsMSName (msName), + itsMeqModel (meqModel), + itsSkyModel (skyModel), + itsDDID (ddid), + itsAnt1 (ant1), + itsAnt2 (ant2), + itsModelType (modelType), + itsCalcUVW (calcUVW), + itsDataColName (dataColName), + itsResidualColName(residualColName) + +{ + TRACER4("WH_PSS3 construction"); + getDataManager().addInDataHolder(0, new DH_WorkOrder("in_0", "KS"), + true); + // getDataManager().addOutDataHolder(0, new DH_WorkOrder("out_0", "KS"), +// true); +} + +WH_PSS3::~WH_PSS3() +{ + TRACER4("WH_PSS3 destructor"); + if (itsCal != 0) + { + delete itsCal; + } +} + +WH_PSS3* WH_PSS3::make (const string& name) +{ + return new WH_PSS3 (name, itsMSName, itsMeqModel, itsSkyModel, itsDDID, + itsAnt1, itsAnt2, itsModelType, itsCalcUVW, + itsDataColName, itsResidualColName); +} + +void WH_PSS3::preprocess() +{ + TRACER4("WH_PSS3 preprocess()"); + itsCal = new Calibrator(); +// itsCal = new Calibrator(itsMSName, itsMeqModel, itsSkyModel, itsDDID, itsAnt1, +// itsAnt2, itsModelType, itsCalcUVW, itsDataColName, +// itsResidualColName); +} + +void WH_PSS3::process() +{ + TRACER4("WH_PSS3 process()"); + DH_WorkOrder* inp = (DH_WorkOrder*)getDataManager().getInHolder(0); + cout << "Strategy number: " << inp->getStrategyNo() << endl; + Strategy strat(inp->getStrategyNo(), itsCal, inp->getArgSize(), + inp->getVarArgsPtr()); + cout << "Parameter names: " << inp->getParam1Name() << ", " + << inp->getParam2Name() << ", " + << inp->getParam3Name() << endl; + + Vector<String> pNames(3); + pNames[0] = inp->getParam1Name(); + pNames[1] = inp->getParam2Name(); + pNames[2] = inp->getParam3Name(); + Vector<float> pValues(3); + + // Execute the strategy until finished with all iterations, intervals + // and sources. + while (strat.execute(pNames, pValues, *inp->getSolution())) + { + cout << "Executed strategy" << endl; + } + +// DH_WorkOrder* outp = (DH_WorkOrder*)getDataManager().getOutHolder(0); +// outp->setID(inp->getID()); +// outp->setStatus(DH_WorkOrder::Executed); +// outp->setParam1Value(11); // Temporary +// outp->setParam2Value(22); +// outp->setParam3Value(33); +// outp->getSolution()->itsMu = 0.99; +} + +void WH_PSS3::dump() +{ +} + diff --git a/CEP/BB/PSS3/src/WH_PSS3.h b/CEP/BB/PSS3/src/WH_PSS3.h new file mode 100644 index 0000000000000000000000000000000000000000..df27d9c389dcebf64dca41cdf55846e25aa9db3c --- /dev/null +++ b/CEP/BB/PSS3/src/WH_PSS3.h @@ -0,0 +1,93 @@ +// WH_PSS3.h: This workholder acts as a knowledge source in the black board. +// +// Copyright (C) 2000, 2001 +// ASTRON (Netherlands Foundation for Research in Astronomy) +// P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// $Id$ +// +// +////////////////////////////////////////////////////////////////////// + +#ifndef PSS3_WH_PSS3_H +#define PSS3_WH_PSS3_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "CEPFrame/WorkHolder.h" +#include <aips/Arrays/Vector.h> + + +class Calibrator; + +/** + This workholder acts as a knowledge source in the black board. + It contains a Calibrator object for calibration. +*/ + +class WH_PSS3: public LOFAR::WorkHolder +{ +public: + /// Construct the work holder and give it a name. + /// Note: antenna numbers arguments must currently be passed as an + /// aips++ vector! + explicit WH_PSS3(const string& name, const String& msName, + const String& meqModel, const String& skyModel, + uInt ddid, const Vector<int>& ant1, + const Vector<int>& ant2, const String& modelType, + bool calcUVW, const String& dataColName, + const String& residualColName); + + virtual ~WH_PSS3(); + + /// Make a fresh copy of the WH object. + virtual WH_PSS3* make (const string& name); + + /// Do a process step. + virtual void process(); + + /// Preprocess. + virtual void preprocess(); + + /// Show the work holder on stdout. + virtual void dump(); + +private: + /// Forbid copy constructor. + WH_PSS3 (const WH_PSS3&); + + /// Forbid assignment. + WH_PSS3& operator= (const WH_PSS3&); + + Calibrator* itsCal; + String itsMSName; + String itsMeqModel; + String itsSkyModel; + unsigned int itsDDID; + Vector<int> itsAnt1; // Aips vector type for antenna numbers + Vector<int> itsAnt2; // Aips vector type for antenna numbers + String itsModelType; + bool itsCalcUVW; + String itsDataColName; + String itsResidualColName; + +}; + + +#endif