Пример #1
0
class Main:
	"""A class for establishing connections"""

	def start_db_hdlr(self, db):
		self.db_hdlr = DatabaseHandler(db)
		self.db_hdlr.flush_rss_readings()
		self.db_hdlr.check_pos_tbl()
		self.db_hdlr.check_rsl_tbl()

	def start_net_srv(self):
		self.net_srv = NetworkServer()
		self.net_srv.start()

	def start_serial_conn(self, port, timeout): 
		self.serial_conn = SerialConnection(port, timeout)
		self.serial_conn.open()
		self.serial_conn.flush_input()

	def start_trilat(self):
		self.trilat = Trilateration()
		self.trilat.start()
	
	def run(self):
		try:
			while True:
				data = self.serial_conn.read().strip()
				tag_id = data[:4]
				rss = data[4:]
				self.db_hdlr.ins_reading(2, tag_id, rss)
		except KeyboardInterrupt:
			self.db_hdlr.close_db()
			self.net_srv.stop()
			self.net_srv.join(60)
			self.trilat.stop()
			self.trilat.join(20)
			self.serial_conn.close()
Пример #2
0
import sys
from PyQt5 import QtWidgets, QtNetwork, QtCore
from main_window import MainWindow
from network_server import NetworkServer
app = QtWidgets.QApplication(sys.argv)

# qwindow
main_window = MainWindow()
main_window.show()

network_server = NetworkServer()
test_socket = QtNetwork.QTcpSocket()
test_socket.connectToHost('127.0.0.1', 54545)
print("its working till here ")
str = "testign testing"
b = bytes(str, 'UTF-8')
temp = test_socket.write(QtCore.QByteArray(b))
print(temp)
sys.exit(app.exec_())
Пример #3
0
	def start_net_srv(self):
		self.net_srv = NetworkServer()
		self.net_srv.start()