odwdinc / Python-SimConnect

Python interface for MSFS2020 SimConnect.dll
GNU Affero General Public License v3.0
270 stars 107 forks source link

Possible to send multiple vars in one request? #106

Open vamshichittaluri opened 2 years ago

vamshichittaluri commented 2 years ago

Hey,

when we set data on the aircraft, instead of individually setting variables is it possible to send them at once? i've been seeing some jittering when i send more than one var immediately. Please suggest. I understand that in the simulation variables there are no structs to send them in as a structure, but I need help figuring out how to solve the jitter issue, when we set multiple vars via simconnect.

Kind Regards Vamshi

fyyyyy commented 2 years ago

If you send them within the same render cycle there should be no jitter?

Taz5150 commented 1 year ago

Hi,

Not sure if I am having the same issue, but here it goes.

Lets say I want to read two SimVars, one after the other, during the same deltaTime (or render cycle as @fyyyyy suggests):

simvar_cn1 = aq.get("TURB_ENG_CORRECTED_N1:1") simvar_fn = aq.get("TURB_ENG_JET_THRUST:1")

Somehow, if I do this, these two variables are read at different cycles (I can tell since I can relate one to the other due to configuration files). I have tested these with SimVar Watcher in MSFS2020, and as expected they are read at the same cycle; but not with SimConnect through Python.

Any ideas how to solve this issue? @fyyyyy, how do you suggest to send them during the same render cycle?

Thank you.

PS: @vamshichittaluri did you solve it?

fyyyyy commented 1 year ago

This is probably a limitation of SimConnect, not related to python or this library in particular.

Taz5150 commented 1 year ago

This is probably a limitation of SimConnect, not related to python or this library in particular.

Not really, we can do that on C# and C++ by controlling reading and writing SimVars at every deltaTime (every frame); SimVar Watcher, for example, works as expected.

There is probably a way to do in Python-Simconnect, I'm just not sure and did not find any examples.

Thank you in any case @fyyyyy

mracko commented 1 year ago

Have you thought about running Python SimConnect multi-threaded? It could potentially solve your issue. I'm using this trick to make the Mobile Companion App run more smoothly.

Taz5150 commented 1 year ago

Have you thought about running Python SimConnect multi-threaded? It could potentially solve your issue. I'm using this trick to make the Mobile Companion App run more smoothly.

Not sure that would help, honestly. I am testing with very small python scripts and just a couple of simvars, so threading should not be the issue or solution in this case.

There has to be a way to read a number of SimVars at a given frame cycle, like SimVar Watcher does.

fyyyyy commented 1 year ago

probalby configured here, try changing these

enum def https://github.com/odwdinc/Python-SimConnect/blob/13ff77f0eb323275a587d20fd0bc30af314bb54c/SimConnect/Enum.py#L152

use: https://github.com/odwdinc/Python-SimConnect/blob/7fe6be86e31539a5a4f05696c01589f0e2a71e41/SimConnect/Attributes.py#L216

class SIMCONNECT_PERIOD(CtypesEnum):  #
    SIMCONNECT_PERIOD_NEVER = 0
    SIMCONNECT_PERIOD_ONCE = 1
    SIMCONNECT_PERIOD_VISUAL_FRAME = 2
    SIMCONNECT_PERIOD_SIM_FRAME = 3
    SIMCONNECT_PERIOD_SECOND = 4
Taz5150 commented 1 year ago

probalby configured here, try changing these

enum def

https://github.com/odwdinc/Python-SimConnect/blob/13ff77f0eb323275a587d20fd0bc30af314bb54c/SimConnect/Enum.py#L152

use:

https://github.com/odwdinc/Python-SimConnect/blob/7fe6be86e31539a5a4f05696c01589f0e2a71e41/SimConnect/Attributes.py#L216

class SIMCONNECT_PERIOD(CtypesEnum):  #
  SIMCONNECT_PERIOD_NEVER = 0
  SIMCONNECT_PERIOD_ONCE = 1
  SIMCONNECT_PERIOD_VISUAL_FRAME = 2
  SIMCONNECT_PERIOD_SIM_FRAME = 3
  SIMCONNECT_PERIOD_SECOND = 4

Good idea. Will look at it ASAP!! Thank you!!