_now() -> now()

This commit is contained in:
Milos Kozak 2021-04-11 17:58:50 +02:00
parent 998eba8b9f
commit 8ce5a881d3
123 changed files with 273 additions and 298 deletions

View file

@ -68,7 +68,7 @@ class MainApp : DaggerApplication() {
commitHash = null
}
disposable += repository.runTransaction(VersionChangeTransaction(BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, gitRemote, commitHash)).subscribe()
disposable += repository.runTransaction(InsertIfNewByTimestampTherapyEventTransaction(timestamp = dateUtil._now(), type = TherapyEvent.Type.NOTE, note = getString(info.nightscout.androidaps.core.R.string.androidaps_start).toString() + " - " + Build.MANUFACTURER + " " + Build.MODEL, glucoseUnit = TherapyEvent.GlucoseUnit.MGDL)).subscribe()
disposable += repository.runTransaction(InsertIfNewByTimestampTherapyEventTransaction(timestamp = dateUtil.now(), type = TherapyEvent.Type.NOTE, note = getString(info.nightscout.androidaps.core.R.string.androidaps_start).toString() + " - " + Build.MANUFACTURER + " " + Build.MODEL, glucoseUnit = TherapyEvent.GlucoseUnit.MGDL)).subscribe()
disposable += compatDBHelper.dbChangeDisposable()
registerActivityLifecycleCallbacks(activityMonitor)
JodaTimeAndroid.init(this)

View file

@ -114,7 +114,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
}
// Profile switch
profileSwitch = databaseHelper.getProfileSwitchData(dateUtil._now() - T.months(2).msecs(), true)
profileSwitch = databaseHelper.getProfileSwitchData(dateUtil.now() - T.months(2).msecs(), true)
binding.profileswitchList.setOnClickListener {
PopupMenu(this, binding.profileswitchList).apply {
@ -141,7 +141,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
profile?.let {
OKDialog.showConfirmation(this, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile), Runnable {
localProfilePlugin.addProfile(localProfilePlugin.copyFrom(it, "DefaultProfile " +
dateUtil.dateAndTimeAndSecondsString(dateUtil._now())
dateUtil.dateAndTimeAndSecondsString(dateUtil.now())
.replace(".", "/")
))
rxBus.send(EventLocalProfileChanged())
@ -210,7 +210,7 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() {
getProfile(ageUsed[1], tddUsed[1], weightUsed[1], pctUsed[1] / 100.0, 1)?.let { profile1 ->
ProfileViewerDialog().also { pvd ->
pvd.arguments = Bundle().also {
it.putLong("time", dateUtil._now())
it.putLong("time", dateUtil.now())
it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal)
it.putString("customProfile", profile0.data.toString())
it.putString("customProfile2", profile1.data.toString())

View file

@ -69,7 +69,7 @@ class SurveyActivity : NoSplashAppCompatActivity() {
defaultProfile.profile(age, tdd, weight, profileFunction.getUnits())?.let { profile ->
ProfileViewerDialog().also { pvd ->
pvd.arguments = Bundle().also {
it.putLong("time", dateUtil._now())
it.putLong("time", dateUtil.now())
it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal)
it.putString("customProfile", runningProfile.data.toString())
it.putString("customProfile2", profile.data.toString())

View file

@ -303,7 +303,7 @@ class CarbsDialog : DialogFragmentWithDate() {
})
}
if (useAlarm && carbs > 0 && timeOffset > 0) {
carbTimer.scheduleReminder(dateUtil._now() + T.mins(timeOffset.toLong()).msecs())
carbTimer.scheduleReminder(dateUtil.now() + T.mins(timeOffset.toLong()).msecs())
}
}, null)
}

View file

@ -175,7 +175,7 @@ class InsulinDialog : DialogFragmentWithDate() {
actions.add(resourceHelper.gs(R.string.temptargetshort) + ": " + (DecimalFormatter.to1Decimal(eatingSoonTT) + " " + unitLabel + " (" + resourceHelper.gs(R.string.format_mins, eatingSoonTTDuration) + ")").formatColor(resourceHelper, R.color.tempTargetConfirmation))
val timeOffset = binding.time.value.toInt()
val time = dateUtil._now() + T.mins(timeOffset.toLong()).msecs()
val time = dateUtil.now() + T.mins(timeOffset.toLong()).msecs()
if (timeOffset != 0)
actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(time))

View file

@ -16,7 +16,6 @@ import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.HtmlHelper
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.resources.ResourceHelper
@ -83,7 +82,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
binding.profile.setSelection(p)
} ?: return
treatmentsPlugin.getProfileSwitchFromHistory(dateUtil._now())?.let { ps ->
treatmentsPlugin.getProfileSwitchFromHistory(dateUtil.now())?.let { ps ->
if (ps.isCPP) {
binding.reuselayout.visibility = View.VISIBLE
binding.reusebutton.text = resourceHelper.gs(R.string.reuse_profile_pct_hours, ps.percentage, ps.timeshift)

View file

@ -88,7 +88,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
// temp target
context?.let { context ->
if (repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() is ValueWrapper.Existing)
if (repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing)
binding.targetCancel.visibility = View.VISIBLE
else
binding.targetCancel.visibility = View.GONE

View file

@ -210,7 +210,7 @@ class WizardDialog : DaggerDialogFragment() {
private fun onCheckedChanged(buttonView: CompoundButton, @Suppress("UNUSED_PARAMETER") state: Boolean) {
saveCheckedStates()
binding.ttcheckbox.isEnabled = binding.bgcheckbox.isChecked && repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() is ValueWrapper.Existing
binding.ttcheckbox.isEnabled = binding.bgcheckbox.isChecked && repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing
if (buttonView.id == binding.cobcheckbox.id)
processCobCheckBox()
calculateInsulin()
@ -268,7 +268,7 @@ class WizardDialog : DaggerDialogFragment() {
// Set BG if not old
binding.bgInput.value = iobCobCalculator.actualBg()?.valueToUnits(units) ?: 0.0
binding.ttcheckbox.isEnabled = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() is ValueWrapper.Existing
binding.ttcheckbox.isEnabled = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing
// IOB calculation
val bolusIob = iobCobCalculator.calculateIobFromBolus().round()
@ -308,7 +308,7 @@ class WizardDialog : DaggerDialogFragment() {
}
bg = if (binding.bgcheckbox.isChecked) bg else 0.0
val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
val tempTarget = if (binding.ttcheckbox.isChecked && dbRecord is ValueWrapper.Existing) dbRecord.value else null
// COB

View file

@ -313,7 +313,7 @@ open class LoopPlugin @Inject constructor(
lastRun = (lastRun ?: LastRun()).also { lastRun ->
lastRun.request = apsResult
lastRun.constraintsProcessed = resultAfterConstraints
lastRun.lastAPSRun = dateUtil._now()
lastRun.lastAPSRun = dateUtil.now()
lastRun.source = (usedAPS as PluginBase).name
lastRun.tbrSetByPump = null
lastRun.smbSetByPump = null
@ -408,7 +408,7 @@ open class LoopPlugin @Inject constructor(
if (result.enacted || result.success) {
lastRun.tbrSetByPump = result
lastRun.lastTBRRequest = lastRun.lastAPSRun
lastRun.lastTBREnact = dateUtil._now()
lastRun.lastTBREnact = dateUtil.now()
rxBus.send(EventLoopUpdateGui())
applySMBRequest(resultAfterConstraints, object : Callback() {
override fun run() {
@ -416,7 +416,7 @@ open class LoopPlugin @Inject constructor(
if (result.enacted || result.success) {
lastRun.smbSetByPump = result
lastRun.lastSMBRequest = lastRun.lastAPSRun
lastRun.lastSMBEnact = dateUtil._now()
lastRun.lastSMBEnact = dateUtil.now()
} else {
Thread {
SystemClock.sleep(1000)
@ -507,8 +507,8 @@ open class LoopPlugin @Inject constructor(
if (result.enacted) {
lastRun.tbrSetByPump = result
lastRun.lastTBRRequest = lastRun.lastAPSRun
lastRun.lastTBREnact = dateUtil._now()
lastRun.lastOpenModeAccept = dateUtil._now()
lastRun.lastTBREnact = dateUtil.now()
lastRun.lastOpenModeAccept = dateUtil.now()
buildDeviceStatus(dateUtil, this@LoopPlugin, iobCobCalculator, profileFunction,
activePlugin.activePump, receiverStatusStore, runningConfiguration,
BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION)?.also {
@ -658,7 +658,7 @@ open class LoopPlugin @Inject constructor(
}
})
}
if (pump.pumpDescription.isExtendedBolusCapable && iobCobCalculator.getExtendedBolus(dateUtil._now()) != null) {
if (pump.pumpDescription.isExtendedBolusCapable && iobCobCalculator.getExtendedBolus(dateUtil.now()) != null) {
commandQueue.cancelExtended(object : Callback() {
override fun run() {
if (!result.success) {
@ -684,7 +684,7 @@ open class LoopPlugin @Inject constructor(
override fun createOfflineEvent(durationInMinutes: Int) {
disposable += repository.runTransactionForResult(InsertIfNewByTimestampTherapyEventTransaction(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
type = TherapyEvent.Type.APS_OFFLINE,
duration = T.mins(durationInMinutes.toLong()).msecs(),
enteredBy = "openaps://" + "AndroidAPS",

View file

@ -13,7 +13,7 @@ class DetermineBasalResultAMA private constructor(injector: HasAndroidInjector)
private var snoozeBG = 0.0
internal constructor(injector: HasAndroidInjector, result: NativeObject, j: JSONObject) : this(injector) {
date = dateUtil._now()
date = dateUtil.now()
json = j
if (result.containsKey("error")) {
reason = result["error"].toString()

View file

@ -116,7 +116,7 @@ open class OpenAPSAMAPlugin @Inject constructor(
var maxBg = hardLimits.verifyHardLimits(Round.roundTo(profile.targetHighMgdl, 0.1), R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MAX_BG[1].toDouble())
var targetBg = hardLimits.verifyHardLimits(profile.targetMgdl, R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble())
var isTempTarget = false
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
if (tempTarget is ValueWrapper.Existing) {
isTempTarget = true
minBg = hardLimits.verifyHardLimits(tempTarget.value.lowTarget, R.string.temp_target_low_target, HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1].toDouble())
@ -160,7 +160,7 @@ open class OpenAPSAMAPlugin @Inject constructor(
lastAPSResult = null
lastAPSRun = 0
} else {
if (determineBasalResultAMA.rate == 0.0 && determineBasalResultAMA.duration == 0 && iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil._now()) == null) determineBasalResultAMA.tempBasalRequested = false
if (determineBasalResultAMA.rate == 0.0 && determineBasalResultAMA.duration == 0 && iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now()) == null) determineBasalResultAMA.tempBasalRequested = false
determineBasalResultAMA.iob = iobArray[0]
val now = System.currentTimeMillis()
determineBasalResultAMA.json?.put("timestamp", dateUtil.toISOString(now))

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.aps.openAPSSMB
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.aps.loop.APSResult
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONException
import org.json.JSONObject
@ -13,7 +12,7 @@ class DetermineBasalResultSMB private constructor(injector: HasAndroidInjector)
private var snoozeBG = 0.0
internal constructor(injector: HasAndroidInjector, result: JSONObject) : this(injector) {
date = dateUtil._now()
date = dateUtil.now()
json = result
try {
if (result.has("error")) {

View file

@ -122,7 +122,7 @@ open class OpenAPSSMBPlugin @Inject constructor(
var maxBg = hardLimits.verifyHardLimits(Round.roundTo(profile.targetHighMgdl, 0.1), R.string.profile_high_target, HardLimits.VERY_HARD_LIMIT_MAX_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_MAX_BG[1].toDouble())
var targetBg = hardLimits.verifyHardLimits(profile.targetMgdl, R.string.temp_target_value, HardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble())
var isTempTarget = false
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
if (tempTarget is ValueWrapper.Existing) {
isTempTarget = true
minBg = hardLimits.verifyHardLimits(tempTarget.value.lowTarget, R.string.temp_target_low_target, HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0].toDouble(), HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1].toDouble())
@ -187,7 +187,7 @@ open class OpenAPSSMBPlugin @Inject constructor(
} else {
// TODO still needed with oref1?
// Fix bug determine basal
if (determineBasalResultSMB.rate == 0.0 && determineBasalResultSMB.duration == 0 && iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil._now()) == null) determineBasalResultSMB.tempBasalRequested = false
if (determineBasalResultSMB.rate == 0.0 && determineBasalResultSMB.duration == 0 && iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now()) == null) determineBasalResultSMB.tempBasalRequested = false
determineBasalResultSMB.iob = iobArray[0]
determineBasalResultSMB.json?.put("timestamp", dateUtil.toISOString(now))
determineBasalResultSMB.inputConstraints = inputConstraints

View file

@ -237,7 +237,7 @@ class ObjectivesFragment : DaggerFragment() {
holder.binding.verify.setOnClickListener {
receiverStatusStore.updateNetworkStatus()
if (binding.fake.isChecked) {
objective.accomplishedOn = dateUtil._now()
objective.accomplishedOn = dateUtil.now()
scrollToCurrentObjective()
startUpdateTimer()
rxBus.send(EventObjectivesUpdateGui())
@ -249,7 +249,7 @@ class ObjectivesFragment : DaggerFragment() {
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0))
sntpClient.ntpTime(object : SntpClient.Callback() {
override fun run() {
aapsLogger.debug("NTP time: $time System time: ${dateUtil._now()}")
aapsLogger.debug("NTP time: $time System time: ${dateUtil.now()}")
SystemClock.sleep(300)
if (!networkConnected) {
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.notconnected), 99))
@ -276,7 +276,7 @@ class ObjectivesFragment : DaggerFragment() {
holder.binding.start.setOnClickListener {
receiverStatusStore.updateNetworkStatus()
if (binding.fake.isChecked) {
objective.startedOn = dateUtil._now()
objective.startedOn = dateUtil.now()
scrollToCurrentObjective()
startUpdateTimer()
rxBus.send(EventObjectivesUpdateGui())
@ -288,7 +288,7 @@ class ObjectivesFragment : DaggerFragment() {
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0))
sntpClient.ntpTime(object : SntpClient.Callback() {
override fun run() {
aapsLogger.debug("NTP time: $time System time: ${dateUtil._now()}")
aapsLogger.debug("NTP time: $time System time: ${dateUtil.now()}")
SystemClock.sleep(300)
if (!networkConnected) {
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.notconnected), 99))

View file

@ -127,22 +127,22 @@ class ObjectivesPlugin @Inject constructor(
if (!url.endsWith("/")) url = "$url/"
@Suppress("DEPRECATION") val hashNS = Hashing.sha1().hashString(url + BuildConfig.APPLICATION_ID + "/" + requestCode, Charsets.UTF_8).toString()
if (request.equals(hashNS.substring(0, 10), ignoreCase = true)) {
sp.putLong("Objectives_" + "openloop" + "_started", dateUtil._now())
sp.putLong("Objectives_" + "openloop" + "_accomplished", dateUtil._now())
sp.putLong("Objectives_" + "maxbasal" + "_started", dateUtil._now())
sp.putLong("Objectives_" + "maxbasal" + "_accomplished", dateUtil._now())
sp.putLong("Objectives_" + "maxiobzero" + "_started", dateUtil._now())
sp.putLong("Objectives_" + "maxiobzero" + "_accomplished", dateUtil._now())
sp.putLong("Objectives_" + "maxiob" + "_started", dateUtil._now())
sp.putLong("Objectives_" + "maxiob" + "_accomplished", dateUtil._now())
sp.putLong("Objectives_" + "autosens" + "_started", dateUtil._now())
sp.putLong("Objectives_" + "autosens" + "_accomplished", dateUtil._now())
sp.putLong("Objectives_" + "ama" + "_started", dateUtil._now())
sp.putLong("Objectives_" + "ama" + "_accomplished", dateUtil._now())
sp.putLong("Objectives_" + "smb" + "_started", dateUtil._now())
sp.putLong("Objectives_" + "smb" + "_accomplished", dateUtil._now())
sp.putLong("Objectives_" + "auto" + "_started", dateUtil._now())
sp.putLong("Objectives_" + "auto" + "_accomplished", dateUtil._now())
sp.putLong("Objectives_" + "openloop" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "openloop" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "maxbasal" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "maxbasal" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "maxiobzero" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "maxiobzero" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "maxiob" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "maxiob" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "autosens" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "autosens" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "ama" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "ama" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "smb" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "smb" + "_accomplished", dateUtil.now())
sp.putLong("Objectives_" + "auto" + "_started", dateUtil.now())
sp.putLong("Objectives_" + "auto" + "_accomplished", dateUtil.now())
setupObjectives()
OKDialog.show(activity, resourceHelper.gs(R.string.objectives), resourceHelper.gs(R.string.codeaccepted))
uel.log(Action.OBJECTIVES_SKIPPED, Sources.Objectives)

View file

@ -108,7 +108,7 @@ class ObjectivesExamDialog : DaggerDialogFragment() {
}
task.answered = result
if (!result) {
task.disabledTo = dateUtil._now() + T.hours(1).msecs()
task.disabledTo = dateUtil.now() + T.hours(1).msecs()
ToastUtils.showToastInUiThread(context, R.string.wronganswer)
} else task.disabledTo = 0
updateGui()

View file

@ -56,7 +56,7 @@ abstract class Objective(injector: HasAndroidInjector, spName: String, @StringRe
this.gate = gate
startedOn = sp.getLong("Objectives_" + spName + "_started", 0L)
accomplishedOn = sp.getLong("Objectives_" + spName + "_accomplished", 0L)
if (accomplishedOn - dateUtil._now() > T.hours(3).msecs() || startedOn - dateUtil._now() > T.hours(3).msecs()) { // more than 3 hours in the future
if (accomplishedOn - dateUtil.now() > T.hours(3).msecs() || startedOn - dateUtil.now() > T.hours(3).msecs()) { // more than 3 hours in the future
startedOn = 0
accomplishedOn = 0
}
@ -70,7 +70,7 @@ abstract class Objective(injector: HasAndroidInjector, spName: String, @StringRe
}
val isAccomplished: Boolean
get() = accomplishedOn != 0L && accomplishedOn < dateUtil._now()
get() = accomplishedOn != 0L && accomplishedOn < dateUtil.now()
val isStarted: Boolean
get() = startedOn != 0L
@ -145,7 +145,7 @@ abstract class Objective(injector: HasAndroidInjector, spName: String, @StringRe
override fun isCompleted(): Boolean = answered
fun isEnabledAnswer(): Boolean = disabledTo < dateUtil._now()
fun isEnabledAnswer(): Boolean = disabledTo < dateUtil.now()
fun option(option: Option): ExamTask {
options.add(option)

View file

@ -64,7 +64,7 @@ class Objective0(injector: HasAndroidInjector) : Objective(injector, "config", R
})
tasks.add(object : Task(this, R.string.activate_profile) {
override fun isCompleted(): Boolean {
return treatmentsPlugin.getProfileSwitchFromHistory(dateUtil._now()) != null
return treatmentsPlugin.getProfileSwitchFromHistory(dateUtil.now()) != null
}
})
}

View file

@ -70,7 +70,7 @@ class SafetyPlugin @Inject constructor(
value[aapsLogger, false, resourceHelper.gs(R.string.closed_loop_disabled_on_dev_branch)] = this
}
val pump = activePlugin.activePump
if (!pump.isFakingTempsByExtendedBoluses && iobCobCalculator.getExtendedBolus(dateUtil._now()) != null) {
if (!pump.isFakingTempsByExtendedBoluses && iobCobCalculator.getExtendedBolus(dateUtil.now()) != null) {
value[aapsLogger, false, resourceHelper.gs(R.string.closed_loop_disabled_with_eb)] = this
}
return value

View file

@ -164,7 +164,7 @@ class ActionsFragment : DaggerFragment() {
}
}
extendedBolusCancel?.setOnClickListener {
if (iobCobCalculator.getExtendedBolus(dateUtil._now()) != null) {
if (iobCobCalculator.getExtendedBolus(dateUtil.now()) != null) {
uel.log(Action.CANCEL_EXTENDED_BOLUS, Sources.Actions)
commandQueue.cancelExtended(object : Callback() {
override fun run() {
@ -179,7 +179,7 @@ class ActionsFragment : DaggerFragment() {
TempBasalDialog().show(childFragmentManager, "Actions")
}
cancelTempBasal?.setOnClickListener {
if (iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil._now()) != null) {
if (iobCobCalculator.getTempBasalIncludingConvertedExtended(dateUtil.now()) != null) {
uel.log(Action.CANCEL_TEMP_BASAL, Sources.Actions)
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
@ -274,7 +274,7 @@ class ActionsFragment : DaggerFragment() {
extendedBolus?.visibility = View.GONE
extendedBolusCancel?.visibility = View.GONE
} else {
val activeExtendedBolus = repository.getExtendedBolusActiveAt(dateUtil._now()).blockingGet()
val activeExtendedBolus = repository.getExtendedBolusActiveAt(dateUtil.now()).blockingGet()
if (activeExtendedBolus is ValueWrapper.Existing) {
extendedBolus?.visibility = View.GONE
extendedBolusCancel?.visibility = View.VISIBLE

View file

@ -41,7 +41,6 @@ import io.reactivex.Single
import java.io.File
import java.io.FileNotFoundException
import java.io.IOException
import java.util.*
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.system.exitProcess
@ -96,7 +95,7 @@ class ImportExportPrefs @Inject constructor(
val metadata: MutableMap<PrefsMetadataKey, PrefMetadata> = mutableMapOf()
metadata[PrefsMetadataKey.DEVICE_NAME] = PrefMetadata(detectUserName(context), PrefsStatus.OK)
metadata[PrefsMetadataKey.CREATED_AT] = PrefMetadata(dateUtil.toISOString(dateUtil._now()), PrefsStatus.OK)
metadata[PrefsMetadataKey.CREATED_AT] = PrefMetadata(dateUtil.toISOString(dateUtil.now()), PrefsStatus.OK)
metadata[PrefsMetadataKey.AAPS_VERSION] = PrefMetadata(BuildConfig.VERSION_NAME, PrefsStatus.OK)
metadata[PrefsMetadataKey.AAPS_FLAVOUR] = PrefMetadata(BuildConfig.FLAVOR, PrefsStatus.OK)
metadata[PrefsMetadataKey.DEVICE_MODEL] = PrefMetadata(config.currentDeviceModelString, PrefsStatus.OK)

View file

@ -71,7 +71,7 @@ class NSClientAddUpdateWorker(
//Find latest date in treatment
val mills = safeGetLong(json, "mills")
if (mills != 0L && mills < dateutil._now())
if (mills != 0L && mills < dateutil.now())
if (mills > latestDateInReceivedData) latestDateInReceivedData = mills
if (insulin > 0) {

View file

@ -164,11 +164,11 @@ class NSDeviceStatus @Inject constructor(
// test warning level
val level = when {
pumpData.clock + nsSettingsStatus.extendedPumpSettings("urgentClock") * 60 * 1000L < dateUtil._now() -> Levels.URGENT
pumpData.clock + nsSettingsStatus.extendedPumpSettings("urgentClock") * 60 * 1000L < dateUtil.now() -> Levels.URGENT
pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("urgentRes") -> Levels.URGENT
pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("urgentBattP") -> Levels.URGENT
!pumpData.isPercent && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("urgentBattV") -> Levels.URGENT
pumpData.clock + nsSettingsStatus.extendedPumpSettings("warnClock") * 60 * 1000L < dateUtil._now() -> Levels.WARN
pumpData.clock + nsSettingsStatus.extendedPumpSettings("warnClock") * 60 * 1000L < dateUtil.now() -> Levels.WARN
pumpData.reservoir < nsSettingsStatus.extendedPumpSettings("warnRes") -> Levels.WARN
pumpData.isPercent && pumpData.percent < nsSettingsStatus.extendedPumpSettings("warnBattP") -> Levels.WARN
!pumpData.isPercent && pumpData.voltage < nsSettingsStatus.extendedPumpSettings("warnBattV") -> Levels.WARN
@ -273,8 +273,8 @@ class NSDeviceStatus @Inject constructor(
// test warning level
val level = when {
deviceStatusOpenAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_urgent_staledatavalue, 31)).msecs() < dateUtil._now() -> Levels.URGENT
deviceStatusOpenAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_staledatavalue, 16)).msecs() < dateUtil._now() -> Levels.WARN
deviceStatusOpenAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_urgent_staledatavalue, 31)).msecs() < dateUtil.now() -> Levels.URGENT
deviceStatusOpenAPSData.clockSuggested + T.mins(sp.getLong(R.string.key_nsalarm_staledatavalue, 16)).msecs() < dateUtil.now() -> Levels.WARN
else -> Levels.INFO
}
string.append("<span style=\"color:${level.toColor()}\">")

View file

@ -228,7 +228,7 @@ public class NSClientService extends DaggerService {
}
public void processAddAck(NSAddAck ack) {
lastAckTime = dateUtil._now();
lastAckTime = dateUtil.now();
// new room way
if (ack.getOriginalObject() instanceof DataSyncSelector.PairTemporaryTarget) {
DataSyncSelector.PairTemporaryTarget pair = (DataSyncSelector.PairTemporaryTarget) ack.getOriginalObject();
@ -400,7 +400,7 @@ public class NSClientService extends DaggerService {
}
public void processUpdateAck(NSUpdateAck ack) {
lastAckTime = dateUtil._now();
lastAckTime = dateUtil.now();
// new room way
if (ack.getOriginalObject() instanceof DataSyncSelector.PairTemporaryTarget) {
DataSyncSelector.PairTemporaryTarget pair = (DataSyncSelector.PairTemporaryTarget) ack.getOriginalObject();
@ -591,7 +591,7 @@ public class NSClientService extends DaggerService {
void watchdog() {
synchronized (reconnections) {
long now = dateUtil._now();
long now = dateUtil.now();
reconnections.add(now);
for (int i = 0; i < reconnections.size(); i++) {
Long r = reconnections.get(i);
@ -833,7 +833,7 @@ public class NSClientService extends DaggerService {
if (action == null) addedOrUpdatedTreatments.put(jsonTreatment);
else if (action.equals("update"))
addedOrUpdatedTreatments.put(jsonTreatment);
else if (action.equals("remove") && mills > dateUtil._now() - T.days(1).msecs()) // handle 1 day old deletions only
else if (action.equals("remove") && mills > dateUtil.now() - T.days(1).msecs()) // handle 1 day old deletions only
removedTreatments.put(jsonTreatment);
}
if (removedTreatments.length() > 0) {

View file

@ -309,7 +309,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
R.id.active_profile -> {
ProfileViewerDialog().also { pvd ->
pvd.arguments = Bundle().also {
it.putLong("time", dateUtil._now())
it.putLong("time", dateUtil.now())
it.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal)
}
}.show(childFragmentManager, "ProfileViewDialog")
@ -549,7 +549,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
if (_binding == null) return
aapsLogger.debug("UpdateGUI from $from")
binding.infoLayout.time.text = dateUtil.timeString(dateUtil._now())
binding.infoLayout.time.text = dateUtil.timeString(dateUtil.now())
if (!profileFunction.isProfileValid("Overview")) {
binding.loopPumpStatusLayout.pumpStatus.setText(R.string.noprofileset)
@ -680,7 +680,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
}
// temp target
val tempTarget: ValueWrapper<TemporaryTarget> = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
val tempTarget: ValueWrapper<TemporaryTarget> = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
if (tempTarget is ValueWrapper.Existing) {
binding.loopPumpStatusLayout.tempTarget.setTextColor(resourceHelper.gc(R.color.ribbonTextWarning))
binding.loopPumpStatusLayout.tempTarget.setBackgroundColor(resourceHelper.gc(R.color.ribbonWarning))
@ -723,7 +723,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
if (percentRate < 100) binding.infoLayout.baseBasalIcon.setImageResource(R.drawable.ic_cp_basal_tbr_low)
// Extended bolus
val extendedBolus = repository.getExtendedBolusActiveAt(dateUtil._now()).blockingGet()
val extendedBolus = repository.getExtendedBolusActiveAt(dateUtil.now()).blockingGet()
binding.infoLayout.extendedBolus.text =
if (extendedBolus is ValueWrapper.Existing && !pump.isFakingTempsByExtendedBoluses)
resourceHelper.gs(R.string.pump_basebasalrate, extendedBolus.value.rate)

View file

@ -415,7 +415,7 @@ class GraphData(
if (showPrediction) {
val autosensData = iobCobCalculator.getLastAutosensDataSynchronized("GraphData")
val lastAutosensResult = autosensData?.autosensResult ?: AutosensResult()
val isTempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet() is ValueWrapper.Existing
val isTempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet() is ValueWrapper.Existing
val iobPrediction: MutableList<DataPointWithLabelInterface> = ArrayList()
val iobPredictionArray = iobCobCalculator.calculateIobArrayForSMB(lastAutosensResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, isTempTarget)
for (i in iobPredictionArray) {

View file

@ -29,7 +29,7 @@ class AuthRequest internal constructor(
init {
injector.androidInjector().inject(this)
date = dateUtil._now()
date = dateUtil.now()
smsCommunicatorPlugin.sendSMS(Sms(requester.phoneNumber, requestText))
}
@ -47,7 +47,7 @@ class AuthRequest internal constructor(
smsCommunicatorPlugin.sendSMS(Sms(requester.phoneNumber, resourceHelper.gs(R.string.sms_wrongcode)))
return
}
if (dateUtil._now() - date < Constants.SMS_CONFIRM_TIMEOUT) {
if (dateUtil.now() - date < Constants.SMS_CONFIRM_TIMEOUT) {
processed = true
aapsLogger.debug(LTag.SMS, "Processing confirmed SMS: " + requester.text)
action.run()

View file

@ -276,7 +276,7 @@ class SmsCommunicatorPlugin @Inject constructor(
else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
"BOLUS" ->
if (!remoteCommandsAllowed) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_remotecommandnotallowed)))
else if (divided.size == 2 && dateUtil._now() - lastRemoteBolusTime < minDistance) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_remotebolusnotallowed)))
else if (divided.size == 2 && dateUtil.now() - lastRemoteBolusTime < minDistance) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.smscommunicator_remotebolusnotallowed)))
else if (divided.size == 2 && pump.isSuspended()) sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.pumpsuspended)))
else if (divided.size == 2 || divided.size == 3) processBOLUS(divided, receivedSms)
else sendSMS(Sms(receivedSms.phoneNumber, resourceHelper.gs(R.string.wrongformat)))
@ -317,7 +317,7 @@ class SmsCommunicatorPlugin @Inject constructor(
if (actualBG != null) {
reply = resourceHelper.gs(R.string.sms_actualbg) + " " + actualBG.valueToUnitsString(units) + ", "
} else if (lastBG != null) {
val agoMilliseconds = dateUtil._now() - lastBG.timestamp
val agoMilliseconds = dateUtil.now() - lastBG.timestamp
val agoMin = (agoMilliseconds / 60.0 / 1000.0).toInt()
reply = resourceHelper.gs(R.string.sms_lastbg) + " " + lastBG.valueToUnitsString(units) + " " + String.format(resourceHelper.gs(R.string.sms_minago), agoMin) + ", "
}
@ -431,7 +431,7 @@ class SmsCommunicatorPlugin @Inject constructor(
commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() {
if (result.success) {
loopPlugin.suspendTo(dateUtil._now() + anInteger() * 60L * 1000)
loopPlugin.suspendTo(dateUtil.now() + anInteger() * 60L * 1000)
loopPlugin.createOfflineEvent(anInteger() * 60)
rxBus.send(EventRefreshOverview("SMS_LOOP_SUSPENDED"))
val replyText = resourceHelper.gs(R.string.smscommunicator_loopsuspended) + " " +
@ -584,7 +584,7 @@ class SmsCommunicatorPlugin @Inject constructor(
val finalPercentage = percentage
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction(list[pIndex - 1] as String, finalPercentage) {
override fun run() {
activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, dateUtil._now())
activePlugin.activeTreatments.doProfileSwitch(store, list[pIndex - 1] as String, 0, finalPercentage, 0, dateUtil.now())
val replyText = resourceHelper.gs(R.string.profileswitchcreated)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
uel.log(Action.PROFILE_SWITCH, Sources.SMS,
@ -804,7 +804,7 @@ class SmsCommunicatorPlugin @Inject constructor(
else
String.format(resourceHelper.gs(R.string.smscommunicator_bolusdelivered), resultBolusDelivered)
replyText += "\n" + activePlugin.activePump.shortStatus(true)
lastRemoteBolusTime = dateUtil._now()
lastRemoteBolusTime = dateUtil.now()
if (isMeal) {
profileFunction.getProfile()?.let { currentProfile ->
var eatingSoonTTDuration = sp.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration)
@ -819,7 +819,7 @@ class SmsCommunicatorPlugin @Inject constructor(
else -> Constants.defaultEatingSoonTTmgdl
}
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
duration = TimeUnit.MINUTES.toMillis(eatingSoonTTDuration.toLong()),
reason = TemporaryTarget.Reason.EATING_SOON,
lowTarget = Profile.toMgdl(eatingSoonTT, profileFunction.getUnits()),
@ -875,7 +875,7 @@ class SmsCommunicatorPlugin @Inject constructor(
private fun processCARBS(divided: Array<String>, receivedSms: Sms) {
var grams = SafeParse.stringToInt(divided[1])
var time = dateUtil._now()
var time = dateUtil.now()
if (divided.size > 2) {
time = toTodayTime(divided[2].toUpperCase(Locale.getDefault()))
if (time == 0L) {
@ -964,7 +964,7 @@ class SmsCommunicatorPlugin @Inject constructor(
tt = Profile.toCurrentUnits(profileFunction, tt)
tt = if (tt > 0) tt else if (units == Constants.MMOL) defaultTargetMMOL else defaultTargetMGDL
disposable += repository.runTransactionForResult(InsertTemporaryTargetAndCancelCurrentTransaction(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
duration = TimeUnit.MINUTES.toMillis(ttDuration.toLong()),
reason = TemporaryTarget.Reason.EATING_SOON,
lowTarget = Profile.toMgdl(tt, profileFunction.getUnits()),
@ -989,7 +989,7 @@ class SmsCommunicatorPlugin @Inject constructor(
receivedSms.processed = true
messageToConfirm = AuthRequest(injector, receivedSms, reply, passCode, object : SmsAction() {
override fun run() {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil._now()))
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil.now()))
.subscribe({ result ->
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }
}, {

View file

@ -86,7 +86,7 @@ class OneTimePassword @Inject constructor(
return OneTimePasswordValidationResult.ERROR_WRONG_PIN
}
val counter: Long = dateUtil._now() / 30000L
val counter: Long = dateUtil.now() / 30000L
val acceptableTokens: MutableList<String> = mutableListOf(generateOneTimePassword(counter))
for (i in 0 until Constants.OTP_ACCEPT_OLD_TOKENS_COUNT) {

View file

@ -232,7 +232,7 @@ class TidepoolUploader @Inject constructor(
}
private fun uploadNext() {
if (uploadChunk.getLastEnd() < dateUtil._now() - T.mins(1).msecs()) {
if (uploadChunk.getLastEnd() < dateUtil.now() - T.mins(1).msecs()) {
SystemClock.sleep(3000)
aapsLogger.debug(LTag.TIDEPOOL, "Restarting doUpload. Last: " + dateUtil.dateAndTimeString(uploadChunk.getLastEnd()))
doUpload()

View file

@ -41,7 +41,7 @@ class UploadChunk @Inject constructor(
return null
session.start = getLastEnd()
session.end = min(session.start + maxUploadSize, dateUtil._now())
session.end = min(session.start + maxUploadSize, dateUtil.now())
val result = get(session.start, session.end)
if (result.length < 3) {
@ -81,7 +81,7 @@ class UploadChunk @Inject constructor(
fun getLastEnd(): Long {
val result = sp.getLong(R.string.key_tidepool_last_end, 0)
return max(result, dateUtil._now() - T.months(2).msecs())
return max(result, dateUtil.now() - T.months(2).msecs())
}
fun setLastEnd(time: Long) {
@ -101,7 +101,7 @@ class UploadChunk @Inject constructor(
// TODO we could make sure we include records older than the first bg record for completeness
val start: Long = 0
val end = dateUtil._now()
val end = dateUtil.now()
val bgReadingList = repository.compatGetBgReadingsDataFromTime(start, end, true)
.blockingGet()

View file

@ -21,13 +21,13 @@ class RateLimit @Inject constructor(
fun rateLimit(name: String, seconds: Int): Boolean {
// check if over limit
rateLimits[name]?.let {
if (dateUtil._now() - it < T.secs(seconds.toLong()).msecs()) {
if (dateUtil.now() - it < T.secs(seconds.toLong()).msecs()) {
aapsLogger.debug(LTag.TIDEPOOL, "$name rate limited: $seconds seconds")
return false
}
}
// not over limit
rateLimits[name] = dateUtil._now()
rateLimits[name] = dateUtil.now()
return true
}
}

View file

@ -220,7 +220,7 @@ class ActionStringHandler @Inject constructor(
}
val format = DecimalFormat("0.00")
val formatInt = DecimalFormat("0")
val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
val tempTarget = if (dbRecord is ValueWrapper.Existing) dbRecord.value else null
val bolusWizard = BolusWizard(injector).doCalc(profile, profileName, tempTarget,
@ -457,7 +457,7 @@ class ActionStringHandler @Inject constructor(
}
val profile = profileFunction.getProfile() ?: return "No profile set :("
//Check for Temp-Target:
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
if (tempTarget is ValueWrapper.Existing) {
ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.value.lowTarget, tempTarget.value.lowTarget, Constants.MGDL, profileFunction.getUnits())
ret += "\nuntil: " + dateUtil.timeString(tempTarget.value.end)

View file

@ -466,7 +466,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
}
private fun calculateFromTreatmentsAndTemps(time: Long, lastAutosensResult: AutosensResult, exercise_mode: Boolean, half_basal_exercise_target: Int, isTempTarget: Boolean): IobTotal {
val now = dateUtil._now()
val now = dateUtil.now()
val bolusIob = calculateIobFromBolusToTime(time).round()
val basalIob = getCalculationToTimeTempBasals(time, lastAutosensResult, exercise_mode, half_basal_exercise_target, isTempTarget).round()
// OpenAPSSMB only
@ -551,7 +551,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
val autosensData = if (_synchronized) getLastAutosensDataSynchronized(reason) else getLastAutosensData(reason)
var displayCob: Double? = null
var futureCarbs = 0.0
val now = dateUtil._now()
val now = dateUtil.now()
val carbs = repository.getCarbsDataFromTimeExpanded(now, true).blockingGet()
if (autosensData != null) {
displayCob = autosensData.cob
@ -658,7 +658,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
override fun calculateIobArrayForSMB(lastAutosensResult: AutosensResult, exercise_mode: Boolean, half_basal_exercise_target: Int, isTempTarget: Boolean): Array<IobTotal> {
// predict IOB out to DIA plus 30m
val now = dateUtil._now()
val now = dateUtil.now()
val len = 4 * 60 / 5
val array = Array(len) { IobTotal(0) }
for ((pos, i) in (0 until len).withIndex()) {
@ -809,7 +809,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
fun range(): Long = ((profileFunction.getProfile()?.dia
?: Constants.defaultDIA) * 60 * 60 * 1000).toLong()
override fun calculateIobFromBolus(): IobTotal = calculateIobFromBolusToTime(dateUtil._now())
override fun calculateIobFromBolus(): IobTotal = calculateIobFromBolusToTime(dateUtil.now())
override fun calculateIobFromBolusToTime(toTime: Long): IobTotal {
val total = IobTotal(toTime)
@ -842,7 +842,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
private fun calculateIobToTimeFromExtendedBoluses(toTime: Long): IobTotal {
val total = IobTotal(toTime)
val now = dateUtil._now()
val now = dateUtil.now()
val pumpInterface = activePlugin.activePump
if (!pumpInterface.isFakingTempsByExtendedBoluses) {
val extendedBoluses = repository.getExtendedBolusDataFromTimeToTime(toTime - range(), toTime, true).blockingGet()
@ -906,11 +906,11 @@ open class IobCobCalculatorPlugin @Inject constructor(
}
override fun calculateIobFromTempBasalsIncludingConvertedExtended(): IobTotal =
calculateIobToTimeFromTempBasalsIncludingConvertedExtended(dateUtil._now())
calculateIobToTimeFromTempBasalsIncludingConvertedExtended(dateUtil.now())
override fun calculateIobToTimeFromTempBasalsIncludingConvertedExtended(toTime: Long): IobTotal {
val total = IobTotal(toTime)
val now = dateUtil._now()
val now = dateUtil.now()
val pumpInterface = activePlugin.activePump
val temporaryBasals = repository.getTemporaryBasalsDataFromTimeToTime(toTime - range(), toTime, true).blockingGet()
@ -947,7 +947,7 @@ open class IobCobCalculatorPlugin @Inject constructor(
open fun getCalculationToTimeTempBasals(toTime: Long, lastAutosensResult: AutosensResult, exercise_mode: Boolean, half_basal_exercise_target: Int, isTempTarget: Boolean): IobTotal {
val total = IobTotal(toTime)
val pumpInterface = activePlugin.activePump
val now = dateUtil._now()
val now = dateUtil.now()
val temporaryBasals = repository.getTemporaryBasalsDataFromTimeToTime(toTime - range(), toTime, true).blockingGet()
for (pos in temporaryBasals.indices) {
val t = temporaryBasals[pos]

View file

@ -66,7 +66,7 @@ class IobCobOref1Thread internal constructor(
}
override fun run() {
val start = dateUtil._now()
val start = dateUtil.now()
mWakeLock?.acquire(T.mins(10).msecs())
try {
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA thread started: $from")
@ -103,7 +103,7 @@ class IobCobOref1Thread internal constructor(
// check if data already exists
var bgTime = bucketedData[i].timestamp
bgTime = iobCobCalculatorPlugin.roundUpTime(bgTime)
if (bgTime > iobCobCalculatorPlugin.roundUpTime(dateUtil._now())) continue
if (bgTime > iobCobCalculatorPlugin.roundUpTime(dateUtil.now())) continue
var existing: AutosensData?
if (autosensDataTable[bgTime].also { existing = it } != null) {
previous = existing
@ -293,7 +293,7 @@ class IobCobOref1Thread internal constructor(
// TODO AS-FIX
@Suppress("SimplifyBooleanWithConstants")
if (false && sp.getBoolean(R.string.key_high_temptarget_raises_sensitivity, SMBDefaults.high_temptarget_raises_sensitivity)) {
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
val tempTarget = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
if (tempTarget is ValueWrapper.Existing && tempTarget.value.target() >= 100) {
autosensData.extraDeviation.add(-(tempTarget.value.target() - 100) / 20)
}
@ -306,7 +306,7 @@ class IobCobOref1Thread internal constructor(
val hours = calendar[Calendar.HOUR_OF_DAY]
if (min in 0..4 && hours % 2 == 0) autosensData.extraDeviation.add(0.0)
previous = autosensData
if (bgTime < dateUtil._now()) autosensDataTable.put(bgTime, autosensData)
if (bgTime < dateUtil.now()) autosensDataTable.put(bgTime, autosensData)
aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime())
val sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime)
aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: $sensitivity")

View file

@ -65,7 +65,7 @@ class IobCobThread @Inject internal constructor(
}
override fun run() {
val start = dateUtil._now()
val start = dateUtil.now()
mWakeLock?.acquire(T.mins(10).msecs())
try {
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA thread started: $from")
@ -102,7 +102,7 @@ class IobCobThread @Inject internal constructor(
// check if data already exists
var bgTime = bucketedData[i].timestamp
bgTime = iobCobCalculatorPlugin.roundUpTime(bgTime)
if (bgTime > iobCobCalculatorPlugin.roundUpTime(dateUtil._now())) continue
if (bgTime > iobCobCalculatorPlugin.roundUpTime(dateUtil.now())) continue
var existing: AutosensData?
if (autosensDataTable[bgTime].also { existing = it } != null) {
previous = existing
@ -253,7 +253,7 @@ class IobCobThread @Inject internal constructor(
autosensData.pastSensitivity += "C"
}
previous = autosensData
if (bgTime < dateUtil._now()) autosensDataTable.put(bgTime, autosensData)
if (bgTime < dateUtil.now()) autosensDataTable.put(bgTime, autosensData)
aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime())
val sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime)
aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: $sensitivity")

View file

@ -204,7 +204,7 @@ class LocalProfilePlugin @Inject constructor(
fun copyFrom(profile: Profile, newName: String): SingleProfile {
var verifiedName = newName
if (rawProfile?.getSpecificProfile(newName) != null) {
verifiedName += " " + dateUtil._now().toString()
verifiedName += " " + dateUtil.now().toString()
}
val sp = SingleProfile()
sp.name = verifiedName
@ -341,7 +341,7 @@ class LocalProfilePlugin @Inject constructor(
}
}
if (numOfProfiles > 0) json.put("defaultProfile", currentProfile()?.name)
json.put("startDate", dateUtil.toISOAsUTC(dateUtil._now()))
json.put("startDate", dateUtil.toISOAsUTC(dateUtil.now()))
json.put("store", store)
} catch (e: JSONException) {
aapsLogger.error("Unhandled exception", e)

View file

@ -68,7 +68,7 @@ class NSProfileFragment : DaggerFragment() {
uel.log(Action.PROFILE_SWITCH, Sources.NSProfile,
ValueWithUnit.SimpleString(name),
ValueWithUnit.Percent(100))
treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, dateUtil._now())
treatmentsPlugin.doProfileSwitch(store, name, 0, 100, 0, dateUtil.now())
})
}
}

View file

@ -79,7 +79,7 @@ class MDIPlugin @Inject constructor(
timestamp = detailedBolusInfo.timestamp,
amount = detailedBolusInfo.insulin,
type = detailedBolusInfo.bolusType,
pumpId = dateUtil._now(),
pumpId = dateUtil.now(),
pumpType = PumpType.MDI,
pumpSerial = serialNumber())
if (detailedBolusInfo.carbs > 0)

View file

@ -95,9 +95,9 @@ class VirtualPumpFragment : DaggerFragment() {
if (_binding == null) return
val profile = profileFunction.getProfile() ?: return
binding.basabasalrate.text = resourceHelper.gs(R.string.pump_basebasalrate, virtualPumpPlugin.baseBasalRate)
binding.tempbasal.text = iobCobCalculator.getTempBasal(dateUtil._now())?.toStringFull(profile, dateUtil)
binding.tempbasal.text = iobCobCalculator.getTempBasal(dateUtil.now())?.toStringFull(profile, dateUtil)
?: ""
binding.extendedbolus.text = iobCobCalculator.getExtendedBolus(dateUtil._now())?.toStringFull(dateUtil)
binding.extendedbolus.text = iobCobCalculator.getExtendedBolus(dateUtil.now())?.toStringFull(dateUtil)
?: ""
binding.battery.text = resourceHelper.gs(R.string.format_percent, virtualPumpPlugin.batteryPercent)
binding.reservoir.text = resourceHelper.gs(R.string.formatinsulinunits, virtualPumpPlugin.reservoirInUnits.toDouble())

View file

@ -206,7 +206,7 @@ open class VirtualPumpPlugin @Inject constructor(
timestamp = detailedBolusInfo.timestamp,
amount = detailedBolusInfo.insulin,
type = detailedBolusInfo.bolusType,
pumpId = dateUtil._now(),
pumpId = dateUtil.now(),
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber())
if (detailedBolusInfo.carbs > 0)
@ -229,12 +229,12 @@ open class VirtualPumpPlugin @Inject constructor(
result.duration = durationInMinutes
result.comment = resourceHelper.gs(R.string.virtualpump_resultok)
pumpSync.syncTemporaryBasalWithPumpId(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
rate = absoluteRate,
duration = T.mins(durationInMinutes.toLong()).msecs(),
isAbsolute = true,
type = tbrType,
pumpId = dateUtil._now(),
pumpId = dateUtil.now(),
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber()
)
@ -254,12 +254,12 @@ open class VirtualPumpPlugin @Inject constructor(
result.duration = durationInMinutes
result.comment = resourceHelper.gs(R.string.virtualpump_resultok)
pumpSync.syncTemporaryBasalWithPumpId(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
rate = percent.toDouble(),
duration = T.mins(durationInMinutes.toLong()).msecs(),
isAbsolute = false,
type = tbrType,
pumpId = dateUtil._now(),
pumpId = dateUtil.now(),
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber()
)
@ -279,11 +279,11 @@ open class VirtualPumpPlugin @Inject constructor(
result.duration = durationInMinutes
result.comment = resourceHelper.gs(R.string.virtualpump_resultok)
pumpSync.syncExtendedBolusWithPumpId(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
amount = insulin,
duration = T.mins(durationInMinutes.toLong()).msecs(),
isEmulatingTB = false,
pumpId = dateUtil._now(),
pumpId = dateUtil.now(),
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber()
)
@ -301,8 +301,8 @@ open class VirtualPumpPlugin @Inject constructor(
if (pumpSync.expectedPumpState().temporaryBasal != null) {
result.enacted = true
pumpSync.syncStopTemporaryBasalWithPumpId(
timestamp = dateUtil._now(),
endPumpId = dateUtil._now(),
timestamp = dateUtil.now(),
endPumpId = dateUtil.now(),
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber()
)
@ -317,8 +317,8 @@ open class VirtualPumpPlugin @Inject constructor(
val result = PumpEnactResult(injector)
if (pumpSync.expectedPumpState().extendedBolus != null) {
pumpSync.syncStopExtendedBolusWithPumpId(
timestamp = dateUtil._now(),
endPumpId = dateUtil._now(),
timestamp = dateUtil.now(),
endPumpId = dateUtil.now(),
pumpType = pumpType ?: PumpType.GENERIC_AAPS,
pumpSerial = serialNumber()
)

View file

@ -120,7 +120,7 @@ class DexcomPlugin @Inject constructor(
for (i in 0 until meters.size()) {
meters.getBundle(i.toString())?.let {
val timestamp = it.getLong("timestamp") * 1000
val now = dateUtil._now()
val now = dateUtil.now()
if (timestamp > now - T.months(1).msecs() && timestamp < now) {
calibrations.add(CgmSourceTransaction.Calibration(
timestamp = it.getLong("timestamp") * 1000,

View file

@ -127,12 +127,12 @@ class NSClientSourcePlugin @Inject constructor(
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>()
for (i in 0 until sgvs.length()) {
val sgv = toGv(sgvs.getJSONObject(i)) ?: continue
if (sgv.timestamp < dateUtil._now() && sgv.timestamp > latestDateInReceivedData) latestDateInReceivedData = sgv.timestamp
if (sgv.timestamp < dateUtil.now() && sgv.timestamp > latestDateInReceivedData) latestDateInReceivedData = sgv.timestamp
glucoseValues += sgv
}
// Was that sgv more less 5 mins ago ?
if (T.msecs(dateUtil._now() - latestDateInReceivedData).mins() < 5L) {
if (T.msecs(dateUtil.now() - latestDateInReceivedData).mins() < 5L) {
rxBus.send(EventDismissNotification(Notification.NS_ALARM))
rxBus.send(EventDismissNotification(Notification.NS_URGENT_ALARM))
}

View file

@ -18,7 +18,6 @@ import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.XDripBroadcast
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.extensions.isRunningTest
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import io.reactivex.disposables.CompositeDisposable
@ -103,7 +102,7 @@ class RandomBgPlugin @Inject constructor(
val glucoseValues = mutableListOf<CgmSourceTransaction.TransactionGlucoseValue>()
glucoseValues += CgmSourceTransaction.TransactionGlucoseValue(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
value = bgMgdl,
raw = 0.0,
noise = null,

View file

@ -127,6 +127,6 @@ class TreatmentsFragment : DaggerFragment() {
private fun updateGui() {
if (_binding == null) return
binding.extendedBoluses.visibility = (activePlugin.activePump.pumpDescription.isExtendedBolusCapable || iobCobCalculator.getExtendedBolus(dateUtil._now()) != null).toVisibility()
binding.extendedBoluses.visibility = (activePlugin.activePump.pumpDescription.isExtendedBolusCapable || iobCobCalculator.getExtendedBolus(dateUtil.now()) != null).toVisibility()
}
}

View file

@ -147,7 +147,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
private void initializeProfileSwitchData(long range) {
getAapsLogger().debug(LTag.DATATREATMENTS, "initializeProfileSwitchData");
synchronized (profiles) {
profiles.reset().add(databaseHelper.getProfileSwitchData(dateUtil._now() - range, false));
profiles.reset().add(databaseHelper.getProfileSwitchData(dateUtil.now() - range, false));
}
}
@ -161,7 +161,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
@Deprecated
@Override
public List<Treatment> getTreatmentsFromHistoryAfterTimestamp(long fromTimestamp) {
return repository.getBolusesIncludingInvalidFromTimeToTime(fromTimestamp, dateUtil._now(), true)
return repository.getBolusesIncludingInvalidFromTimeToTime(fromTimestamp, dateUtil.now(), true)
.blockingGet()
.stream()
.map(bolus -> new Treatment(getInjector(), bolus))

View file

@ -113,7 +113,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() {
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.overview_treatment_label), resourceHelper.gs(R.string.deletefuturetreatments) + "?", Runnable {
uel.log(Action.DELETE_FUTURE_TREATMENTS, Sources.Treatments)
repository
.getBolusesDataFromTime(dateUtil._now(), false)
.getBolusesDataFromTime(dateUtil.now(), false)
.observeOn(aapsSchedulers.main)
.subscribe { list ->
list.forEach { bolus ->
@ -125,7 +125,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() {
}
}
repository
.getCarbsDataFromTime(dateUtil._now(), false)
.getCarbsDataFromTime(dateUtil.now(), false)
.observeOn(aapsSchedulers.main)
.subscribe { list ->
list.forEach { carb ->
@ -137,7 +137,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() {
}
}
repository
.getBolusCalculatorResultsDataFromTime(dateUtil._now(), false)
.getBolusCalculatorResultsDataFromTime(dateUtil.now(), false)
.observeOn(aapsSchedulers.main)
.subscribe { list ->
list.forEach { bolusCalc ->
@ -281,7 +281,7 @@ class TreatmentsBolusCarbsFragment : DaggerFragment() {
val iob = bolus.iobCalc(activePlugin, System.currentTimeMillis(), profile.dia)
holder.binding.iob.text = resourceHelper.gs(R.string.formatinsulinunits, iob.iobContrib)
if (iob.iobContrib != 0.0) holder.binding.iob.setTextColor(resourceHelper.gc(R.color.colorActive)) else holder.binding.iob.setTextColor(holder.binding.carbs.currentTextColor)
if (bolus.timestamp > dateUtil._now()) holder.binding.date.setTextColor(resourceHelper.gc(R.color.colorScheduled)) else holder.binding.date.setTextColor(holder.binding.carbs.currentTextColor)
if (bolus.timestamp > dateUtil.now()) holder.binding.date.setTextColor(resourceHelper.gc(R.color.colorScheduled)) else holder.binding.date.setTextColor(holder.binding.carbs.currentTextColor)
holder.binding.mealOrCorrection.text =
when (ml.bolus.type) {
Bolus.Type.SMB -> "SMB"

View file

@ -69,7 +69,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
super.onViewCreated(view, savedInstanceState)
binding.recyclerview.setHasFixedSize(true)
binding.recyclerview.layoutManager = LinearLayoutManager(view.context)
binding.recyclerview.adapter = RecyclerProfileViewAdapter(databaseHelper.getProfileSwitchData(dateUtil._now() - T.days(30).msecs(), false))
binding.recyclerview.adapter = RecyclerProfileViewAdapter(databaseHelper.getProfileSwitchData(dateUtil.now() - T.days(30).msecs(), false))
binding.refreshFromNightscout.setOnClickListener {
activity?.let { activity ->
@ -108,7 +108,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
fun updateGUI() {
if (_binding == null) return
binding.recyclerview.swapAdapter(RecyclerProfileViewAdapter(databaseHelper.getProfileSwitchData(dateUtil._now() - T.days(30).msecs(), false)), false)
binding.recyclerview.swapAdapter(RecyclerProfileViewAdapter(databaseHelper.getProfileSwitchData(dateUtil.now() - T.days(30).msecs(), false)), false)
}
inner class RecyclerProfileViewAdapter(private var profileSwitchList: List<ProfileSwitch>) : RecyclerView.Adapter<ProfileSwitchViewHolder>() {

View file

@ -153,7 +153,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
private inner class RecyclerViewAdapter internal constructor(private var tempTargetList: List<TemporaryTarget>) : RecyclerView.Adapter<TempTargetsViewHolder>() {
private val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
private val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
private val currentlyActiveTarget = if (dbRecord is ValueWrapper.Existing) dbRecord.value else null
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): TempTargetsViewHolder =
@ -174,7 +174,7 @@ class TreatmentsTempTargetFragment : DaggerFragment() {
holder.binding.date.setTextColor(
when {
tempTarget.id == currentlyActiveTarget?.id -> resourceHelper.gc(R.color.colorActive)
tempTarget.timestamp > dateUtil._now() -> resourceHelper.gc(R.color.colorScheduled)
tempTarget.timestamp > dateUtil.now() -> resourceHelper.gc(R.color.colorScheduled)
else -> holder.binding.reasonColon.currentTextColor
})
holder.binding.remove.tag = tempTarget

View file

@ -171,7 +171,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
holder.binding.duration.text = resourceHelper.gs(R.string.format_mins, T.msecs(tempBasal.duration).mins())
if (tempBasal.isAbsolute) holder.binding.rate.text = resourceHelper.gs(R.string.pump_basebasalrate, tempBasal.rate)
else holder.binding.rate.text = resourceHelper.gs(R.string.format_percent, tempBasal.rate.toInt())
val now = dateUtil._now()
val now = dateUtil.now()
var iob = IobTotal(now)
val profile = profileFunction.getProfile(now)
if (profile != null) iob = tempBasal.iobCalc(now, profile, activePlugin.activeInsulin)
@ -194,7 +194,7 @@ class TreatmentsTemporaryBasalsFragment : DaggerFragment() {
init {
binding.remove.setOnClickListener { v: View ->
val tempBasal = v.tag as TemporaryBasal
val profile = profileFunction.getProfile(dateUtil._now())
val profile = profileFunction.getProfile(dateUtil.now())
?: return@setOnClickListener
context?.let {
OKDialog.showConfirmation(it, resourceHelper.gs(R.string.removerecord),

View file

@ -201,7 +201,7 @@ open class CommandQueue @Inject constructor(
if ((detailedBolusInfo.carbs > 0) &&
(!activePlugin.get().activePump.pumpDescription.storesCarbInfo ||
detailedBolusInfo.carbsDuration != 0L ||
(detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp) > dateUtil._now())
(detailedBolusInfo.carbsTimestamp ?: detailedBolusInfo.timestamp) > dateUtil.now())
) {
disposable += repository.runTransactionForResult(detailedBolusInfo.insertCarbsTransaction())
.subscribeBy(

View file

@ -23,7 +23,7 @@ class CommandSMBBolus(
override fun execute() {
val r: PumpEnactResult
val lastBolusTime = repository.getLastBolusRecord()?.timestamp ?: 0L
if (lastBolusTime != 0L && lastBolusTime + T.mins(3).msecs() > dateUtil._now()) {
if (lastBolusTime != 0L && lastBolusTime + T.mins(3).msecs() > dateUtil.now()) {
aapsLogger.debug(LTag.PUMPQUEUE, "SMB requested but still in 3 min interval")
r = PumpEnactResult(injector).enacted(false).success(false).comment("SMB requested but still in 3 min interval")
} else if (detailedBolusInfo.deliverAtTheLatest != 0L && detailedBolusInfo.deliverAtTheLatest + T.mins(1).msecs() > System.currentTimeMillis()) {

View file

@ -106,7 +106,7 @@ class KeepAliveReceiver : DaggerBroadcastReceiver() {
shouldUploadStatus = true
else if (dateUtil.isOlderThan(activePlugin.activeAPS.lastAPSRun, 5)) shouldUploadStatus = true
if (dateUtil.isOlderThan(lastIobUpload, IOB_UPDATE_FREQUENCY_IN_MINUTES) && shouldUploadStatus) {
lastIobUpload = dateUtil._now()
lastIobUpload = dateUtil.now()
buildDeviceStatus(dateUtil, loopPlugin, iobCobCalculatorPlugin, profileFunction,
activePlugin.activePump, receiverStatusStore, runningConfiguration,
BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION)?.also {

View file

@ -27,10 +27,10 @@ class ActivityMonitor @Inject constructor(
aapsLogger.debug(LTag.UI, "onActivityPaused: $name resumed == 0")
return
}
val elapsed = dateUtil._now() - resumed
val elapsed = dateUtil.now() - resumed
val total = sp.getLong("Monitor_" + name + "_total", 0)
if (total == 0L) {
sp.putLong("Monitor_" + name + "_start", dateUtil._now())
sp.putLong("Monitor_" + name + "_start", dateUtil.now())
}
sp.putLong("Monitor_" + name + "_total", total + elapsed)
aapsLogger.debug(LTag.UI, "onActivityPaused: $name elapsed=$elapsed total=${total + elapsed}")
@ -39,7 +39,7 @@ class ActivityMonitor @Inject constructor(
override fun onActivityResumed(activity: Activity?) {
val name = activity?.javaClass?.simpleName ?: return
aapsLogger.debug(LTag.UI, "onActivityResumed: $name")
sp.putLong("Monitor_" + name + "_" + "resumed", dateUtil._now())
sp.putLong("Monitor_" + name + "_" + "resumed", dateUtil.now())
}
override fun onActivityStarted(activity: Activity?) {
@ -66,7 +66,7 @@ class ActivityMonitor @Inject constructor(
val activity = key.split("_")[1].replace("Activity", "")
val duration = dateUtil.niceTimeScalar(v as Long, resourceHelper)
val start = sp.getLong(key.replace("total", "start"), 0)
val days = T.msecs(dateUtil._now() - start).days()
val days = T.msecs(dateUtil.now() - start).days()
result += resourceHelper.gs(R.string.activitymonitorformat, activity, duration, days)
}
return result

View file

@ -30,8 +30,8 @@ class TddCalculator @Inject constructor(
) {
fun calculate(days: Long): LongSparseArray<TDD> {
val startTime = MidnightTime.calc(dateUtil._now() - T.days(days).msecs())
val endTime = MidnightTime.calc(dateUtil._now())
val startTime = MidnightTime.calc(dateUtil.now() - T.days(days).msecs())
val endTime = MidnightTime.calc(dateUtil.now())
val result = LongSparseArray<TDD>()
repository.getBolusesDataFromTimeToTime(startTime, endTime, true).blockingGet()

View file

@ -26,8 +26,8 @@ class TirCalculator @Inject constructor(
fun calculate(days: Long, lowMgdl: Double, highMgdl: Double): LongSparseArray<TIR> {
if (lowMgdl < 39) throw RuntimeException("Low below 39")
if (lowMgdl > highMgdl) throw RuntimeException("Low > High")
val startTime = MidnightTime.calc(dateUtil._now() - T.days(days).msecs())
val endTime = MidnightTime.calc(dateUtil._now())
val startTime = MidnightTime.calc(dateUtil.now() - T.days(days).msecs())
val endTime = MidnightTime.calc(dateUtil.now())
val bgReadings = repository.compatGetBgReadingsDataFromTime(startTime, endTime, true).blockingGet()
val result = LongSparseArray<TIR>()

View file

@ -249,7 +249,7 @@ class BolusWizard @Inject constructor(
private fun createBolusCalculatorResult(): BolusCalculatorResult =
BolusCalculatorResult(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
targetBGLow = targetBGLow,
targetBGHigh = targetBGHigh,
isf = sens,
@ -439,7 +439,7 @@ class BolusWizard @Inject constructor(
}
if (useAlarm && carbs > 0 && carbTime > 0) {
carbTimer.scheduleReminder(dateUtil._now() + T.mins(carbTime.toLong()).msecs())
carbTimer.scheduleReminder(dateUtil.now() + T.mins(carbTime.toLong()).msecs())
}
}
})

View file

@ -18,7 +18,6 @@ import info.nightscout.androidaps.extensions.valueToUnits
import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.json.JSONException
import org.json.JSONObject
import java.util.*
import javax.inject.Inject
class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjector) {
@ -77,7 +76,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
fun isActive(): Boolean = Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo()
fun doCalc(profile: Profile, profileName: String, lastBG: GlucoseValue, _synchronized: Boolean): BolusWizard {
val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
val dbRecord = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
val tempTarget = if (dbRecord is ValueWrapper.Existing) dbRecord.value else null
//BG
var bg = 0.0

View file

@ -55,7 +55,7 @@ class ObjectivesPluginTest : TestBase() {
c = objectivesPlugin.isLoopInvocationAllowed(c)
Assert.assertEquals("Objectives: Objective 1 not started", c.getReasons(aapsLogger))
Assert.assertEquals(false, c.value())
objectivesPlugin.objectives[ObjectivesPlugin.FIRST_OBJECTIVE].startedOn = dateUtil._now()
objectivesPlugin.objectives[ObjectivesPlugin.FIRST_OBJECTIVE].startedOn = dateUtil.now()
}
@Test fun notStartedObjective6ShouldLimitClosedLoop() {

View file

@ -5,7 +5,6 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R
import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePassword
import info.nightscout.androidaps.plugins.general.smsCommunicator.otp.OneTimePasswordValidationResult
import info.nightscout.androidaps.utils.DateUtil
@ -89,10 +88,10 @@ class AuthRequestTest : TestBase() {
// test timed out message
val now: Long = 10000
PowerMockito.mockStatic(DateUtil::class.java)
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
authRequest = AuthRequest(injector, requester, "Request text", "ABC", action)
actionCalled = false
PowerMockito.`when`(dateUtil._now()).thenReturn(now + T.mins(Constants.SMS_CONFIRM_TIMEOUT).msecs() + 1)
PowerMockito.`when`(dateUtil.now()).thenReturn(now + T.mins(Constants.SMS_CONFIRM_TIMEOUT).msecs() + 1)
authRequest.action("ABC")
Assert.assertFalse(actionCalled)
}

View file

@ -2,7 +2,6 @@
package info.nightscout.androidaps.plugins.general.smsCommunicator
import android.content.Context
import android.telephony.SmsManager
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
@ -885,7 +884,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("BOLUS", smsCommunicatorPlugin.messages[0].text)
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text)
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(1.0))
PowerMockito.`when`(dateUtilMocked._now()).thenReturn(1000L)
PowerMockito.`when`(dateUtilMocked.now()).thenReturn(1000L)
`when`(sp.getLong(R.string.key_smscommunicator_remotebolusmindistance, T.msecs(Constants.remoteBolusMinDistance).mins())).thenReturn(15L)
//BOLUS 1
smsCommunicatorPlugin.messages = ArrayList()
@ -894,7 +893,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.messages[0].text)
Assert.assertEquals("Remote bolus not available. Try again later.", smsCommunicatorPlugin.messages[1].text)
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
PowerMockito.`when`(dateUtilMocked._now()).thenReturn(Constants.remoteBolusMinDistance + 1002L)
PowerMockito.`when`(dateUtilMocked.now()).thenReturn(Constants.remoteBolusMinDistance + 1002L)
//BOLUS 0
smsCommunicatorPlugin.messages = ArrayList()
@ -990,7 +989,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
}
@Test fun processCarbsTest() {
PowerMockito.`when`(dateUtilMocked._now()).thenReturn(1000000L)
PowerMockito.`when`(dateUtilMocked.now()).thenReturn(1000000L)
`when`(sp.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(false)
//CAL
smsCommunicatorPlugin.messages = ArrayList()

View file

@ -84,6 +84,6 @@ class AutomationEvent(private val injector: HasAndroidInjector) {
}
fun shouldRun(): Boolean {
return lastRun <= dateUtil._now() - T.mins(5).msecs()
return lastRun <= dateUtil.now() - T.mins(5).msecs()
}
}

View file

@ -208,7 +208,7 @@ class AutomationPlugin @Inject constructor(
action.doAction(object : Callback() {
override fun run() {
val sb = StringBuilder()
sb.append(dateUtil.timeString(dateUtil._now()))
sb.append(dateUtil.timeString(dateUtil.now()))
sb.append(" ")
sb.append(if (result.success) "" else "")
sb.append(" <b>")
@ -229,7 +229,7 @@ class AutomationPlugin @Inject constructor(
}
}
SystemClock.sleep(1100)
event.lastRun = dateUtil._now()
event.lastRun = dateUtil.now()
if (event.autoRemove) automationEvents.remove(event)
}
}

View file

@ -40,7 +40,7 @@ class ActionAlarm(injector: HasAndroidInjector) : Action(injector) {
override fun isValid(): Boolean = true // empty alarm will show app name
override fun doAction(callback: Callback) {
timerUtil.scheduleReminder(dateUtil._now() + T.secs(10L).msecs(), text.value.takeIf { it.isNotBlank() }
timerUtil.scheduleReminder(dateUtil.now() + T.secs(10L).msecs(), text.value.takeIf { it.isNotBlank() }
?: resourceHelper.gs(R.string.app_name))
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
}

View file

@ -62,7 +62,7 @@ class ActionProfileSwitch(injector: HasAndroidInjector) : Action(injector) {
uel.log(UserEntry.Action.PROFILE_SWITCH, Sources.Automation, title,
ValueWithUnit.SimpleString(inputProfileName.value),
ValueWithUnit.Percent(100))
activePlugin.activeTreatments.doProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, dateUtil._now())
activePlugin.activeTreatments.doProfileSwitch(profileStore, inputProfileName.value, 0, 100, 0, dateUtil.now())
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()
}

View file

@ -106,7 +106,7 @@ class ActionStartTempTarget(injector: HasAndroidInjector) : Action(injector) {
}
fun tt() = TemporaryTarget(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
duration = TimeUnit.MINUTES.toMillis(duration.getMinutes().toLong()),
reason = TemporaryTarget.Reason.AUTOMATION,
lowTarget = Profile.toMgdl(value.value, value.units),

View file

@ -30,7 +30,7 @@ class ActionStopTempTarget(injector: HasAndroidInjector) : Action(injector) {
override fun icon(): Int = R.drawable.ic_stop_24dp
override fun doAction(callback: Callback) {
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil._now()))
disposable += repository.runTransactionForResult(CancelCurrentTemporaryTargetIfAnyTransaction(dateUtil.now()))
.subscribe({ result ->
uel.log(UserEntry.Action.CANCEL_TT, Sources.Automation, title)
result.updated.forEach { aapsLogger.debug(LTag.DATABASE, "Updated temp target $it") }

View file

@ -12,7 +12,7 @@ import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.*
class InputDateTime(private val resourceHelper: ResourceHelper, private val dateUtil: DateUtil, var value: Long = dateUtil._now()) : Element() {
class InputDateTime(private val resourceHelper: ResourceHelper, private val dateUtil: DateUtil, var value: Long = dateUtil.now()) : Element() {
override fun addToLayout(root: LinearLayout) {
val label = TextView(root.context)

View file

@ -15,7 +15,7 @@ import java.util.*
class InputTime(private val resourceHelper: ResourceHelper, private val dateUtil: DateUtil) : Element() {
var value: Int = getMinSinceMidnight(dateUtil._now())
var value: Int = getMinSinceMidnight(dateUtil.now())
override fun addToLayout(root: LinearLayout) {
val label = TextView(root.context)

View file

@ -15,8 +15,8 @@ import java.util.*
class InputTimeRange(private val resourceHelper: ResourceHelper, private val dateUtil: DateUtil) : Element() {
var start: Int = getMinSinceMidnight(dateUtil._now())
var end: Int = getMinSinceMidnight(dateUtil._now())
var start: Int = getMinSinceMidnight(dateUtil.now())
var end: Int = getMinSinceMidnight(dateUtil.now())
override fun addToLayout(root: LinearLayout) {
val label = TextView(root.context)

View file

@ -45,7 +45,7 @@ class TriggerBolusAgo(injector: HasAndroidInjector) : Trigger(injector) {
aapsLogger.debug(LTag.AUTOMATION, "NOT ready for execution: " + friendlyDescription())
false
}
val last = (dateUtil._now() - lastBolusTime).toDouble() / (60 * 1000)
val last = (dateUtil.now() - lastBolusTime).toDouble() / (60 * 1000)
aapsLogger.debug(LTag.AUTOMATION, "LastBolus min ago: $minutesAgo")
val doRun = comparator.value.check(last.toInt(), minutesAgo.getMinutes())
if (doRun) {

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.general.automation.elements.InputInsul
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.JsonHelper
import org.json.JSONObject
@ -35,7 +34,7 @@ class TriggerIob(injector: HasAndroidInjector) : Trigger(injector) {
override fun shouldRun(): Boolean {
val profile = profileFunction.getProfile() ?: return false
val iob = iobCobCalculatorPlugin.calculateFromTreatmentsAndTempsSynchronized(dateUtil._now(), profile)
val iob = iobCobCalculatorPlugin.calculateFromTreatmentsAndTempsSynchronized(dateUtil.now(), profile)
if (comparator.value.check(iob.iob, insulin.value)) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
return true

View file

@ -10,7 +10,6 @@ import info.nightscout.androidaps.plugins.general.automation.elements.InputDurat
import info.nightscout.androidaps.plugins.general.automation.elements.LabelWithElement
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.JsonHelper.safeGetInt
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
import org.json.JSONObject
@ -47,7 +46,7 @@ class TriggerPumpLastConnection(injector: HasAndroidInjector) : Trigger(injector
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
return true
}
val connectionAgo = (dateUtil._now() - lastConnection) / (60 * 1000)
val connectionAgo = (dateUtil.now() - lastConnection) / (60 * 1000)
aapsLogger.debug(LTag.AUTOMATION, "Last connection min ago: $connectionAgo")
if (comparator.value.check(connectionAgo.toInt(), minutesAgo.value)) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())

View file

@ -32,7 +32,7 @@ class TriggerRecurringTime(injector: HasAndroidInjector) : Trigger(injector) {
}
override fun shouldRun(): Boolean {
val currentMinSinceMidnight = getMinSinceMidnight(dateUtil._now())
val currentMinSinceMidnight = getMinSinceMidnight(dateUtil.now())
val scheduledDayOfWeek = Calendar.getInstance()[Calendar.DAY_OF_WEEK]
if (days.isSet(Objects.requireNonNull(InputWeekDay.DayOfWeek.fromCalendarInt(scheduledDayOfWeek)))) {
if (currentMinSinceMidnight >= time.value && currentMinSinceMidnight - time.value < 5) {

View file

@ -30,7 +30,7 @@ class TriggerTempTarget(injector: HasAndroidInjector) : Trigger(injector) {
}
override fun shouldRun(): Boolean {
val tt = repository.getTemporaryTargetActiveAt(dateUtil._now()).blockingGet()
val tt = repository.getTemporaryTargetActiveAt(dateUtil.now()).blockingGet()
if (tt is ValueWrapper.Absent && comparator.value == ComparatorExists.Compare.NOT_EXISTS) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
return true

View file

@ -8,7 +8,6 @@ import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.automation.elements.InputDateTime
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.JsonHelper
import info.nightscout.androidaps.utils.T
import org.json.JSONObject
@ -32,7 +31,7 @@ class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) {
}
override fun shouldRun(): Boolean {
val now = dateUtil._now()
val now = dateUtil.now()
if (now >= time.value && now - time.value < T.mins(5).msecs()) {
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
return true

View file

@ -9,7 +9,6 @@ import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.general.automation.elements.InputTimeRange
import info.nightscout.androidaps.plugins.general.automation.elements.LayoutBuilder
import info.nightscout.androidaps.plugins.general.automation.elements.StaticLabel
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.JsonHelper.safeGetInt
import info.nightscout.androidaps.utils.MidnightTime
import org.json.JSONObject
@ -38,7 +37,7 @@ class TriggerTimeRange(injector: HasAndroidInjector) : Trigger(injector) {
}
override fun shouldRun(): Boolean {
val currentMinSinceMidnight = getMinSinceMidnight(dateUtil._now())
val currentMinSinceMidnight = getMinSinceMidnight(dateUtil.now())
var doRun = false
if (range.start < range.end && range.start < currentMinSinceMidnight && currentMinSinceMidnight < range.end) doRun = true
else if (range.start > range.end && (range.start < currentMinSinceMidnight || currentMinSinceMidnight < range.end)) doRun = true

View file

@ -114,7 +114,7 @@ class TriggerAutosensValueTest : TriggerTestBase() {
@Before
fun mock() {
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
}
private fun generateAutosensData(): AutosensData {

View file

@ -13,7 +13,6 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
import java.util.*
@ -28,7 +27,7 @@ class TriggerBgTest : TriggerTestBase() {
fun prepare() {
`when`(profileFunction.getUnits()).thenReturn(Constants.MGDL)
`when`(iobCobCalculatorPlugin.dataLock).thenReturn(Any())
`when`(dateUtil._now()).thenReturn(now)
`when`(dateUtil.now()).thenReturn(now)
}
@Test

View file

@ -24,7 +24,7 @@ class TriggerBolusAgoTest : TriggerTestBase() {
@Before
fun mock() {
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
}
@Test
@ -36,7 +36,7 @@ class TriggerBolusAgoTest : TriggerTestBase() {
type = Bolus.Type.NORMAL
)
) // Set last bolus time to now
`when`(dateUtil._now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min
`when`(dateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min
var t = TriggerBolusAgo(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL)
Assert.assertEquals(110, t.minutesAgo.value)
Assert.assertEquals(Comparator.Compare.IS_EQUAL, t.comparator.value)

View file

@ -22,7 +22,7 @@ class TriggerCOBTest : TriggerTestBase() {
var now = 1514766900000L
@Before fun mock() {
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
PowerMockito.`when`(sp.getInt(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt())).thenReturn(48)
}

View file

@ -27,7 +27,7 @@ class TriggerDeltaTest : TriggerTestBase() {
@Before
fun mock() {
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
`when`(iobCobCalculatorPlugin.dataLock).thenReturn(Any())
`when`(profileFunction.getUnits()).thenReturn(Constants.MGDL)
}

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
import com.google.common.base.Optional
import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.IobTotal
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONObject
@ -13,7 +12,6 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers
import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@ -24,7 +22,7 @@ class TriggerIobTest : TriggerTestBase() {
var now = 1514766900000L
@Before fun mock() {
`when`(dateUtil._now()).thenReturn(now)
`when`(dateUtil.now()).thenReturn(now)
`when`(profileFunction.getProfile()).thenReturn(validProfile)
}

View file

@ -25,7 +25,7 @@ class TriggerLocationTest : TriggerTestBase() {
@Before fun mock() {
PowerMockito.mockStatic(LocationService::class.java)
`when`(dateUtil._now()).thenReturn(now)
`when`(dateUtil.now()).thenReturn(now)
PowerMockito.spy(LocationService::class.java)
`when`(locationDataContainer.lastLocation).thenReturn(mockedLocation())
}

View file

@ -23,7 +23,7 @@ class TriggerProfilePercentTest : TriggerTestBase() {
@Before fun mock() {
`when`(profileFunction.getProfile()).thenReturn(validProfile)
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
}
@Test fun shouldRunTest() {

View file

@ -21,7 +21,7 @@ class TriggerPumpLastConnectionTest : TriggerTestBase() {
@Before
fun mock() {
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
}
@Test
@ -29,7 +29,7 @@ class TriggerPumpLastConnectionTest : TriggerTestBase() {
// System.currentTimeMillis() is always 0
// and so is every last connection time
Assert.assertEquals(0L, testPumpPlugin.lastDataTime())
PowerMockito.`when`(dateUtil._now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min
PowerMockito.`when`(dateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min
var t = TriggerPumpLastConnection(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL)
Assert.assertEquals(110, t.minutesAgo.value)
Assert.assertEquals(Comparator.Compare.IS_EQUAL, t.comparator.value)

View file

@ -20,7 +20,7 @@ class TriggerRecurringTimeTest : TriggerTestBase() {
@Before fun mock() {
now = MidnightTime.calc() + T.mins(95).msecs() // 95 min from midnight
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
}
@Test fun shouldRunTest() {

View file

@ -20,7 +20,7 @@ class TriggerTempTargetTest : TriggerTestBase() {
var now = 1514766900000L
@Before fun mock() {
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
}
/*
@Test fun shouldRunTest() {

View file

@ -23,7 +23,7 @@ class TriggerTimeRangeTest : TriggerTestBase() {
@Before
fun mock() {
val nowMills = MidnightTime.calcPlusMinutes(now)
PowerMockito.`when`(dateUtil._now()).thenReturn(nowMills)
PowerMockito.`when`(dateUtil.now()).thenReturn(nowMills)
}
@Test

View file

@ -21,7 +21,7 @@ class TriggerTimeTest : TriggerTestBase() {
var now = 1514766900000L
@Before fun mock() {
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
}
@Test fun shouldRunTest() {

View file

@ -24,7 +24,7 @@ class TriggerWifiSsidTest : TriggerTestBase() {
@Before fun mock() {
PowerMockito.mockStatic(NetworkChangeReceiver::class.java)
PowerMockito.`when`(dateUtil._now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
}
@Test fun shouldRunTest() {

View file

@ -969,7 +969,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
// so update the var with it, so the check routines below can work on it
preCheckResult = alertConfirmationResult;
} else if (activeAlert.errorCode != null) {
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, dateUtil._now(), getResourceHelper().gs(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message), Notification.URGENT, 0);
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, dateUtil.now(), getResourceHelper().gs(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message), Notification.URGENT, 0);
rxBus.send(new EventNewNotification(notification));
return preCheckResult.success(false);
}
@ -1067,7 +1067,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
throw new IllegalArgumentException(activeAlert.toString());
}
Notification notification = new Notification();
notification.setDate(dateUtil._now());
notification.setDate(dateUtil.now());
notification.setId(Notification.COMBO_PUMP_ALARM);
notification.setLevel(Notification.NORMAL);
if (activeAlert.warningCode == PumpWarningCodes.CARTRIDGE_LOW) {

View file

@ -235,7 +235,7 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
@Override
public boolean isValid() {
boolean isValid = getProfileObject() != null && getProfileObject().isValid(dateUtil.dateAndTimeString(date));
ProfileSwitch active = treatmentsPlugin.getProfileSwitchFromHistory(dateUtil._now());
ProfileSwitch active = treatmentsPlugin.getProfileSwitchFromHistory(dateUtil.now());
long activeProfileSwitchDate = active != null ? active.date : -1L;
if (!isValid && date == activeProfileSwitchDate)
createNotificationInvalidProfile(dateUtil.dateAndTimeString(date));

View file

@ -43,7 +43,7 @@ fun buildDeviceStatus(
var apsResult: JSONObject? = null
var iob: JSONObject? = null
var enacted: JSONObject? = null
if (lastRun != null && lastRun.lastAPSRun > dateUtil._now() - 300 * 1000L) {
if (lastRun != null && lastRun.lastAPSRun > dateUtil.now() - 300 * 1000L) {
// do not send if result is older than 1 min
apsResult = lastRun.request?.json()?.also {
it.put("timestamp", dateUtil.toISOString(lastRun.lastAPSRun))
@ -69,11 +69,11 @@ fun buildDeviceStatus(
val calcIob = iobCobCalculatorPlugin.calculateIobArrayInDia(profile)
if (calcIob.isNotEmpty()) {
iob = calcIob[0].json(dateUtil)
iob.put("time", dateUtil.toISOString(dateUtil._now()))
iob.put("time", dateUtil.toISOString(dateUtil.now()))
}
}
return DeviceStatus(
timestamp = dateUtil._now(),
timestamp = dateUtil.now(),
suggested = apsResult?.toString(),
iob = iob?.toString(),
enacted = enacted?.toString(),

View file

@ -22,17 +22,17 @@ import kotlin.math.round
import kotlin.math.roundToInt
fun ExtendedBolus.isInProgress(dateUtil: DateUtil): Boolean =
dateUtil._now() in timestamp..timestamp + duration
dateUtil.now() in timestamp..timestamp + duration
val ExtendedBolus.plannedRemainingMinutes: Int
get() = max(round((end - System.currentTimeMillis()) / 1000.0 / 60).toInt(), 0)
fun ExtendedBolus.toStringFull(dateUtil: DateUtil): String =
"E " + to2Decimal(rate) + "U/h @" + dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + T.msecs(duration).mins() + "min"
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "min"
fun ExtendedBolus.toStringMedium(dateUtil: DateUtil): String =
to2Decimal(rate) + "U/h " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + T.msecs(duration).mins() + "'"
to2Decimal(rate) + "U/h " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "'"
fun ExtendedBolus.toStringTotal(): String = "${to2Decimal(amount)}U ( ${to2Decimal(rate)} U/h )"

View file

@ -35,13 +35,13 @@ fun PumpSync.PumpState.TemporaryBasal.toStringFull(dateUtil: DateUtil): String {
isAbsolute -> {
DecimalFormatter.to2Decimal(rate) + "U/h @" +
dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'"
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
}
else -> { // percent
rate.toString() + "% @" +
dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'"
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
}
}
}
@ -58,5 +58,5 @@ fun PumpSync.PumpState.ExtendedBolus.getPassedDurationToTimeInMinutes(time: Long
fun PumpSync.PumpState.ExtendedBolus.toStringFull(dateUtil: DateUtil): String =
"E " + to2Decimal(rate) + "U/h @" +
dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + T.msecs(duration).mins() + "min"
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + T.msecs(duration).mins() + "min"

View file

@ -45,19 +45,19 @@ fun TemporaryBasal.toStringFull(profile: Profile, dateUtil: DateUtil): String {
type == TemporaryBasal.Type.FAKE_EXTENDED -> {
to2Decimal(rate) + "U/h (" + to2Decimal(netExtendedRate(profile)) + "E) @" +
dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'"
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
}
isAbsolute -> {
to2Decimal(rate) + "U/h @" +
dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'"
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
}
else -> { // percent
rate.toString() + "% @" +
dateUtil.timeString(timestamp) +
" " + getPassedDurationToTimeInMinutes(dateUtil._now()) + "/" + durationInMinutes + "'"
" " + getPassedDurationToTimeInMinutes(dateUtil.now()) + "/" + durationInMinutes + "'"
}
}
}

View file

@ -27,7 +27,7 @@ class GlucoseStatusProvider @Inject constructor(
aapsLogger.debug(LTag.GLUCOSE, "sizeRecords==0")
return null
}
if (data[0].timestamp < dateUtil._now() - 7 * 60 * 1000L && !allowOldData) {
if (data[0].timestamp < dateUtil.now() - 7 * 60 * 1000L && !allowOldData) {
aapsLogger.debug(LTag.GLUCOSE, "oldData")
return null
}

View file

@ -63,8 +63,8 @@ class PumpSyncImplementation @Inject constructor(
aapsLogger.debug(LTag.PUMP, "Registering new pump ${type.description} $serialNumber")
sp.putString(R.string.key_active_pump_type, type.description)
sp.putString(R.string.key_active_pump_serial_number, serialNumber)
sp.putLong(R.string.key_active_pump_change_timestamp, dateUtil._now()) // allow only data newer than register time (ie. ignore older history)
return timestamp > dateUtil._now() - T.mins(1).msecs() // allow first record to be 1 min old
sp.putLong(R.string.key_active_pump_change_timestamp, dateUtil.now()) // allow only data newer than register time (ie. ignore older history)
return timestamp > dateUtil.now() - T.mins(1).msecs() // allow first record to be 1 min old
}
if (type.description == storedType && serialNumber == storedSerial && timestamp >= storedTimestamp) {
@ -80,8 +80,8 @@ class PumpSyncImplementation @Inject constructor(
override fun expectedPumpState(): PumpSync.PumpState {
val bolus = repository.getLastBolusRecord()
val temporaryBasal = repository.getTemporaryBasalActiveAt(dateUtil._now()).blockingGet()
val extendedBolus = repository.getExtendedBolusActiveAt(dateUtil._now()).blockingGet()
val temporaryBasal = repository.getTemporaryBasalActiveAt(dateUtil.now()).blockingGet()
val extendedBolus = repository.getExtendedBolusActiveAt(dateUtil.now()).blockingGet()
return PumpSync.PumpState(
temporaryBasal =
@ -229,7 +229,7 @@ class PumpSyncImplementation @Inject constructor(
}
override fun insertAnnouncement(error: String, pumpId: Long?, pumpType: PumpType, pumpSerial: String) {
if (!confirmActivePump(dateUtil._now(), pumpType, pumpSerial)) return
if (!confirmActivePump(dateUtil.now(), pumpType, pumpSerial)) return
disposable += repository.runTransaction(InsertTherapyEventAnnouncementTransaction(error, pumpId, pumpType.toDbPumpType(), pumpSerial))
.subscribe()
}

View file

@ -134,17 +134,17 @@ open class DateUtil @Inject constructor(private val context: Context) {
}
fun minAgo(resourceHelper: ResourceHelper, time: Long): String {
val mins = ((_now() - time) / 1000 / 60).toInt()
val mins = ((now() - time) / 1000 / 60).toInt()
return resourceHelper.gs(R.string.minago, mins)
}
fun minAgoShort(time: Long): String {
val mins = ((time - _now()) / 1000 / 60).toInt()
val mins = ((time - now()) / 1000 / 60).toInt()
return (if (mins > 0) "+" else "") + mins
}
fun hourAgo(time: Long, resourceHelper: ResourceHelper): String {
val hours = (_now() - time) / 1000.0 / 60 / 60
val hours = (now() - time) / 1000.0 / 60 / 60
return resourceHelper.gs(R.string.hoursago, hours)
}
@ -171,7 +171,7 @@ open class DateUtil @Inject constructor(private val context: Context) {
return timeFrameString(timestamp - System.currentTimeMillis(), resourceHelper)
}
fun _now(): Long {
fun now(): Long {
return System.currentTimeMillis()
}
@ -182,12 +182,12 @@ open class DateUtil @Inject constructor(private val context: Context) {
}
fun isCloseToNow(date: Long): Boolean {
val diff = abs(date - _now())
val diff = abs(date - now())
return diff < T.mins(2L).msecs()
}
fun isOlderThan(date: Long, minutes: Long): Boolean {
val diff = _now() - date
val diff = now() - date
return diff > T.mins(minutes).msecs()
}

Some files were not shown because too many files have changed in this diff Show more