LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
CommandEvent.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
34 #include <iomanip>
35 #include <sstream>
36 #include <stdexcept>
37 #include <limits>
38 #include <cstring>
39 
41 #include "lsst/ctrl/events/Event.h"
44 #include "lsst/daf/base/DateTime.h"
46 #include "lsst/pex/exceptions.h"
47 #include <sys/socket.h>
48 #include <sys/un.h>
49 #include <netdb.h>
50 #include <time.h>
51 
52 #include <activemq/core/ActiveMQConnectionFactory.h>
53 
54 
55 using namespace std;
56 
57 namespace lsst {
58 namespace ctrl {
59 namespace events {
60 
61 const std::string CommandEvent::ORIGINATORID = "ORIGINATORID";
62 const std::string CommandEvent::ORIG_LOCALID = "ORIG_LOCALID";
63 const std::string CommandEvent::ORIG_PROCESSID = "ORIG_PROCESSID";
64 const std::string CommandEvent::ORIG_IPID = "ORIG_IPID";
65 
66 const std::string CommandEvent::DESTINATIONID = "DESTINATIONID";
67 const std::string CommandEvent::DEST_LOCALID = "DEST_LOCALID";
68 const std::string CommandEvent::DEST_PROCESSID = "DEST_PROCESSID";
69 const std::string CommandEvent::DEST_IPID = "DEST_IPID";
70 
75 CommandEvent::CommandEvent() : Event() {
76  _init();
77 }
78 
79 
81  _keywords.insert(ORIGINATORID);
82  _keywords.insert(ORIG_LOCALID);
83  _keywords.insert(ORIG_PROCESSID);
84  _keywords.insert(ORIG_IPID);
85 
86  _keywords.insert(DESTINATIONID);
87  _keywords.insert(DEST_LOCALID);
88  _keywords.insert(DEST_PROCESSID);
89  _keywords.insert(DEST_IPID);
90 }
91 
92 CommandEvent::CommandEvent(cms::TextMessage *msg) : Event(msg) {
93  _init();
94 
95 
96  _psp->set(ORIGINATORID, (int64_t)msg->getLongProperty(ORIGINATORID));
97  _psp->set(ORIG_LOCALID, (short)msg->getShortProperty(ORIG_LOCALID));
98  _psp->set(ORIG_PROCESSID, (int)msg->getIntProperty(ORIG_PROCESSID));
99  _psp->set(ORIG_IPID, (int)msg->getIntProperty(ORIG_IPID));
100 
101  _psp->set(DESTINATIONID, (int64_t)msg->getLongProperty(DESTINATIONID));
102  _psp->set(DEST_LOCALID, (short)msg->getShortProperty(DEST_LOCALID));
103  _psp->set(DEST_PROCESSID, (int)msg->getIntProperty(DEST_PROCESSID));
104  _psp->set(DEST_IPID, (int)msg->getIntProperty(DEST_IPID));
105 
106 }
107 
108 CommandEvent::CommandEvent( const std::string& runId, const int64_t originatorId, const int64_t destinationId, const PropertySet::Ptr psp) : Event(runId, *psp) {
109  _constructor(runId, originatorId, destinationId, *psp);
110 }
111 
112 CommandEvent::CommandEvent( const std::string& runId, const int64_t originatorId, const int64_t destinationId, const PropertySet& ps) : Event(runId, ps) {
113  _constructor(runId, originatorId, destinationId, ps);
114 }
115 
116 void CommandEvent::_constructor( const std::string& runId, const int64_t originatorId, const int64_t destinationId, const PropertySet& ps) {
117  _init();
118 
120 
121  //_originatorId = eventSystem.createOriginatorId();
122  _psp->set(ORIGINATORID, originatorId);
123  _psp->set(ORIG_LOCALID, eventSystem.extractLocalId(originatorId));
124  _psp->set(ORIG_PROCESSID, eventSystem.extractProcessId(originatorId));
125  _psp->set(ORIG_IPID, eventSystem.extractIPId(originatorId));
126 
127  _psp->set(DESTINATIONID, destinationId);
128  _psp->set(DEST_LOCALID, eventSystem.extractLocalId(destinationId));
129  _psp->set(DEST_PROCESSID, eventSystem.extractProcessId(destinationId));
130  _psp->set(DEST_IPID, eventSystem.extractIPId(destinationId));
131 
133 
134 }
135 
136 void CommandEvent::populateHeader(cms::TextMessage* msg) const {
138 
139  msg->setLongProperty(ORIGINATORID, _psp->get<int64_t>(ORIGINATORID));
140  msg->setShortProperty(ORIG_LOCALID, _psp->get<short>(ORIG_LOCALID));
141  msg->setIntProperty(ORIG_PROCESSID, _psp->get<int>(ORIG_PROCESSID));
142  msg->setIntProperty(ORIG_IPID, _psp->get<int>(ORIG_IPID));
143 
144  msg->setLongProperty(DESTINATIONID, _psp->get<int64_t>(DESTINATIONID));
145  msg->setShortProperty(DEST_LOCALID, _psp->get<short>(DEST_LOCALID));
146  msg->setIntProperty(DEST_PROCESSID, _psp->get<int>(DEST_PROCESSID));
147  msg->setIntProperty(DEST_IPID, _psp->get<int>(DEST_IPID));
148 }
149 
151  return _psp->get<int64_t>(ORIGINATORID);
152 }
153 
155  return _psp->get<short>(ORIG_LOCALID);
156 }
157 
159  return _psp->get<int>(ORIG_PROCESSID);
160 }
161 
163  return _psp->get<int>(ORIG_IPID);
164 }
165 
167  return _psp->get<int64_t>(DESTINATIONID);
168 }
169 
171  return _psp->get<short>(DEST_LOCALID);
172 }
173 
175  return _psp->get<int>(DEST_PROCESSID);
176 }
177 
179  return _psp->get<int>(DEST_IPID);
180 }
181 
185 }
186 
187 }
188 }
189 }
virtual void populateHeader(cms::TextMessage *msg) const
Definition: Event.cc:201
PropertySet::Ptr _psp
Definition: Event.h:117
static const std::string ORIG_PROCESSID
Definition: CommandEvent.h:68
CommandEvent()
Creates CommandEvent which contains a PropertySet.
Definition: CommandEvent.cc:75
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
defines EventTypes
static const std::string DESTINATIONID
Definition: CommandEvent.h:71
static const std::string TYPE
Creates Event which contains a PropertySet.
Definition: Event.h:71
static EventSystem & getDefaultEventSystem()
return the default EventSystem object, which can access all previously created Transmitters and recei...
Definition: EventSystem.cc:80
static const std::string DEST_LOCALID
Definition: CommandEvent.h:72
void _constructor(const std::string &runId, const int64_t originatorId, const int64_t destinationId, const PropertySet &ps)
int extractIPId(int64_t identificationId)
extract the 32-bit IPId embedded in this identificationId. This is the integer representation of the ...
Definition: EventSystem.cc:261
virtual void populateHeader(cms::TextMessage *msg) const
static const std::string ORIG_IPID
Definition: CommandEvent.h:69
Include files required for standard LSST Exception handling.
defines the CommandEvent class
defines the Event class
int extractProcessId(int64_t identificationId)
extract the 17-bit processId embedded in this identificationId
Definition: EventSystem.cc:268
Interface for DateTime class.
static const std::string DEST_IPID
Definition: CommandEvent.h:74
static const std::string COMMAND
Definition: EventTypes.h:49
Representation of an LSST Event.
Definition: Event.h:67
Class for storing generic metadata.
Definition: PropertySet.h:82
short extractLocalId(int64_t identificationId)
extract the 15-bit localId embedded in this identificationId
Definition: EventSystem.cc:275
static const std::string ORIGINATORID
Definition: CommandEvent.h:66
Interface for PropertySet class.
static const std::string DEST_PROCESSID
Definition: CommandEvent.h:73
Coordinate publishing and receiving events.
Definition: EventSystem.h:65
set< std::string > _keywords
Definition: Event.h:118
defines the EventSystem class
virtual ~CommandEvent()
destructor
static const std::string ORIG_LOCALID
Definition: CommandEvent.h:67