@Test public void energyLTE_RRCStateIsLTE_CR_TAIL(){ ProfileLTE profileLte04 = Mockito.mock(ProfileLTE.class); List<PacketInfo> packets = new ArrayList<PacketInfo>(); when(profileLte04.getIdlePingTime()).thenReturn(1.0); when(profileLte04.getLteIdlePingPower()).thenReturn(1.0); when(profileLte04.getIdlePingPeriod()).thenReturn(2.0); when(profileLte04.getLteIdlePower()).thenReturn(1.0); double testResult = profilefactory.energyLTE(date.getTime()+0.0, date.getTime()+1000.0, RRCState.LTE_CR_TAIL, profileLte04,packets); assertEquals(0.0,testResult,0.0); }
@Override public double energyLTE(double time1, double time2, RRCState state, ProfileLTE prof, List<PacketInfo> packets) { double deltaTime = time2 - time1; double result = 0.0; switch (state) { case LTE_PROMOTION : return deltaTime * prof.getLtePromotionPower(); case LTE_CR_TAIL: return deltaTime * prof.getLteBeta(); case LTE_CONTINUOUS: for (Throughput throughput : throughputcalculator.calculateThroughput(time1, time2, prof.getThroughputWindow(), packets)) { result += (((prof.getLteAlphaUp() / 1000.0) * throughput.getUploadMbps()) + ((prof.getLteAlphaDown() / 1000.0) * throughput.getDownloadMbps()) + prof.getLteBeta()) * throughput.getSamplePeriod(); } break; case LTE_DRX_SHORT : return (deltaTime / prof.getDrxShortPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxShortPingPower()) + ((prof.getDrxShortPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_DRX_LONG : return (deltaTime / prof.getDrxLongPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxLongPingPower()) + ((prof.getDrxLongPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_IDLE : result = ((int) (deltaTime / prof.getIdlePingPeriod())) * ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((prof.getIdlePingPeriod() - prof.getIdlePingTime()) * prof.getLteIdlePower())); double tres = deltaTime % prof.getIdlePingPeriod(); result += tres <= prof.getIdlePingTime() ? tres * prof.getLteIdlePingPower() : ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((tres - prof.getIdlePingTime()) * prof.getLteIdlePingPower())); break; default: break; } return result; }
ProfileFactoryImpl implements IProfileFactory { @Override public double energyLTE(double time1, double time2, RRCState state, ProfileLTE prof, List<PacketInfo> packets) { double deltaTime = time2 - time1; double result = 0.0; switch (state) { case LTE_PROMOTION : return deltaTime * prof.getLtePromotionPower(); case LTE_CR_TAIL: return deltaTime * prof.getLteBeta(); case LTE_CONTINUOUS: for (Throughput throughput : throughputcalculator.calculateThroughput(time1, time2, prof.getThroughputWindow(), packets)) { result += (((prof.getLteAlphaUp() / 1000.0) * throughput.getUploadMbps()) + ((prof.getLteAlphaDown() / 1000.0) * throughput.getDownloadMbps()) + prof.getLteBeta()) * throughput.getSamplePeriod(); } break; case LTE_DRX_SHORT : return (deltaTime / prof.getDrxShortPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxShortPingPower()) + ((prof.getDrxShortPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_DRX_LONG : return (deltaTime / prof.getDrxLongPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxLongPingPower()) + ((prof.getDrxLongPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_IDLE : result = ((int) (deltaTime / prof.getIdlePingPeriod())) * ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((prof.getIdlePingPeriod() - prof.getIdlePingTime()) * prof.getLteIdlePower())); double tres = deltaTime % prof.getIdlePingPeriod(); result += tres <= prof.getIdlePingTime() ? tres * prof.getLteIdlePingPower() : ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((tres - prof.getIdlePingTime()) * prof.getLteIdlePingPower())); break; default: break; } return result; } }
ProfileFactoryImpl implements IProfileFactory { @Override public double energyLTE(double time1, double time2, RRCState state, ProfileLTE prof, List<PacketInfo> packets) { double deltaTime = time2 - time1; double result = 0.0; switch (state) { case LTE_PROMOTION : return deltaTime * prof.getLtePromotionPower(); case LTE_CR_TAIL: return deltaTime * prof.getLteBeta(); case LTE_CONTINUOUS: for (Throughput throughput : throughputcalculator.calculateThroughput(time1, time2, prof.getThroughputWindow(), packets)) { result += (((prof.getLteAlphaUp() / 1000.0) * throughput.getUploadMbps()) + ((prof.getLteAlphaDown() / 1000.0) * throughput.getDownloadMbps()) + prof.getLteBeta()) * throughput.getSamplePeriod(); } break; case LTE_DRX_SHORT : return (deltaTime / prof.getDrxShortPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxShortPingPower()) + ((prof.getDrxShortPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_DRX_LONG : return (deltaTime / prof.getDrxLongPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxLongPingPower()) + ((prof.getDrxLongPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_IDLE : result = ((int) (deltaTime / prof.getIdlePingPeriod())) * ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((prof.getIdlePingPeriod() - prof.getIdlePingTime()) * prof.getLteIdlePower())); double tres = deltaTime % prof.getIdlePingPeriod(); result += tres <= prof.getIdlePingTime() ? tres * prof.getLteIdlePingPower() : ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((tres - prof.getIdlePingTime()) * prof.getLteIdlePingPower())); break; default: break; } return result; }  }
ProfileFactoryImpl implements IProfileFactory { @Override public double energyLTE(double time1, double time2, RRCState state, ProfileLTE prof, List<PacketInfo> packets) { double deltaTime = time2 - time1; double result = 0.0; switch (state) { case LTE_PROMOTION : return deltaTime * prof.getLtePromotionPower(); case LTE_CR_TAIL: return deltaTime * prof.getLteBeta(); case LTE_CONTINUOUS: for (Throughput throughput : throughputcalculator.calculateThroughput(time1, time2, prof.getThroughputWindow(), packets)) { result += (((prof.getLteAlphaUp() / 1000.0) * throughput.getUploadMbps()) + ((prof.getLteAlphaDown() / 1000.0) * throughput.getDownloadMbps()) + prof.getLteBeta()) * throughput.getSamplePeriod(); } break; case LTE_DRX_SHORT : return (deltaTime / prof.getDrxShortPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxShortPingPower()) + ((prof.getDrxShortPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_DRX_LONG : return (deltaTime / prof.getDrxLongPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxLongPingPower()) + ((prof.getDrxLongPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_IDLE : result = ((int) (deltaTime / prof.getIdlePingPeriod())) * ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((prof.getIdlePingPeriod() - prof.getIdlePingTime()) * prof.getLteIdlePower())); double tres = deltaTime % prof.getIdlePingPeriod(); result += tres <= prof.getIdlePingTime() ? tres * prof.getLteIdlePingPower() : ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((tres - prof.getIdlePingTime()) * prof.getLteIdlePingPower())); break; default: break; } return result; }  @Override Profile create(ProfileType typeParm, Properties prop); @Override double energy3G(double time1, double time2, RRCState state, Profile3G prof); @Override Profile create3Gdefault(); @Override Profile create3GFromDefaultResourceFile(); @Override Profile create3GFromFilePath(String filepath); @Override Profile create3G(InputStream input); @Override Profile create3G(Properties properties); @Override void save3G(String filepath, Profile3G prof); @Override void save3G(OutputStream output, Profile3G prof); @Override double energyLTE(double time1, double time2, RRCState state, ProfileLTE prof, List<PacketInfo> packets); @Override Profile createLTEdefault(); @Override Profile createLTEFromDefaultResourceFile(); @Override Profile createLTEFromFilePath(String filepath); @Override Profile createLTE(InputStream input); @Override Profile createLTE(Properties properties); @Override void saveLTE(String filepath, ProfileLTE prof); @Override void saveLTE(OutputStream output, ProfileLTE prof); @Override double energyWiFi(double time1, double time2, RRCState state , ProfileWiFi prof); @Override Profile createWiFidefault(); @Override Profile createWiFiFromFilePath(String filepath); @Override Profile createWiFiFromDefaultResourceFile(); @Override Profile createWiFi(InputStream input); @Override Profile createWiFi(Properties properties); @Override void saveWiFi(String filepath, ProfileWiFi prof); @Override void saveWiFi(OutputStream output, ProfileWiFi prof); }
ProfileFactoryImpl implements IProfileFactory { @Override public double energyLTE(double time1, double time2, RRCState state, ProfileLTE prof, List<PacketInfo> packets) { double deltaTime = time2 - time1; double result = 0.0; switch (state) { case LTE_PROMOTION : return deltaTime * prof.getLtePromotionPower(); case LTE_CR_TAIL: return deltaTime * prof.getLteBeta(); case LTE_CONTINUOUS: for (Throughput throughput : throughputcalculator.calculateThroughput(time1, time2, prof.getThroughputWindow(), packets)) { result += (((prof.getLteAlphaUp() / 1000.0) * throughput.getUploadMbps()) + ((prof.getLteAlphaDown() / 1000.0) * throughput.getDownloadMbps()) + prof.getLteBeta()) * throughput.getSamplePeriod(); } break; case LTE_DRX_SHORT : return (deltaTime / prof.getDrxShortPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxShortPingPower()) + ((prof.getDrxShortPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_DRX_LONG : return (deltaTime / prof.getDrxLongPingPeriod()) * ((prof.getDrxPingTime() * prof.getDrxLongPingPower()) + ((prof.getDrxLongPingPeriod() - prof.getDrxPingTime()) * prof.getLteTailPower())); case LTE_IDLE : result = ((int) (deltaTime / prof.getIdlePingPeriod())) * ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((prof.getIdlePingPeriod() - prof.getIdlePingTime()) * prof.getLteIdlePower())); double tres = deltaTime % prof.getIdlePingPeriod(); result += tres <= prof.getIdlePingTime() ? tres * prof.getLteIdlePingPower() : ((prof.getIdlePingTime() * prof.getLteIdlePingPower()) + ((tres - prof.getIdlePingTime()) * prof.getLteIdlePingPower())); break; default: break; } return result; }  @Override Profile create(ProfileType typeParm, Properties prop); @Override double energy3G(double time1, double time2, RRCState state, Profile3G prof); @Override Profile create3Gdefault(); @Override Profile create3GFromDefaultResourceFile(); @Override Profile create3GFromFilePath(String filepath); @Override Profile create3G(InputStream input); @Override Profile create3G(Properties properties); @Override void save3G(String filepath, Profile3G prof); @Override void save3G(OutputStream output, Profile3G prof); @Override double energyLTE(double time1, double time2, RRCState state, ProfileLTE prof, List<PacketInfo> packets); @Override Profile createLTEdefault(); @Override Profile createLTEFromDefaultResourceFile(); @Override Profile createLTEFromFilePath(String filepath); @Override Profile createLTE(InputStream input); @Override Profile createLTE(Properties properties); @Override void saveLTE(String filepath, ProfileLTE prof); @Override void saveLTE(OutputStream output, ProfileLTE prof); @Override double energyWiFi(double time1, double time2, RRCState state , ProfileWiFi prof); @Override Profile createWiFidefault(); @Override Profile createWiFiFromFilePath(String filepath); @Override Profile createWiFiFromDefaultResourceFile(); @Override Profile createWiFi(InputStream input); @Override Profile createWiFi(Properties properties); @Override void saveWiFi(String filepath, ProfileWiFi prof); @Override void saveWiFi(OutputStream output, ProfileWiFi prof);  }