2019-08-15 09:40:18 -07:00
|
|
|
from networktables import NetworkTables
|
2019-03-10 22:29:29 +02:00
|
|
|
import tornado.ioloop
|
2019-05-24 05:16:15 -07:00
|
|
|
import logging
|
2019-03-10 22:29:29 +02:00
|
|
|
from app.ChameleonVisionApp import ChameleonApplication
|
2019-04-13 11:57:43 -07:00
|
|
|
from app.classes.SettingsManager import SettingsManager
|
2019-03-10 22:29:29 +02:00
|
|
|
from tornado.options import options
|
2019-08-09 02:21:52 -07:00
|
|
|
import threading
|
|
|
|
|
import asyncio
|
2019-08-15 09:40:18 -07:00
|
|
|
from app.handlers.CameraHander import CameraHandler
|
2019-03-10 22:29:29 +02:00
|
|
|
|
2019-05-24 05:16:15 -07:00
|
|
|
|
2019-05-10 07:01:39 -07:00
|
|
|
def run_server():
|
2019-08-09 02:21:52 -07:00
|
|
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
2019-03-10 22:29:29 +02:00
|
|
|
tornado.options.parse_command_line()
|
|
|
|
|
app = ChameleonApplication()
|
|
|
|
|
print(f"Serving on port {options.port}")
|
|
|
|
|
app.listen(options.port)
|
|
|
|
|
tornado.ioloop.IOLoop.current().start()
|
2019-08-15 11:17:26 -07:00
|
|
|
|
|
|
|
|
|
2019-08-15 09:40:18 -07:00
|
|
|
def run():
|
2019-08-15 11:17:26 -07:00
|
|
|
NetworkTables.startClientTeam(team=settings_manager.general_settings.get("team_number", 1577))
|
2019-08-15 09:40:18 -07:00
|
|
|
port = 5550
|
|
|
|
|
for cam_name in settings_manager.usb_cameras:
|
|
|
|
|
CameraHandler(cam_name, port).run()
|
|
|
|
|
port += 1
|
2019-05-10 07:01:39 -07:00
|
|
|
|
2019-08-15 11:17:26 -07:00
|
|
|
|
2019-08-16 15:00:28 +03:00
|
|
|
|
2019-05-24 05:16:15 -07:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG)
|
2019-08-15 09:40:18 -07:00
|
|
|
settings_manager = SettingsManager()
|
2019-08-15 11:17:26 -07:00
|
|
|
run()
|
2019-08-09 02:21:52 -07:00
|
|
|
server_thread = threading.Thread(target=run_server)
|
|
|
|
|
server_thread.start()
|
2019-08-15 11:17:26 -07:00
|
|
|
|