Python Forum
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Collect real time data
#1
Hello,
I would like to create a very simple animation (a moving dot) guided by data recorded in real time.i achieved the script to collect data (the code below) but i don't know how to keep these data in order to animate my dot point in a GUI frame.The real time data is marker.x.
Ideally, i would like to have a script which collect real time data and output the real time data i could use in an other GUI script.
Thanks!
import asyncio
import qtm
import xml.etree.ElementTree as ET


def labelMarker(xml_Str):
    print(xml_Str)


async def setup():
    """ Main function """
    connection = await qtm.connect("127.0.0.1",version="1.16")
    if connection is None:
        return
    """ Marker Label identification"""
    xml_string=await connection.get_parameters(parameters=["3d"])
    root = ET.fromstring(xml_string)
    label=[]# list creation
    dico_marker={} # dictionnary creation
    for sub1 in root:
        for name in sub1.iter('Name'):
            label.append(name.text)
        
    def streamData(packet):
        """ Callback function that is called everytime a data packet arrives from QTM """
        #print("Framenumber: {}".format(packet.framenumber))
        header, markers = packet.get_3d_markers()
        i=0
        ''' Data are stored in a dictionnary'''
        for marker in markers:
            dico_marker[label[i%len(label)],'X',i]=marker.x
            i=i+1
            #print(dico_marker.keys())
            
    await connection.stream_frames(components=["3d"], on_packet=streamData)
    
        
    
def main():
    asyncio.ensure_future(setup()) # creation of future object that will eventually give a result  some time in the future
    loop=asyncio.get_event_loop() # creation of event loop which schedule my coroutine
    loop.run_forever() # run the event loop until stop()is called
   

if __name__ == "__main__":
    main()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Non-blocking real-time plotting slow_rider 5 3,601 Jan-07-2023, 09:47 PM
Last Post: woooee
  Real time database satyanarayana 3 1,661 Feb-16-2022, 01:37 PM
Last Post: buran
  Real time data satyanarayana 3 23,269 Feb-16-2022, 07:46 AM
Last Post: satyanarayana
  Real time Detection and Display Gilush 0 1,782 Feb-05-2022, 08:28 PM
Last Post: Gilush
  How to read rainfall time series and insert missing data points MadsM 4 2,165 Jan-06-2022, 10:39 AM
Last Post: amdi40
  Real-Time output of server script on a client script. throwaway34 2 2,048 Oct-03-2021, 09:37 AM
Last Post: ibreeden
Smile Set 'Time' format cell when writing data to excel and not 'custom' limors 3 6,282 Mar-29-2021, 09:36 PM
Last Post: Larz60+
  Real Time Audio Processing with Python Sound-Device not working Slartybartfast 2 3,958 Mar-14-2021, 07:20 PM
Last Post: Slartybartfast
  python tool to collect the time measurement of entire code maiya 3 2,296 Feb-12-2021, 05:39 PM
Last Post: BashBedlam
Question I can't get my real-time chart with Python (Help!) Bastian_ElProfe 1 2,219 Jan-20-2021, 01:34 PM
Last Post: wostan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020