RINASim  October 2016
Documentation of framework for OMNeT++
APStream.cc
Go to the documentation of this file.
1 //
2 // This program is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public License
13 // along with this program. If not, see http://www.gnu.org/licenses/.
14 //
15 
16 #include <APStream/APStream.h>
17 
19 
21 
22 }
23 
25 }
26 
29  if (strcmp(par("dstApName").stringValue(),"AppErr")) {
30  m1 = new cMessage("start");
31  scheduleAt(simTime() + par("startAt").longValue(), m1);
32 
33  m2 = new cMessage("stop");
34  scheduleAt(simTime() + par("stopAt").longValue(), m2);
35  }
36 }
37 
38 void APStream::handleMessage(cMessage *msg) {
39  if(msg->isSelfMessage()) {
40  if ( !strcmp(msg->getName(), "start") ) {
42  a_open(invokeId, par("dstApName").stringValue(), "0", "AEMonitor", "-1");
43  }
44  else if (!strcmp(msg->getName(), "stop")){
45  a_close(conID);
46  }
47  else if (!strcmp(msg->getName(), "stream")){
48  if (par("stopAt").doubleValue() < (simTime().dbl()+1)) {
49  object_t obj;
50  obj.objectName = "stream";
51  obj.objectVal = (cObject*)"tmp";
52  a_write(conID, "stream", &obj, -1);
53 
54  m2 = new cMessage("stream");
55  scheduleAt(simTime() + par("interval"), m2);
56  }
57 
58  }
59  else
60  EV << this->getFullPath() << " received unknown self-message " << msg->getName();
61  delete(msg);
62 
63  }
64 }
65 
67  if (result->getInvokeId() == invokeId) {
68  conID = result->getCDAPConId();
69  object_t obj;
70  obj.objectName = "stream";
71  obj.objectVal = (cObject*)"tmp";
72  a_write(conID, "stream", &obj, -1);
73 
74  m2 = new cMessage("stream");
75  scheduleAt(simTime() + par("interval"), m2);
76  }
77 }
unsigned long getInvokeId()
Definition: APIObjBase.cc:44
void onA_getOpen(APIResult *result)
Definition: APStream.cc:66
unsigned long getCDAPConId()
Definition: APIObjBase.cc:36
unsigned long conID
Definition: APStream.h:44
void handleMessage(cMessage *msg)
Definition: APStream.cc:38
virtual bool a_close(int CDAPConn, int invokeID=0)
Definition: AP.cc:110
cMessage * m1
Definition: APStream.h:45
cMessage * m2
Definition: APStream.h:46
APStream()
Definition: APStream.cc:20
int getNewInvokeID()
Definition: APBase.cc:59
Define_Module(APStream)
void initialize()
Definition: APStream.cc:27
int invokeId
Definition: APStream.h:43
virtual bool a_open(int invokeID, std::string APname, std::string APinst, std::string AEname, std::string AEinst)
Definition: AP.cc:75
ObjectPtr objectVal
virtual bool a_write(int CDAPConn, std::string objName, object_t *obj, int invokeID=0)
Definition: AP.cc:130
::omnetpp::opp_string objectName
virtual ~APStream()
Definition: APStream.cc:24
virtual void initialize()
Definition: AP.cc:34