forked from ahmadrezamontazerolghaem/Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmartMeter.h
109 lines (89 loc) · 3.65 KB
/
SmartMeter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef __SMART3P_SMARTMETER_H
#define __SMART3P_SMARTMETER_H
#include "Unit.h"
#include <omnetpp.h>
class SMAdapter;
namespace smart3p {
using namespace omnetpp;
//! Simulation Smart Meter class
class SmartMeter : public Unit
{
private:
//state
/*!
Contains the amount of time to delay the simulation.
\sa addSimTime(double)
*/
simtime_t curDelay;
/*! Simulation time of the last successful outgoing message */
simtime_t lastArrival;
long int smID;
/*! Energy data output queue */
cQueue *energyDataQueue;
/*! Internal message to start sending more energy consumption data.
\sa sendEnergyConsumption(cMessage *msg) */
cMessage *startSendingEnergyData;
// statistics
/*! \sa log(simsignal_t id, double value) and log(char* tag, double value)*/
simsignal_t stackSizeSignal;
/*! \sa log(simsignal_t id, double value) and log(char* tag, double value)*/
simsignal_t sessionKeyDecryptionTimeSignal;
/*! \sa log(simsignal_t id, double value) and log(char* tag, double value)*/
simsignal_t sessionKeyEncryptionTimeSignal;
/*! \sa log(simsignal_t id, double value) and log(char* tag, double value)*/
simsignal_t dataEncryptionTimeSignal;
/*! \sa log(simsignal_t id, double value) and log(char* tag, double value)*/
cDoubleHistogram iaTimeHistogram;
/*! \sa log(simsignal_t id, double value) and log(char* tag, double value)*/
cOutVector arrivalsVector;
// functionality
//! Initilization
/*! Initilizes all the variables and signals for logging */
void smartMeterInit(cMessage *msg);
/*! Registers the smart3p::SmartMeter with smart3p::UtilityCompany. */
void registerAtUC();
/*! Registers the key data from smart3p::UtilityCompany. */
void registerInfoFromUC(cMessage *msg);
/*! Recieves the data from TTP and sends the new session key back. */
void startSessionKeyExchange(cMessage *msg);
/*! Finishes session key registration and verification. */
void endOfSessionKeyExchange(cMessage *msg);
/*! Puts the next message onto the energyDataQueue. */
void sendEnergyConsumption(cMessage *msg);
/*! Encapsulates energy data and sends it to smart3p::Collector */
void sendQueueDataToCollector();
//! adapter
/*! Pointer to the adapter. */
SMAdapter* sm;
protected:
//! Initializer
virtual void initialize();
//! Message Handler
virtual void timedHandleMessage(cMessage *msg);
//! Deconstructor
virtual void finish();
public:
//emit
/*!
Emits statistical data to be registered by the simulation.
\param id simsignal_t id of the data collection to put value into.
\param value The value to add to the data collection identified by id.
\sa log(char* tag, double value)
*/
void log(simsignal_t id, double value); //simsignal_t is just type def'ed as an int
/*!
Emits statistical data to be registered by the simulation.
\param tag The c-string which corresponds to the id of the data collection to add data to.
\param value The value to add to the data collection identified by tag.
\sa log(simsignal_t id, double value)
*/
void log(char* tag, double value);
/*!
Adds additional time to the simulation based upon the amount of time taken to perform protocol-level processing.
Omnet++ treats all computations as taking no time at all in the simulation. So to properly record statistical data we have to add additional time to the simulation.
\param t Time to add to the simulation.
*/
void addSimTime(double t); //sets the delay to add to sim time for next scheduled event
};
}; // namespace
#endif