/// <summary> /// Gets the battery level for the INS /// </summary> /// <param name="theSummit">Summit System</param> /// <param name="_log">Caliburn Micro Logger</param> /// <returns>String that tells the battery status of the INS</returns> public string GetINSBatteryLevel(ref SummitSystem theSummit, ILog _log) { BatteryStatusResult outputBuffer = null; APIReturnInfo commandInfo = new APIReturnInfo(); //Return Not Connected if summit is null if (theSummit == null) { return(INSBatteryLevel); } try { commandInfo = theSummit.ReadBatteryLevel(out outputBuffer); } catch (Exception e) { _log.Error(e); } // Ensure the command was successful before using the result try { //Check if command was successful if (commandInfo.RejectCode == 0) { // Retrieve the battery level from the output buffer if (outputBuffer != null) { INSBatteryLevel = outputBuffer.BatteryLevelPercent.ToString(); } } else { INSBatteryLevel = ""; } } catch (Exception e) { INSBatteryLevel = ""; _log.Error(e); } //Return either battery level, empty string or Not Connected return(INSBatteryLevel); }
/// <summary> /// Resets the POR bit if it was set /// </summary> /// <param name="localSummit">SummitSystem for the api call</param> private void ResetPOR(SummitSystem localSummit) { if (localSummit == null || localSummit.IsDisposed) { _log.Warn("Summit Disposed"); return; } _log.Info("POR was set, resetting..."); APIReturnInfo bufferReturnInfo; try { // reset POR bufferReturnInfo = localSummit.ResetErrorFlags(Medtronic.NeuroStim.Olympus.DataTypes.Core.StatusBits.Por); if (bufferReturnInfo.RejectCode != 0) { return; } // check battery BatteryStatusResult theStatus; localSummit.ReadBatteryLevel(out theStatus); if (bufferReturnInfo.RejectCode != 0) { return; } // perform interrogate command and check if therapy is enabled.s GeneralInterrogateData interrogateBuffer; localSummit.ReadGeneralInfo(out interrogateBuffer); if (interrogateBuffer.IsTherapyUnavailable) { _log.Warn("Therapy still unavailable after POR reset"); return; } } catch (Exception e) { _log.Error(e); } }