8 #include "BaseConnectionProbe.hpp" 12 BaseConnectionProbe::BaseConnectionProbe() {}
14 BaseConnectionProbe::BaseConnectionProbe(
const char *name, HyPerCol *hc) { initialize(name, hc); }
16 BaseConnectionProbe::~BaseConnectionProbe() {
delete mIOTimer; }
18 int BaseConnectionProbe::initialize(
const char *name, HyPerCol *hc) {
24 parent->parameters()->ioParamString(ioFlag, name,
"targetConnection", &targetName, NULL,
false);
25 if (targetName == NULL) {
30 Response::Status BaseConnectionProbe::respond(std::shared_ptr<BaseMessage const> message) {
31 Response::Status status = BaseProbe::respond(message);
32 if (status != Response::SUCCESS) {
37 std::dynamic_pointer_cast<ConnectionProbeWriteParamsMessage const>(message)) {
38 return respondConnectionProbeWriteParams(castMessage);
40 else if (
auto castMessage = std::dynamic_pointer_cast<ConnectionOutputMessage const>(message)) {
41 return respondConnectionOutput(castMessage);
48 Response::Status BaseConnectionProbe::respondConnectionProbeWriteParams(
49 std::shared_ptr<ConnectionProbeWriteParamsMessage const> message) {
51 return Response::SUCCESS;
54 Response::Status BaseConnectionProbe::respondConnectionOutput(
55 std::shared_ptr<ConnectionOutputMessage const> message) {
63 std::shared_ptr<CommunicateInitInfoMessage const> message) {
65 if (status != Response::SUCCESS) {
70 mTargetConn = message->lookup<
BaseConnection>(std::string(targetName));
71 if (mTargetConn ==
nullptr) {
73 "%s, rank %d process: targetConnection \"%s\" is not a connection in the column.\n",
80 MPI_Barrier(parent->getCommunicator()->communicator());
84 return Response::SUCCESS;
92 mIOTimer =
new Timer(getName(),
"probe",
"update");
93 checkpointer->registerTimer(mIOTimer);
94 return Response::SUCCESS;
98 MPIBlock const *mpiBlock = checkpointer->getMPIBlock();
99 if (getMPIBlock()->getRank() == 0) {
101 if (probeOutputFilename) {
102 std::string path(probeOutputFilename);
103 std::ios_base::openmode mode = std::ios_base::out;
104 if (!checkpointer->getCheckpointReadDirectory().empty()) {
105 mode |= std::ios_base::app;
107 if (path[0] !=
'/') {
110 auto stream =
new FileStream(path.c_str(), mode, checkpointer->doesVerifyWrites());
111 mOutputStreams.push_back(stream);
114 auto stream =
new PrintStream(PV::getOutputStream());
115 mOutputStreams.push_back(stream);
119 mOutputStreams.clear();
virtual Response::Status registerData(Checkpointer *checkpointer) override
char const * getProbeOutputFilename()
static bool completed(Status &a)
virtual Response::Status registerData(Checkpointer *checkpointer) override
virtual Response::Status outputStateWrapper(double timef, double dt)
virtual void ioParam_targetName(enum ParamsIOFlag ioFlag) override
targetName: the name of the object that the probe attaches to. In LayerProbe, targetName is used to d...
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override
virtual void initOutputStreams(const char *filename, Checkpointer *checkpointer) override
virtual void ioParam_targetName(enum ParamsIOFlag ioFlag)
targetName: the name of the object that the probe attaches to. In LayerProbe, targetName is used to d...
int initialize(const char *name, HyPerCol *hc)
virtual Response::Status communicateInitInfo(std::shared_ptr< CommunicateInitInfoMessage const > message) override=0
std::string makeOutputPathFilename(std::string const &path)