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
StatusEvent.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 namespace pexExceptions = lsst::pex::exceptions;
55 namespace pexLogging = lsst::pex::logging;
56 
57 
58 using namespace std;
59 using std::numeric_limits;
60 
61 namespace lsst {
62 namespace ctrl {
63 namespace events {
64 
65 const std::string StatusEvent::ORIGINATORID = "ORIGINATORID";
66 const std::string StatusEvent::LOCALID = "LOCALID";
67 const std::string StatusEvent::PROCESSID = "PROCESSID";
68 const std::string StatusEvent::IPID = "IPID";
69 
74 StatusEvent::StatusEvent() : Event() {
75  _init();
76 }
77 
78 
80  _keywords.insert(ORIGINATORID);
81  _keywords.insert(LOCALID);
82  _keywords.insert(PROCESSID);
83  _keywords.insert(IPID);
84 }
85 
86 StatusEvent::StatusEvent(cms::TextMessage *msg) : Event(msg) {
87  _init();
88 
89  _psp->set(ORIGINATORID, (int64_t)msg->getLongProperty(ORIGINATORID));
90  _psp->set(LOCALID, (short)msg->getShortProperty(LOCALID));
91  _psp->set(PROCESSID, (int)msg->getIntProperty(PROCESSID));
92  _psp->set(IPID, (signed int)msg->getIntProperty(IPID));
93 
94 }
95 
96 StatusEvent::StatusEvent( const std::string& runId, const int64_t originatorId, const PropertySet::Ptr psp) : Event(runId, *psp) {
97  _constructor(runId, originatorId, *psp);
98 }
99 
100 StatusEvent::StatusEvent( const std::string& runId, const int64_t originatorId, const PropertySet& ps) : Event(runId, ps) {
101  _constructor(runId, originatorId, ps);
102 }
103 
104 void StatusEvent::_constructor(const std::string& runId, const int64_t originatorId, const PropertySet& ps) {
105  _init();
106 
107 
109 
110  _psp->set(ORIGINATORID, originatorId);
111 
112  _psp->set(LOCALID, eventSystem.extractLocalId(originatorId));
113  _psp->set(PROCESSID, eventSystem.extractProcessId(originatorId));
114  _psp->set(IPID, eventSystem.extractIPId(originatorId));
116 
117 }
118 
119 void StatusEvent::populateHeader(cms::TextMessage* msg) const {
121 
122  msg->setLongProperty(ORIGINATORID, _psp->get<int64_t>(ORIGINATORID));
123  msg->setShortProperty(LOCALID, _psp->get<short>(LOCALID));
124  msg->setIntProperty(PROCESSID, _psp->get<int>(PROCESSID));
125  msg->setIntProperty(IPID, _psp->get<int>(IPID));
126 }
127 
129  return _psp->get<int64_t>(ORIGINATORID);
130 }
131 
133  return _psp->set(ORIGINATORID, id);
134 }
135 
136 
138  return _psp->get<short>(LOCALID);
139 }
140 
142  return _psp->get<int>(PROCESSID);
143 }
144 
146  return _psp->get<int>(IPID);
147 }
148 
152 }
153 
154 }
155 }
156 }
void _constructor(const std::string &runid, int64_t originator, const PropertySet &ps)
Definition: StatusEvent.cc:104
virtual void populateHeader(cms::TextMessage *msg) const
Definition: Event.cc:201
PropertySet::Ptr _psp
Definition: Event.h:117
static const std::string ORIGINATORID
Definition: StatusEvent.h:66
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
virtual void populateHeader(cms::TextMessage *msg) const
Definition: StatusEvent.cc:119
defines EventTypes
static const std::string TYPE
Creates Event which contains a PropertySet.
Definition: Event.h:71
void setOriginatorId(int64_t id)
Definition: StatusEvent.cc:132
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 LOCALID
Definition: StatusEvent.h:67
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
StatusEvent()
Creates StatusEvent which contains a PropertySet.
Definition: StatusEvent.cc:74
Include files required for standard LSST Exception handling.
static const std::string IPID
Definition: StatusEvent.h:69
virtual ~StatusEvent()
destructor
Definition: StatusEvent.cc:151
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 STATUS
Definition: EventTypes.h:48
static const std::string PROCESSID
Definition: StatusEvent.h:68
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
Interface for PropertySet class.
Coordinate publishing and receiving events.
Definition: EventSystem.h:65
set< std::string > _keywords
Definition: Event.h:118
defines the EventSystem class