Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time delta is incorrectly large when exiting cardiac arrest #6530

Closed
kymckay opened this issue Aug 14, 2018 · 5 comments
Closed

time delta is incorrectly large when exiting cardiac arrest #6530

kymckay opened this issue Aug 14, 2018 · 5 comments

Comments

@kymckay
Copy link
Member

kymckay commented Aug 14, 2018

Issue revealed and discussed as part of #6523

Basically because vitals loop isn't ran as part of the cardiac arrest state, when you recover the time delta becomes large because the previously stored time was back before you entered cardiac arrest. This leads to some values trying to incorrectly change massively.

I see two potential solutions:

  1. Run the vitals loop while in cardiac arrest (I think we might need to do this anyway because it looks like it updates some values unrelated to the heart rate)
  2. Update the stored GVAR(lastTimeUpdated) value on the unit when exiting cardiac arrest
@thojkooi
Copy link
Contributor

I think we should go with approach 1.

@kymckay
Copy link
Member Author

kymckay commented May 12, 2019

For reference:

// Temporary fix for vitals loop on cardiac arrest exit
_unit setVariable [QGVAR(lastTimeUpdated), CBA_missionTime];

@kymckay
Copy link
Member Author

kymckay commented May 12, 2019

Refreshed my memory on this one.

The issue is that in statemachine, the cardiac arrest state doesn't have an onState function like the others which is where the calls are made to EFUNC(medical_vitals,handleUnitVitals). This results in the time tracking used by that function not updating the variable on the unit - which leads to the big time delta if the unit becomes stable again.

The temporary fix currently implemented (see above) isn't even a valid fix because it should be QEGVAR(medical_vitals,lastTimeUpdated) 😄 I imagine the variable changed and that wasn't originally broken.

In terms of the solution to this, it depends whether handleUnitVitals updates anything independent of heart rate (although CPR also causes heart rate so that might be untrue). If it doesn't, then the "temporary fix" is enough because the loop doesn't need to be ran since we know nothing is changing while HR=0.

If it does, the fix would be to add an onState to cardiac arrest to call the vitals function and update the function so that only relevant code is executed while in cardiac arrest.

@commy2 commy2 changed the title Fix time delta being incorrectly large when exiting cardiac arrest time delta is incorrectly large when exiting cardiac arrest May 12, 2019
@commy2
Copy link
Contributor

commy2 commented May 12, 2019

It bothered me that this issue was named "fix", but is not a pull request.

@kymckay
Copy link
Member Author

kymckay commented Jul 7, 2019

Fixed by #7060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

3 participants