-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMsgSched_Power.cpp
50 lines (41 loc) · 918 Bytes
/
MsgSched_Power.cpp
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
/*
* MS_Power.cpp
*
* Created on: Aug 1, 2013
* Author: Ashish Choudhari
* Real-Time Systems
* ECE Department
* Southern Illinois University, Carbondale, IL
*/
#include "MsgSched_Power.h"
MS_Power::MS_Power(MS_Tick_Type _Phase_Time, int _TPT)
{
Phase_Time = _Phase_Time;
TPT = _TPT;
}
MS_Power::~MS_Power()
{
}
int MS_Power::Calculate_Delta(MS_Tick_Type _Curr_Period, MS_Tick_Type _Curr_RTT, MS_Tick_Type _t, int _PT)
{
int Delta=0;
int Total_Msgs=0;
MS_Tick_Type LTT = Get_Last_Transfer_Time(_Curr_RTT, _t);
if(!LTT)
return 0;
Total_Msgs = (LTT - _t)/ _Curr_Period;
Delta = (TPT - _PT) / Total_Msgs;
return Delta;
}
MS_Tick_Type MS_Power::Get_Last_Transfer_Time(MS_Tick_Type _Curr_RTT, MS_Tick_Type _t)
{
if( (_t + _Curr_RTT) > Phase_Time )
{
cout << "\n\nMS_Power: PHASE TIME OVER: cannot transfer power\n\n";
return 0;
}
else
{
return (Phase_Time - _Curr_RTT);
}
}