Skip to content

Commit

Permalink
0.0.7
Browse files Browse the repository at this point in the history
[*] The first fully working prototype was implemented to demonstrate the project (This is only a demo version).
[+] A lot of things.
  • Loading branch information
ANameSpace committed Feb 27, 2024
1 parent b576814 commit ebc6fd2
Show file tree
Hide file tree
Showing 16 changed files with 1,097 additions and 527 deletions.
221 changes: 174 additions & 47 deletions ui/UI.py → app/ui/UI.py

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions app/ui/utils/AfkUtil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import time

from app.utils.tools.Log import Log


class AfkUtil:
def __init__(self):
self.last_time = time.time()
self.changes = False

def check_new_changes(self):
current_time = time.time()

if not self.changes:
return False

if current_time - self.last_time > 300: # 5 min = 300 sec
self.changes = False
Log().send(Log.LogType.INFO, "Absence of actions in the last 5 minutes. Return to the initial window.")
return True
return False

def action(self):
self.changes = True
self.last_time = time.time()
656 changes: 656 additions & 0 deletions app/utils/Data.py

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions app/utils/Navigation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import matplotlib.pyplot as plt
import networkx as nx

from app.utils.Data import Data


# G = nx.Graph() # создаём объект графа
#
# # определяем список узлов (ID узлов)
# nodes = ["1,1,1", 1, 2, 3, 4, 5]
#
# # определяем список рёбер
# # список кортежей, каждый из которых представляет ребро
# # кортеж (id_1, id_2) означает, что узлы id_1 и id_2 соединены ребром
# edges = [("1,1,1", 2), (1, 3), (2, 3), (2, 4), (3, 5), (5, 5)]
#
# # добавляем информацию в объект графа
# G.add_nodes_from(nodes)
# G.add_edges_from(edges)
#
# # рисуем граф и отображаем его
# nx.draw(G, with_labels=True, font_weight='bold')
# plt.show()


class Navigation:
_instance = None
_init_already = False

def __new__(cls, *args, **kwargs):
if not cls._instance:
cls._instance = super().__new__(cls, *args, **kwargs)
return cls._instance

def __init__(self):
if not Navigation._init_already:
self.d = Data()

self.graph1 = nx.Graph()
self.nodes1 = []
self.edges1 = []

self.graph2 = nx.Graph()
self.nodes2 = []
self.edges2 = []

# Load floors
self.graph1.add_node("f1")
self.graph2.add_node("f2")

for room in self.d.get_rooms("1"):
self.graph1.add_node(room.getName())

self.graph2.add_edge("f1", room.getName(), weight=1)

for room in self.d.get_rooms("2"):
self.graph2.add_node(room.getName())

self.graph1.add_edge("f1", "101", weight=1)

self.graph1.add_edge("f1", "f1-t-108", weight=1)
self.graph1.add_edge("f1-t-108", "108", weight=1)

self.graph1.add_edge("f1-t-108", "f1-t-110-109", weight=1)
self.graph1.add_edge("f1-t-110-109", "109", weight=1)
self.graph1.add_edge("f1-t-110-109", "110", weight=1)



self.graph2.add_edge("f2", "208-207-f2", weight=1)

self.graph2.add_edge("f2", "200-f2", weight=1)
self.graph2.add_edge("200-f2", "200", weight=1)

self.graph2.add_edge("208-207-f2", "207", weight=1)
self.graph2.add_edge("208-207-f2", "208", weight=1)

self.graph2.add_edge("200-f2", "f2-t", weight=1)

self.graph2.add_edge("f2-t", "f2-t-206", weight=1)
self.graph2.add_edge("f2-t-206", "206", weight=1)

self.graph2.add_edge("f2-t-206", "f2-t-203-204", weight=1)
self.graph2.add_edge("f2-t-203-204", "203", weight=1)
self.graph2.add_edge("f2-t-203-204", "204", weight=1)

self.graph2.add_edge("f2-t-203-204", "f2-t-201-202", weight=1)
self.graph2.add_edge("f2-t-201-202", "201", weight=1)
self.graph2.add_edge("f2-t-201-202", "202", weight=1)


#self.graph2.add_edge(n, room.getCorridor(), weight=1)


Navigation._init_already = True

def run(self, end_point_name: str, z):
if z == "2":
return nx.shortest_path(self.graph2, "f2", str(end_point_name))
else:
return nx.shortest_path(self.graph1, "f1", str(end_point_name))
36 changes: 36 additions & 0 deletions app/utils/obj/advanced/CorridorlineObj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import uuid
from functools import lru_cache


class CorridorlineObj:
def __init__(self, name: str, x1: int, y1: int, x2: int, y2: int, img_name: str, img_text):
self.uuid = uuid.uuid4()
self.name = name

self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2

self.img_name = img_name
self.img_text = img_text
self.points = 0


def getId(self):
return self.uuid

def getName(self):
return self.name

@lru_cache
def getLocation(self):
return tuple([self.x1, self.y1, self.x2, self.y2])

def getImg(self):
return self.img_name

def getText(self):
return self.img_text
def getPoints1(self):
return self.points
25 changes: 20 additions & 5 deletions utils/obj/LadderObj.py → app/utils/obj/advanced/LadderObj.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
import uuid
from functools import lru_cache


class LadderObj:
def __init__(self, name: str, x: int, y: int, width: int, height: int):
def __init__(self, name: str, x: int, y: int, width: int, height: int, img_name: str):
self.uuid = uuid.uuid4()
self.name = name

self.x = x
self.y = y
self.width = width
self.height = height

def getLocation(self):
return tuple([self.x, self.y, self.width, self.height])
self.img_name = img_name

def getId(self):
return self.uuid

def getName(self):
return self.name

def getCorridor(self):
return "self.name"
@lru_cache
def getLocation(self):
return tuple([self.x, self.y, self.width, self.height])

def getImg(self):
return self.img_name

def getText(self):
return "Зайдите на лестницу"
51 changes: 51 additions & 0 deletions app/utils/obj/advanced/RoomObj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import uuid
from functools import lru_cache
import os

from PySide6 import QtGui
from PySide6.QtWidgets import QLabel

from app.utils.tools.Log import Log


class RoomObj:
def __init__(self, name: str, x: int, y: int, width: int, height: int, img_name: str, flor: str):
self.uuid = uuid.uuid4()
self.name = name

self.x = x
self.y = y
self.width = width
self.height = height

self.img_name = img_name

self.flor = flor

def getId(self):
return self.uuid

def getName(self):
return self.name

@lru_cache
def getLocation(self):
return tuple([self.x, self.y, self.width, self.height])

def getImg(self):
return self.img_name

def getText(self):
return "Откройте дверь"

def getflor(self):
return self.flor

def getImgL(self):
img = QtGui.QPixmap(self.img_name)
if img.isNull():
Log().send(Log.LogType.ERROR, "Failed to load navigation image!")
else:
object = QLabel()
object.setPixmap(img)
return object
13 changes: 13 additions & 0 deletions app/utils/obj/simple/EmptyRoomObj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from functools import lru_cache


class EmptyRoomObj:
def __init__(self, x: int, y: int, width: int, height: int):
self.x = x
self.y = y
self.width = width
self.height = height

@lru_cache
def getLocation(self):
return tuple([self.x, self.y, self.width, self.height])
13 changes: 13 additions & 0 deletions app/utils/obj/simple/WallObj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from functools import lru_cache


class WallObj:
def __init__(self, x1: int, y1: int, x2: int, y2: int):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2

@lru_cache
def getLocation(self):
return tuple([self.x1, self.y1, self.x2, self.y2])
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import requests

from utils.tools.Log import Log
from app.utils.tools.Log import Log


def check(ver: str):
Expand Down
16 changes: 7 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from PySide6.QtWidgets import QApplication
import os

from ui.UI import UI
from utils.Data import Data
from utils.tools import UpdateChecker
from utils.tools.Log import Log
from app.ui.UI import UI
from app.utils.Data import Data
from app.utils.tools import UpdateChecker
from app.utils.tools.Log import Log

APP_VERSION = "0.0.4"
APP_VERSION = "0.0.7"


# BUILD
Expand All @@ -19,27 +19,25 @@
app_directory = os.path.join(os.getcwd(), "UniversityNavigationSystem")
if not os.path.exists(app_directory):
os.makedirs(app_directory)

# Init logs system
log = Log()
log.send(Log.LogType.INFO, "Launching the program...")

# Checking for updates
log.send(Log.LogType.INFO, "Checking for updates...")
UpdateChecker.check(APP_VERSION)
# UpdateChecker.check(APP_VERSION)

# Init data system
log.send(Log.LogType.INFO, "Uploading data...")
data = Data()
#TODO

# Loading the window
Log().send(Log.LogType.INFO, "Loading the window...")
app = None
u_name = "Name"
try:
app = QApplication(sys.argv)
window = UI(Data().get_name())
window = UI(str(Data().get_name() + " | UniversityNavigationSystem"))
window.show()
except:
Log().send(Log.LogType.ERROR, "The window could not be created!")
Expand Down
18 changes: 0 additions & 18 deletions ui/AFK.py

This file was deleted.

Loading

0 comments on commit ebc6fd2

Please sign in to comment.