-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathChargingNode.h
123 lines (112 loc) · 4.32 KB
/
ChargingNode.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
#ifndef CHARGINGNODE_H_
#define CHARGINGNODE_H_
#include <omnetpp.h>
#include "Battery.h"
#include "ChargeAlgorithmCCCV.h"
#include "ChargeAlgorithmCCCVCurrent.h"
#include "ChargingNodeSpotElement.h"
#include "Command.h"
#include "CommandExecEngine.h"
#include "GenericNode.h"
#include "IChargeAlgorithm.h"
#include "MobileNode.h"
#include "msgs/ForecastPointInTimeRequest_m.h"
#include "msgs/ForecastTargetRequest_m.h"
#include "msgs/ForecastResponse_m.h"
#include "msgs/UpdateChargingMsg_m.h"
#include "msgs/MobileNodeRequest_m.h"
#include "msgs/MobileNodeResponse_m.h"
#include "msgs/ReserveSpotMsg_m.h"
using namespace omnetpp;
class ChargingNodeSpotElement;
class ChargingNode : public GenericNode {
private:
double usedPower = 0;
double chargedPower = 0;
int chargedMobileNodes = 0;
int reservations = 0;
protected:
Battery battery;
double chargeCurrent;
double chargeEffectivenessPercentage;
unsigned int spotsWaiting;
unsigned int spotsCharging;
std::deque<ChargingNodeSpotElement*> objectsWaiting;
std::deque<ChargingNodeSpotElement*> objectsCharging;
std::deque<MobileNode*> objectsFinished;
IChargeAlgorithm* chargeAlgorithm;
bool active = false;
bool prioritizeFastCharge;
public:
ChargingNode();
virtual ~ChargingNode();
virtual void finish() override;
virtual void selectNextCommand() override;
virtual void initializeState() override;
virtual void loadCommands(CommandQueue commands, bool isMission = true) override;
virtual void clearCommands() override;
virtual void updateState() override;
virtual bool isCommandCompleted() override;
virtual double nextNeededUpdate() override;
virtual void collectStatistics() override;
virtual ReplacementData* endOfOperation() override;
// Could be moved to private methods, there functionality is externally available via messages
double getForecastRemainingToTarget(double remaining, double capacity, double targetPercentage = 100.0);
double getForecastRemainingToPointInTime(double remaining, double capacity, simtime_t pointInTime);
MobileNode* getSufficientlyChargedNode(double current);
bool checkForSufficientlyChargedNode(MobileNode* nextNode, MobileNode* sufficientlyChargedNode, double current);
bool checkForHighestChargedNode(MobileNode* nextNode, MobileNode* highestChargedNode);
// Getters
unsigned int getSpotsCharging() const
{
return spotsCharging;
}
unsigned int getSpotsWaiting() const
{
return spotsWaiting;
}
IChargeAlgorithm* getChargeAlgorithm() const
{
return chargeAlgorithm;
}
double getUsedPower() const
{
return usedPower;
}
int getChargedUAVs() const
{
return chargedMobileNodes;
}
protected:
virtual void initialize(int stage) override;
virtual void handleMessage(cMessage *msg) override;
virtual void refreshDisplay() const override;
void removeFromChargingNode(MobileNode* mobileNode);
void appendToObjectsWaiting(MobileNode* mobileNode, double targetPercentage, simtime_t reservationTime = 0, simtime_t estimatedArrival = 0,
double consumption = 0);
bool isInWaitingQueue(MobileNode* mobileNode);
std::deque<ChargingNodeSpotElement*>::iterator getNextWaitingObjectIterator(bool fastCharge);
int numberWaitingAndPhysicallyPresent();
bool isPhysicallyPresent(MobileNode* mobileNode);
double calculateSecondsToNextEvent(MobileNode* mn, bool prioritizeFastCharge);
void fillChargingSpots();
void clearChargingSpots();
void rearrangeChargingSpots();
void chargeAllChargingSpots();
double getEstimatedWaitingSeconds();
};
#endif /* CHARGINGNODE_H_ */