-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[*] The first fully working prototype was implemented to demonstrate the project (This is only a demo version). [+] A lot of things.
- Loading branch information
1 parent
b576814
commit ebc6fd2
Showing
16 changed files
with
1,097 additions
and
527 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
utils/obj/LadderObj.py → app/utils/obj/advanced/LadderObj.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "Зайдите на лестницу" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
2 changes: 1 addition & 1 deletion
2
utils/tools/UpdateChecker.py → app/utils/tools/UpdateChecker.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.