/// <summary> /// Gets the Stim Therapy Status from the API /// </summary> /// <param name="theSummit">SummitSystem for making the call to the API to the INS</param> /// <returns>String showing Therapy Active or Therapy Inactive</returns> public string GetTherapyStatus(ref SummitSystem theSummit) { if (theSummit == null || theSummit.IsDisposed) { return(""); } GeneralInterrogateData insGeneralInfo = null; try { //Add a sleep in there to allow status of therapy to get pass Therapy Transitioning state //Allows it to either be Active or InActive and not inbetween Thread.Sleep(200); //Get data from api bufferInfo = theSummit.ReadGeneralInfo(out insGeneralInfo); //parse insGeneralInfo to get stim therapy status if (insGeneralInfo != null) { stimState = insGeneralInfo.TherapyStatusData.TherapyStatus.ToString(); } } catch (Exception e) { _log.Error(e); } return(stimState); }
/// <summary> /// Gets the Stim parameters for a Group /// </summary> /// <param name="theSummit">SummitSystem for making the api call to INS</param> /// <param name="group">Group number to get the data</param> /// <returns>StimParameterModel that contains stim amp, stim rate and pulse width</returns> public Tuple <bool, string, TherapyGroup> GetTherapyDataForGroup(SummitSystem theSummit, GroupNumber group) { TherapyGroup insStateGroup = null; if (theSummit == null || theSummit.IsDisposed) { return(Tuple.Create(false, "Summit Disposed", insStateGroup)); } try { //Get the data from the api bufferInfo = theSummit.ReadStimGroup(group, out insStateGroup); if (bufferInfo.RejectCode != 0 || insStateGroup == null) { _log.Warn("Could not read stim group from Medtronic api call"); return(Tuple.Create(false, "Could not read stim group from Medtronic api call", insStateGroup)); } } catch (Exception e) { _log.Error(e); return(Tuple.Create(false, "Error reading stim group.", insStateGroup)); } return(Tuple.Create(true, "Success", insStateGroup)); }
private void CheckRejectCode(APIReturnInfo info, string location) { if (info.RejectCode != 0) { MessageBox.Show("Error from Medtronic device. Could not report. Please try again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); _log.Warn("Error from medtronic device for Report. Location of Error: " + location + ". Reject Code: " + info.RejectCode + ". Reject Description: " + info.Descriptor); } }
/// <summary> /// Checks for return error code from APIReturnInfo from Medtronic /// If there is an error, the method calls error handling method SetEmbeddedOffGroupAStimOnWhenErrorOccurs() to turn embedded off, change to group A and turn Stim ON /// The Error location and error descriptor from the returned API call are displayed to user in a message box. /// </summary> /// <param name="info">The APIReturnInfo value returned from the Medtronic API call</param> /// <param name="errorLocation">The location where the error is being check. Can be turning stim on, changing group, etc</param> /// <param name="showErrorMessage">True if you want a popup message on errors or false if show no error popup</param> /// <returns>True if there was an error or false if no error</returns> private bool CheckForReturnError(APIReturnInfo info, string errorLocation, bool showErrorMessage) { if (info.RejectCode != 0) { _log.Warn("Error from Medtronic device during " + errorLocation + ". Reject code: " + info.RejectCode + ". Reject description: " + info.Descriptor); if (showErrorMessage) { MessageBox.Show("Error from Medtronic device during " + errorLocation + ". If sensing doesn't start then please close out program and retry.", "Error", MessageBoxButton.OK, MessageBoxImage.Hand); } return(false); } return(true); }
/// <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> /// reset stimulation sweep by bringing all values back to starting values /// </summary> public void ResetSweep() { //set parameters back to initial values int iAmp = 0, iPulseWidth = 0, iFreq = 0; //don't care about these TherapyGroup groupInfo; //To be certain current values are accurate, get current values from INS if (!SummitUtils.CheckCurrentStimParameters(m_summit, m_groupNum, 0, out m_currentAmp, out m_currentPulseWidth, out m_currentFreq)) { throw new Exception(); } m_stimPaused = false; //now reset the values to the start values m_summitInfo = m_summit.StimChangeStepAmp(0, Math.Round(-1 * m_currentAmp.Value, 1), out m_currentAmp); if (m_summitInfo.RejectCode != 0) { Console.WriteLine("Error when bringing stim amplitude to zero at end of sweep. Recommend restart program, as no more sweeps can be started. Error descriptor:" + m_summitInfo.Descriptor); if (!SummitUtils.CheckCurrentStimParameters(m_summit, m_groupNum, 0, out m_currentAmp, out m_currentPulseWidth, out m_currentFreq)) { throw new Exception(); } } int periodMS = (int)Math.Ceiling(1000 / m_currentFreq.Value); Thread.Sleep(periodMS); try { ResetParameter(m_sweepParameters.freqOrder, ref iAmp, ref iPulseWidth, ref iFreq); //get rate period of the current freq periodMS = (int)Math.Ceiling(1000 / m_currentFreq.Value); Thread.Sleep(periodMS); ResetParameter(m_sweepParameters.pulseWidthOrder, ref iAmp, ref iPulseWidth, ref iFreq); } catch { throw; } Thread.Sleep(periodMS); }
/// <summary> /// Gets the battery level for the CTM /// </summary> /// <param name="theSummit">Summit System</param> /// <param name="_log">Caliburn Micro logger</param> /// <returns>String that tells the battery status of the CTM</returns> public string GetCTMBatteryLevel(ref SummitSystem theSummit, ILog _log) { TelemetryModuleInfo telem_info = null; APIReturnInfo ctm_return_info = new APIReturnInfo(); if (theSummit == null) { return(CTMBatteryLevel); } try { //Get info from summit ctm_return_info = theSummit.ReadTelemetryModuleInfo(out telem_info); } catch (Exception e) { _log.Error(e); } try { //Make sure reject code was successful and write string to CTMBatteryLevel string if (ctm_return_info.RejectCode == 0) { if (telem_info != null) { CTMBatteryLevel = Convert.ToString(telem_info.BatteryLevel); } } else { CTMBatteryLevel = ""; } } catch (Exception e) { CTMBatteryLevel = ""; _log.Error(e); } return(CTMBatteryLevel); }
/// <summary> /// function to pause stimulation by changing amplitude to 0 (note that there is still some residual stimulation, that's just the way the hardware is) /// </summary> /// <param name="pauseDuration">How long to pause the program in milliseconds</param> public void IntraSweepPause(int pauseDuration) { if (pauseDuration != 0) { m_stimPaused = true; //"turn off" stimulation by bringing amp to 0 m_prePauseAmp = m_currentAmp.Value; m_summitInfo = m_summit.StimChangeStepAmp(0, Math.Round(m_currentAmp.Value * -1, 2), out m_currentAmp); if (m_summitInfo.RejectCode != 0) { Console.WriteLine("Error when bringing stim amplitude to zero. Error descriptor:" + m_summitInfo.Descriptor); if (!SummitUtils.CheckCurrentStimParameters(m_summit, m_groupNum, 0, out m_currentAmp, out m_currentPulseWidth, out m_currentFreq)) { throw new Exception(); } } //pause for the specified amount of time Thread.Sleep(pauseDuration); } }
/// <summary> /// Gets the Active group from the api /// </summary> /// <param name="theSummit">SummitSystem to make api calls to INS</param> /// <returns>The active group in the format Group A instead of the format returned from medtonic such as Group0</returns> public string GetActiveGroup(ref SummitSystem theSummit) { if (theSummit == null || theSummit.IsDisposed) { return(""); } GeneralInterrogateData insGeneralInfo = null; try { //Get the group from the api call bufferInfo = theSummit.ReadGeneralInfo(out insGeneralInfo); if (insGeneralInfo != null) { activeGroup = insGeneralInfo.TherapyStatusData.ActiveGroup.ToString(); } } catch (Exception e) { _log.Error(e); } //This returns the converted group from something like Group0 to Group A return(ConvertActiveGroupToReadableForm(activeGroup)); }
public async Task <ActionResult <APIReturnInfo <UserWatchHistory> > > SingleUserWatchHistory(Guid Id) { return(APIReturnInfo <UserWatchHistory> .Success(await this.UserWatchHistoryDomainService.SingleUserWatchHistory(Id))); }
public async Task <ActionResult <APIReturnInfo <UserWatchHistory> > > EditUserWatchHistory(UserWatchHistory model) { return(APIReturnInfo <UserWatchHistory> .Success(await this.UserWatchHistoryDomainService.EditUserWatchHistory(model))); }
public async Task <ActionResult <APIReturnInfo <NewestMovie> > > SingleNewestMovie(Guid Id) { return(APIReturnInfo <NewestMovie> .Success(await this.NewestMovieDomainService.SingleNewestMovie(Id))); }
public async Task <ActionResult <APIReturnInfo <IList <Notice> > > > AllNotice() { return(APIReturnInfo <IList <Notice> > .Success(await this.noticeDomainService.AllNotice())); }
public async Task <ActionResult <APIReturnInfo <Notice> > > EditNotice(Notice model) { return(APIReturnInfo <Notice> .Success(await this.noticeDomainService.EditNotice(model))); }
public async Task <ActionResult <APIReturnInfo <IList <AnimationOpera> > > > AllAnimationOpera() { return(APIReturnInfo <IList <AnimationOpera> > .Success(await this.animationOperaDomainService.AllAnimationOpera())); }
public async Task <ActionResult <APIReturnInfo <AnimationOpera> > > EditAnimationOpera(AnimationOpera model) { return(APIReturnInfo <AnimationOpera> .Success(await this.animationOperaDomainService.EditAnimationOpera(model))); }
public async Task <ActionResult <APIReturnInfo <IList <UserWatchHistory> > > > AllUserWatchHistory() { return(APIReturnInfo <IList <UserWatchHistory> > .Success(await this.UserWatchHistoryDomainService.AllUserWatchHistory())); }
public async Task <ActionResult <APIReturnInfo <MainlandOpera> > > RemovedMainlandOpera(Guid Id) { return(APIReturnInfo <MainlandOpera> .Success(await this.mainlandOperaDomainService.RemovedMainlandOpera(Id))); }
public async Task <ActionResult <APIReturnInfo <IList <UserWatchHistoryValue> > > > FindWathcHistory() { return(APIReturnInfo <IList <UserWatchHistoryValue> > .Success(await this.UserWatchHistoryDomainService.FindWatchHistoryByUserId(this.UserId()))); }
public async Task <ActionResult <APIReturnInfo <User> > > EditUser([FromBody] User Model) { return(APIReturnInfo <User> .Success(await this.userDomainService.EditUser(Model))); }
public async Task <ActionResult <APIReturnInfo <AnimationOpera> > > SingleAnimationOpera(Guid Id) { return(APIReturnInfo <AnimationOpera> .Success(await this.animationOperaDomainService.SingleAnimationOpera(Id))); }
public async Task <ActionResult <APIReturnInfo <User> > > AddUser() { return(APIReturnInfo <User> .Success(await this.userDomainService.SingleUser(Guid.Parse(this.UserId())))); }
public async Task <ActionResult <APIReturnInfo <IList <AnimationOpera> > > > Pagin(int PageNum, int PageSize) { return(APIReturnInfo <IList <AnimationOpera> > .Success(await this.animationOperaDomainService.Pagein(PageNum, PageSize))); }
public async Task <ActionResult <APIReturnInfo <User> > > Delete(Guid Id) { return(APIReturnInfo <User> .Success(await this.userDomainService.RemoveUser(Id))); }
public async Task <ActionResult <APIReturnInfo <Notice> > > SingleNotice(Guid Id) { return(APIReturnInfo <Notice> .Success(await this.noticeDomainService.SingleNotice(Id))); }
public async Task <ActionResult <APIReturnInfo <string> > > Authorization(string Code) { return(APIReturnInfo <string> .Success(await this.userDomainService.Authorization(Code))); }
public async Task <ActionResult <APIReturnInfo <NewestMovie> > > EditNewestMovie(NewestMovie model) { return(APIReturnInfo <NewestMovie> .Success(await this.NewestMovieDomainService.EditNewestMovie(model))); }
public async Task <ActionResult <APIReturnInfo <IList <UserWatchHistory> > > > Pagin(int PageNum, int PageSize) { return(APIReturnInfo <IList <UserWatchHistory> > .Success(await this.UserWatchHistoryDomainService.Pagin(PageNum, PageSize))); }
public async Task <ActionResult <APIReturnInfo <IList <NewestMovie> > > > Pagin(int PageNum, int PageSize) { return(APIReturnInfo <IList <NewestMovie> > .Success(await this.NewestMovieDomainService.Pagin(PageNum, PageSize))); }
public async Task <ActionResult <APIReturnInfo <UserWatchHistory> > > AddUserWatchHistory(UserWatchHistory model) { model.UserId = this.UserId(); return(APIReturnInfo <UserWatchHistory> .Success(await this.UserWatchHistoryDomainService.AddUserWatchHistory(model))); }