fix tests

This commit is contained in:
Milos Kozak 2020-05-07 23:40:59 +02:00
parent 120c526b80
commit 70e9d3e88a
183 changed files with 814 additions and 617 deletions

View file

@ -16,13 +16,12 @@ class StatsActivity : NoSplashAppCompatActivity() {
@Inject lateinit var tirCalculator: TirCalculator @Inject lateinit var tirCalculator: TirCalculator
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var activityMonitor: ActivityMonitor @Inject lateinit var activityMonitor: ActivityMonitor
@Inject lateinit var dateUtil: DateUtil
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_stats) setContentView(R.layout.activity_stats)
stats_tdds.text = tddCalculator.stats(dateUtil) stats_tdds.text = tddCalculator.stats()
stats_tir.text = tirCalculator.stats() stats_tir.text = tirCalculator.stats()
stats_activity.text = activityMonitor.stats() stats_activity.text = activityMonitor.stats()

View file

@ -31,7 +31,6 @@ class SurveyActivity : NoSplashAppCompatActivity() {
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var activityMonitor: ActivityMonitor @Inject lateinit var activityMonitor: ActivityMonitor
@Inject lateinit var defaultProfile: DefaultProfile @Inject lateinit var defaultProfile: DefaultProfile
@Inject lateinit var dateUtil: DateUtil
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -43,7 +42,7 @@ class SurveyActivity : NoSplashAppCompatActivity() {
val profileList = profileStore?.getProfileList() ?: return val profileList = profileStore?.getProfileList() ?: return
survey_spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList) survey_spinner.adapter = ArrayAdapter(this, R.layout.spinner_centered, profileList)
survey_tdds.text = tddCalculator.stats(dateUtil) survey_tdds.text = tddCalculator.stats()
survey_tir.text = tirCalculator.stats() survey_tir.text = tirCalculator.stats()
survey_activity.text = activityMonitor.stats() survey_activity.text = activityMonitor.stats()

View file

@ -170,7 +170,7 @@ class CarbsDialog : DialogFragmentWithDate() {
eventTime -= eventTime % 1000 eventTime -= eventTime % 1000
val time = eventTime + timeOffset * 1000 * 60 val time = eventTime + timeOffset * 1000 * 60
if (timeOffset != 0) if (timeOffset != 0)
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time)) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(time))
val duration = overview_carbs_duration.value.toInt() val duration = overview_carbs_duration.value.toInt()
if (duration > 0) if (duration > 0)
actions.add(resourceHelper.gs(R.string.duration) + ": " + duration + resourceHelper.gs(R.string.shorthour)) actions.add(resourceHelper.gs(R.string.duration) + ": " + duration + resourceHelper.gs(R.string.shorthour))
@ -184,7 +184,7 @@ class CarbsDialog : DialogFragmentWithDate() {
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes) actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes)
if (eventTimeChanged) if (eventTimeChanged)
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
if (carbsAfterConstraints > 0 || activitySelected || eatingSoonSelected || hypoSelected) { if (carbsAfterConstraints > 0 || activitySelected || eatingSoonSelected || hypoSelected) {
activity?.let { activity -> activity?.let { activity ->

View file

@ -167,7 +167,7 @@ class CareDialog : DialogFragmentWithDate() {
eventTime -= eventTime % 1000 eventTime -= eventTime % 1000
if (eventTimeChanged) if (eventTimeChanged)
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
json.put("created_at", DateUtil.toISOString(eventTime)) json.put("created_at", DateUtil.toISOString(eventTime))
json.put("mills", eventTime) json.put("mills", eventTime)

View file

@ -112,7 +112,7 @@ class FillDialog : DialogFragmentWithDate() {
eventTime -= eventTime % 1000 eventTime -= eventTime % 1000
if (eventTimeChanged) if (eventTimeChanged)
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
if (insulinAfterConstraints > 0 || fill_catheter_change.isChecked || fill_cartridge_change.isChecked) { if (insulinAfterConstraints > 0 || fill_catheter_change.isChecked || fill_cartridge_change.isChecked) {
activity?.let { activity -> activity?.let { activity ->

View file

@ -145,7 +145,7 @@ class InsulinDialog : DialogFragmentWithDate() {
val timeOffset = overview_insulin_time.value.toInt() val timeOffset = overview_insulin_time.value.toInt()
val time = DateUtil.now() + T.mins(timeOffset.toLong()).msecs() val time = DateUtil.now() + T.mins(timeOffset.toLong()).msecs()
if (timeOffset != 0) if (timeOffset != 0)
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(time)) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(time))
val notes = notes.text.toString() val notes = notes.text.toString()
if (notes.isNotEmpty()) if (notes.isNotEmpty())

View file

@ -98,7 +98,7 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
if (notes.isNotEmpty()) if (notes.isNotEmpty())
actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes) actions.add(resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + notes)
if (eventTimeChanged) if (eventTimeChanged)
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {

View file

@ -23,6 +23,7 @@ class ProfileViewerDialog : DaggerDialogFragment() {
@Inject lateinit var injector: HasAndroidInjector @Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var treatmentsPlugin: TreatmentsPlugin
@Inject lateinit var dateUtil: DateUtil
private var time: Long = 0 private var time: Long = 0
@ -67,7 +68,7 @@ class ProfileViewerDialog : DaggerDialogFragment() {
Mode.RUNNING_PROFILE -> { Mode.RUNNING_PROFILE -> {
profile = treatmentsPlugin.getProfileSwitchFromHistory(time)?.profileObject profile = treatmentsPlugin.getProfileSwitchFromHistory(time)?.profileObject
profileName = treatmentsPlugin.getProfileSwitchFromHistory(time)?.customizedName profileName = treatmentsPlugin.getProfileSwitchFromHistory(time)?.customizedName
date = DateUtil.dateAndTimeString(treatmentsPlugin.getProfileSwitchFromHistory(time)?.date date = dateUtil.dateAndTimeString(treatmentsPlugin.getProfileSwitchFromHistory(time)?.date
?: 0) ?: 0)
profileview_datelayout.visibility = View.VISIBLE profileview_datelayout.visibility = View.VISIBLE
} }

View file

@ -129,7 +129,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
actions.add(resourceHelper.gs(R.string.stoptemptarget)) actions.add(resourceHelper.gs(R.string.stoptemptarget))
} }
if (eventTimeChanged) if (eventTimeChanged)
actions.add(resourceHelper.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime)) actions.add(resourceHelper.gs(R.string.time) + ": " + dateUtil.dateAndTimeString(eventTime))
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {

View file

@ -54,6 +54,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
@Inject lateinit var buildHelper: BuildHelper @Inject lateinit var buildHelper: BuildHelper
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var overviewMenus: OverviewMenus @Inject lateinit var overviewMenus: OverviewMenus
@Inject lateinit var dateUtil: DateUtil
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -117,7 +118,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
cal.set(Calendar.MONTH, monthOfYear) cal.set(Calendar.MONTH, monthOfYear)
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth) cal.set(Calendar.DAY_OF_MONTH, dayOfMonth)
start = cal.timeInMillis start = cal.timeInMillis
historybrowse_date?.text = DateUtil.dateAndTimeString(start) historybrowse_date?.text = dateUtil.dateAndTimeString(start)
updateGUI("onClickDate") updateGUI("onClickDate")
runCalculation("onClickDate") runCalculation("onClickDate")
} }
@ -236,7 +237,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
val lowLine = defaultValueHelper.determineLowLine() val lowLine = defaultValueHelper.determineLowLine()
val highLine = defaultValueHelper.determineHighLine() val highLine = defaultValueHelper.determineHighLine()
historybrowse_date?.text = DateUtil.dateAndTimeString(start) historybrowse_date?.text = dateUtil.dateAndTimeString(start)
historybrowse_zoom?.text = rangeToDisplay.toString() historybrowse_zoom?.text = rangeToDisplay.toString()
GlobalScope.launch(Dispatchers.Main) { GlobalScope.launch(Dispatchers.Main) {
@ -248,7 +249,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
withContext(Dispatchers.Default) { withContext(Dispatchers.Default) {
val fromTime: Long = start + T.secs(100).msecs() val fromTime: Long = start + T.secs(100).msecs()
val toTime: Long = start + T.hours(rangeToDisplay.toLong()).msecs() val toTime: Long = start + T.hours(rangeToDisplay.toLong()).msecs()
aapsLogger.debug(LTag.UI, "Period: " + DateUtil.dateAndTimeString(fromTime) + " - " + DateUtil.dateAndTimeString(toTime)) aapsLogger.debug(LTag.UI, "Period: " + dateUtil.dateAndTimeString(fromTime) + " - " + dateUtil.dateAndTimeString(toTime))
val pointer = System.currentTimeMillis() val pointer = System.currentTimeMillis()
// **** In range Area **** // **** In range Area ****

View file

@ -10,6 +10,7 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
@ -27,9 +28,10 @@ class IobCobStaticCalculatorPlugin @Inject constructor(
sensitivityOref1Plugin: SensitivityOref1Plugin, sensitivityOref1Plugin: SensitivityOref1Plugin,
sensitivityAAPSPlugin: SensitivityAAPSPlugin, sensitivityAAPSPlugin: SensitivityAAPSPlugin,
sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin, sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin,
fabricPrivacy: FabricPrivacy fabricPrivacy: FabricPrivacy,
dateUtil: DateUtil
) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction, ) : IobCobCalculatorPlugin(injector, aapsLogger, rxBus, sp, resourceHelper, profileFunction,
activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy) { activePlugin, treatmentsPlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil) {
override fun onStart() { // do not attach to rxbus override fun onStart() { // do not attach to rxbus
} }

View file

@ -29,6 +29,7 @@ class LoopFragment : DaggerFragment() {
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var loopPlugin: LoopPlugin @Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var dateUtil: DateUtil
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
@ -81,12 +82,12 @@ class LoopFragment : DaggerFragment() {
loop_request?.text = it.request?.toSpanned() ?: "" loop_request?.text = it.request?.toSpanned() ?: ""
loop_constraintsprocessed?.text = it.constraintsProcessed?.toSpanned() ?: "" loop_constraintsprocessed?.text = it.constraintsProcessed?.toSpanned() ?: ""
loop_source?.text = it.source ?: "" loop_source?.text = it.source ?: ""
loop_lastrun?.text = DateUtil.dateAndTimeString(it.lastAPSRun) loop_lastrun?.text = dateUtil.dateAndTimeString(it.lastAPSRun)
?: "" ?: ""
loop_smbrequest_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastSMBRequest) loop_smbrequest_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastSMBRequest)
loop_smbexecution_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastSMBEnact) loop_smbexecution_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastSMBEnact)
loop_tbrrequest_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest) loop_tbrrequest_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBRRequest)
loop_tbrexecution_time?.text = DateUtil.dateAndTimeAndSecondsString(it.lastTBREnact) loop_tbrexecution_time?.text = dateUtil.dateAndTimeAndSecondsString(it.lastTBREnact)
loop_tbrsetbypump?.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) } loop_tbrsetbypump?.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) }
?: "" ?: ""

View file

@ -32,6 +32,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin @Inject lateinit var openAPSAMAPlugin: OpenAPSAMAPlugin
@Inject lateinit var dateUtil: DateUtil
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View? {
@ -96,7 +97,7 @@ class OpenAPSAMAFragment : DaggerFragment() {
openapsma_scriptdebugdata.text = determineBasalAdapterAMAJS.scriptDebug openapsma_scriptdebugdata.text = determineBasalAdapterAMAJS.scriptDebug
} }
if (openAPSAMAPlugin.lastAPSRun != 0L) { if (openAPSAMAPlugin.lastAPSRun != 0L) {
openapsma_lastrun.text = DateUtil.dateAndTimeString(openAPSAMAPlugin.lastAPSRun) openapsma_lastrun.text = dateUtil.dateAndTimeString(openAPSAMAPlugin.lastAPSRun)
} }
openAPSAMAPlugin.lastAutosensResult?.let { openAPSAMAPlugin.lastAutosensResult?.let {
openapsma_autosensdata.text = JSONFormatter.format(it.json()) openapsma_autosensdata.text = JSONFormatter.format(it.json())

View file

@ -33,6 +33,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin @Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
@Inject lateinit var dateUtil: DateUtil
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View? {
@ -99,7 +100,7 @@ class OpenAPSSMBFragment : DaggerFragment() {
} }
} }
if (openAPSSMBPlugin.lastAPSRun != 0L) { if (openAPSSMBPlugin.lastAPSRun != 0L) {
openapsma_lastrun.text = DateUtil.dateAndTimeString(openAPSSMBPlugin.lastAPSRun) openapsma_lastrun.text = dateUtil.dateAndTimeString(openAPSSMBPlugin.lastAPSRun)
} }
openAPSSMBPlugin.lastAutosensResult?.let { openAPSSMBPlugin.lastAutosensResult?.let {
openapsma_autosensdata.text = JSONFormatter.format(it.json()) openapsma_autosensdata.text = JSONFormatter.format(it.json())

View file

@ -49,6 +49,8 @@ class ObjectivesFragment : DaggerFragment() {
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var objectivesPlugin: ObjectivesPlugin @Inject lateinit var objectivesPlugin: ObjectivesPlugin
@Inject lateinit var receiverStatusStore: ReceiverStatusStore @Inject lateinit var receiverStatusStore: ReceiverStatusStore
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var sntpClient: SntpClient
private val objectivesAdapter = ObjectivesAdapter() private val objectivesAdapter = ObjectivesAdapter()
private val handler = Handler(Looper.getMainLooper()) private val handler = Handler(Looper.getMainLooper())
@ -221,7 +223,7 @@ class ObjectivesFragment : DaggerFragment() {
holder.progress.addView(separator, LinearLayout.LayoutParams.MATCH_PARENT, 2) holder.progress.addView(separator, LinearLayout.LayoutParams.MATCH_PARENT, 2)
} }
} }
holder.accomplished.text = resourceHelper.gs(R.string.accomplished, DateUtil.dateAndTimeString(objective.accomplishedOn)) holder.accomplished.text = resourceHelper.gs(R.string.accomplished, dateUtil.dateAndTimeString(objective.accomplishedOn))
holder.accomplished.setTextColor(-0x3e3e3f) holder.accomplished.setTextColor(-0x3e3e3f)
holder.verify.setOnClickListener { holder.verify.setOnClickListener {
receiverStatusStore.updateNetworkStatus() receiverStatusStore.updateNetworkStatus()
@ -236,7 +238,7 @@ class ObjectivesFragment : DaggerFragment() {
Thread { Thread {
NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck") NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck")
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0)) rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0))
SntpClient.ntpTime(object : SntpClient.Callback() { sntpClient.ntpTime(object : SntpClient.Callback() {
override fun run() { override fun run() {
aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}") aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}")
SystemClock.sleep(300) SystemClock.sleep(300)
@ -275,7 +277,7 @@ class ObjectivesFragment : DaggerFragment() {
Thread { Thread {
NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck") NtpProgressDialog().show((context as AppCompatActivity).supportFragmentManager, "NtpCheck")
rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0)) rxBus.send(EventNtpStatus(resourceHelper.gs(R.string.timedetection), 0))
SntpClient.ntpTime(object : SntpClient.Callback() { sntpClient.ntpTime(object : SntpClient.Callback() {
override fun run() { override fun run() {
aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}") aapsLogger.debug("NTP time: $time System time: ${DateUtil.now()}")
SystemClock.sleep(300) SystemClock.sleep(300)

View file

@ -248,7 +248,7 @@ class ActionsFragment : DaggerFragment() {
private fun checkPumpCustomActions() { private fun checkPumpCustomActions() {
val activePump = activePlugin.activePump val activePump = activePlugin.activePump
val customActions = activePump.customActions val customActions = activePump.customActions ?: return
removePumpCustomActions() removePumpCustomActions()
for (customAction in customActions) { for (customAction in customActions) {

View file

@ -12,8 +12,11 @@ import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.JsonHelper import info.nightscout.androidaps.utils.JsonHelper
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import org.json.JSONObject import org.json.JSONObject
import javax.inject.Inject
class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) { class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) {
@Inject lateinit var dateUtil: DateUtil
var time = InputDateTime(injector) var time = InputDateTime(injector)
constructor(injector: HasAndroidInjector, runAt: Long) : this(injector) { constructor(injector: HasAndroidInjector, runAt: Long) : this(injector) {
@ -57,7 +60,7 @@ class TriggerTime(injector: HasAndroidInjector) : Trigger(injector) {
override fun friendlyName(): Int = R.string.time override fun friendlyName(): Int = R.string.time
override fun friendlyDescription(): String = override fun friendlyDescription(): String =
resourceHelper.gs(R.string.atspecifiedtime, DateUtil.dateAndTimeString(time.value)) resourceHelper.gs(R.string.atspecifiedtime, dateUtil.dateAndTimeString(time.value))
override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp) override fun icon(): Optional<Int?> = Optional.of(R.drawable.ic_access_alarm_24dp)

View file

@ -699,7 +699,7 @@ public class NewNSTreatmentDialog extends DaggerDialogFragment implements View.O
if (data.has("created_at")) { if (data.has("created_at")) {
ret += resourceHelper.gs(R.string.event_time_label); ret += resourceHelper.gs(R.string.event_time_label);
ret += ": "; ret += ": ";
ret += DateUtil.dateAndTimeString(eventTime); ret += dateUtil.dateAndTimeString(eventTime);
ret += "\n"; ret += "\n";
} }
if (data.has("enteredBy")) { if (data.has("enteredBy")) {

View file

@ -90,6 +90,7 @@ public class NSClientService extends DaggerService {
@Inject NSClientPlugin nsClientPlugin; @Inject NSClientPlugin nsClientPlugin;
@Inject BuildHelper buildHelper; @Inject BuildHelper buildHelper;
@Inject Config config; @Inject Config config;
@Inject DateUtil dateUtil;
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT); private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
@ -721,7 +722,7 @@ public class NSClientService extends DaggerService {
} }
handleNewSgv(sgvs, isDelta); handleNewSgv(sgvs, isDelta);
} }
rxBus.send(new EventNSClientNewLog("LAST", DateUtil.dateAndTimeString(latestDateInReceivedData))); rxBus.send(new EventNSClientNewLog("LAST", dateUtil.dateAndTimeString(latestDateInReceivedData)));
} catch (JSONException e) { } catch (JSONException e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }

View file

@ -38,7 +38,8 @@ class TidepoolUploader @Inject constructor(
private val resourceHelper: ResourceHelper, private val resourceHelper: ResourceHelper,
private val sp: SP, private val sp: SP,
private val uploadChunk: UploadChunk, private val uploadChunk: UploadChunk,
private val activePlugin: ActivePluginProvider private val activePlugin: ActivePluginProvider,
private val dateUtil: DateUtil
) { ) {
private var wl: PowerManager.WakeLock? = null private var wl: PowerManager.WakeLock? = null
@ -233,7 +234,7 @@ class TidepoolUploader @Inject constructor(
private fun uploadNext() { private fun uploadNext() {
if (uploadChunk.getLastEnd() < DateUtil.now() - T.mins(1).msecs()) { if (uploadChunk.getLastEnd() < DateUtil.now() - T.mins(1).msecs()) {
SystemClock.sleep(3000) SystemClock.sleep(3000)
aapsLogger.debug(LTag.TIDEPOOL, "Restarting doUpload. Last: " + DateUtil.dateAndTimeString(uploadChunk.getLastEnd())) aapsLogger.debug(LTag.TIDEPOOL, "Restarting doUpload. Last: " + dateUtil.dateAndTimeString(uploadChunk.getLastEnd()))
doUpload() doUpload()
} }
} }

View file

@ -29,7 +29,8 @@ class UploadChunk @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
private val treatmentsPlugin: TreatmentsPlugin, private val treatmentsPlugin: TreatmentsPlugin,
private val activePlugin: ActivePluginProvider private val activePlugin: ActivePluginProvider,
private val dateUtil: DateUtil
) { ) {
private val MAX_UPLOAD_SIZE = T.days(7).msecs() // don't change this private val MAX_UPLOAD_SIZE = T.days(7).msecs() // don't change this
@ -51,9 +52,9 @@ class UploadChunk @Inject constructor(
operator fun get(start: Long, end: Long): String { operator fun get(start: Long, end: Long): String {
aapsLogger.debug(LTag.TIDEPOOL, "Syncing data between: " + DateUtil.dateAndTimeString(start) + " -> " + DateUtil.dateAndTimeString(end)) aapsLogger.debug(LTag.TIDEPOOL, "Syncing data between: " + dateUtil.dateAndTimeString(start) + " -> " + dateUtil.dateAndTimeString(end))
if (end <= start) { if (end <= start) {
aapsLogger.debug(LTag.TIDEPOOL, "End is <= start: " + DateUtil.dateAndTimeString(start) + " " + DateUtil.dateAndTimeString(end)) aapsLogger.debug(LTag.TIDEPOOL, "End is <= start: " + dateUtil.dateAndTimeString(start) + " " + dateUtil.dateAndTimeString(end))
return "" return ""
} }
if (end - start > MAX_UPLOAD_SIZE) { if (end - start > MAX_UPLOAD_SIZE) {
@ -85,11 +86,11 @@ class UploadChunk @Inject constructor(
fun setLastEnd(time: Long) { fun setLastEnd(time: Long) {
if (time > getLastEnd()) { if (time > getLastEnd()) {
sp.putLong(R.string.key_tidepool_last_end, time) sp.putLong(R.string.key_tidepool_last_end, time)
val friendlyEnd = DateUtil.dateAndTimeString(time) val friendlyEnd = dateUtil.dateAndTimeString(time)
rxBus.send(EventTidepoolStatus(("Marking uploaded data up to $friendlyEnd"))) rxBus.send(EventTidepoolStatus(("Marking uploaded data up to $friendlyEnd")))
aapsLogger.debug(LTag.TIDEPOOL, "Updating last end to: " + DateUtil.dateAndTimeString(time)) aapsLogger.debug(LTag.TIDEPOOL, "Updating last end to: " + dateUtil.dateAndTimeString(time))
} else { } else {
aapsLogger.debug(LTag.TIDEPOOL, "Cannot set last end to: " + DateUtil.dateAndTimeString(time) + " vs " + DateUtil.dateAndTimeString(getLastEnd())) aapsLogger.debug(LTag.TIDEPOOL, "Cannot set last end to: " + dateUtil.dateAndTimeString(time) + " vs " + dateUtil.dateAndTimeString(getLastEnd()))
} }
} }
@ -129,7 +130,7 @@ class UploadChunk @Inject constructor(
} }
internal fun getBgReadings(start: Long, end: Long): List<SensorGlucoseElement> { private fun getBgReadings(start: Long, end: Long): List<SensorGlucoseElement> {
val readings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, end, true) val readings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, end, true)
val selection = SensorGlucoseElement.fromBgReadings(readings) val selection = SensorGlucoseElement.fromBgReadings(readings)
if (selection.isNotEmpty()) if (selection.isNotEmpty())

View file

@ -69,6 +69,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
private final SensitivityAAPSPlugin sensitivityAAPSPlugin; private final SensitivityAAPSPlugin sensitivityAAPSPlugin;
private final SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin; private final SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin;
private final FabricPrivacy fabricPrivacy; private final FabricPrivacy fabricPrivacy;
private final DateUtil dateUtil;
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
@ -98,7 +99,8 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
SensitivityOref1Plugin sensitivityOref1Plugin, SensitivityOref1Plugin sensitivityOref1Plugin,
SensitivityAAPSPlugin sensitivityAAPSPlugin, SensitivityAAPSPlugin sensitivityAAPSPlugin,
SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin, SensitivityWeightedAveragePlugin sensitivityWeightedAveragePlugin,
FabricPrivacy fabricPrivacy FabricPrivacy fabricPrivacy,
DateUtil dateUtil
) { ) {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.GENERAL) .mainType(PluginType.GENERAL)
@ -119,6 +121,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
this.sensitivityAAPSPlugin = sensitivityAAPSPlugin; this.sensitivityAAPSPlugin = sensitivityAAPSPlugin;
this.sensitivityWeightedAveragePlugin = sensitivityWeightedAveragePlugin; this.sensitivityWeightedAveragePlugin = sensitivityWeightedAveragePlugin;
this.fabricPrivacy = fabricPrivacy; this.fabricPrivacy = fabricPrivacy;
this.dateUtil = dateUtil;
} }
@Override @Override
@ -247,10 +250,10 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
// if close to now expect there can be some readings with time in close future (caused by wrong time setting) // if close to now expect there can be some readings with time in close future (caused by wrong time setting)
// so read all records // so read all records
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, false); bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, false);
getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start)); getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + dateUtil.dateAndTimeString(start));
} else { } else {
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, to, false); bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, to, false);
getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(to)); getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + dateUtil.dateAndTimeString(start) + " End date: " + dateUtil.dateAndTimeString(to));
} }
} }
@ -440,7 +443,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
if (limitDataToOldestAvailable) { if (limitDataToOldestAvailable) {
getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia))); getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia)));
if (getBGDataFrom == oldestDataAvailable) if (getBGDataFrom == oldestDataAvailable)
getAapsLogger().debug(LTag.AUTOSENS, "Limiting data to oldest available temps: " + DateUtil.dateAndTimeString(oldestDataAvailable)); getAapsLogger().debug(LTag.AUTOSENS, "Limiting data to oldest available temps: " + dateUtil.dateAndTimeString(oldestDataAvailable));
} else } else
getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia)); getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia));
return getBGDataFrom; return getBGDataFrom;
@ -675,7 +678,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
return null; return null;
} }
if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) { if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) {
getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time)); getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + dateUtil.dateAndTimeString(data.time));
return null; return null;
} else { } else {
getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA (" + reason + ") " + data.toString()); getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA (" + reason + ") " + data.toString());
@ -686,7 +689,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
@Override @Override
public String lastDataTime() { public String lastDataTime() {
if (autosensDataTable.size() > 0) if (autosensDataTable.size() > 0)
return DateUtil.dateAndTimeString(autosensDataTable.valueAt(autosensDataTable.size() - 1).time); return dateUtil.dateAndTimeString(autosensDataTable.valueAt(autosensDataTable.size() - 1).time);
else else
return "autosensDataTable empty"; return "autosensDataTable empty";
} }
@ -808,7 +811,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
} }
public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) { public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) {
getAapsLogger().debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end)); getAapsLogger().debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + dateUtil.dateAndTimeString(end));
if (thread == null || thread.getState() == Thread.State.TERMINATED) { if (thread == null || thread.getState() == Thread.State.TERMINATED) {
if (sensitivityOref1Plugin.isEnabled()) if (sensitivityOref1Plugin.isEnabled())
thread = new IobCobOref1Thread(injector, from, end, bgDataReload, limitDataToOldestAvailable, cause); thread = new IobCobOref1Thread(injector, from, end, bgDataReload, limitDataToOldestAvailable, cause);
@ -825,10 +828,10 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
synchronized (dataLock) { synchronized (dataLock) {
// clear up 5 min back for proper COB calculation // clear up 5 min back for proper COB calculation
long time = ev.getTime() - 5 * 60 * 1000L; long time = ev.getTime() - 5 * 60 * 1000L;
getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data to: " + DateUtil.dateAndTimeString(time)); getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data to: " + dateUtil.dateAndTimeString(time));
for (int index = iobTable.size() - 1; index >= 0; index--) { for (int index = iobTable.size() - 1; index >= 0; index--) {
if (iobTable.keyAt(index) > time) { if (iobTable.keyAt(index) > time) {
getAapsLogger().debug(LTag.AUTOSENS, "Removing from iobTable: " + DateUtil.dateAndTimeString(iobTable.keyAt(index))); getAapsLogger().debug(LTag.AUTOSENS, "Removing from iobTable: " + dateUtil.dateAndTimeString(iobTable.keyAt(index)));
iobTable.removeAt(index); iobTable.removeAt(index);
} else { } else {
break; break;
@ -836,7 +839,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
} }
for (int index = absIobTable.size() - 1; index >= 0; index--) { for (int index = absIobTable.size() - 1; index >= 0; index--) {
if (absIobTable.keyAt(index) > time) { if (absIobTable.keyAt(index) > time) {
getAapsLogger().debug(LTag.AUTOSENS, "Removing from absIobTable: " + DateUtil.dateAndTimeString(absIobTable.keyAt(index))); getAapsLogger().debug(LTag.AUTOSENS, "Removing from absIobTable: " + dateUtil.dateAndTimeString(absIobTable.keyAt(index)));
absIobTable.removeAt(index); absIobTable.removeAt(index);
} else { } else {
break; break;
@ -844,7 +847,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
} }
for (int index = autosensDataTable.size() - 1; index >= 0; index--) { for (int index = autosensDataTable.size() - 1; index >= 0; index--) {
if (autosensDataTable.keyAt(index) > time) { if (autosensDataTable.keyAt(index) > time) {
getAapsLogger().debug(LTag.AUTOSENS, "Removing from autosensDataTable: " + DateUtil.dateAndTimeString(autosensDataTable.keyAt(index))); getAapsLogger().debug(LTag.AUTOSENS, "Removing from autosensDataTable: " + dateUtil.dateAndTimeString(autosensDataTable.keyAt(index)));
autosensDataTable.removeAt(index); autosensDataTable.removeAt(index);
} else { } else {
break; break;
@ -852,7 +855,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
} }
for (int index = basalDataTable.size() - 1; index >= 0; index--) { for (int index = basalDataTable.size() - 1; index >= 0; index--) {
if (basalDataTable.keyAt(index) > time) { if (basalDataTable.keyAt(index) > time) {
getAapsLogger().debug(LTag.AUTOSENS, "Removing from basalDataTable: " + DateUtil.dateAndTimeString(basalDataTable.keyAt(index))); getAapsLogger().debug(LTag.AUTOSENS, "Removing from basalDataTable: " + dateUtil.dateAndTimeString(basalDataTable.keyAt(index)));
basalDataTable.removeAt(index); basalDataTable.removeAt(index);
} else { } else {
break; break;

View file

@ -68,6 +68,7 @@ public class IobCobOref1Thread extends Thread {
@Inject BuildHelper buildHelper; @Inject BuildHelper buildHelper;
@Inject Profiler profiler; @Inject Profiler profiler;
@Inject FabricPrivacy fabricPrivacy; @Inject FabricPrivacy fabricPrivacy;
@Inject DateUtil dateUtil;
private final HasAndroidInjector injector; private final HasAndroidInjector injector;
private boolean bgDataReload; private boolean bgDataReload;
@ -122,7 +123,7 @@ public class IobCobOref1Thread extends Thread {
} }
long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date);
aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + DateUtil.dateAndTimeString(prevDataTime)); aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + dateUtil.dateAndTimeString(prevDataTime));
AutosensData previous = autosensDataTable.get(prevDataTime); AutosensData previous = autosensDataTable.get(prevDataTime);
// start from oldest to be able sub cob // start from oldest to be able sub cob
for (int i = bucketed_data.size() - 4; i >= 0; i--) { for (int i = bucketed_data.size() - 4; i >= 0; i--) {
@ -378,7 +379,7 @@ public class IobCobOref1Thread extends Thread {
previous = autosensData; previous = autosensData;
if (bgTime < now()) if (bgTime < now())
autosensDataTable.put(bgTime, autosensData); autosensDataTable.put(bgTime, autosensData);
aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()); aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime());
AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime);
aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: " + sensitivity.toString()); aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: " + sensitivity.toString());
autosensData.autosensResult = sensitivity; autosensData.autosensResult = sensitivity;

View file

@ -65,6 +65,7 @@ public class IobCobThread extends Thread {
@Inject BuildHelper buildHelper; @Inject BuildHelper buildHelper;
@Inject Profiler profiler; @Inject Profiler profiler;
@Inject FabricPrivacy fabricPrivacy; @Inject FabricPrivacy fabricPrivacy;
@Inject DateUtil dateUtil;
private final HasAndroidInjector injector; private final HasAndroidInjector injector;
private boolean bgDataReload; private boolean bgDataReload;
@ -119,7 +120,7 @@ public class IobCobThread extends Thread {
} }
long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date);
aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + DateUtil.dateAndTimeString(prevDataTime)); aapsLogger.debug(LTag.AUTOSENS, "Prev data time: " + dateUtil.dateAndTimeString(prevDataTime));
AutosensData previous = autosensDataTable.get(prevDataTime); AutosensData previous = autosensDataTable.get(prevDataTime);
// start from oldest to be able sub cob // start from oldest to be able sub cob
for (int i = bucketed_data.size() - 4; i >= 0; i--) { for (int i = bucketed_data.size() - 4; i >= 0; i--) {
@ -302,7 +303,7 @@ public class IobCobThread extends Thread {
previous = autosensData; previous = autosensData;
if (bgTime < now()) if (bgTime < now())
autosensDataTable.put(bgTime, autosensData); autosensDataTable.put(bgTime, autosensData);
aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + DateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + DateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime()); aapsLogger.debug(LTag.AUTOSENS, "Running detectSensitivity from: " + dateUtil.dateAndTimeString(oldestTimeWithData) + " to: " + dateUtil.dateAndTimeString(bgTime) + " lastDataTime:" + iobCobCalculatorPlugin.lastDataTime());
AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime); AutosensResult sensitivity = iobCobCalculatorPlugin.detectSensitivityWithLock(oldestTimeWithData, bgTime);
aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: " + sensitivity.toString()); aapsLogger.debug(LTag.AUTOSENS, "Sensitivity result: " + sensitivity.toString());
autosensData.autosensResult = sensitivity; autosensData.autosensResult = sensitivity;

View file

@ -14,6 +14,7 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.data.Profile import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA
import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged
@ -28,12 +29,14 @@ import java.text.DecimalFormat
import javax.inject.Inject import javax.inject.Inject
class LocalProfileFragment : DaggerFragment() { class LocalProfileFragment : DaggerFragment() {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var localProfilePlugin: LocalProfilePlugin @Inject lateinit var localProfilePlugin: LocalProfilePlugin
@Inject lateinit var hardLimits: HardLimits @Inject lateinit var hardLimits: HardLimits
@Inject lateinit var dateUtil: DateUtil
private var disposable: CompositeDisposable = CompositeDisposable() private var disposable: CompositeDisposable = CompositeDisposable()
@ -103,14 +106,14 @@ class LocalProfileFragment : DaggerFragment() {
localprofile_name.addTextChangedListener(textWatch) localprofile_name.addTextChangedListener(textWatch)
localprofile_dia.setParams(localProfilePlugin.currentProfile().dia, hardLimits.MINDIA, hardLimits.MAXDIA, 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch) localprofile_dia.setParams(localProfilePlugin.currentProfile().dia, hardLimits.MINDIA, hardLimits.MAXDIA, 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch)
localprofile_dia.tag = "LP_DIA" localprofile_dia.tag = "LP_DIA"
TimeListEdit(context, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.nsprofileview_ic_label), localProfilePlugin.currentProfile().ic, null, hardLimits.MINIC, hardLimits.MAXIC, 0.1, DecimalFormat("0.0"), save) TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.nsprofileview_ic_label), localProfilePlugin.currentProfile().ic, null, hardLimits.MINIC, hardLimits.MAXIC, 0.1, DecimalFormat("0.0"), save)
basalView = TimeListEdit(context, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.nsprofileview_basal_label) + ": " + sumLabel(), localProfilePlugin.currentProfile().basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save) basalView = TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.nsprofileview_basal_label) + ": " + sumLabel(), localProfilePlugin.currentProfile().basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save)
if (units == Constants.MGDL) { if (units == Constants.MGDL) {
TimeListEdit(context, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label), localProfilePlugin.currentProfile().isf, null, hardLimits.MINISF, hardLimits.MAXISF, 1.0, DecimalFormat("0"), save) TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label), localProfilePlugin.currentProfile().isf, null, hardLimits.MINISF, hardLimits.MAXISF, 1.0, DecimalFormat("0"), save)
TimeListEdit(context, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label), localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, hardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), hardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), 1.0, DecimalFormat("0"), save) TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label), localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, hardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), hardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), 1.0, DecimalFormat("0"), save)
} else { } else {
TimeListEdit(context, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label), localProfilePlugin.currentProfile().isf, null, Profile.fromMgdlToUnits(hardLimits.MINISF, Constants.MMOL), Profile.fromMgdlToUnits(hardLimits.MAXISF, Constants.MMOL), 0.1, DecimalFormat("0.0"), save) TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label), localProfilePlugin.currentProfile().isf, null, Profile.fromMgdlToUnits(hardLimits.MINISF, Constants.MMOL), Profile.fromMgdlToUnits(hardLimits.MAXISF, Constants.MMOL), 0.1, DecimalFormat("0.0"), save)
TimeListEdit(context, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label), localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, Profile.fromMgdlToUnits(hardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), Constants.MMOL), Profile.fromMgdlToUnits(hardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), Constants.MMOL), 0.1, DecimalFormat("0.0"), save) TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label), localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, Profile.fromMgdlToUnits(hardLimits.VERY_HARD_LIMIT_TARGET_BG[0].toDouble(), Constants.MMOL), Profile.fromMgdlToUnits(hardLimits.VERY_HARD_LIMIT_TARGET_BG[1].toDouble(), Constants.MMOL), 0.1, DecimalFormat("0.0"), save)
} }
// Spinner // Spinner
@ -187,10 +190,10 @@ class LocalProfileFragment : DaggerFragment() {
localprofile_units.text = resourceHelper.gs(R.string.units_colon) + " " + (if (localProfilePlugin.currentProfile().mgdl) resourceHelper.gs(R.string.mgdl) else resourceHelper.gs(R.string.mmol)) localprofile_units.text = resourceHelper.gs(R.string.units_colon) + " " + (if (localProfilePlugin.currentProfile().mgdl) resourceHelper.gs(R.string.mgdl) else resourceHelper.gs(R.string.mmol))
localprofile_dia.setParams(localProfilePlugin.currentProfile().dia, MIN_DIA, 12.0, 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch) localprofile_dia.setParams(localProfilePlugin.currentProfile().dia, MIN_DIA, 12.0, 0.1, DecimalFormat("0.0"), false, localprofile_save, textWatch)
localprofile_dia.tag = "LP_DIA" localprofile_dia.tag = "LP_DIA"
TimeListEdit(context, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.nsprofileview_ic_label) + ":", localProfilePlugin.currentProfile().ic, null, 0.5, 50.0, 0.1, DecimalFormat("0.0"), save) TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_ic, "IC", resourceHelper.gs(R.string.nsprofileview_ic_label) + ":", localProfilePlugin.currentProfile().ic, null, 0.5, 50.0, 0.1, DecimalFormat("0.0"), save)
TimeListEdit(context, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label) + ":", localProfilePlugin.currentProfile().isf, null, 0.5, 500.0, 0.1, DecimalFormat("0.0"), save) TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_isf, "ISF", resourceHelper.gs(R.string.nsprofileview_isf_label) + ":", localProfilePlugin.currentProfile().isf, null, 0.5, 500.0, 0.1, DecimalFormat("0.0"), save)
basalView = TimeListEdit(context, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.nsprofileview_basal_label) + ": " + sumLabel(), localProfilePlugin.currentProfile().basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save) basalView = TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_basal, "BASAL", resourceHelper.gs(R.string.nsprofileview_basal_label) + ": " + sumLabel(), localProfilePlugin.currentProfile().basal, null, pumpDescription.basalMinimumRate, 10.0, 0.01, DecimalFormat("0.00"), save)
TimeListEdit(context, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label) + ":", localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, 3.0, 200.0, 0.1, DecimalFormat("0.0"), save) TimeListEdit(context, aapsLogger, dateUtil, view, R.id.localprofile_target, "TARGET", resourceHelper.gs(R.string.nsprofileview_target_label) + ":", localProfilePlugin.currentProfile().targetLow, localProfilePlugin.currentProfile().targetHigh, 3.0, 200.0, 0.1, DecimalFormat("0.0"), save)
updateGUI() updateGUI()
} }

View file

@ -65,6 +65,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
protected ResourceHelper resourceHelper; protected ResourceHelper resourceHelper;
protected CommandQueueProvider commandQueue; protected CommandQueueProvider commandQueue;
protected SP sp; protected SP sp;
protected DateUtil dateUtil;
/* /*
protected static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult().success(false) protected static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult().success(false)
@ -92,7 +93,8 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
ActivePluginProvider activePlugin, ActivePluginProvider activePlugin,
SP sp, SP sp,
Context context, Context context,
FabricPrivacy fabricPrivacy FabricPrivacy fabricPrivacy,
DateUtil dateUtil
) { ) {
super(pluginDescription, injector, aapsLogger, resourceHelper, commandQueue); super(pluginDescription, injector, aapsLogger, resourceHelper, commandQueue);
@ -107,7 +109,7 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
pumpDescription.setPumpDescription(pumpType); pumpDescription.setPumpDescription(pumpType);
this.pumpType = pumpType; this.pumpType = pumpType;
this.dateUtil = dateUtil;
} }
@ -345,14 +347,14 @@ public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpI
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", extended.put("TempBasalAbsoluteRate",
tb.tempBasalConvertedToAbsolute(System.currentTimeMillis(), profile)); tb.tempBasalConvertedToAbsolute(System.currentTimeMillis(), profile));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = activePlugin.getActiveTreatments().getExtendedBolusFromHistory(System.currentTimeMillis()); ExtendedBolus eb = activePlugin.getActiveTreatments().getExtendedBolusFromHistory(System.currentTimeMillis());
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date));
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes()); extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
} }

View file

@ -32,6 +32,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus; import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.resources.ResourceHelper;
/** /**
@ -45,6 +46,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
@Inject MedtronicUtil medtronicUtil; @Inject MedtronicUtil medtronicUtil;
@Inject AAPSLogger aapsLogger; @Inject AAPSLogger aapsLogger;
@Inject RileyLinkServiceData rileyLinkServiceData; @Inject RileyLinkServiceData rileyLinkServiceData;
@Inject DateUtil dateUtil;
TextView connectionStatus; TextView connectionStatus;
TextView configuredAddress; TextView configuredAddress;
@ -148,7 +150,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
rileyLinkServiceData.lastGoodFrequency)); rileyLinkServiceData.lastGoodFrequency));
if (medtronicPumpStatus.lastConnection != 0) if (medtronicPumpStatus.lastConnection != 0)
this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime( this.lastDeviceContact.setText(StringUtil.toDateTimeString(dateUtil, new LocalDateTime(
medtronicPumpStatus.lastDataTime))); medtronicPumpStatus.lastDataTime)));
else else
this.lastDeviceContact.setText(resourceHelper.gs(R.string.common_never)); this.lastDeviceContact.setText(resourceHelper.gs(R.string.common_never));
@ -182,7 +184,7 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
rileyLinkServiceData.lastGoodFrequency)); rileyLinkServiceData.lastGoodFrequency));
if (omnipodPumpStatus.lastConnection != 0) if (omnipodPumpStatus.lastConnection != 0)
this.lastDeviceContact.setText(StringUtil.toDateTimeString(new LocalDateTime( this.lastDeviceContact.setText(StringUtil.toDateTimeString(dateUtil, new LocalDateTime(
omnipodPumpStatus.lastDataTime))); omnipodPumpStatus.lastDataTime)));
else else
this.lastDeviceContact.setText(resourceHelper.gs(R.string.common_never)); this.lastDeviceContact.setText(resourceHelper.gs(R.string.common_never));

View file

@ -34,6 +34,7 @@ public class RileyLinkStatusHistoryFragment extends DaggerFragment implements Re
@Inject RileyLinkUtil rileyLinkUtil; @Inject RileyLinkUtil rileyLinkUtil;
@Inject ResourceHelper resourceHelper; @Inject ResourceHelper resourceHelper;
@Inject DateUtil dateUtil;
RecyclerView recyclerView; RecyclerView recyclerView;
RecyclerViewAdapter recyclerViewAdapter; RecyclerViewAdapter recyclerViewAdapter;
@ -136,7 +137,7 @@ public class RileyLinkStatusHistoryFragment extends DaggerFragment implements Re
RLHistoryItem item = historyList.get(position); RLHistoryItem item = historyList.get(position);
if (item != null) { if (item != null) {
holder.timeView.setText(DateUtil.dateAndTimeAndSecondsString(item.getDateTime().toDateTime().getMillis())); holder.timeView.setText(dateUtil.dateAndTimeAndSecondsString(item.getDateTime().toDateTime().getMillis()));
holder.typeView.setText(item.getSource().getDesc()); holder.typeView.setText(item.getSource().getDesc());
holder.valueView.setText(item.getDescription(resourceHelper)); holder.valueView.setText(item.getDescription(resourceHelper));
} }

View file

@ -84,8 +84,8 @@ public class StringUtil {
} }
public static String toDateTimeString(LocalDateTime localDateTime) { public static String toDateTimeString(DateUtil dateUtil, LocalDateTime localDateTime) {
return DateUtil.dateAndTimeAndSecondsString(localDateTime.toDateTime().getMillis()); return dateUtil.dateAndTimeAndSecondsString(localDateTime.toDateTime().getMillis());
//return localDateTime.toString("dd.MM.yyyy HH:mm:ss"); //return localDateTime.toString("dd.MM.yyyy HH:mm:ss");
} }

View file

@ -59,6 +59,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
protected RxBusWrapper rxBus; protected RxBusWrapper rxBus;
protected TreatmentsPlugin treatmentsPlugin; protected TreatmentsPlugin treatmentsPlugin;
protected SP sp; protected SP sp;
protected DateUtil dateUtil;
protected AbstractDanaRPlugin( protected AbstractDanaRPlugin(
HasAndroidInjector injector, HasAndroidInjector injector,
@ -69,7 +70,8 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
CommandQueueProvider commandQueue, CommandQueueProvider commandQueue,
RxBusWrapper rxBus, RxBusWrapper rxBus,
TreatmentsPlugin treatmentsPlugin, TreatmentsPlugin treatmentsPlugin,
SP sp SP sp,
DateUtil dateUtil
) { ) {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.PUMP) .mainType(PluginType.PUMP)
@ -85,6 +87,7 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
this.rxBus = rxBus; this.rxBus = rxBus;
this.treatmentsPlugin = treatmentsPlugin; this.treatmentsPlugin = treatmentsPlugin;
this.sp = sp; this.sp = sp;
this.dateUtil = dateUtil;
} }
@Override @Override
@ -349,19 +352,19 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
status.put("timestamp", DateUtil.toISOString(pump.getLastConnection())); status.put("timestamp", DateUtil.toISOString(pump.getLastConnection()));
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
if (pump.getLastBolusTime() != 0) { if (pump.getLastBolusTime() != 0) {
extended.put("LastBolus", DateUtil.dateAndTimeString(pump.getLastBolusTime())); extended.put("LastBolus", dateUtil.dateAndTimeString(pump.getLastBolusTime()));
extended.put("LastBolusAmount", pump.getLastBolusAmount()); extended.put("LastBolusAmount", pump.getLastBolusAmount());
} }
TemporaryBasal tb = treatmentsPlugin.getRealTempBasalFromHistory(now); TemporaryBasal tb = treatmentsPlugin.getRealTempBasalFromHistory(now);
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now); ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now);
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date));
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes()); extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
} }
extended.put("BaseBasalRate", getBaseBasalRate()); extended.put("BaseBasalRate", getBaseBasalRate());

View file

@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
import info.nightscout.androidaps.plugins.pump.danaR.services.DanaRExecutionService; import info.nightscout.androidaps.plugins.pump.danaR.services.DanaRExecutionService;
import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.Round; import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.resources.ResourceHelper;
@ -58,9 +59,10 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
TreatmentsPlugin treatmentsPlugin, TreatmentsPlugin treatmentsPlugin,
SP sp, SP sp,
CommandQueueProvider commandQueue, CommandQueueProvider commandQueue,
DanaRPump danaRPump DanaRPump danaRPump,
DateUtil dateUtil
) { ) {
super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp); super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp, dateUtil);
this.aapsLogger = aapsLogger; this.aapsLogger = aapsLogger;
this.context = context; this.context = context;
this.resourceHelper = resourceHelper; this.resourceHelper = resourceHelper;

View file

@ -47,6 +47,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
@Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin @Inject lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
@Inject lateinit var danaRSPlugin: DanaRSPlugin @Inject lateinit var danaRSPlugin: DanaRSPlugin
@Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var commandQueue: CommandQueueProvider
@Inject lateinit var dateUtil: DateUtil
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -143,7 +144,7 @@ class DanaRHistoryActivity : NoSplashAppCompatActivity() {
override fun onBindViewHolder(holder: HistoryViewHolder, position: Int) { override fun onBindViewHolder(holder: HistoryViewHolder, position: Int) {
val record = historyList[position] val record = historyList[position]
holder.time.text = DateUtil.dateAndTimeString(record.recordDate) holder.time.text = dateUtil.dateAndTimeString(record.recordDate)
holder.value.text = DecimalFormatter.to2Decimal(record.recordValue) holder.value.text = DecimalFormatter.to2Decimal(record.recordValue)
holder.stringValue.text = record.stringRecordValue holder.stringValue.text = record.stringRecordValue
holder.bolusType.text = record.bolusType holder.bolusType.text = record.bolusType

View file

@ -10,6 +10,7 @@ import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
@ -27,7 +28,8 @@ class MessageHashTableR @Inject constructor(
configBuilderPlugin: ConfigBuilderPlugin, configBuilderPlugin: ConfigBuilderPlugin,
commandQueue: CommandQueueProvider, commandQueue: CommandQueueProvider,
activePlugin: ActivePluginProvider, activePlugin: ActivePluginProvider,
injector: HasAndroidInjector injector: HasAndroidInjector,
dateUtil: DateUtil
) : MessageHashTableBase { ) : MessageHashTableBase {
var messages: HashMap<Int, MessageBase> = HashMap() var messages: HashMap<Int, MessageBase> = HashMap()
@ -39,11 +41,11 @@ class MessageHashTableR @Inject constructor(
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil)) // 0x0207 CMD_PUMP_EXPANS_INS_I
put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
// 0x0301 CMD_PUMPINIT_TIME_INFO // 0x0301 CMD_PUMPINIT_TIME_INFO
put(MsgInitConnStatusTime(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) put(MsgInitConnStatusTime(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, dateUtil))
put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO
put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO
put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION
@ -55,15 +57,15 @@ class MessageHashTableR @Inject constructor(
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT
put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT
put(MsgHistoryBolus(aapsLogger, rxBus)) // 0x3101 CMD_HISTORY_MEAL_INS put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS
put(MsgHistoryDailyInsulin(aapsLogger, rxBus)) // 0x3102 CMD_HISTORY_DAY_INS put(MsgHistoryDailyInsulin(aapsLogger, rxBus, dateUtil)) // 0x3102 CMD_HISTORY_DAY_INS
put(MsgHistoryGlucose(aapsLogger, rxBus)) // 0x3104 CMD_HISTORY_GLUCOSE put(MsgHistoryGlucose(aapsLogger, rxBus, dateUtil)) // 0x3104 CMD_HISTORY_GLUCOSE
put(MsgHistoryAlarm(aapsLogger, rxBus)) // 0x3105 CMD_HISTORY_ALARM put(MsgHistoryAlarm(aapsLogger, rxBus, dateUtil)) // 0x3105 CMD_HISTORY_ALARM
put(MsgHistoryError(aapsLogger, rxBus)) // 0x3106 CMD_HISTORY_ERROR put(MsgHistoryError(aapsLogger, rxBus, dateUtil)) // 0x3106 CMD_HISTORY_ERROR
put(MsgHistoryCarbo(aapsLogger, rxBus)) // 0x3107 CMD_HISTORY_CARBOHY put(MsgHistoryCarbo(aapsLogger, rxBus, dateUtil)) // 0x3107 CMD_HISTORY_CARBOHY
put(MsgHistoryRefill(aapsLogger, rxBus)) // 0x3108 CMD_HISTORY_REFILL put(MsgHistoryRefill(aapsLogger, rxBus, dateUtil)) // 0x3108 CMD_HISTORY_REFILL
put(MsgHistorySuspend(aapsLogger, rxBus)) // 0x3109 CMD_HISTORY_SUSPEND put(MsgHistorySuspend(aapsLogger, rxBus, dateUtil)) // 0x3109 CMD_HISTORY_SUSPEND
put(MsgHistoryBasalHour(aapsLogger, rxBus)) // 0x310A CMD_HISTORY_BASAL_HOUR put(MsgHistoryBasalHour(aapsLogger, rxBus, dateUtil)) // 0x310A CMD_HISTORY_BASAL_HOUR
put(MsgHistoryDone(aapsLogger, danaRPump)) // 0x31F1 CMD_HISTORY_DONT_USED put(MsgHistoryDone(aapsLogger, danaRPump)) // 0x31F1 CMD_HISTORY_DONT_USED
// 0x3202 CMD_SETTING_V_BASAL_INS_I // 0x3202 CMD_SETTING_V_BASAL_INS_I
put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin)) put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin))
@ -74,7 +76,7 @@ class MessageHashTableR @Inject constructor(
put(MsgSettingBasalProfileAll(aapsLogger, danaRPump)) // 0x3206 CMD_SETTING_V_BASAL_PROFILE_ALL put(MsgSettingBasalProfileAll(aapsLogger, danaRPump)) // 0x3206 CMD_SETTING_V_BASAL_PROFILE_ALL
put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I
put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY
put(MsgSettingPumpTime(aapsLogger, danaRPump)) // 0x320A CMD_SETTING_V_TIME_I put(MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)) // 0x320A CMD_SETTING_V_TIME_I
put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS
put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER
put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE
@ -83,9 +85,9 @@ class MessageHashTableR @Inject constructor(
put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S
put(MsgSetActivateBasalProfile(aapsLogger, 0.toByte())) // 0x330C CMD_SETTING_PROFILE_NUMBER_S put(MsgSetActivateBasalProfile(aapsLogger, 0.toByte())) // 0x330C CMD_SETTING_PROFILE_NUMBER_S
put(MsgHistoryAllDone(aapsLogger, danaRPump)) // 0x41F1 CMD_HISTORY_ALL_DONE put(MsgHistoryAllDone(aapsLogger, danaRPump)) // 0x41F1 CMD_HISTORY_ALL_DONE
put(MsgHistoryAll(aapsLogger, rxBus)) // 0x41F2 CMD_HISTORY_ALL put(MsgHistoryAll(aapsLogger, rxBus, dateUtil)) // 0x41F2 CMD_HISTORY_ALL
put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE
put(MsgHistoryNew(aapsLogger, rxBus)) // 0x42F2 CMD_HISTORY_NEW put(MsgHistoryNew(aapsLogger, rxBus, dateUtil)) // 0x42F2 CMD_HISTORY_NEW
// 0xF0F1 CMD_PUMP_CHECK_VALUE // 0xF0F1 CMD_PUMP_CHECK_VALUE
put(MsgCheckValue(aapsLogger, danaRPump, danaRPlugin)) put(MsgCheckValue(aapsLogger, danaRPump, danaRPlugin))
} }

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistoryAlarm( class MsgHistoryAlarm(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x3105) SetCommand(0x3105)

View file

@ -10,7 +10,8 @@ import info.nightscout.androidaps.utils.DateUtil
open class MsgHistoryAll( open class MsgHistoryAll(
val aapsLogger: AAPSLogger, val aapsLogger: AAPSLogger,
val rxBus: RxBusWrapper val rxBus: RxBusWrapper,
private val dateUtil: DateUtil
) : MessageBase() { ) : MessageBase() {
init { init {
@ -138,6 +139,6 @@ open class MsgHistoryAll(
17.toByte() -> failed = true 17.toByte() -> failed = true
} }
MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord) MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord)
rxBus.send(EventDanaRSyncStatus(DateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType)) rxBus.send(EventDanaRSyncStatus(dateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType))
} }
} }

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistoryBasalHour( class MsgHistoryBasalHour(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x310A) SetCommand(0x310A)

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistoryBolus( class MsgHistoryBolus(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x3101) SetCommand(0x3101)

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistoryCarbo( class MsgHistoryCarbo(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x3107) SetCommand(0x3107)

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistoryDailyInsulin( class MsgHistoryDailyInsulin(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x3102) SetCommand(0x3102)

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistoryError( class MsgHistoryError(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x3106) SetCommand(0x3106)

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistoryGlucose( class MsgHistoryGlucose(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x3104) SetCommand(0x3104)

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistoryNew( class MsgHistoryNew(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x42F2) SetCommand(0x42F2)

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistoryRefill( class MsgHistoryRefill(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x3108) SetCommand(0x3108)

View file

@ -3,11 +3,13 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class MsgHistorySuspend( class MsgHistorySuspend(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper rxBus: RxBusWrapper,
) : MsgHistoryAll(aapsLogger, rxBus) { dateUtil: DateUtil
) : MsgHistoryAll(aapsLogger, rxBus, dateUtil) {
init { init {
SetCommand(0x3109) SetCommand(0x3109)

View file

@ -24,7 +24,8 @@ class MsgInitConnStatusTime(
private val danaRPlugin: DanaRPlugin, private val danaRPlugin: DanaRPlugin,
private val danaRKoreanPlugin: DanaRKoreanPlugin, private val danaRKoreanPlugin: DanaRKoreanPlugin,
private val configBuilderPlugin: ConfigBuilderPlugin, private val configBuilderPlugin: ConfigBuilderPlugin,
private val commandQueue: CommandQueueProvider private val commandQueue: CommandQueueProvider,
private val dateUtil: DateUtil
) : MessageBase() { ) : MessageBase() {
init { init {
@ -54,7 +55,7 @@ class MsgInitConnStatusTime(
} }
val time = dateTimeSecFromBuff(bytes, 0) val time = dateTimeSecFromBuff(bytes, 0)
val versionCode = intFromBuff(bytes, 6, 1) val versionCode = intFromBuff(bytes, 6, 1)
aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + DateUtil.dateAndTimeString(time)) aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + dateUtil.dateAndTimeString(time))
aapsLogger.debug(LTag.PUMPCOMM, "Version code: $versionCode") aapsLogger.debug(LTag.PUMPCOMM, "Version code: $versionCode")
} }
} }

View file

@ -7,13 +7,14 @@ import java.util.*
class MsgSetTime( class MsgSetTime(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val dateUtil: DateUtil,
time: Date time: Date
) : MessageBase() { ) : MessageBase() {
init { init {
SetCommand(0x330a) SetCommand(0x330a)
AddParamDateTime(time) AddParamDateTime(time)
aapsLogger.debug(LTag.PUMPCOMM, "New message: time:" + DateUtil.dateAndTimeString(time)) aapsLogger.debug(LTag.PUMPCOMM, "New message: time:" + dateUtil.dateAndTimeString(time))
} }
override fun handleMessage(bytes: ByteArray) { override fun handleMessage(bytes: ByteArray) {

View file

@ -8,7 +8,8 @@ import java.util.*
class MsgSettingPumpTime( class MsgSettingPumpTime(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val danaRPump: DanaRPump private val danaRPump: DanaRPump,
private val dateUtil: DateUtil
) : MessageBase() { ) : MessageBase() {
init { init {
@ -25,7 +26,7 @@ class MsgSettingPumpTime(
intFromBuff(bytes, 1, 1), intFromBuff(bytes, 1, 1),
intFromBuff(bytes, 0, 1) intFromBuff(bytes, 0, 1)
).time ).time
aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + DateUtil.dateAndTimeString(time) + " Phone time: " + Date()) aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + dateUtil.dateAndTimeString(time) + " Phone time: " + Date())
danaRPump.pumpTime = time danaRPump.pumpTime = time
} }

View file

@ -14,7 +14,8 @@ class MsgStatusBolusExtended(
private val injector: HasAndroidInjector, private val injector: HasAndroidInjector,
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val danaRPump: DanaRPump, private val danaRPump: DanaRPump,
private val activePlugin: ActivePluginProvider private val activePlugin: ActivePluginProvider,
private val dateUtil: DateUtil
) : MessageBase() { ) : MessageBase() {
init { init {
@ -48,7 +49,7 @@ class MsgStatusBolusExtended(
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus amount: $extendedBolusAmount") aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus amount: $extendedBolusAmount")
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus so far in minutes: $extendedBolusSoFarInMinutes") aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus so far in minutes: $extendedBolusSoFarInMinutes")
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus absolute rate: $extendedBolusAbsoluteRate") aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus absolute rate: $extendedBolusAbsoluteRate")
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus start: " + DateUtil.dateAndTimeString(extendedBolusStart)) aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus start: " + dateUtil.dateAndTimeString(extendedBolusStart))
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: $extendedBolusRemainingMinutes") aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: $extendedBolusRemainingMinutes")
} }

View file

@ -62,6 +62,7 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
@Inject ResourceHelper resourceHelper; @Inject ResourceHelper resourceHelper;
@Inject DanaRPump danaRPump; @Inject DanaRPump danaRPump;
@Inject FabricPrivacy fabricPrivacy; @Inject FabricPrivacy fabricPrivacy;
@Inject DateUtil dateUtil;
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
@ -228,31 +229,31 @@ public abstract class AbstractDanaRExecutionService extends DaggerService {
MessageBase msg = null; MessageBase msg = null;
switch (type) { switch (type) {
case RecordTypes.RECORD_TYPE_ALARM: case RecordTypes.RECORD_TYPE_ALARM:
msg = new MsgHistoryAlarm(aapsLogger, rxBus); msg = new MsgHistoryAlarm(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_BASALHOUR: case RecordTypes.RECORD_TYPE_BASALHOUR:
msg = new MsgHistoryBasalHour(aapsLogger, rxBus); msg = new MsgHistoryBasalHour(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_BOLUS: case RecordTypes.RECORD_TYPE_BOLUS:
msg = new MsgHistoryBolus(aapsLogger, rxBus); msg = new MsgHistoryBolus(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_CARBO: case RecordTypes.RECORD_TYPE_CARBO:
msg = new MsgHistoryCarbo(aapsLogger, rxBus); msg = new MsgHistoryCarbo(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_DAILY: case RecordTypes.RECORD_TYPE_DAILY:
msg = new MsgHistoryDailyInsulin(aapsLogger, rxBus); msg = new MsgHistoryDailyInsulin(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_ERROR: case RecordTypes.RECORD_TYPE_ERROR:
msg = new MsgHistoryError(aapsLogger, rxBus); msg = new MsgHistoryError(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_GLUCOSE: case RecordTypes.RECORD_TYPE_GLUCOSE:
msg = new MsgHistoryGlucose(aapsLogger, rxBus); msg = new MsgHistoryGlucose(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_REFILL: case RecordTypes.RECORD_TYPE_REFILL:
msg = new MsgHistoryRefill(aapsLogger, rxBus); msg = new MsgHistoryRefill(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_SUSPEND: case RecordTypes.RECORD_TYPE_SUSPEND:
msg = new MsgHistorySuspend(aapsLogger, rxBus); msg = new MsgHistorySuspend(aapsLogger, rxBus, dateUtil);
break; break;
} }
danaRPump.setHistoryDoneReceived(false); danaRPump.setHistoryDoneReceived(false);

View file

@ -14,18 +14,19 @@ import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.dialogs.BolusProgressDialog; import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.CommandQueueProvider;
import info.nightscout.androidaps.interfaces.ProfileFunction;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
import info.nightscout.androidaps.interfaces.ProfileFunction;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
@ -63,10 +64,8 @@ import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgStatusBolusExtended
import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgStatusTempBasal; import info.nightscout.androidaps.plugins.pump.danaR.comm.MsgStatusTempBasal;
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus; import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus;
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin; import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.androidaps.queue.commands.Command;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP; import info.nightscout.androidaps.utils.sharedPreferences.SP;
@ -143,7 +142,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump); MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump);
MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump); MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump);
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector); MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin); MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil);
MsgCheckValue checkValue = new MsgCheckValue(aapsLogger, danaRPump, danaRPlugin); MsgCheckValue checkValue = new MsgCheckValue(aapsLogger, danaRPump, danaRPlugin);
if (danaRPump.isNewPump()) { if (danaRPump.isNewPump()) {
@ -187,7 +186,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll(aapsLogger, danaRPump));
mSerialIOThread.sendMessage(new MsgSettingUserOptions(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingUserOptions(aapsLogger, danaRPump));
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil));
if (danaRPump.getPumpTime() == 0) { if (danaRPump.getPumpTime() == 0) {
// initial handshake was not successfull // initial handshake was not successfull
// deinitialize pump // deinitialize pump
@ -200,8 +199,8 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
long timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; long timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
if (Math.abs(timeDiff) > 10) { if (Math.abs(timeDiff) > 10) {
mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, new Date())); mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, dateUtil, new Date()));
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil));
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
} }
@ -252,7 +251,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
if (!isConnected()) return false; if (!isConnected()) return false;
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF))); mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF)));
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)); mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil));
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
} }
@ -261,7 +260,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
if (!isConnected()) return false; if (!isConnected()) return false;
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger)); mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)); mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil));
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
} }
@ -350,7 +349,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
t.insulin = danaRPump.getLastBolusAmount(); t.insulin = danaRPump.getLastBolusAmount();
aapsLogger.debug(LTag.PUMP, "Used bolus amount from history: " + danaRPump.getLastBolusAmount()); aapsLogger.debug(LTag.PUMP, "Used bolus amount from history: " + danaRPump.getLastBolusAmount());
} else { } else {
aapsLogger.debug(LTag.PUMP, "Bolus amount in history too old: " + DateUtil.dateAndTimeString(danaRPump.getLastBolusTime())); aapsLogger.debug(LTag.PUMP, "Bolus amount in history too old: " + dateUtil.dateAndTimeString(danaRPump.getLastBolusTime()));
} }
synchronized (o) { synchronized (o) {
o.notify(); o.notify();

View file

@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
import info.nightscout.androidaps.plugins.pump.danaRKorean.services.DanaRKoreanExecutionService; import info.nightscout.androidaps.plugins.pump.danaRKorean.services.DanaRKoreanExecutionService;
import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.Round; import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.resources.ResourceHelper;
@ -60,10 +61,10 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
ConstraintChecker constraintChecker, ConstraintChecker constraintChecker,
TreatmentsPlugin treatmentsPlugin, TreatmentsPlugin treatmentsPlugin,
SP sp, SP sp,
CommandQueueProvider commandQueue CommandQueueProvider commandQueue,
DateUtil dateUtil
) { ) {
super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp); super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp, dateUtil);
this.aapsLogger = aapsLogger; this.aapsLogger = aapsLogger;
this.context = context; this.context = context;
this.resourceHelper = resourceHelper; this.resourceHelper = resourceHelper;

View file

@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
import info.nightscout.androidaps.plugins.pump.danaR.comm.* import info.nightscout.androidaps.plugins.pump.danaR.comm.*
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
@ -28,6 +29,7 @@ class MessageHashTableRKorean @Inject constructor(
configBuilderPlugin: ConfigBuilderPlugin, configBuilderPlugin: ConfigBuilderPlugin,
commandQueue: CommandQueueProvider, commandQueue: CommandQueueProvider,
activePlugin: ActivePluginProvider, activePlugin: ActivePluginProvider,
dateUtil: DateUtil,
injector: HasAndroidInjector injector: HasAndroidInjector
) : MessageHashTableBase { ) : MessageHashTableBase {
@ -39,10 +41,10 @@ class MessageHashTableRKorean @Inject constructor(
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE put(MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector)) // 0x0205 CMD_PUMP_EXERCISE_MODE
put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)) // 0x0207 CMD_PUMP_EXPANS_INS_I put(MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil)) // 0x0207 CMD_PUMP_EXPANS_INS_I
put(MsgStatusBasic_k(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I put(MsgStatusBasic_k(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
put(MsgStatus_k(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS put(MsgStatus_k(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
put(MsgInitConnStatusTime_k(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) // 0x0301 CMD_PUMPINIT_TIME_INFO put(MsgInitConnStatusTime_k(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, dateUtil)) // 0x0301 CMD_PUMPINIT_TIME_INFO
put(MsgInitConnStatusBolus_k(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO put(MsgInitConnStatusBolus_k(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO
put(MsgInitConnStatusBasic_k(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO put(MsgInitConnStatusBasic_k(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO
put(MsgSetTempBasalStart(aapsLogger, 0, 0)) // 0x0401 CMD_PUMPSET_EXERCISE_S put(MsgSetTempBasalStart(aapsLogger, 0, 0)) // 0x0401 CMD_PUMPSET_EXERCISE_S
@ -53,11 +55,11 @@ class MessageHashTableRKorean @Inject constructor(
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT
put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT
put(MsgHistoryBolus(aapsLogger, rxBus)) // 0x3101 CMD_HISTORY_MEAL_INS put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS
put(MsgHistoryDailyInsulin(aapsLogger, rxBus)) // 0x3102 CMD_HISTORY_DAY_INS put(MsgHistoryDailyInsulin(aapsLogger, rxBus, dateUtil)) // 0x3102 CMD_HISTORY_DAY_INS
put(MsgHistoryGlucose(aapsLogger, rxBus)) // 0x3104 CMD_HISTORY_GLUCOSE put(MsgHistoryGlucose(aapsLogger, rxBus, dateUtil)) // 0x3104 CMD_HISTORY_GLUCOSE
put(MsgHistoryAlarm(aapsLogger, rxBus)) // 0x3105 CMD_HISTORY_ALARM put(MsgHistoryAlarm(aapsLogger, rxBus, dateUtil)) // 0x3105 CMD_HISTORY_ALARM
put(MsgHistoryCarbo(aapsLogger, rxBus)) // 0x3107 CMD_HISTORY_CARBOHY put(MsgHistoryCarbo(aapsLogger, rxBus, dateUtil)) // 0x3107 CMD_HISTORY_CARBOHY
put(MsgSettingBasal_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I put(MsgSettingBasal_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I
put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I
put(MsgSettingProfileRatios(aapsLogger, danaRPump)) // 0x3204 CMD_SETTING_V_CCC_I put(MsgSettingProfileRatios(aapsLogger, danaRPump)) // 0x3204 CMD_SETTING_V_CCC_I
@ -65,11 +67,11 @@ class MessageHashTableRKorean @Inject constructor(
put(MsgSettingBasalProfileAll_k(aapsLogger, danaRPump)) // 0x3206 CMD_SETTING_V_BASAL_PROFILE_ALL put(MsgSettingBasalProfileAll_k(aapsLogger, danaRPump)) // 0x3206 CMD_SETTING_V_BASAL_PROFILE_ALL
put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I
put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY
put(MsgSettingPumpTime(aapsLogger, danaRPump)) // 0x320A CMD_SETTING_V_TIME_I put(MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)) // 0x320A CMD_SETTING_V_TIME_I
put(MsgSetSingleBasalProfile(aapsLogger, rxBus, resourceHelper, Array(24) { 0.0 })) // 0x3302 CMD_SETTING_BASAL_INS_S put(MsgSetSingleBasalProfile(aapsLogger, rxBus, resourceHelper, Array(24) { 0.0 })) // 0x3302 CMD_SETTING_BASAL_INS_S
put(MsgHistoryAll(aapsLogger, rxBus)) // 0x41F2 CMD_HISTORY_ALL put(MsgHistoryAll(aapsLogger, rxBus, dateUtil)) // 0x41F2 CMD_HISTORY_ALL
put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE
put(MsgHistoryNew(aapsLogger, rxBus)) // 0x42F2 CMD_HISTORY_NEW put(MsgHistoryNew(aapsLogger, rxBus, dateUtil)) // 0x42F2 CMD_HISTORY_NEW
put(MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0xF0F1 CMD_PUMP_CHECK_VALUE put(MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin)) // 0xF0F1 CMD_PUMP_CHECK_VALUE
} }

View file

@ -25,7 +25,8 @@ class MsgInitConnStatusTime_k(
private val danaRPlugin: DanaRPlugin, private val danaRPlugin: DanaRPlugin,
private val danaRKoreanPlugin: DanaRKoreanPlugin, private val danaRKoreanPlugin: DanaRKoreanPlugin,
private val configBuilderPlugin: ConfigBuilderPlugin, private val configBuilderPlugin: ConfigBuilderPlugin,
private val commandQueue: CommandQueueProvider private val commandQueue: CommandQueueProvider,
private val dateUtil: DateUtil
) : MessageBase() { ) : MessageBase() {
init { init {
@ -55,7 +56,7 @@ class MsgInitConnStatusTime_k(
val versionCode2 = intFromBuff(bytes, 7, 1) val versionCode2 = intFromBuff(bytes, 7, 1)
val versionCode3 = intFromBuff(bytes, 8, 1) val versionCode3 = intFromBuff(bytes, 8, 1)
val versionCode4 = intFromBuff(bytes, 9, 1) val versionCode4 = intFromBuff(bytes, 9, 1)
aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + DateUtil.dateAndTimeString(time)) aapsLogger.debug(LTag.PUMPCOMM, "Pump time: " + dateUtil.dateAndTimeString(time))
aapsLogger.debug(LTag.PUMPCOMM, "Version code1: $versionCode1") aapsLogger.debug(LTag.PUMPCOMM, "Version code1: $versionCode1")
aapsLogger.debug(LTag.PUMPCOMM, "Version code2: $versionCode2") aapsLogger.debug(LTag.PUMPCOMM, "Version code2: $versionCode2")
aapsLogger.debug(LTag.PUMPCOMM, "Version code3: $versionCode3") aapsLogger.debug(LTag.PUMPCOMM, "Version code3: $versionCode3")

View file

@ -75,6 +75,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
@Inject MessageHashTableRKorean messageHashTableRKorean; @Inject MessageHashTableRKorean messageHashTableRKorean;
@Inject ActivePluginProvider activePlugin; @Inject ActivePluginProvider activePlugin;
@Inject ProfileFunction profileFunction; @Inject ProfileFunction profileFunction;
@Inject DateUtil dateUtil;
public DanaRKoreanExecutionService() { public DanaRKoreanExecutionService() {
} }
@ -132,7 +133,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
//MsgStatus_k statusMsg = new MsgStatus_k(); //MsgStatus_k statusMsg = new MsgStatus_k();
MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k(aapsLogger, danaRPump); MsgStatusBasic_k statusBasicMsg = new MsgStatusBasic_k(aapsLogger, danaRPump);
MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector); MsgStatusTempBasal tempStatusMsg = new MsgStatusTempBasal(aapsLogger, danaRPump, activePlugin, injector);
MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin); MsgStatusBolusExtended exStatusMsg = new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil);
MsgCheckValue_k checkValue = new MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin); MsgCheckValue_k checkValue = new MsgCheckValue_k(aapsLogger, danaRPump, danaRKoreanPlugin);
if (danaRPump.isNewPump()) { if (danaRPump.isNewPump()) {
@ -172,7 +173,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(new MsgSettingGlucose(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingGlucose(aapsLogger, danaRPump));
mSerialIOThread.sendMessage(new MsgSettingProfileRatios(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingProfileRatios(aapsLogger, danaRPump));
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil));
if (danaRPump.getPumpTime() == 0) { if (danaRPump.getPumpTime() == 0) {
// initial handshake was not successfull // initial handshake was not successfull
// deinitialize pump // deinitialize pump
@ -187,8 +188,8 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if (Math.abs(timeDiff) > 10) { if (Math.abs(timeDiff) > 10) {
waitForWholeMinute(); // Dana can set only whole minute waitForWholeMinute(); // Dana can set only whole minute
// add 10sec to be sure we are over minute (will be cutted off anyway) // add 10sec to be sure we are over minute (will be cutted off anyway)
mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, new Date(DateUtil.now() + T.secs(10).msecs()))); mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, dateUtil, new Date(DateUtil.now() + T.secs(10).msecs())));
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil));
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
} }
@ -239,7 +240,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if (!isConnected()) return false; if (!isConnected()) return false;
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF))); mSerialIOThread.sendMessage(new MsgSetExtendedBolusStart(aapsLogger, constraintChecker, insulin, (byte) (durationInHalfHours & 0xFF)));
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)); mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil));
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
} }
@ -248,7 +249,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
if (!isConnected()) return false; if (!isConnected()) return false;
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingextendedbolus)));
mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger)); mSerialIOThread.sendMessage(new MsgSetExtendedBolusStop(aapsLogger));
mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin)); mSerialIOThread.sendMessage(new MsgStatusBolusExtended(injector, aapsLogger, danaRPump, activePlugin, dateUtil));
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
} }

View file

@ -81,6 +81,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR
private final CommandQueueProvider commandQueue; private final CommandQueueProvider commandQueue;
private final DanaRPump danaRPump; private final DanaRPump danaRPump;
private final DetailedBolusInfoStorage detailedBolusInfoStorage; private final DetailedBolusInfoStorage detailedBolusInfoStorage;
private final DateUtil dateUtil;
private static DanaRSService danaRSService; private static DanaRSService danaRSService;
@ -113,7 +114,8 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR
SP sp, SP sp,
CommandQueueProvider commandQueue, CommandQueueProvider commandQueue,
DanaRPump danaRPump, DanaRPump danaRPump,
DetailedBolusInfoStorage detailedBolusInfoStorage DetailedBolusInfoStorage detailedBolusInfoStorage,
DateUtil dateUtil
) { ) {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.PUMP) .mainType(PluginType.PUMP)
@ -134,6 +136,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR
this.commandQueue = commandQueue; this.commandQueue = commandQueue;
this.danaRPump = danaRPump; this.danaRPump = danaRPump;
this.detailedBolusInfoStorage = detailedBolusInfoStorage; this.detailedBolusInfoStorage = detailedBolusInfoStorage;
this.dateUtil = dateUtil;
pumpDescription.setPumpDescription(PumpType.DanaRS); pumpDescription.setPumpDescription(PumpType.DanaRS);
} }
@ -720,19 +723,19 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR
status.put("timestamp", DateUtil.toISOString(pump.getLastConnection())); status.put("timestamp", DateUtil.toISOString(pump.getLastConnection()));
extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION); extended.put("Version", BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION);
if (pump.getLastBolusTime() != 0) { if (pump.getLastBolusTime() != 0) {
extended.put("LastBolus", DateUtil.dateAndTimeString(pump.getLastBolusTime())); extended.put("LastBolus", dateUtil.dateAndTimeString(pump.getLastBolusTime()));
extended.put("LastBolusAmount", pump.getLastBolusAmount()); extended.put("LastBolusAmount", pump.getLastBolusAmount());
} }
TemporaryBasal tb = treatmentsPlugin.getTempBasalFromHistory(now); TemporaryBasal tb = treatmentsPlugin.getTempBasalFromHistory(now);
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now); ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now);
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date));
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes()); extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
} }
extended.put("BaseBasalRate", getBaseBasalRate()); extended.put("BaseBasalRate", getBaseBasalRate());

View file

@ -49,7 +49,7 @@ class DanaRSMessageHashTable @Inject constructor(
put(DanaRS_Packet_Basal_Set_Suspend_Off(aapsLogger)) put(DanaRS_Packet_Basal_Set_Suspend_Off(aapsLogger))
put(DanaRS_Packet_Basal_Set_Suspend_On(aapsLogger)) put(DanaRS_Packet_Basal_Set_Suspend_On(aapsLogger))
put(DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger)) put(DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger))
put(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)) put(DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil))
put(DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)) put(DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump))
put(DanaRS_Packet_Bolus_Get_Initial_Bolus(aapsLogger)) put(DanaRS_Packet_Bolus_Get_Initial_Bolus(aapsLogger))
put(DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump)) put(DanaRS_Packet_Bolus_Get_Calculation_Information(aapsLogger, danaRPump))
@ -59,7 +59,7 @@ class DanaRSMessageHashTable @Inject constructor(
put(DanaRS_Packet_Bolus_Get_Extended_Bolus(aapsLogger, danaRPump)) put(DanaRS_Packet_Bolus_Get_Extended_Bolus(aapsLogger, danaRPump))
put(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)) put(DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump))
put(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(aapsLogger, danaRPump)) put(DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(aapsLogger, danaRPump))
put(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)) put(DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump, dateUtil))
put(DanaRS_Packet_Bolus_Set_Bolus_Option(aapsLogger)) put(DanaRS_Packet_Bolus_Set_Bolus_Option(aapsLogger))
put(DanaRS_Packet_Bolus_Set_Initial_Bolus(aapsLogger)) put(DanaRS_Packet_Bolus_Set_Initial_Bolus(aapsLogger))
put(DanaRS_Packet_Bolus_Set_CIR_CF_Array(aapsLogger)) put(DanaRS_Packet_Bolus_Set_CIR_CF_Array(aapsLogger))
@ -77,33 +77,33 @@ class DanaRSMessageHashTable @Inject constructor(
put(DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRSPlugin)) put(DanaRS_Packet_Notify_Delivery_Complete(aapsLogger, rxBus, resourceHelper, danaRSPlugin))
put(DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRSPlugin)) put(DanaRS_Packet_Notify_Delivery_Rate_Display(aapsLogger, rxBus, resourceHelper, danaRSPlugin))
put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(aapsLogger)) put(DanaRS_Packet_Notify_Missed_Bolus_Alarm(aapsLogger))
put(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)) put(DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump, dateUtil))
put(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump)) put(DanaRS_Packet_Option_Get_User_Option(aapsLogger, danaRPump))
put(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger)) put(DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, dateUtil))
put(DanaRS_Packet_Option_Set_User_Option(aapsLogger, danaRPump)) put(DanaRS_Packet_Option_Set_User_Option(aapsLogger, danaRPump))
//put(new DanaRS_Packet_History_()); //put(new DanaRS_Packet_History_());
put(DanaRS_Packet_History_Alarm(aapsLogger, rxBus)) put(DanaRS_Packet_History_Alarm(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_History_All_History(aapsLogger, rxBus)) put(DanaRS_Packet_History_All_History(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_History_Basal(aapsLogger, rxBus)) put(DanaRS_Packet_History_Basal(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus)) put(DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_History_Bolus(aapsLogger, rxBus)) put(DanaRS_Packet_History_Bolus(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_Review_Bolus_Avg(aapsLogger)) put(DanaRS_Packet_Review_Bolus_Avg(aapsLogger))
put(DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus)) put(DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_History_Daily(aapsLogger, rxBus)) put(DanaRS_Packet_History_Daily(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump)) put(DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump, dateUtil))
put(DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)) put(DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper))
put(DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)) put(DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump, dateUtil))
put(DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump)) put(DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump))
put(DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger)) put(DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger))
put(DanaRS_Packet_History_Prime(aapsLogger, rxBus)) put(DanaRS_Packet_History_Prime(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_History_Refill(aapsLogger, rxBus)) put(DanaRS_Packet_History_Refill(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger)) put(DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger))
put(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(aapsLogger)) put(DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(aapsLogger))
put(DanaRS_Packet_History_Suspend(aapsLogger, rxBus)) put(DanaRS_Packet_History_Suspend(aapsLogger, rxBus, dateUtil))
put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus)) put(DanaRS_Packet_History_Temporary(aapsLogger, rxBus, dateUtil))
// APS // APS
put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0)) put(DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, 0))
put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, dateUtil, 0)) put(DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, dateUtil, 0))
put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, 0, 0, 0, 0)) put(DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, 0, 0, 0, 0))
} }
} }

View file

@ -52,7 +52,7 @@ open class DanaRS_Packet_APS_History_Events(
hour = cal[Calendar.HOUR_OF_DAY] hour = cal[Calendar.HOUR_OF_DAY]
min = cal[Calendar.MINUTE] min = cal[Calendar.MINUTE]
sec = cal[Calendar.SECOND] sec = cal[Calendar.SECOND]
aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(cal.timeInMillis)) aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(cal.timeInMillis))
danaRSPlugin.apsHistoryDone = false danaRSPlugin.apsHistoryDone = false
} }
@ -83,7 +83,7 @@ open class DanaRS_Packet_APS_History_Events(
val status: String val status: String
when (recordCode.toInt()) { when (recordCode.toInt()) {
DanaRPump.TEMPSTART -> { DanaRPump.TEMPSTART -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min")
temporaryBasal.percentRate = param1 temporaryBasal.percentRate = param1
temporaryBasal.durationInMinutes = param2 temporaryBasal.durationInMinutes = param2
activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal) activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal)
@ -91,13 +91,13 @@ open class DanaRS_Packet_APS_History_Events(
} }
DanaRPump.TEMPSTOP -> { DanaRPump.TEMPSTOP -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime)) aapsLogger.debug(LTag.PUMPCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime))
activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal) activePlugin.activeTreatments.addToHistoryTempBasal(temporaryBasal)
status = "TEMPSTOP " + dateUtil.timeString(datetime) status = "TEMPSTOP " + dateUtil.timeString(datetime)
} }
DanaRPump.EXTENDEDSTART -> { DanaRPump.EXTENDEDSTART -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min")
extendedBolus.insulin = param1 / 100.0 extendedBolus.insulin = param1 / 100.0
extendedBolus.durationInMinutes = param2 extendedBolus.durationInMinutes = param2
activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus)
@ -105,7 +105,7 @@ open class DanaRS_Packet_APS_History_Events(
} }
DanaRPump.EXTENDEDSTOP -> { DanaRPump.EXTENDEDSTOP -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") aapsLogger.debug(LTag.PUMPCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min")
activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus)
status = "EXTENDEDSTOP " + dateUtil.timeString(datetime) status = "EXTENDEDSTOP " + dateUtil.timeString(datetime)
} }
@ -118,7 +118,7 @@ open class DanaRS_Packet_APS_History_Events(
detailedBolusInfo.pumpId = datetime detailedBolusInfo.pumpId = datetime
detailedBolusInfo.insulin = param1 / 100.0 detailedBolusInfo.insulin = param1 / 100.0
val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min")
status = "BOLUS " + dateUtil.timeString(datetime) status = "BOLUS " + dateUtil.timeString(datetime)
} }
@ -130,12 +130,12 @@ open class DanaRS_Packet_APS_History_Events(
detailedBolusInfo.pumpId = datetime detailedBolusInfo.pumpId = datetime
detailedBolusInfo.insulin = param1 / 100.0 detailedBolusInfo.insulin = param1 / 100.0
val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false) val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(detailedBolusInfo, false)
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min")
status = "DUALBOLUS " + dateUtil.timeString(datetime) status = "DUALBOLUS " + dateUtil.timeString(datetime)
} }
DanaRPump.DUALEXTENDEDSTART -> { DanaRPump.DUALEXTENDEDSTART -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min")
extendedBolus.insulin = param1 / 100.0 extendedBolus.insulin = param1 / 100.0
extendedBolus.durationInMinutes = param2 extendedBolus.durationInMinutes = param2
activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus)
@ -143,33 +143,33 @@ open class DanaRS_Packet_APS_History_Events(
} }
DanaRPump.DUALEXTENDEDSTOP -> { DanaRPump.DUALEXTENDEDSTOP -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") aapsLogger.debug(LTag.PUMPCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min")
activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus) activePlugin.activeTreatments.addToHistoryExtendedBolus(extendedBolus)
status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime) status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime)
} }
DanaRPump.SUSPENDON -> { DanaRPump.SUSPENDON -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDON (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDON (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
status = "SUSPENDON " + dateUtil.timeString(datetime) status = "SUSPENDON " + dateUtil.timeString(datetime)
} }
DanaRPump.SUSPENDOFF -> { DanaRPump.SUSPENDOFF -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") aapsLogger.debug(LTag.PUMPCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
status = "SUSPENDOFF " + dateUtil.timeString(datetime) status = "SUSPENDOFF " + dateUtil.timeString(datetime)
} }
DanaRPump.REFILL -> { DanaRPump.REFILL -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT REFILL (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") aapsLogger.debug(LTag.PUMPCOMM, "EVENT REFILL (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
status = "REFILL " + dateUtil.timeString(datetime) status = "REFILL " + dateUtil.timeString(datetime)
} }
DanaRPump.PRIME -> { DanaRPump.PRIME -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIME (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIME (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
status = "PRIME " + dateUtil.timeString(datetime) status = "PRIME " + dateUtil.timeString(datetime)
} }
DanaRPump.PROFILECHANGE -> { DanaRPump.PROFILECHANGE -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") aapsLogger.debug(LTag.PUMPCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h")
status = "PROFILECHANGE " + dateUtil.timeString(datetime) status = "PROFILECHANGE " + dateUtil.timeString(datetime)
} }
@ -180,17 +180,17 @@ open class DanaRS_Packet_APS_History_Events(
emptyCarbsInfo.source = Source.PUMP emptyCarbsInfo.source = Source.PUMP
emptyCarbsInfo.pumpId = datetime emptyCarbsInfo.pumpId = datetime
val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(emptyCarbsInfo, false) val newRecord = activePlugin.activeTreatments.addToHistoryTreatment(emptyCarbsInfo, false)
aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") aapsLogger.debug(LTag.PUMPCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g")
status = "CARBS " + dateUtil.timeString(datetime) status = "CARBS " + dateUtil.timeString(datetime)
} }
DanaRPump.PRIMECANNULA -> { DanaRPump.PRIMECANNULA -> {
aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIMECANNULA(" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") aapsLogger.debug(LTag.PUMPCOMM, "EVENT PRIMECANNULA(" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
status = "PRIMECANNULA " + dateUtil.timeString(datetime) status = "PRIMECANNULA " + dateUtil.timeString(datetime)
} }
else -> { else -> {
aapsLogger.debug(LTag.PUMPCOMM, "Event: " + recordCode + " " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) aapsLogger.debug(LTag.PUMPCOMM, "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2)
status = "UNKNOWN " + dateUtil.timeString(datetime) status = "UNKNOWN " + dateUtil.timeString(datetime)
} }
} }

View file

@ -9,6 +9,7 @@ import java.util.*
class DanaRS_Packet_APS_Set_Event_History( class DanaRS_Packet_APS_Set_Event_History(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val dateUtil: DateUtil,
private var packetType: Int, private var packetType: Int,
private var time: Long, private var time: Long,
private var param1: Int, private var param1: Int,
@ -18,7 +19,7 @@ class DanaRS_Packet_APS_Set_Event_History(
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY
if ((packetType == DanaRPump.CARBS || packetType == DanaRPump.BOLUS) && param1 <= 0) this.param1 = 0 if ((packetType == DanaRPump.CARBS || packetType == DanaRPump.BOLUS) && param1 <= 0) this.param1 = 0
aapsLogger.debug(LTag.PUMPCOMM, "Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + packetType + " param1: " + param1 + " param2: " + param2) aapsLogger.debug(LTag.PUMPCOMM, "Set history entry: " + dateUtil.dateAndTimeString(time) + " type: " + packetType + " param1: " + param1 + " param2: " + param2)
} }
override fun getRequestParams(): ByteArray { override fun getRequestParams(): ByteArray {

View file

@ -9,7 +9,8 @@ import kotlin.math.ceil
class DanaRS_Packet_Basal_Get_Temporary_Basal_State( class DanaRS_Packet_Basal_Get_Temporary_Basal_State(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val danaRPump: DanaRPump private val danaRPump: DanaRPump,
private val dateUtil: DateUtil
) : DanaRS_Packet() { ) : DanaRS_Packet() {
init { init {
@ -35,7 +36,7 @@ class DanaRS_Packet_Basal_Get_Temporary_Basal_State(
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal percent: " + danaRPump.tempBasalPercent) aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal percent: " + danaRPump.tempBasalPercent)
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal remaining min: $tempBasalRemainingMin") aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal remaining min: $tempBasalRemainingMin")
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal total sec: " + danaRPump.tempBasalTotalSec) aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal total sec: " + danaRPump.tempBasalTotalSec)
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal start: " + DateUtil.dateAndTimeString(tempBasalStart)) aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal start: " + dateUtil.dateAndTimeString(tempBasalStart))
} }
override fun getFriendlyName(): String { override fun getFriendlyName(): String {

View file

@ -9,7 +9,8 @@ import java.util.*
class DanaRS_Packet_Bolus_Get_Step_Bolus_Information( class DanaRS_Packet_Bolus_Get_Step_Bolus_Information(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val danaRPump: DanaRPump private val danaRPump: DanaRPump,
private val dateUtil: DateUtil
) : DanaRS_Packet() { ) : DanaRS_Packet() {
init { init {
@ -48,7 +49,7 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_Information(
aapsLogger.debug(LTag.PUMPCOMM, "Result: $error") aapsLogger.debug(LTag.PUMPCOMM, "Result: $error")
aapsLogger.debug(LTag.PUMPCOMM, "BolusType: $bolusType") aapsLogger.debug(LTag.PUMPCOMM, "BolusType: $bolusType")
aapsLogger.debug(LTag.PUMPCOMM, "Initial bolus amount: " + danaRPump.initialBolusAmount + " U") aapsLogger.debug(LTag.PUMPCOMM, "Initial bolus amount: " + danaRPump.initialBolusAmount + " U")
aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + DateUtil.dateAndTimeString(danaRPump.lastBolusTime)) aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + dateUtil.dateAndTimeString(danaRPump.lastBolusTime))
aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount) aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount)
aapsLogger.debug(LTag.PUMPCOMM, "Max bolus: " + danaRPump.maxBolus + " U") aapsLogger.debug(LTag.PUMPCOMM, "Max bolus: " + danaRPump.maxBolus + " U")
aapsLogger.debug(LTag.PUMPCOMM, "Bolus step: " + danaRPump.bolusStep + " U") aapsLogger.debug(LTag.PUMPCOMM, "Bolus step: " + danaRPump.bolusStep + " U")

View file

@ -9,7 +9,8 @@ import java.util.*
class DanaRS_Packet_General_Get_More_Information( class DanaRS_Packet_General_Get_More_Information(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val danaRPump: DanaRPump private val danaRPump: DanaRPump,
private val dateUtil: DateUtil
) : DanaRS_Packet() { ) : DanaRS_Packet() {
init { init {
@ -52,7 +53,7 @@ class DanaRS_Packet_General_Get_More_Information(
aapsLogger.debug(LTag.PUMPCOMM, "Daily total units: " + danaRPump.dailyTotalUnits.toString() + " U") aapsLogger.debug(LTag.PUMPCOMM, "Daily total units: " + danaRPump.dailyTotalUnits.toString() + " U")
aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: " + danaRPump.isExtendedInProgress) aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: " + danaRPump.isExtendedInProgress)
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: " + danaRPump.extendedBolusRemainingMinutes) aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: " + danaRPump.extendedBolusRemainingMinutes)
aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + DateUtil.dateAndTimeAndSecondsString(lastBolusTime.time)) aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + dateUtil.dateAndTimeAndSecondsString(lastBolusTime.time))
aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount) aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount)
} }

View file

@ -8,7 +8,8 @@ import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_General_Get_Shipping_Information( class DanaRS_Packet_General_Get_Shipping_Information(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val danaRPump: DanaRPump private val danaRPump: DanaRPump,
private val dateUtil: DateUtil
) : DanaRS_Packet() { ) : DanaRS_Packet() {
init { init {
@ -31,7 +32,7 @@ class DanaRS_Packet_General_Get_Shipping_Information(
dataSize = 3 dataSize = 3
danaRPump.shippingCountry = asciiStringFromBuff(data, dataIndex, dataSize) danaRPump.shippingCountry = asciiStringFromBuff(data, dataIndex, dataSize)
aapsLogger.debug(LTag.PUMPCOMM, "Serial number: " + danaRPump.serialNumber) aapsLogger.debug(LTag.PUMPCOMM, "Serial number: " + danaRPump.serialNumber)
aapsLogger.debug(LTag.PUMPCOMM, "Shipping date: " + DateUtil.dateAndTimeString(danaRPump.shippingDate)) aapsLogger.debug(LTag.PUMPCOMM, "Shipping date: " + dateUtil.dateAndTimeString(danaRPump.shippingDate))
aapsLogger.debug(LTag.PUMPCOMM, "Shipping country: " + danaRPump.shippingCountry) aapsLogger.debug(LTag.PUMPCOMM, "Shipping country: " + danaRPump.shippingCountry)
} }

View file

@ -13,6 +13,7 @@ import java.util.*
abstract class DanaRS_Packet_History_( abstract class DanaRS_Packet_History_(
protected val aapsLogger: AAPSLogger, protected val aapsLogger: AAPSLogger,
protected val rxBus: RxBusWrapper, protected val rxBus: RxBusWrapper,
protected val dateUtil: DateUtil,
protected val from: Long protected val from: Long
) : DanaRS_Packet() { ) : DanaRS_Packet() {
@ -36,7 +37,7 @@ abstract class DanaRS_Packet_History_(
hour = cal[Calendar.HOUR_OF_DAY] hour = cal[Calendar.HOUR_OF_DAY]
min = cal[Calendar.MINUTE] min = cal[Calendar.MINUTE]
sec = cal[Calendar.SECOND] sec = cal[Calendar.SECOND]
aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(cal.timeInMillis)) aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(cal.timeInMillis))
} }
override fun getRequestParams(): ByteArray { override fun getRequestParams(): ByteArray {
@ -85,7 +86,7 @@ abstract class DanaRS_Packet_History_(
val historyCode = byteArrayToInt(getBytes(data, DATA_START + 7, 1)) val historyCode = byteArrayToInt(getBytes(data, DATA_START + 7, 1))
val paramByte8 = historyCode.toByte() val paramByte8 = historyCode.toByte()
val value: Int = (data[DATA_START + 8].toInt() and 0xFF shl 8) + (data[DATA_START + 9].toInt() and 0xFF) val value: Int = (data[DATA_START + 8].toInt() and 0xFF shl 8) + (data[DATA_START + 9].toInt() and 0xFF)
aapsLogger.debug(LTag.PUMPCOMM, "History packet: " + recordCode + " Date: " + DateUtil.dateAndTimeString(datetimewihtsec) + " Code: " + historyCode + " Value: " + value) aapsLogger.debug(LTag.PUMPCOMM, "History packet: " + recordCode + " Date: " + dateUtil.dateAndTimeString(datetimewihtsec) + " Code: " + historyCode + " Value: " + value)
val danaRHistoryRecord = DanaRHistoryRecord() val danaRHistoryRecord = DanaRHistoryRecord()
danaRHistoryRecord.setBytes(data) danaRHistoryRecord.setBytes(data)
// danaRHistoryRecord.recordCode is different from DanaR codes // danaRHistoryRecord.recordCode is different from DanaR codes
@ -197,7 +198,7 @@ abstract class DanaRS_Packet_History_(
} }
} }
MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord) MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord)
rxBus.send(EventDanaRSyncStatus(DateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType)) rxBus.send(EventDanaRSyncStatus(dateUtil.dateAndTimeString(danaRHistoryRecord.recordDate) + " " + messageType))
} }
} }

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Alarm @JvmOverloads constructor( class DanaRS_Packet_History_Alarm @JvmOverloads constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_All_History( class DanaRS_Packet_History_All_History(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Basal @JvmOverloads constructor( class DanaRS_Packet_History_Basal @JvmOverloads constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Blood_Glucose @JvmOverloads constructor( class DanaRS_Packet_History_Blood_Glucose @JvmOverloads constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Bolus @JvmOverloads constructor( class DanaRS_Packet_History_Bolus @JvmOverloads constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Carbohydrate @JvmOverloads constructor( class DanaRS_Packet_History_Carbohydrate @JvmOverloads constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Daily @JvmOverloads constructor( class DanaRS_Packet_History_Daily @JvmOverloads constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Prime @JvmOverloads constructor( class DanaRS_Packet_History_Prime @JvmOverloads constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Refill @JvmOverloads constructor( class DanaRS_Packet_History_Refill @JvmOverloads constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Suspend @JvmOverloads constructor( class DanaRS_Packet_History_Suspend @JvmOverloads constructor(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND

View file

@ -4,12 +4,14 @@ import com.cozmo.danar.util.BleCommandUtil
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.utils.DateUtil
class DanaRS_Packet_History_Temporary( class DanaRS_Packet_History_Temporary(
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rxBus: RxBusWrapper, rxBus: RxBusWrapper,
dateUtil: DateUtil,
from: Long = 0 from: Long = 0
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) { ) : DanaRS_Packet_History_(aapsLogger, rxBus, dateUtil, from) {
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY

View file

@ -9,7 +9,8 @@ import java.util.*
class DanaRS_Packet_Option_Get_Pump_Time( class DanaRS_Packet_Option_Get_Pump_Time(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val danaRPump: DanaRPump private val danaRPump: DanaRPump,
private val dateUtil: DateUtil
) : DanaRS_Packet() { ) : DanaRS_Packet() {
init { init {
@ -39,7 +40,7 @@ class DanaRS_Packet_Option_Get_Pump_Time(
val time = Date(100 + year, month - 1, day, hour, min, sec) val time = Date(100 + year, month - 1, day, hour, min, sec)
danaRPump.pumpTime = time.time danaRPump.pumpTime = time.time
failed = year == month && month == day && day == hour && hour == min && min == sec && sec == 1 failed = year == month && month == day && day == hour && hour == min && min == sec && sec == 1
aapsLogger.debug(LTag.PUMPCOMM, "Pump time " + DateUtil.dateAndTimeString(time)) aapsLogger.debug(LTag.PUMPCOMM, "Pump time " + dateUtil.dateAndTimeString(time))
} }
override fun handleMessageNotReceived() { override fun handleMessageNotReceived() {

View file

@ -8,6 +8,7 @@ import java.util.*
class DanaRS_Packet_Option_Set_Pump_Time( class DanaRS_Packet_Option_Set_Pump_Time(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val dateUtil: DateUtil,
private var time: Long = 0 private var time: Long = 0
) : DanaRS_Packet() { ) : DanaRS_Packet() {
@ -15,7 +16,7 @@ class DanaRS_Packet_Option_Set_Pump_Time(
init { init {
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_PUMP_TIME opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_PUMP_TIME
aapsLogger.debug(LTag.PUMPCOMM, "Setting pump time " + DateUtil.dateAndTimeString(time)) aapsLogger.debug(LTag.PUMPCOMM, "Setting pump time " + dateUtil.dateAndTimeString(time))
} }
override fun getRequestParams(): ByteArray { override fun getRequestParams(): ByteArray {

View file

@ -167,9 +167,9 @@ public class DanaRSService extends DaggerService {
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingextendedbolusstatus))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingextendedbolusstatus)));
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Extended_Bolus_State(aapsLogger, danaRPump));
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus)));
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)); // last bolus, bolusStep, maxBolus bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump, dateUtil)); // last bolus, bolusStep, maxBolus
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingtempbasalstatus))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingtempbasalstatus)));
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil));
danaRPump.setLastConnection(System.currentTimeMillis()); danaRPump.setLastConnection(System.currentTimeMillis());
@ -184,7 +184,7 @@ public class DanaRSService extends DaggerService {
} }
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime)));
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump, dateUtil));
long timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; long timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
if (danaRPump.getPumpTime() == 0) { if (danaRPump.getPumpTime() == 0) {
@ -198,7 +198,7 @@ public class DanaRSService extends DaggerService {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (danaRPump.getLastSettingsRead() + 60 * 60 * 1000L < now || !pump.isInitialized()) { if (danaRPump.getLastSettingsRead() + 60 * 60 * 1000L < now || !pump.isInitialized()) {
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpsettings)));
bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)); // serial no bleComm.sendMessage(new DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump, dateUtil)); // serial no
bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)); // firmware bleComm.sendMessage(new DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)); // firmware
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number(aapsLogger, danaRPump));
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)); // isExtendedEnabled bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Bolus_Option(aapsLogger, rxBus, resourceHelper, danaRPump)); // isExtendedEnabled
@ -228,13 +228,13 @@ public class DanaRSService extends DaggerService {
return; return;
} else { } else {
if (danaRPump.getProtocol() >= 6) { if (danaRPump.getProtocol() >= 6) {
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now())); bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, dateUtil, DateUtil.now()));
} else { } else {
waitForWholeMinute(); // Dana can set only whole minute waitForWholeMinute(); // Dana can set only whole minute
// add 10sec to be sure we are over minute (will be cutted off anyway) // add 10sec to be sure we are over minute (will be cutted off anyway)
bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, DateUtil.now() + T.secs(10).msecs())); bleComm.sendMessage(new DanaRS_Packet_Option_Set_Pump_Time(aapsLogger, dateUtil, DateUtil.now() + T.secs(10).msecs()));
} }
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time(aapsLogger, danaRPump, dateUtil));
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: " + timeDiff + " seconds"); aapsLogger.debug(LTag.PUMPCOMM, "Pump time difference: " + timeDiff + " seconds");
} }
@ -276,7 +276,7 @@ public class DanaRSService extends DaggerService {
aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history"); aapsLogger.debug(LTag.PUMPCOMM, "Loading complete event history");
} else { } else {
msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, dateUtil, lastHistoryFetched); msg = new DanaRS_Packet_APS_History_Events(aapsLogger, rxBus, resourceHelper, activePlugin, danaRSPlugin, detailedBolusInfoStorage, injector, dateUtil, lastHistoryFetched);
aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)); aapsLogger.debug(LTag.PUMPCOMM, "Loading event history from: " + dateUtil.dateAndTimeString(lastHistoryFetched));
} }
bleComm.sendMessage(msg); bleComm.sendMessage(msg);
while (!danaRSPlugin.apsHistoryDone && bleComm.isConnected()) { while (!danaRSPlugin.apsHistoryDone && bleComm.isConnected()) {
@ -315,7 +315,7 @@ public class DanaRSService extends DaggerService {
if (carbs > 0) { if (carbs > 0) {
// MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs); #### // MsgSetCarbsEntry msg = new MsgSetCarbsEntry(carbtime, carbs); ####
// bleComm.sendMessage(msg); // bleComm.sendMessage(msg);
DanaRS_Packet_APS_Set_Event_History msgSetHistoryEntry_v2 = new DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, carbtime, carbs, 0); DanaRS_Packet_APS_Set_Event_History msgSetHistoryEntry_v2 = new DanaRS_Packet_APS_Set_Event_History(aapsLogger, dateUtil, DanaRPump.CARBS, carbtime, carbs, 0);
bleComm.sendMessage(msgSetHistoryEntry_v2); bleComm.sendMessage(msgSetHistoryEntry_v2);
lastHistoryFetched = Math.min(lastHistoryFetched, carbtime - T.mins(1).msecs()); lastHistoryFetched = Math.min(lastHistoryFetched, carbtime - T.mins(1).msecs());
} }
@ -370,7 +370,7 @@ public class DanaRSService extends DaggerService {
public void run() { public void run() {
// reread bolus status // reread bolus status
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingbolusstatus)));
bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump)); // last bolus bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information(aapsLogger, danaRPump, dateUtil)); // last bolus
bolusingEvent.setPercent(100); bolusingEvent.setPercent(100);
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.disconnecting))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.disconnecting)));
} }
@ -403,7 +403,7 @@ public class DanaRSService extends DaggerService {
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger, percent, durationInHours)); bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Temporary_Basal(aapsLogger, percent, durationInHours));
SystemClock.sleep(200); SystemClock.sleep(200);
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil));
loadEvents(); loadEvents();
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
@ -417,7 +417,7 @@ public class DanaRSService extends DaggerService {
} }
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)); bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent));
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil));
loadEvents(); loadEvents();
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
@ -436,7 +436,7 @@ public class DanaRSService extends DaggerService {
} }
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent)); bleComm.sendMessage(new DanaRS_Packet_APS_Basal_Set_Temporary_Basal(aapsLogger, percent));
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil));
loadEvents(); loadEvents();
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
@ -446,7 +446,7 @@ public class DanaRSService extends DaggerService {
if (!isConnected()) return false; if (!isConnected()) return false;
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger)); bleComm.sendMessage(new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(aapsLogger));
bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump)); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Temporary_Basal_State(aapsLogger, danaRPump, dateUtil));
loadEvents(); loadEvents();
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
@ -493,31 +493,31 @@ public class DanaRSService extends DaggerService {
DanaRS_Packet_History_ msg = null; DanaRS_Packet_History_ msg = null;
switch (type) { switch (type) {
case RecordTypes.RECORD_TYPE_ALARM: case RecordTypes.RECORD_TYPE_ALARM:
msg = new DanaRS_Packet_History_Alarm(aapsLogger, rxBus); msg = new DanaRS_Packet_History_Alarm(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_PRIME: case RecordTypes.RECORD_TYPE_PRIME:
msg = new DanaRS_Packet_History_Prime(aapsLogger, rxBus); msg = new DanaRS_Packet_History_Prime(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_BASALHOUR: case RecordTypes.RECORD_TYPE_BASALHOUR:
msg = new DanaRS_Packet_History_Basal(aapsLogger, rxBus); msg = new DanaRS_Packet_History_Basal(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_BOLUS: case RecordTypes.RECORD_TYPE_BOLUS:
msg = new DanaRS_Packet_History_Bolus(aapsLogger, rxBus); msg = new DanaRS_Packet_History_Bolus(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_CARBO: case RecordTypes.RECORD_TYPE_CARBO:
msg = new DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus); msg = new DanaRS_Packet_History_Carbohydrate(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_DAILY: case RecordTypes.RECORD_TYPE_DAILY:
msg = new DanaRS_Packet_History_Daily(aapsLogger, rxBus); msg = new DanaRS_Packet_History_Daily(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_GLUCOSE: case RecordTypes.RECORD_TYPE_GLUCOSE:
msg = new DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus); msg = new DanaRS_Packet_History_Blood_Glucose(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_REFILL: case RecordTypes.RECORD_TYPE_REFILL:
msg = new DanaRS_Packet_History_Refill(aapsLogger, rxBus); msg = new DanaRS_Packet_History_Refill(aapsLogger, rxBus, dateUtil);
break; break;
case RecordTypes.RECORD_TYPE_SUSPEND: case RecordTypes.RECORD_TYPE_SUSPEND:
msg = new DanaRS_Packet_History_Suspend(aapsLogger, rxBus); msg = new DanaRS_Packet_History_Suspend(aapsLogger, rxBus, dateUtil);
break; break;
} }
if (msg != null) { if (msg != null) {

View file

@ -66,9 +66,10 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
TreatmentsPlugin treatmentsPlugin, TreatmentsPlugin treatmentsPlugin,
SP sp, SP sp,
CommandQueueProvider commandQueue, CommandQueueProvider commandQueue,
DetailedBolusInfoStorage detailedBolusInfoStorage DetailedBolusInfoStorage detailedBolusInfoStorage,
DateUtil dateUtil
) { ) {
super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp); super(injector, danaRPump, resourceHelper, constraintChecker, aapsLogger, commandQueue, rxBus, treatmentsPlugin, sp, dateUtil);
this.aapsLogger = aapsLogger; this.aapsLogger = aapsLogger;
this.context = context; this.context = context;
this.resourceHelper = resourceHelper; this.resourceHelper = resourceHelper;

View file

@ -47,11 +47,11 @@ class MessageHashTableRv2 @Inject constructor(
put(MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, 0.0, 0)) // 0x0104 CMD_MEALINS_START_DATA_SPEED put(MsgBolusStartWithSpeed(aapsLogger, constraintChecker, danaRPump, 0.0, 0)) // 0x0104 CMD_MEALINS_START_DATA_SPEED
put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS put(MsgBolusProgress(aapsLogger, resourceHelper, rxBus, danaRPump)) // 0x0202 CMD_PUMP_THIS_REMAINDER_MEAL_INS
put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING put(MsgStatusProfile(aapsLogger, danaRPump)) // 0x0204 CMD_PUMP_CALCULATION_SETTING
put(MsgStatusTempBasal_v2(aapsLogger, danaRPump)) // 0x0205 CMD_PUMP_EXERCISE_MODE put(MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil)) // 0x0205 CMD_PUMP_EXERCISE_MODE
put(MsgStatusBolusExtended_v2(aapsLogger, danaRPump)) // 0x0207 CMD_PUMP_EXPANS_INS_I put(MsgStatusBolusExtended_v2(aapsLogger, danaRPump)) // 0x0207 CMD_PUMP_EXPANS_INS_I
put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I put(MsgStatusBasic(aapsLogger, danaRPump)) // 0x020A CMD_PUMP_INITVIEW_I
put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS put(MsgStatus(aapsLogger, danaRPump)) // 0x020B CMD_PUMP_STATUS
put(MsgInitConnStatusTime(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue)) // 0x0301 CMD_PUMPINIT_TIME_INFO put(MsgInitConnStatusTime(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, configBuilderPlugin, commandQueue, dateUtil)) // 0x0301 CMD_PUMPINIT_TIME_INFO
put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO put(MsgInitConnStatusBolus(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0302 CMD_PUMPINIT_BOLUS_INFO
put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO put(MsgInitConnStatusBasic(aapsLogger, danaRPump)) // 0x0303 CMD_PUMPINIT_INIT_INFO
put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION put(MsgInitConnStatusOption(aapsLogger, rxBus, resourceHelper, danaRPump, activePlugin)) // 0x0304 CMD_PUMPINIT_OPTION
@ -63,15 +63,15 @@ class MessageHashTableRv2 @Inject constructor(
put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(MsgError(aapsLogger, rxBus, resourceHelper, danaRPump)) // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS
put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT put(MsgPCCommStart(aapsLogger)) // 0x3001 CMD_CONNECT
put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT put(MsgPCCommStop(aapsLogger)) // 0x3002 CMD_DISCONNECT
put(MsgHistoryBolus(aapsLogger, rxBus)) // 0x3101 CMD_HISTORY_MEAL_INS put(MsgHistoryBolus(aapsLogger, rxBus, dateUtil)) // 0x3101 CMD_HISTORY_MEAL_INS
put(MsgHistoryDailyInsulin(aapsLogger, rxBus)) // 0x3102 CMD_HISTORY_DAY_INS put(MsgHistoryDailyInsulin(aapsLogger, rxBus, dateUtil)) // 0x3102 CMD_HISTORY_DAY_INS
put(MsgHistoryGlucose(aapsLogger, rxBus)) // 0x3104 CMD_HISTORY_GLUCOSE put(MsgHistoryGlucose(aapsLogger, rxBus, dateUtil)) // 0x3104 CMD_HISTORY_GLUCOSE
put(MsgHistoryAlarm(aapsLogger, rxBus)) // 0x3105 CMD_HISTORY_ALARM put(MsgHistoryAlarm(aapsLogger, rxBus, dateUtil)) // 0x3105 CMD_HISTORY_ALARM
put(MsgHistoryError(aapsLogger, rxBus)) // 0x3106 CMD_HISTORY_ERROR put(MsgHistoryError(aapsLogger, rxBus, dateUtil)) // 0x3106 CMD_HISTORY_ERROR
put(MsgHistoryCarbo(aapsLogger, rxBus)) // 0x3107 CMD_HISTORY_CARBOHY put(MsgHistoryCarbo(aapsLogger, rxBus, dateUtil)) // 0x3107 CMD_HISTORY_CARBOHY
put(MsgHistoryRefill(aapsLogger, rxBus)) // 0x3108 CMD_HISTORY_REFILL put(MsgHistoryRefill(aapsLogger, rxBus, dateUtil)) // 0x3108 CMD_HISTORY_REFILL
put(MsgHistorySuspend(aapsLogger, rxBus)) // 0x3109 CMD_HISTORY_SUSPEND put(MsgHistorySuspend(aapsLogger, rxBus, dateUtil)) // 0x3109 CMD_HISTORY_SUSPEND
put(MsgHistoryBasalHour(aapsLogger, rxBus)) // 0x310A CMD_HISTORY_BASAL_HOUR put(MsgHistoryBasalHour(aapsLogger, rxBus, dateUtil)) // 0x310A CMD_HISTORY_BASAL_HOUR
put(MsgHistoryDone(aapsLogger, danaRPump)) // 0x31F1 CMD_HISTORY_DONT_USED put(MsgHistoryDone(aapsLogger, danaRPump)) // 0x31F1 CMD_HISTORY_DONT_USED
put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I put(MsgSettingBasal(aapsLogger, danaRPump, danaRPlugin)) // 0x3202 CMD_SETTING_V_BASAL_INS_I
put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I put(MsgSettingMeal(aapsLogger, rxBus, resourceHelper, danaRPump, danaRKoreanPlugin)) // 0x3203 CMD_SETTING_V_MEAL_SETTING_I
@ -80,7 +80,7 @@ class MessageHashTableRv2 @Inject constructor(
put(MsgSettingBasalProfileAll(aapsLogger, danaRPump)) // 0x3206 CMD_SETTING_V_BASAL_PROFILE_ALL put(MsgSettingBasalProfileAll(aapsLogger, danaRPump)) // 0x3206 CMD_SETTING_V_BASAL_PROFILE_ALL
put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I put(MsgSettingShippingInfo(aapsLogger, danaRPump)) // 0x3207 CMD_SETTING_V_SHIPPING_I
put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY put(MsgSettingGlucose(aapsLogger, danaRPump)) // 0x3209 CMD_SETTING_V_GLUCOSEandEASY
put(MsgSettingPumpTime(aapsLogger, danaRPump)) // 0x320A CMD_SETTING_V_TIME_I put(MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil)) // 0x320A CMD_SETTING_V_TIME_I
put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS put(MsgSettingUserOptions(aapsLogger, danaRPump)) // 0x320B CMD_SETTING_V_USER_OPTIONS
put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER put(MsgSettingActiveProfile(aapsLogger, danaRPump)) // 0x320C CMD_SETTING_V_PROFILE_NUMBER
put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE put(MsgSettingProfileRatiosAll(aapsLogger, danaRPump)) // 0x320D CMD_SETTING_V_CIR_CF_VALUE
@ -89,9 +89,9 @@ class MessageHashTableRv2 @Inject constructor(
put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S put(MsgSetUserOptions(aapsLogger, danaRPump)) // 0x330B CMD_SETTING_USER_OPTIONS_S
put(MsgSetActivateBasalProfile(aapsLogger, 0.toByte())) // 0x330C CMD_SETTING_PROFILE_NUMBER_S put(MsgSetActivateBasalProfile(aapsLogger, 0.toByte())) // 0x330C CMD_SETTING_PROFILE_NUMBER_S
put(MsgHistoryAllDone(aapsLogger, danaRPump)) // 0x41F1 CMD_HISTORY_ALL_DONE put(MsgHistoryAllDone(aapsLogger, danaRPump)) // 0x41F1 CMD_HISTORY_ALL_DONE
put(MsgHistoryAll(aapsLogger, rxBus)) // 0x41F2 CMD_HISTORY_ALL put(MsgHistoryAll(aapsLogger, rxBus, dateUtil)) // 0x41F2 CMD_HISTORY_ALL
put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE put(MsgHistoryNewDone(aapsLogger, danaRPump)) // 0x42F1 CMD_HISTORY_NEW_DONE
put(MsgHistoryNew(aapsLogger, rxBus)) // 0x42F2 CMD_HISTORY_NEW put(MsgHistoryNew(aapsLogger, rxBus, dateUtil)) // 0x42F2 CMD_HISTORY_NEW
put(MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)) // 0xF0F1 CMD_PUMP_CHECK_VALUE put(MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue)) // 0xF0F1 CMD_PUMP_CHECK_VALUE
put(MsgStatusAPS_v2(aapsLogger, danaRPump)) // 0xE001 CMD_PUMPSTATUS_APS put(MsgStatusAPS_v2(aapsLogger, danaRPump)) // 0xE001 CMD_PUMPSTATUS_APS
put(MsgSetAPSTempBasalStart_v2(aapsLogger, 0, false, false)) // 0xE002 CMD_PUMPSET_APSTEMP put(MsgSetAPSTempBasalStart_v2(aapsLogger, 0, false, false)) // 0xE002 CMD_PUMPSET_APSTEMP

View file

@ -75,7 +75,7 @@ class MsgHistoryEvents_v2 constructor(
val status: String val status: String
when (recordCode.toInt()) { when (recordCode.toInt()) {
DanaRPump.TEMPSTART -> { DanaRPump.TEMPSTART -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT TEMPSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT TEMPSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Ratio: " + param1 + "% Duration: " + param2 + "min")
temporaryBasal.percentRate = param1 temporaryBasal.percentRate = param1
temporaryBasal.durationInMinutes = param2 temporaryBasal.durationInMinutes = param2
treatmentsPlugin.addToHistoryTempBasal(temporaryBasal) treatmentsPlugin.addToHistoryTempBasal(temporaryBasal)
@ -83,13 +83,13 @@ class MsgHistoryEvents_v2 constructor(
} }
DanaRPump.TEMPSTOP -> { DanaRPump.TEMPSTOP -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime)) aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT TEMPSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime))
treatmentsPlugin.addToHistoryTempBasal(temporaryBasal) treatmentsPlugin.addToHistoryTempBasal(temporaryBasal)
status = "TEMPSTOP " + dateUtil.timeString(datetime) status = "TEMPSTOP " + dateUtil.timeString(datetime)
} }
DanaRPump.EXTENDEDSTART -> { DanaRPump.EXTENDEDSTART -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT EXTENDEDSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT EXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min")
extendedBolus.insulin = param1 / 100.0 extendedBolus.insulin = param1 / 100.0
extendedBolus.durationInMinutes = param2 extendedBolus.durationInMinutes = param2
treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus)
@ -97,7 +97,7 @@ class MsgHistoryEvents_v2 constructor(
} }
DanaRPump.EXTENDEDSTOP -> { DanaRPump.EXTENDEDSTOP -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT EXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min")
treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus)
status = "EXTENDEDSTOP " + dateUtil.timeString(datetime) status = "EXTENDEDSTOP " + dateUtil.timeString(datetime)
} }
@ -110,7 +110,7 @@ class MsgHistoryEvents_v2 constructor(
detailedBolusInfo.pumpId = datetime detailedBolusInfo.pumpId = datetime
detailedBolusInfo.insulin = param1 / 100.0 detailedBolusInfo.insulin = param1 / 100.0
val newRecord = treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false) val newRecord = treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false)
aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT BOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min")
status = "BOLUS " + dateUtil.timeString(datetime) status = "BOLUS " + dateUtil.timeString(datetime)
} }
@ -122,12 +122,12 @@ class MsgHistoryEvents_v2 constructor(
detailedBolusInfo.pumpId = datetime detailedBolusInfo.pumpId = datetime
detailedBolusInfo.insulin = param1 / 100.0 detailedBolusInfo.insulin = param1 / 100.0
val newRecord = treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false) val newRecord = treatmentsPlugin.addToHistoryTreatment(detailedBolusInfo, false)
aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT DUALBOLUS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Bolus: " + param1 / 100.0 + "U Duration: " + param2 + "min")
status = "DUALBOLUS " + dateUtil.timeString(datetime) status = "DUALBOLUS " + dateUtil.timeString(datetime)
} }
DanaRPump.DUALEXTENDEDSTART -> { DanaRPump.DUALEXTENDEDSTART -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT DUALEXTENDEDSTART (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U Duration: " + param2 + "min")
extendedBolus.insulin = param1 / 100.0 extendedBolus.insulin = param1 / 100.0
extendedBolus.durationInMinutes = param2 extendedBolus.durationInMinutes = param2
treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus)
@ -135,33 +135,33 @@ class MsgHistoryEvents_v2 constructor(
} }
DanaRPump.DUALEXTENDEDSTOP -> { DanaRPump.DUALEXTENDEDSTOP -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Delivered: " + param1 / 100.0 + "U RealDuration: " + param2 + "min")
treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus) treatmentsPlugin.addToHistoryExtendedBolus(extendedBolus)
status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime) status = "DUALEXTENDEDSTOP " + dateUtil.timeString(datetime)
} }
DanaRPump.SUSPENDON -> { DanaRPump.SUSPENDON -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDON (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDON (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
status = "SUSPENDON " + dateUtil.timeString(datetime) status = "SUSPENDON " + dateUtil.timeString(datetime)
} }
DanaRPump.SUSPENDOFF -> { DanaRPump.SUSPENDOFF -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT SUSPENDOFF (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")")
status = "SUSPENDOFF " + dateUtil.timeString(datetime) status = "SUSPENDOFF " + dateUtil.timeString(datetime)
} }
DanaRPump.REFILL -> { DanaRPump.REFILL -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT REFILL (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT REFILL (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
status = "REFILL " + dateUtil.timeString(datetime) status = "REFILL " + dateUtil.timeString(datetime)
} }
DanaRPump.PRIME -> { DanaRPump.PRIME -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PRIME (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PRIME (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Amount: " + param1 / 100.0 + "U")
status = "PRIME " + dateUtil.timeString(datetime) status = "PRIME " + dateUtil.timeString(datetime)
} }
DanaRPump.PROFILECHANGE -> { DanaRPump.PROFILECHANGE -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h") aapsLogger.debug(LTag.PUMPBTCOMM, "EVENT PROFILECHANGE (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " No: " + param1 + " CurrentRate: " + param2 / 100.0 + "U/h")
status = "PROFILECHANGE " + dateUtil.timeString(datetime) status = "PROFILECHANGE " + dateUtil.timeString(datetime)
} }
@ -172,12 +172,12 @@ class MsgHistoryEvents_v2 constructor(
emptyCarbsInfo.source = Source.PUMP emptyCarbsInfo.source = Source.PUMP
emptyCarbsInfo.pumpId = datetime emptyCarbsInfo.pumpId = datetime
val newRecord = treatmentsPlugin.addToHistoryTreatment(emptyCarbsInfo, false) val newRecord = treatmentsPlugin.addToHistoryTreatment(emptyCarbsInfo, false)
aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g") aapsLogger.debug(LTag.PUMPBTCOMM, (if (newRecord) "**NEW** " else "") + "EVENT CARBS (" + recordCode + ") " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Carbs: " + param1 + "g")
status = "CARBS " + dateUtil.timeString(datetime) status = "CARBS " + dateUtil.timeString(datetime)
} }
else -> { else -> {
aapsLogger.debug(LTag.PUMPBTCOMM, "Event: " + recordCode + " " + DateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2) aapsLogger.debug(LTag.PUMPBTCOMM, "Event: " + recordCode + " " + dateUtil.dateAndTimeString(datetime) + " (" + datetime + ")" + " Param1: " + param1 + " Param2: " + param2)
status = "UNKNOWN " + dateUtil.timeString(datetime) status = "UNKNOWN " + dateUtil.timeString(datetime)
} }
} }

View file

@ -9,8 +9,8 @@ import kotlin.math.ceil
class MsgStatusTempBasal_v2( class MsgStatusTempBasal_v2(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,
private val danaRPump: DanaRPump private val danaRPump: DanaRPump,
private val dateUtil: DateUtil
) : MessageBase() { ) : MessageBase() {
init { init {
@ -37,7 +37,7 @@ class MsgStatusTempBasal_v2(
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal percent: $tempBasalPercent") aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal percent: $tempBasalPercent")
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal remaining min: $tempBasalRemainingMin") aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal remaining min: $tempBasalRemainingMin")
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal total sec: $tempBasalTotalSec") aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal total sec: $tempBasalTotalSec")
aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal start: " + DateUtil.dateAndTimeString(tempBasalStart)) aapsLogger.debug(LTag.PUMPCOMM, "Current temp basal start: " + dateUtil.dateAndTimeString(tempBasalStart))
} }
private fun getDateFromTempBasalSecAgo(tempBasalAgoSecs: Int): Long { private fun getDateFromTempBasalSecAgo(tempBasalAgoSecs: Int): Long {

View file

@ -16,19 +16,20 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.activities.ErrorHelperActivity; import info.nightscout.androidaps.activities.ErrorHelperActivity;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.dialogs.BolusProgressDialog; import info.nightscout.androidaps.dialogs.BolusProgressDialog;
import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventInitializationChanged;
import info.nightscout.androidaps.events.EventProfileNeedsUpdate; import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.CommandQueueProvider;
import info.nightscout.androidaps.interfaces.ProfileFunction;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker; import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
import info.nightscout.androidaps.interfaces.ProfileFunction;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload; import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
@ -72,7 +73,6 @@ import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgSetAPSTempBasalSt
import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgSetHistoryEntry_v2; import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgSetHistoryEntry_v2;
import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgStatusBolusExtended_v2; import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgStatusBolusExtended_v2;
import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgStatusTempBasal_v2; import info.nightscout.androidaps.plugins.pump.danaRv2.comm.MsgStatusTempBasal_v2;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.androidaps.queue.commands.Command;
@ -159,7 +159,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumpstatus)));
MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump); MsgStatus statusMsg = new MsgStatus(aapsLogger, danaRPump);
MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump); MsgStatusBasic statusBasicMsg = new MsgStatusBasic(aapsLogger, danaRPump);
MsgStatusTempBasal_v2 tempStatusMsg = new MsgStatusTempBasal_v2(aapsLogger, danaRPump); MsgStatusTempBasal_v2 tempStatusMsg = new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil);
MsgStatusBolusExtended_v2 exStatusMsg = new MsgStatusBolusExtended_v2(aapsLogger, danaRPump); MsgStatusBolusExtended_v2 exStatusMsg = new MsgStatusBolusExtended_v2(aapsLogger, danaRPump);
MsgCheckValue_v2 checkValue = new MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue); MsgCheckValue_v2 checkValue = new MsgCheckValue_v2(aapsLogger, rxBus, resourceHelper, danaRPump, danaRPlugin, danaRKoreanPlugin, danaRv2Plugin, configBuilderPlugin, commandQueue);
@ -191,7 +191,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
} }
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.gettingpumptime)));
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil));
if (danaRPump.getPumpTime() == 0) { if (danaRPump.getPumpTime() == 0) {
// initial handshake was not successfull // initial handshake was not successfull
// deinitialize pump // deinitialize pump
@ -222,8 +222,8 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
} else { } else {
waitForWholeMinute(); // Dana can set only whole minute waitForWholeMinute(); // Dana can set only whole minute
// add 10sec to be sure we are over minute (will be cutted off anyway) // add 10sec to be sure we are over minute (will be cutted off anyway)
mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, new Date(DateUtil.now() + T.secs(10).msecs()))); mSerialIOThread.sendMessage(new MsgSetTime(aapsLogger, dateUtil, new Date(DateUtil.now() + T.secs(10).msecs())));
mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgSettingPumpTime(aapsLogger, danaRPump, dateUtil));
timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L; timeDiff = (danaRPump.getPumpTime() - System.currentTimeMillis()) / 1000L;
aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds"); aapsLogger.debug(LTag.PUMP, "Pump time difference: " + timeDiff + " seconds");
} }
@ -274,7 +274,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
} }
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours)); mSerialIOThread.sendMessage(new MsgSetTempBasalStart(aapsLogger, percent, durationInHours));
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil));
loadEvents(); loadEvents();
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
@ -289,7 +289,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
} }
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(aapsLogger, percent, durationInMinutes == 15, durationInMinutes == 30)); mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(aapsLogger, percent, durationInMinutes == 15, durationInMinutes == 30));
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil));
loadEvents(); loadEvents();
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
@ -309,7 +309,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
} }
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.settingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(aapsLogger, percent, durationInMinutes == 15, durationInMinutes == 30)); mSerialIOThread.sendMessage(new MsgSetAPSTempBasalStart_v2(aapsLogger, percent, durationInMinutes == 15, durationInMinutes == 30));
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil));
loadEvents(); loadEvents();
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
@ -319,7 +319,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
if (!isConnected()) return false; if (!isConnected()) return false;
rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal))); rxBus.send(new EventPumpStatusChanged(resourceHelper.gs(R.string.stoppingtempbasal)));
mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger)); mSerialIOThread.sendMessage(new MsgSetTempBasalStop(aapsLogger));
mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump)); mSerialIOThread.sendMessage(new MsgStatusTempBasal_v2(aapsLogger, danaRPump, dateUtil));
loadEvents(); loadEvents();
rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING)); rxBus.send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTING));
return true; return true;
@ -450,7 +450,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
return new PumpEnactResult(injector).success(false); return new PumpEnactResult(injector).success(false);
SystemClock.sleep(300); SystemClock.sleep(300);
MsgHistoryEvents_v2 msg = new MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, injector, dateUtil, lastHistoryFetched); MsgHistoryEvents_v2 msg = new MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, rxBus, treatmentsPlugin, injector, dateUtil, lastHistoryFetched);
aapsLogger.debug(LTag.PUMP, "Loading event history from: " + DateUtil.dateAndTimeString(lastHistoryFetched)); aapsLogger.debug(LTag.PUMP, "Loading event history from: " + dateUtil.dateAndTimeString(lastHistoryFetched));
mSerialIOThread.sendMessage(msg); mSerialIOThread.sendMessage(msg);
while (!danaRv2Plugin.eventsLoadingDone && mRfcommSocket.isConnected()) { while (!danaRv2Plugin.eventsLoadingDone && mRfcommSocket.isConnected()) {

View file

@ -150,6 +150,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
private final CommandQueueProvider commandQueue; private final CommandQueueProvider commandQueue;
private final ProfileFunction profileFunction; private final ProfileFunction profileFunction;
private final Context context; private final Context context;
private final DateUtil dateUtil;
public static final String ALERT_CHANNEL_ID = "AndroidAPS-InsightAlert"; public static final String ALERT_CHANNEL_ID = "AndroidAPS-InsightAlert";
@ -209,7 +210,8 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
CommandQueueProvider commandQueue, CommandQueueProvider commandQueue,
ProfileFunction profileFunction, ProfileFunction profileFunction,
Context context, Context context,
Config config Config config,
DateUtil dateUtil
) { ) {
super(new PluginDescription() super(new PluginDescription()
.pluginName(R.string.insight_local) .pluginName(R.string.insight_local)
@ -229,6 +231,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
this.commandQueue = commandQueue; this.commandQueue = commandQueue;
this.profileFunction = profileFunction; this.profileFunction = profileFunction;
this.context = context; this.context = context;
this.dateUtil = dateUtil;
pumpDescription = new PumpDescription(); pumpDescription = new PumpDescription();
pumpDescription.setPumpDescription(PumpType.AccuChekInsightBluetooth); pumpDescription.setPumpDescription(PumpType.AccuChekInsightBluetooth);
@ -996,13 +999,13 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
TemporaryBasal tb = treatmentsPlugin.getTempBasalFromHistory(now); TemporaryBasal tb = treatmentsPlugin.getTempBasalFromHistory(now);
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now); ExtendedBolus eb = treatmentsPlugin.getExtendedBolusFromHistory(now);
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date));
extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes()); extended.put("ExtendedBolusRemaining", eb.getPlannedRemainingMinutes());
} }
extended.put("BaseBasalRate", getBaseBasalRate()); extended.put("BaseBasalRate", getBaseBasalRate());

View file

@ -84,6 +84,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButt
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService; import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.TimeChangeType; import info.nightscout.androidaps.utils.TimeChangeType;
import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.resources.ResourceHelper;
@ -136,7 +137,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
MedtronicPumpStatus medtronicPumpStatus, MedtronicPumpStatus medtronicPumpStatus,
MedtronicHistoryData medtronicHistoryData, MedtronicHistoryData medtronicHistoryData,
RileyLinkServiceData rileyLinkServiceData, RileyLinkServiceData rileyLinkServiceData,
ServiceTaskExecutor serviceTaskExecutor ServiceTaskExecutor serviceTaskExecutor,
DateUtil dateUtil
) { ) {
super(new PluginDescription() // super(new PluginDescription() //
@ -147,7 +149,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
.preferencesId(R.xml.pref_medtronic) .preferencesId(R.xml.pref_medtronic)
.description(R.string.description_pump_medtronic), // .description(R.string.description_pump_medtronic), //
PumpType.Medtronic_522_722, // we default to most basic model, correct model from config is loaded later PumpType.Medtronic_522_722, // we default to most basic model, correct model from config is loaded later
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil
); );
this.rileyLinkUtil = rileyLinkUtil; this.rileyLinkUtil = rileyLinkUtil;

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface; import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem;
import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil; import info.nightscout.androidaps.plugins.pump.common.utils.StringUtil;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.resources.ResourceHelper;
/** /**
@ -32,6 +33,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
public class RileyLinkStatusDeviceMedtronic extends DaggerFragment implements RefreshableInterface { public class RileyLinkStatusDeviceMedtronic extends DaggerFragment implements RefreshableInterface {
@Inject ResourceHelper resourceHelper; @Inject ResourceHelper resourceHelper;
@Inject DateUtil dateUtil;
// @BindView(R.id.rileylink_history_list) // @BindView(R.id.rileylink_history_list)
ListView listView; ListView listView;
@ -153,7 +155,7 @@ public class RileyLinkStatusDeviceMedtronic extends DaggerFragment implements Re
} }
RLHistoryItem item = historyItemList.get(i); RLHistoryItem item = historyItemList.get(i);
viewHolder.itemTime.setText(StringUtil.toDateTimeString(item.getDateTime())); viewHolder.itemTime.setText(StringUtil.toDateTimeString(dateUtil, item.getDateTime()));
viewHolder.itemSource.setText("Riley Link"); // for now viewHolder.itemSource.setText("Riley Link"); // for now
viewHolder.itemDescription.setText(item.getDescription(resourceHelper)); viewHolder.itemDescription.setText(item.getDescription(resourceHelper));

View file

@ -73,6 +73,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodRefres
import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService; import info.nightscout.androidaps.plugins.pump.omnipod.service.RileyLinkOmnipodService;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodConst;
import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil; import info.nightscout.androidaps.plugins.pump.omnipod.util.OmnipodUtil;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.FabricPrivacy; import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.Round; import info.nightscout.androidaps.utils.Round;
import info.nightscout.androidaps.utils.TimeChangeType; import info.nightscout.androidaps.utils.TimeChangeType;
@ -136,7 +137,9 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
CommandQueueProvider commandQueue, CommandQueueProvider commandQueue,
FabricPrivacy fabricPrivacy, FabricPrivacy fabricPrivacy,
RileyLinkServiceData rileyLinkServiceData, RileyLinkServiceData rileyLinkServiceData,
ServiceTaskExecutor serviceTaskExecutor) { ServiceTaskExecutor serviceTaskExecutor,
DateUtil dateUtil
) {
super(new PluginDescription() // super(new PluginDescription() //
.mainType(PluginType.PUMP) // .mainType(PluginType.PUMP) //
@ -146,7 +149,7 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
.preferencesId(R.xml.pref_omnipod) // .preferencesId(R.xml.pref_omnipod) //
.description(R.string.description_pump_omnipod), // .description(R.string.description_pump_omnipod), //
PumpType.Insulet_Omnipod, PumpType.Insulet_Omnipod,
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil
); );
this.rileyLinkServiceData = rileyLinkServiceData; this.rileyLinkServiceData = rileyLinkServiceData;
this.serviceTaskExecutor = serviceTaskExecutor; this.serviceTaskExecutor = serviceTaskExecutor;
@ -232,8 +235,10 @@ public class OmnipodPumpPlugin extends PumpPluginAbstract implements OmnipodPump
ActivePluginProvider activePlugin, ActivePluginProvider activePlugin,
info.nightscout.androidaps.utils.sharedPreferences.SP sp, info.nightscout.androidaps.utils.sharedPreferences.SP sp,
CommandQueueProvider commandQueue, CommandQueueProvider commandQueue,
FabricPrivacy fabricPrivacy) { FabricPrivacy fabricPrivacy,
super(pluginDescription, pumpType, injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy); DateUtil dateUtil
) {
super(pluginDescription, pumpType, injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy, dateUtil);
// this.rileyLinkUtil = rileyLinkUtil; // this.rileyLinkUtil = rileyLinkUtil;
// this.medtronicUtil = medtronicUtil; // this.medtronicUtil = medtronicUtil;

View file

@ -36,6 +36,7 @@ public class PodSessionState extends PodState {
@Inject AAPSLogger aapsLogger; @Inject AAPSLogger aapsLogger;
@Inject SP sp; @Inject SP sp;
@Inject OmnipodUtil omnipodUtil; @Inject OmnipodUtil omnipodUtil;
@Inject DateUtil dateUtil;
private final Map<AlertSlot, AlertType> configuredAlerts; private final Map<AlertSlot, AlertType> configuredAlerts;
private transient PodStateChangedHandler stateChangedHandler; private transient PodStateChangedHandler stateChangedHandler;
@ -112,7 +113,7 @@ public class PodSessionState extends PodState {
} }
public String getExpiryDateAsString() { public String getExpiryDateAsString() {
return expiresAt == null ? "???" : DateUtil.dateAndTimeString(expiresAt.toDate()); return expiresAt == null ? "???" : dateUtil.dateAndTimeString(expiresAt.toDate());
} }
public FirmwareVersion getPiVersion() { public FirmwareVersion getPiVersion() {

View file

@ -52,7 +52,8 @@ class VirtualPumpPlugin @Inject constructor(
private val profileFunction: ProfileFunction, private val profileFunction: ProfileFunction,
private val treatmentsPlugin: TreatmentsPlugin, private val treatmentsPlugin: TreatmentsPlugin,
commandQueue: CommandQueueProvider, commandQueue: CommandQueueProvider,
private val config: Config private val config: Config,
private val dateUtil: DateUtil
) : PumpPluginBase(PluginDescription() ) : PumpPluginBase(PluginDescription()
.mainType(PluginType.PUMP) .mainType(PluginType.PUMP)
.fragmentClass(VirtualPumpFragment::class.java.name) .fragmentClass(VirtualPumpFragment::class.java.name)
@ -356,13 +357,13 @@ class VirtualPumpPlugin @Inject constructor(
val tb = treatmentsPlugin.getTempBasalFromHistory(now) val tb = treatmentsPlugin.getTempBasalFromHistory(now)
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile)) extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile))
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)) extended.put("TempBasalStart", dateUtil.dateAndTimeString(tb.date))
extended.put("TempBasalRemaining", tb.plannedRemainingMinutes) extended.put("TempBasalRemaining", tb.plannedRemainingMinutes)
} }
val eb = treatmentsPlugin.getExtendedBolusFromHistory(now) val eb = treatmentsPlugin.getExtendedBolusFromHistory(now)
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()) extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate())
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)) extended.put("ExtendedBolusStart", dateUtil.dateAndTimeString(eb.date))
extended.put("ExtendedBolusRemaining", eb.plannedRemainingMinutes) extended.put("ExtendedBolusRemaining", eb.plannedRemainingMinutes)
} }
status.put("timestamp", DateUtil.toISOString(now)) status.put("timestamp", DateUtil.toISOString(now))

View file

@ -38,7 +38,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
private SP sp; private SP sp;
private ProfileFunction profileFunction; private ProfileFunction profileFunction;
private ResourceHelper resourceHelper; private DateUtil dateUtil;
@Inject @Inject
public SensitivityAAPSPlugin( public SensitivityAAPSPlugin(
@ -46,7 +46,8 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
AAPSLogger aapsLogger, AAPSLogger aapsLogger,
ResourceHelper resourceHelper, ResourceHelper resourceHelper,
SP sp, SP sp,
ProfileFunction profileFunction ProfileFunction profileFunction,
DateUtil dateUtil
) { ) {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.SENSITIVITY) .mainType(PluginType.SENSITIVITY)
@ -58,6 +59,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
); );
this.sp = sp; this.sp = sp;
this.profileFunction = profileFunction; this.profileFunction = profileFunction;
this.dateUtil = dateUtil;
} }
@NonNull @Override @NonNull @Override
@ -66,9 +68,9 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
String age = sp.getString(R.string.key_age, ""); String age = sp.getString(R.string.key_age, "");
int defaultHours = 24; int defaultHours = 24;
if (age.equals(resourceHelper.gs(R.string.key_adult))) defaultHours = 24; if (age.equals(getResourceHelper().gs(R.string.key_adult))) defaultHours = 24;
if (age.equals(resourceHelper.gs(R.string.key_teenage))) defaultHours = 4; if (age.equals(getResourceHelper().gs(R.string.key_teenage))) defaultHours = 4;
if (age.equals(resourceHelper.gs(R.string.key_child))) defaultHours = 4; if (age.equals(getResourceHelper().gs(R.string.key_child))) defaultHours = 4;
int hoursForDetection = sp.getInt(R.string.key_openapsama_autosens_period, defaultHours); int hoursForDetection = sp.getInt(R.string.key_openapsama_autosens_period, defaultHours);
Profile profile = profileFunction.getProfile(); Profile profile = profileFunction.getProfile();
@ -85,7 +87,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already
if (current == null) { if (current == null) {
getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + dateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }
@ -116,7 +118,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
} }
// reset deviations after profile switch // reset deviations after profile switch
if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) { if (new ProfileSwitch(getInjector()).isEvent5minBack(profileSwitches, autosensData.time, true)) {
deviationsArray.clear(); deviationsArray.clear();
pastSensitivity += "(PROFILESWITCH)"; pastSensitivity += "(PROFILESWITCH)";
} }
@ -172,7 +174,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
sensResult, deviationsArray.size()); sensResult, deviationsArray.size());
getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: " getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: "
+ DateUtil.dateAndTimeString(toTime) + + dateUtil.dateAndTimeString(toTime) +
" ratio: " + output.ratio " ratio: " + output.ratio
+ " mealCOB: " + current.cob); + " mealCOB: " + current.cob);
getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: deviations " + Arrays.toString(deviations)); getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: deviations " + Arrays.toString(deviations));

View file

@ -35,7 +35,8 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
@Singleton @Singleton
public class SensitivityOref1Plugin extends AbstractSensitivityPlugin { public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
private ProfileFunction profileFunction; private final ProfileFunction profileFunction;
private final DateUtil dateUtil;
@Inject @Inject
public SensitivityOref1Plugin( public SensitivityOref1Plugin(
@ -43,7 +44,8 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
AAPSLogger aapsLogger, AAPSLogger aapsLogger,
ResourceHelper resourceHelper, ResourceHelper resourceHelper,
SP sp, SP sp,
ProfileFunction profileFunction ProfileFunction profileFunction,
DateUtil dateUtil
) { ) {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.SENSITIVITY) .mainType(PluginType.SENSITIVITY)
@ -56,6 +58,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
injector, aapsLogger, resourceHelper, sp injector, aapsLogger, resourceHelper, sp
); );
this.profileFunction = profileFunction; this.profileFunction = profileFunction;
this.dateUtil = dateUtil;
} }
@Override @Override
@ -79,7 +82,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
// the current // the current
AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already
if (current == null) { if (current == null) {
getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + dateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }
@ -125,7 +128,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
} }
// reset deviations after profile switch // reset deviations after profile switch
if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) { if (new ProfileSwitch(getInjector()).isEvent5minBack(profileSwitches, autosensData.time, true)) {
deviationsArray.clear(); deviationsArray.clear();
pastSensitivity += "(PROFILESWITCH)"; pastSensitivity += "(PROFILESWITCH)";
} }
@ -241,7 +244,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
sensResultArray.get(key) + comparison, deviationsHour.get(key).size()); sensResultArray.get(key) + comparison, deviationsHour.get(key).size());
getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: " getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: "
+ DateUtil.dateAndTimeString(toTime) + + dateUtil.dateAndTimeString(toTime) +
" ratio: " + output.ratio " ratio: " + output.ratio
+ " mealCOB: " + current.cob); + " mealCOB: " + current.cob);

View file

@ -32,7 +32,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin { public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin {
private SP sp; private SP sp;
private ResourceHelper resourceHelper; private DateUtil dateUtil;
private ProfileFunction profileFunction; private ProfileFunction profileFunction;
@Inject @Inject
@ -41,7 +41,8 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
AAPSLogger aapsLogger, AAPSLogger aapsLogger,
ResourceHelper resourceHelper, ResourceHelper resourceHelper,
SP sp, SP sp,
ProfileFunction profileFunction ProfileFunction profileFunction,
DateUtil dateUtil
) { ) {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.SENSITIVITY) .mainType(PluginType.SENSITIVITY)
@ -52,7 +53,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
injector, aapsLogger, resourceHelper, sp injector, aapsLogger, resourceHelper, sp
); );
this.sp = sp; this.sp = sp;
this.resourceHelper = resourceHelper; this.dateUtil = dateUtil;
this.profileFunction = profileFunction; this.profileFunction = profileFunction;
} }
@ -62,9 +63,9 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
String age = sp.getString(R.string.key_age, ""); String age = sp.getString(R.string.key_age, "");
int defaultHours = 24; int defaultHours = 24;
if (age.equals(resourceHelper.gs(R.string.key_adult))) defaultHours = 24; if (age.equals(getResourceHelper().gs(R.string.key_adult))) defaultHours = 24;
if (age.equals(resourceHelper.gs(R.string.key_teenage))) defaultHours = 4; if (age.equals(getResourceHelper().gs(R.string.key_teenage))) defaultHours = 4;
if (age.equals(resourceHelper.gs(R.string.key_child))) defaultHours = 4; if (age.equals(getResourceHelper().gs(R.string.key_child))) defaultHours = 4;
int hoursForDetection = sp.getInt(R.string.key_openapsama_autosens_period, defaultHours); int hoursForDetection = sp.getInt(R.string.key_openapsama_autosens_period, defaultHours);
if (autosensDataTable == null || autosensDataTable.size() < 4) { if (autosensDataTable == null || autosensDataTable.size() < 4) {
@ -74,7 +75,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already
if (current == null) { if (current == null) {
getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime()); getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + dateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult(); return new AutosensResult();
} }
@ -117,7 +118,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
} }
// reset deviations after profile switch // reset deviations after profile switch
if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) { if (new ProfileSwitch(getInjector()).isEvent5minBack(profileSwitches, autosensData.time, true)) {
data.clear(); data.clear();
pastSensitivity += "(PROFILESWITCH)"; pastSensitivity += "(PROFILESWITCH)";
} }
@ -145,10 +146,10 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
} }
if (data.size() == 0) { if (data.size() == 0) {
getAapsLogger().debug(LTag.AUTOSENS, "Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime)); getAapsLogger().debug(LTag.AUTOSENS, "Data size: " + data.size() + " fromTime: " + dateUtil.dateAndTimeString(fromTime) + " toTime: " + dateUtil.dateAndTimeString(toTime));
return new AutosensResult(); return new AutosensResult();
} else { } else {
getAapsLogger().debug(LTag.AUTOSENS, "Data size: " + data.size() + " fromTime: " + DateUtil.dateAndTimeString(fromTime) + " toTime: " + DateUtil.dateAndTimeString(toTime)); getAapsLogger().debug(LTag.AUTOSENS, "Data size: " + data.size() + " fromTime: " + dateUtil.dateAndTimeString(fromTime) + " toTime: " + dateUtil.dateAndTimeString(toTime));
} }
double weightedsum = 0; double weightedsum = 0;
@ -192,7 +193,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
sensResult, data.size()); sensResult, data.size());
getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: " getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: "
+ DateUtil.dateAndTimeString(toTime) + + dateUtil.dateAndTimeString(toTime) +
" ratio: " + output.ratio " ratio: " + output.ratio
+ " mealCOB: " + current.cob); + " mealCOB: " + current.cob);

View file

@ -12,17 +12,16 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.MainApp
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.db.BgReading import info.nightscout.androidaps.db.BgReading
import info.nightscout.androidaps.db.DatabaseHelper
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface import info.nightscout.androidaps.interfaces.DatabaseHelperInterface
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
import info.nightscout.androidaps.plugins.source.BGSourceFragment.RecyclerViewAdapter.BgReadingsViewHolder import info.nightscout.androidaps.plugins.source.BGSourceFragment.RecyclerViewAdapter.BgReadingsViewHolder
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.CompositeDisposable
@ -34,6 +33,7 @@ class BGSourceFragment : DaggerFragment() {
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var databaseHelper: DatabaseHelperInterface @Inject lateinit var databaseHelper: DatabaseHelperInterface
private val disposable = CompositeDisposable() private val disposable = CompositeDisposable()
@ -84,7 +84,7 @@ class BGSourceFragment : DaggerFragment() {
val bgReading = bgReadings[position] val bgReading = bgReadings[position]
holder.ns.visibility = if (NSUpload.isIdValid(bgReading._id)) View.VISIBLE else View.GONE holder.ns.visibility = if (NSUpload.isIdValid(bgReading._id)) View.VISIBLE else View.GONE
holder.invalid.visibility = if (!bgReading.isValid) View.VISIBLE else View.GONE holder.invalid.visibility = if (!bgReading.isValid) View.VISIBLE else View.GONE
holder.date.text = DateUtil.dateAndTimeString(bgReading.date) holder.date.text = dateUtil.dateAndTimeString(bgReading.date)
holder.value.text = bgReading.valueToUnitsToString(profileFunction.getUnits()) holder.value.text = bgReading.valueToUnitsToString(profileFunction.getUnits())
holder.direction.text = bgReading.directionToSymbol(databaseHelper) holder.direction.text = bgReading.directionToSymbol(databaseHelper)
holder.remove.tag = bgReading holder.remove.tag = bgReading
@ -106,7 +106,7 @@ class BGSourceFragment : DaggerFragment() {
remove.setOnClickListener { v: View -> remove.setOnClickListener { v: View ->
val bgReading = v.tag as BgReading val bgReading = v.tag as BgReading
activity?.let { activity -> activity?.let { activity ->
val text = DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profileFunction.getUnits()) val text = dateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profileFunction.getUnits())
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
bgReading.isValid = false bgReading.isValid = false
MainApp.getDbHelper().update(bgReading) MainApp.getDbHelper().update(bgReading)

View file

@ -28,7 +28,8 @@ class EversensePlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,
private val sp: SP, private val sp: SP,
resourceHelper: ResourceHelper, resourceHelper: ResourceHelper,
aapsLogger: AAPSLogger aapsLogger: AAPSLogger,
private val dateUtil: DateUtil
) : PluginBase(PluginDescription() ) : PluginBase(PluginDescription()
.mainType(PluginType.BGSOURCE) .mainType(PluginType.BGSOURCE)
.fragmentClass(BGSourceFragment::class.java.name) .fragmentClass(BGSourceFragment::class.java.name)
@ -50,7 +51,7 @@ class EversensePlugin @Inject constructor(
if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress")) if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress"))
if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel")) if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel"))
if (bundle.containsKey("glucoseTrendDirection")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTrendDirection: " + bundle.getString("glucoseTrendDirection")) if (bundle.containsKey("glucoseTrendDirection")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTrendDirection: " + bundle.getString("glucoseTrendDirection"))
if (bundle.containsKey("glucoseTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamp: " + DateUtil.dateAndTimeString(bundle.getLong("glucoseTimestamp"))) if (bundle.containsKey("glucoseTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamp: " + dateUtil.dateAndTimeString(bundle.getLong("glucoseTimestamp")))
if (bundle.containsKey("batteryLevel")) aapsLogger.debug(LTag.BGSOURCE, "batteryLevel: " + bundle.getString("batteryLevel")) if (bundle.containsKey("batteryLevel")) aapsLogger.debug(LTag.BGSOURCE, "batteryLevel: " + bundle.getString("batteryLevel"))
if (bundle.containsKey("signalStrength")) aapsLogger.debug(LTag.BGSOURCE, "signalStrength: " + bundle.getString("signalStrength")) if (bundle.containsKey("signalStrength")) aapsLogger.debug(LTag.BGSOURCE, "signalStrength: " + bundle.getString("signalStrength"))
if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber")) if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber"))
@ -58,7 +59,7 @@ class EversensePlugin @Inject constructor(
if (bundle.containsKey("transmitterModelNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterModelNumber: " + bundle.getString("transmitterModelNumber")) if (bundle.containsKey("transmitterModelNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterModelNumber: " + bundle.getString("transmitterModelNumber"))
if (bundle.containsKey("transmitterSerialNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterSerialNumber: " + bundle.getString("transmitterSerialNumber")) if (bundle.containsKey("transmitterSerialNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterSerialNumber: " + bundle.getString("transmitterSerialNumber"))
if (bundle.containsKey("transmitterAddress")) aapsLogger.debug(LTag.BGSOURCE, "transmitterAddress: " + bundle.getString("transmitterAddress")) if (bundle.containsKey("transmitterAddress")) aapsLogger.debug(LTag.BGSOURCE, "transmitterAddress: " + bundle.getString("transmitterAddress"))
if (bundle.containsKey("sensorInsertionTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "sensorInsertionTimestamp: " + DateUtil.dateAndTimeString(bundle.getLong("sensorInsertionTimestamp"))) if (bundle.containsKey("sensorInsertionTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "sensorInsertionTimestamp: " + dateUtil.dateAndTimeString(bundle.getLong("sensorInsertionTimestamp")))
if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber")) if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber"))
if (bundle.containsKey("transmitterConnectionState")) aapsLogger.debug(LTag.BGSOURCE, "transmitterConnectionState: " + bundle.getString("transmitterConnectionState")) if (bundle.containsKey("transmitterConnectionState")) aapsLogger.debug(LTag.BGSOURCE, "transmitterConnectionState: " + bundle.getString("transmitterConnectionState"))
if (bundle.containsKey("glucoseLevels")) { if (bundle.containsKey("glucoseLevels")) {

View file

@ -70,7 +70,7 @@ class NSClientSourcePlugin @Inject constructor(
private fun storeSgv(sgvJson: JSONObject) { private fun storeSgv(sgvJson: JSONObject) {
val nsSgv = NSSgv(sgvJson) val nsSgv = NSSgv(sgvJson)
val bgReading = BgReading(nsSgv) val bgReading = BgReading(injector, nsSgv)
MainApp.getDbHelper().createIfNotExists(bgReading, "NS") MainApp.getDbHelper().createIfNotExists(bgReading, "NS")
detectSource(safeGetString(sgvJson, "device", "none"), safeGetLong(sgvJson, "mills")) detectSource(safeGetString(sgvJson, "device", "none"), safeGetLong(sgvJson, "mills"))
} }

View file

@ -76,6 +76,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
private final ProfileFunction profileFunction; private final ProfileFunction profileFunction;
private final ActivePluginProvider activePlugin; private final ActivePluginProvider activePlugin;
private final FabricPrivacy fabricPrivacy; private final FabricPrivacy fabricPrivacy;
private final DateUtil dateUtil;
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
@ -100,7 +101,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
SP sp, SP sp,
ProfileFunction profileFunction, ProfileFunction profileFunction,
ActivePluginProvider activePlugin, ActivePluginProvider activePlugin,
FabricPrivacy fabricPrivacy FabricPrivacy fabricPrivacy,
DateUtil dateUtil
) { ) {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.TREATMENT) .mainType(PluginType.TREATMENT)
@ -119,6 +121,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
this.profileFunction = profileFunction; this.profileFunction = profileFunction;
this.activePlugin = activePlugin; this.activePlugin = activePlugin;
this.fabricPrivacy = fabricPrivacy; this.fabricPrivacy = fabricPrivacy;
this.dateUtil = dateUtil;
} }
@Override @Override
@ -339,7 +342,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
last = t.date; last = t.date;
} }
} }
getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: " + DateUtil.dateAndTimeString(last)); getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: " + dateUtil.dateAndTimeString(last));
return last; return last;
} }
@ -354,7 +357,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
last = t.date; last = t.date;
} }
} }
getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: " + DateUtil.dateAndTimeString(last)); getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: " + dateUtil.dateAndTimeString(last));
return last; return last;
} }
@ -643,7 +646,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
if (!allowUpdate && !creatOrUpdateResult.success) { if (!allowUpdate && !creatOrUpdateResult.success) {
getAapsLogger().error("Treatment could not be added to DB", new Exception()); getAapsLogger().error("Treatment could not be added to DB", new Exception());
String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, DateUtil.dateAndTimeString(treatment.date)); String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, dateUtil.dateAndTimeString(treatment.date));
Intent i = new Intent(context, ErrorHelperActivity.class); Intent i = new Intent(context, ErrorHelperActivity.class);
i.putExtra("soundid", R.raw.error); i.putExtra("soundid", R.raw.error);

View file

@ -42,6 +42,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var treatmentsPlugin: TreatmentsPlugin
@Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var dateUtil: DateUtil
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View? {
@ -109,7 +110,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
override fun onBindViewHolder(holder: TreatmentsViewHolder, position: Int) { override fun onBindViewHolder(holder: TreatmentsViewHolder, position: Int) {
val profile = profileFunction.getProfile() ?: return val profile = profileFunction.getProfile() ?: return
val t = treatments[position] val t = treatments[position]
holder.date.text = DateUtil.dateAndTimeString(t.date) holder.date.text = dateUtil.dateAndTimeString(t.date)
holder.insulin.text = resourceHelper.gs(R.string.formatinsulinunits, t.insulin) holder.insulin.text = resourceHelper.gs(R.string.formatinsulinunits, t.insulin)
holder.carbs.text = resourceHelper.gs(R.string.format_carbs, t.carbs.toInt()) holder.carbs.text = resourceHelper.gs(R.string.format_carbs, t.carbs.toInt())
val iob = t.iobCalc(System.currentTimeMillis(), profile.dia) val iob = t.iobCalc(System.currentTimeMillis(), profile.dia)
@ -158,7 +159,7 @@ class TreatmentsBolusFragment : DaggerFragment() {
val text = resourceHelper.gs(R.string.configbuilder_insulin) + ": " + val text = resourceHelper.gs(R.string.configbuilder_insulin) + ": " +
resourceHelper.gs(R.string.formatinsulinunits, treatment.insulin) + "\n" + resourceHelper.gs(R.string.formatinsulinunits, treatment.insulin) + "\n" +
resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" + resourceHelper.gs(R.string.carbs) + ": " + resourceHelper.gs(R.string.format_carbs, treatment.carbs.toInt()) + "\n" +
resourceHelper.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(treatment.date) resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(treatment.date)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
if (treatment.source == Source.PUMP) { if (treatment.source == Source.PUMP) {
treatment.isValid = false treatment.isValid = false

View file

@ -38,6 +38,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var translator: Translator @Inject lateinit var translator: Translator
@Inject lateinit var dateUtil: DateUtil
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View? {
@ -106,7 +107,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
override fun onBindViewHolder(holder: CareportalEventsViewHolder, position: Int) { override fun onBindViewHolder(holder: CareportalEventsViewHolder, position: Int) {
val careportalEvent = careportalEventList[position] val careportalEvent = careportalEventList[position]
holder.ns.visibility = if (NSUpload.isIdValid(careportalEvent._id)) View.VISIBLE else View.GONE holder.ns.visibility = if (NSUpload.isIdValid(careportalEvent._id)) View.VISIBLE else View.GONE
holder.date.text = DateUtil.dateAndTimeString(careportalEvent.date) holder.date.text = dateUtil.dateAndTimeString(careportalEvent.date)
holder.duration.text = if (careportalEvent.durationInMsec() == 0L) "" else DateUtil.niceTimeScalar(careportalEvent.durationInMsec(), resourceHelper) holder.duration.text = if (careportalEvent.durationInMsec() == 0L) "" else DateUtil.niceTimeScalar(careportalEvent.durationInMsec(), resourceHelper)
holder.note.text = careportalEvent.notes holder.note.text = careportalEvent.notes
holder.type.text = translator.translate(careportalEvent.eventType) holder.type.text = translator.translate(careportalEvent.eventType)
@ -132,7 +133,7 @@ class TreatmentsCareportalFragment : DaggerFragment() {
activity?.let { activity -> activity?.let { activity ->
val text = resourceHelper.gs(R.string.careportal_newnstreatment_eventtype) + ": " + translator.translate(careportalEvent.eventType) + "\n" + val text = resourceHelper.gs(R.string.careportal_newnstreatment_eventtype) + ": " + translator.translate(careportalEvent.eventType) + "\n" +
resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + careportalEvent.notes + "\n" + resourceHelper.gs(R.string.careportal_newnstreatment_notes_label) + ": " + careportalEvent.notes + "\n" +
resourceHelper.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(careportalEvent.date) resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(careportalEvent.date)
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
if (NSUpload.isIdValid(careportalEvent._id)) if (NSUpload.isIdValid(careportalEvent._id))
NSUpload.removeCareportalEntryFromNS(careportalEvent._id) NSUpload.removeCareportalEntryFromNS(careportalEvent._id)

View file

@ -64,7 +64,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
holder.ph.visibility = if (extendedBolus.source == Source.PUMP) View.VISIBLE else View.GONE holder.ph.visibility = if (extendedBolus.source == Source.PUMP) View.VISIBLE else View.GONE
holder.ns.visibility = if (NSUpload.isIdValid(extendedBolus._id)) View.VISIBLE else View.GONE holder.ns.visibility = if (NSUpload.isIdValid(extendedBolus._id)) View.VISIBLE else View.GONE
if (extendedBolus.isEndingEvent) { if (extendedBolus.isEndingEvent) {
holder.date.text = DateUtil.dateAndTimeString(extendedBolus.date) holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date)
holder.duration.text = resourceHelper.gs(R.string.cancel) holder.duration.text = resourceHelper.gs(R.string.cancel)
holder.insulin.text = "" holder.insulin.text = ""
holder.realDuration.text = "" holder.realDuration.text = ""
@ -73,8 +73,8 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
holder.ratio.text = "" holder.ratio.text = ""
} else { } else {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
if (extendedBolus.isInProgress) holder.date.text = DateUtil.dateAndTimeString(extendedBolus.date) if (extendedBolus.isInProgress) holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date)
else holder.date.text = DateUtil.dateAndTimeString(extendedBolus.date) + " - " + dateUtil.timeString(extendedBolus.end()) else holder.date.text = dateUtil.dateAndTimeString(extendedBolus.date) + " - " + dateUtil.timeString(extendedBolus.end())
holder.duration.text = resourceHelper.gs(R.string.format_mins, extendedBolus.durationInMinutes) holder.duration.text = resourceHelper.gs(R.string.format_mins, extendedBolus.durationInMinutes)
holder.insulin.text = resourceHelper.gs(R.string.formatinsulinunits, extendedBolus.insulin) holder.insulin.text = resourceHelper.gs(R.string.formatinsulinunits, extendedBolus.insulin)
@ -113,7 +113,7 @@ class TreatmentsExtendedBolusesFragment : DaggerFragment() {
showConfirmation(it, resourceHelper.gs(R.string.removerecord), showConfirmation(it, resourceHelper.gs(R.string.removerecord),
""" """
${resourceHelper.gs(R.string.extended_bolus)} ${resourceHelper.gs(R.string.extended_bolus)}
${resourceHelper.gs(R.string.date)}: ${DateUtil.dateAndTimeString(extendedBolus.date)} ${resourceHelper.gs(R.string.date)}: ${dateUtil.dateAndTimeString(extendedBolus.date)}
""".trimIndent(), DialogInterface.OnClickListener { _: DialogInterface, _: Int -> """.trimIndent(), DialogInterface.OnClickListener { _: DialogInterface, _: Int ->
val id = extendedBolus._id val id = extendedBolus._id
if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id) if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id)

View file

@ -43,6 +43,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
@Inject lateinit var localProfilePlugin: LocalProfilePlugin @Inject lateinit var localProfilePlugin: LocalProfilePlugin
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var fabricPrivacy: FabricPrivacy
@Inject lateinit var dateUtil: DateUtil
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? { savedInstanceState: Bundle?): View? {
@ -95,7 +96,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
val profileSwitch = profileSwitchList[position] val profileSwitch = profileSwitchList[position]
holder.ph.visibility = (profileSwitch.source == Source.PUMP).toVisibility() holder.ph.visibility = (profileSwitch.source == Source.PUMP).toVisibility()
holder.ns.visibility = NSUpload.isIdValid(profileSwitch._id).toVisibility() holder.ns.visibility = NSUpload.isIdValid(profileSwitch._id).toVisibility()
holder.date.text = DateUtil.dateAndTimeString(profileSwitch.date) holder.date.text = dateUtil.dateAndTimeString(profileSwitch.date)
if (!profileSwitch.isEndingEvent) { if (!profileSwitch.isEndingEvent) {
holder.duration.text = resourceHelper.gs(R.string.format_mins, profileSwitch.durationInMinutes) holder.duration.text = resourceHelper.gs(R.string.format_mins, profileSwitch.durationInMinutes)
} else { } else {
@ -132,7 +133,7 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord),
resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName + resourceHelper.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName +
"\n" + resourceHelper.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(profileSwitch.date), Runnable { "\n" + resourceHelper.gs(R.string.date) + ": " + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
val id = profileSwitch._id val id = profileSwitch._id
if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id) if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id)
else UploadQueue.removeID("dbAdd", id) else UploadQueue.removeID("dbAdd", id)
@ -141,10 +142,10 @@ class TreatmentsProfileSwitchFragment : DaggerFragment() {
} }
R.id.profileswitch_clone -> R.id.profileswitch_clone ->
activity?.let { activity -> activity?.let { activity ->
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + DateUtil.dateAndTimeString(profileSwitch.date), Runnable { OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.careportal_profileswitch), resourceHelper.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + dateUtil.dateAndTimeString(profileSwitch.date), Runnable {
profileSwitch.profileObject?.let { profileSwitch.profileObject?.let {
val nonCustomized = it.convertToNonCustomizedProfile() val nonCustomized = it.convertToNonCustomizedProfile()
localProfilePlugin.addProfile(LocalProfilePlugin.SingleProfile().copyFrom(localProfilePlugin.rawProfile, nonCustomized, profileSwitch.customizedName + " " + DateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_"))) localProfilePlugin.addProfile(LocalProfilePlugin.SingleProfile().copyFrom(localProfilePlugin.rawProfile, nonCustomized, profileSwitch.customizedName + " " + dateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_")))
rxBus.send(EventLocalProfileChanged()) rxBus.send(EventLocalProfileChanged())
} }
}) })

View file

@ -78,13 +78,13 @@ public class TreatmentsTempTargetFragment extends DaggerFragment {
holder.ph.setVisibility(tempTarget.source == Source.PUMP ? View.VISIBLE : View.GONE); holder.ph.setVisibility(tempTarget.source == Source.PUMP ? View.VISIBLE : View.GONE);
holder.ns.setVisibility(NSUpload.isIdValid(tempTarget._id) ? View.VISIBLE : View.GONE); holder.ns.setVisibility(NSUpload.isIdValid(tempTarget._id) ? View.VISIBLE : View.GONE);
if (!tempTarget.isEndingEvent()) { if (!tempTarget.isEndingEvent()) {
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date) + " - " + dateUtil.timeString(tempTarget.originalEnd())); holder.date.setText(dateUtil.dateAndTimeString(tempTarget.date) + " - " + dateUtil.timeString(tempTarget.originalEnd()));
holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.durationInMinutes) + " min"); holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.durationInMinutes) + " min");
holder.low.setText(tempTarget.lowValueToUnitsToString(units)); holder.low.setText(tempTarget.lowValueToUnitsToString(units));
holder.high.setText(tempTarget.highValueToUnitsToString(units)); holder.high.setText(tempTarget.highValueToUnitsToString(units));
holder.reason.setText(tempTarget.reason); holder.reason.setText(tempTarget.reason);
} else { } else {
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date)); holder.date.setText(dateUtil.dateAndTimeString(tempTarget.date));
holder.duration.setText(R.string.cancel); holder.duration.setText(R.string.cancel);
holder.low.setText(""); holder.low.setText("");
holder.high.setText(""); holder.high.setText("");
@ -142,7 +142,7 @@ public class TreatmentsTempTargetFragment extends DaggerFragment {
final TempTarget tempTarget = (TempTarget) v.getTag(); final TempTarget tempTarget = (TempTarget) v.getTag();
OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.removerecord), OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.removerecord),
resourceHelper.gs(R.string.careportal_temporarytarget) + ": " + tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper) + resourceHelper.gs(R.string.careportal_temporarytarget) + ": " + tempTarget.friendlyDescription(profileFunction.getUnits(), resourceHelper) +
"\n" + DateUtil.dateAndTimeString(tempTarget.date), "\n" + dateUtil.dateAndTimeString(tempTarget.date),
(dialog, id) -> { (dialog, id) -> {
final String _id = tempTarget._id; final String _id = tempTarget._id;
if (NSUpload.isIdValid(_id)) { if (NSUpload.isIdValid(_id)) {

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