RINASim  October 2016
Documentation of framework for OMNeT++
APPing.cc
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 #include <APPing/APPing.h>
24 
26 
28 }
29 
31 }
32 
35  if (strcmp(par("dstApName").stringValue(),"AppErr")) {
36  m1 = new cMessage("start");
37  scheduleAt(simTime() + par("startAt").longValue(), m1);
38 
39  m2 = new cMessage("stop");
40  scheduleAt(simTime() + par("stopAt").longValue(), m2);
41  }
42 }
43 
44 void APPing::handleMessage(cMessage *msg) {
45  if(msg->isSelfMessage()) {
46  if ( !strcmp(msg->getName(), "start") ) {
48  a_open(invokeId, par("dstApName").stringValue(), "0", "AEMonitor", "-1");
49  }
50  else if (!strcmp(msg->getName(), "stop")) {
51  a_close(conID);
52  }
53  else if (!strcmp(msg->getName(), "ping")) {
54  if (par("stopAt").doubleValue() < (simTime().dbl()+1)) {
55  a_read(conID, "ping");
56  m2 = new cMessage("ping");
57  scheduleAt(simTime() + par("interval"), m2);
58  }
59  }
60  else
61  EV << this->getFullPath() << " received unknown self-message " << msg->getName();
62  delete(msg);
63  }
64 }
65 
66 
68  if (result->getInvokeId() == invokeId) {
69  conID = result->getCDAPConId();
70  a_read(conID, "ping");
71 
72  m2 = new cMessage("ping");
73  scheduleAt(simTime() + par("interval"), m2);
74  }
75 }
76 
78  value = (int*)(result->getObj()->objectVal);
79 }
unsigned long conID
Definition: APPing.h:44
unsigned long getInvokeId()
Definition: APIObjBase.cc:44
unsigned long getCDAPConId()
Definition: APIObjBase.cc:36
APPing()
Definition: APPing.cc:27
virtual bool a_close(int CDAPConn, int invokeID=0)
Definition: AP.cc:110
object_t * getObj()
Definition: APIResult.cc:44
int * value
Definition: APPing.h:42
cMessage * m2
Definition: APPing.h:46
Definition: APPing.h:32
virtual bool a_read(int CDAPConn, std::string objName, int invokeID=0)
Definition: AP.cc:119
void onA_getOpen(APIResult *result)
Definition: APPing.cc:67
int getNewInvokeID()
Definition: APBase.cc:59
Define_Module(APPing)
virtual bool a_open(int invokeID, std::string APname, std::string APinst, std::string AEname, std::string AEinst)
Definition: AP.cc:75
ObjectPtr objectVal
void onA_getRead(APIResult *result)
Definition: APPing.cc:77
void handleMessage(cMessage *msg)
Definition: APPing.cc:44
virtual ~APPing()
Definition: APPing.cc:30
int invokeId
Definition: APPing.h:43
virtual void initialize()
Definition: AP.cc:34
cMessage * m1
Definition: APPing.h:45
void initialize()
Definition: APPing.cc:33