I am new to socket programing and SW architecture.
My system must be : a GUI in my laptop using python. There are many embedded systems with same sensors ( GPS, Temperature, pressure ...). Each time you select an embedded system, my program needs to establish a connection with it , I need to show its GPS position and the real time feed of its sensors in the GUI ( For now the GUI is not the problem, I can do with Kivy or Tkinter).
This is how it must function :
- In the GUI, there is a field to enter the ID of embedded system and a button to try to connect with it.
- When the button is clicked, the program establishes connection and shows GPS, Temperature and pressure in real time continuously until connection is lost.
I was thinking of doing it with this architecture :
- A thread to deal with the GUI
- Each time a button is clicked and an embedded system is found, an object of a class I created is instantiated.
- The class has as attributes :
- list GPS ( to store GPS feed)
- list temperature ( to store Temperature feed)
- list pressure
- a thread_socket ( the socket is created in a thread to be a client to the embedded system. So each time an object is instantiated of the class, a separate socket is create )
- The class has as methods :
- Get_Gps() : Each time this method is called the GPS list attribute is updated
- Get_Temperature() / Pressure()
- Stop() : When this method is called the embedded system needs to shutdown.
In the socket thread, I have methods such as send_message() and receive_message() to send through TCP/IP the request for getting GPS and sensor data or stopping the system.
On each embedded system I will put a server using python that is set up everytime the system starts. This way the ID of the system is the ip of the server, And my laptop would be a client, searching for the ip adress when I select a system.
My questions are :
- Does this architecture seem alright to you ?
- Is it correct to receive real time feed in a list ? for example for the gps.
- Each time I find a system I instanciate an object to keep things clean, is this a good way to do it?
- Do you see any issues or improvements ?
Thank you in advance,