Merge pull request #2533 from jotomo/2742-2

SMS Carb command update
This commit is contained in:
Milos Kozak 2020-04-05 21:09:12 +02:00 committed by GitHub
commit 970f553a9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 12 deletions

View file

@ -713,20 +713,28 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
override fun run() { override fun run() {
val detailedBolusInfo = DetailedBolusInfo() val detailedBolusInfo = DetailedBolusInfo()
detailedBolusInfo.carbs = anInteger().toDouble() detailedBolusInfo.carbs = anInteger().toDouble()
detailedBolusInfo.source = Source.USER
detailedBolusInfo.date = secondLong() detailedBolusInfo.date = secondLong()
ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() { if (ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.storesCarbInfo == true) {
override fun run() { ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() {
if (result.success) { override fun run() {
var replyText = String.format(MainApp.gs(R.string.smscommunicator_carbsset), anInteger) if (result.success) {
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true) var replyText = String.format(MainApp.gs(R.string.smscommunicator_carbsset), anInteger)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText)) replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
} else { sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
var replyText = MainApp.gs(R.string.smscommunicator_carbsfailed) } else {
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true) var replyText = MainApp.gs(R.string.smscommunicator_carbsfailed)
sendSMS(Sms(receivedSms.phoneNumber, replyText)) replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
sendSMS(Sms(receivedSms.phoneNumber, replyText))
}
} }
} })
}) } else {
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, true)
var replyText = String.format(MainApp.gs(R.string.smscommunicator_carbsset), anInteger)
replyText += "\n" + ConfigBuilderPlugin.getPlugin().activePump?.shortStatus(true)
sendSMSToAllNumbers(Sms(receivedSms.phoneNumber, replyText))
}
} }
}) })
} }

View file

@ -280,6 +280,10 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
// return true if new record is created // return true if new record is created
public UpdateReturn createOrUpdate(Treatment treatment) { public UpdateReturn createOrUpdate(Treatment treatment) {
if (treatment != null && treatment.source == Source.NONE) {
log.error("Coder error: source is not set for treatment: " + treatment, new Exception());
FabricPrivacy.logException(new Exception("Coder error: source is not set for treatment: " + treatment));
}
try { try {
Treatment old; Treatment old;
treatment.date = DatabaseHelper.roundDateToSec(treatment.date); treatment.date = DatabaseHelper.roundDateToSec(treatment.date);