コード例 #1
0
 def __init__(self, onj=None, *args, **kwargs):
     super(MainWindow, self).__init__(*args, **kwargs)
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     self.messageController = MessageController()
     self.simSettings = SimulatorSettings()
     self.sim = Simulator(self.simSettings, self.messageController)
     self.con = Controller(self.simSettings, self.sim.hospitalsLocations(),
                           self.sim.ambulancesDistribution(),
                           self.messageController)
     self.ui.Mplwidget
     self.ui.Mplwidget.draw_hospital_on_map(self.con.Hospitals)
     self.ui.hospwidget
     self.ui.hospwidget.draw_all_hosp_inf(self.con.Hospitals)
     self.tablica_komunikatow = []
     self.control_events = []
     self.observ_from_message = []
     self.ui.start.clicked.connect(self.start_sim)
     self.ui.pauza.clicked.connect(self.stop_sim)
     self.ui.reset.clicked.connect(self.reset_sim)
     self.ui.delay_time.setValue(50)
     self.ui.delay_time.valueChanged.connect(self.change_interval)
     self.timer = QtCore.QTimer(self,
                                interval=self.ui.delay_time.value(),
                                timeout=self.simulation)
     self.printedCar = []
     self.printedVirus = []
     self.iterationsNumber = 0
コード例 #2
0
def main():
    root = Tk()
    app = Controller(root)
    app.change_camera_image('../media/title_image.jpg')
    app.change_homo_bird_view_image(lat=0, lon=0, zoom=1, maptype="satellite")
    app.change_peri_bird_view_image(lat=0, lon=0, zoom=1, maptype="satellite")
    app.view.root.mainloop()
    return 0
コード例 #3
0
def create_controller(name_test):
    return Controller('test.db',
                      False,
                      True,
                      'test.log',
                      True,
                      name_test=str(name_test))
コード例 #4
0
def main():
    parser = argparse.ArgumentParser(
        description="Proiect Colectiv - Platforma joburi")
    parser.add_argument(
        'config',
        metavar='config_file',
        type=str,
        help='Config file for flask server and database connection')
    args = parser.parse_args()

    config_file = args.config

    init_logger()
    logger.debug("Logger was initialised.")

    if not os.path.exists(config_file):
        logger.error("Error: Path '{}' does not exist".format(config_file))
        return

    flask_config, db_config = parse_input_file(config_file)
    logger.debug('Input file {} was parsed.'.format(config_file))
    logger.debug("Flask config: {}".format(flask_config))
    logger.debug("Db config: {}".format(db_config))

    controller = Controller(db_config)
    init_flask_server(flask_config, controller)
コード例 #5
0
def main():
    try:
        i = 0
        history = []
        carCtrl = Controller()
        camCtrl = Camera()
        thread.start_new_thread(carCtrl.steering, ())
        while True:

            #camCtrl.save_img(camCtrl.capture())
            camCtrl.make_img(i)
            history.append(carCtrl.control_order)
            i += 1

            # check if stop capturing
            if carCtrl.control_sequence == False:
                print("Checked if control_sequence is still alive :: No!")
                break

        with open("Data/history.csv", "w") as csvfile:
            filecsv = csv.writer(csvfile, delimiter=",")
            for command in history:
                filecsv.writerow([command])

    except OSError as err:
        print(err)
        pass

    finally:
        #camCtrl.close_cam()
        pass
コード例 #6
0
ファイル: chat.py プロジェクト: lautimartner/Chat
 def __init__(self, system_argv):
     super(StartChat, self).__init__(system_argv)
     self.client = Client(None,None,None)
     self.controller = Controller(self.client)
     self.gui = View(self.controller, self.client)
     self.client.connToServer(None)
     main_thread = threading.Thread(target=self.client.input_manager)
     main_thread.setDaemon(True)
     main_thread.start()
     self.gui.show()
コード例 #7
0
 def reset_sim(self):
     del self.messageController
     del self.simSettings
     del self.sim
     del self.con
     self.ui.Mplwidget.clean_hospital_on_map()
     self.ui.hospwidget.clean_all_hosp_inf()
     self.clear_widget_scrol()
     self.messageController = MessageController()
     self.simSettings = SimulatorSettings()
     self.sim = Simulator(self.simSettings, self.messageController)
     self.con = Controller(self.simSettings, self.sim.hospitalsLocations(),
                           self.sim.ambulancesDistribution(),
                           self.messageController)
     self.ui.Mplwidget.draw_hospital_on_map(self.con.Hospitals)
     self.ui.hospwidget.draw_all_hosp_inf(self.con.Hospitals)
     self.printedCar.clear()
     self.printedVirus.clear()
     self.iterationsNumber = 0
コード例 #8
0
ファイル: game.py プロジェクト: rayyouxinsheng/ZJU_3_2_AI
def start_game(root, player):
    root.destroy()
    root = Tk()
    screen = BoardCanvas(root,
                         width=screen_width,
                         height=screen_height,
                         background="#856c23",
                         highlightthickness=0)
    controller = Controller(root, screen, init_game)
    init_game(controller, player, screen)

    root.focus_set()
    root.mainloop()
コード例 #9
0
 def test_add_car_seat(self):
     controller = Controller()
     controller.login("*****@*****.**", "password")
     controller.add_car_seat("CD80D789SD8090S", "Graco - Extend to Fit")
     self.assertEqual(controller.active_user.car_seats[1].serial_number,
                      "CD80D789SD8090S")
     self.assertEqual(controller.active_user.car_seats[1].model,
                      "Graco - Extend to Fit")
コード例 #10
0
def main():
    messageController = MessageController()

    simSettings = SimulatorSettings()
    sim = Simulator(simSettings, messageController)

    con = Controller(simSettings, sim.hospitalsLocations(), messageController)
    con.printState()

    for i in range(1000):
        sim.simulatorMianLoop()
        con.controllerMainLoop()
        in_data = input()
        if in_data == 'y':  #write y to show the current state
            con.printState()
コード例 #11
0
def main():
    file_log = 'controller.log'
    file_db = 'DataBase.db'
    lc = False
    lf = False
    only_site = False
    cleanup_database = False
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'h:s:t:c', ['log_file=', 'database=', 'cleanup_database', 'only_site'])
    except getopt.GetoptError:
        print('main.py -t -c --log_file=<filelog> --database=<filedb>')
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print('main.py -t -c --log_file=<filelog> --database=<filedb>')
            sys.exit()
        elif opt == '-t':
            os.system('python -m pytest -vv Controller/test.py')
            sys.exit()
        elif opt == "-c":
            lc = True
        elif opt == "--log_file":
            if arg == '':
                print('main.py -c --log_file=<filelog> --database=<filedb>')
                sys.exit()
            lf = True
            file_log = arg
        elif opt == '--database':
            file_db = arg
        elif opt == '--cleanup_database':
            cleanup_database = True
        elif opt == '--only_site':
            only_site = True
    c = Controller(file_db, lc, lf, file_log)
    if not only_site:
        LibraryBot = start_bot(c)
        site = Main(c, LibraryBot.get_bot())
        if cleanup_database:
            site.api.dbmanager.cleanup_database()
            site.api.dbmanager.init_tables()
        thread_site = threading.Thread(target=site.run)
        thread_site.start()
        LibraryBot.run()
    else:
        print('saotehus')
        site = Main(c, None)
        if cleanup_database:
            site.api.dbmanager.cleanup_database()
            site.api.dbmanager.init_tables()
        site.run()
コード例 #12
0
    def run(self):

        repo = RepositoryFile("../sentences.txt")
        repo.readFromFile()
        controller = Controller(repo)
        ui = UI(controller)
        ui.showMenu()
        while True:
            value = input("Choose from the menu an instruction.")

            if value == '1':
                print("Insert a sentence: ")
                ui.addUI()

            if value == '2':
                ui.playGame()
コード例 #13
0
def main():
    controller = Controller('Model\\frames_file.pls')
    controller.run()
コード例 #14
0
ファイル: test3.py プロジェクト: LibrinnoTeam/LibraryHelpBot
v = {
    'id': 1110,
    'name': 'Veronika Rama',
    'address': 'Stret Atocha, 27',
    'status': 'Visiting Professor',
    'phone': ': 30005',
    'history': [],
    'current_docs': []
}

date1 = datetime(2018, 3, 5)
date2 = date(2018, 4, 2)
date3 = datetime(2018, 3, 29)
date4 = datetime(2018, 3, 26)
m = Manager()
c = Controller()


def clear_tables():
    m.drop_tables()
    add_all()


def check_out_doc(user_id, doc_id, type_bd, date=datetime.now()):
    if (c.check_out_doc(user_id, doc_id, type_bd,
                        date_when_took=date)[0] == False):
        c.add_queue_order(user_id, type_bd, doc_id)


def return_doc(user_id, doc_id):
    orders = c.get_user_orders(user_id)
コード例 #15
0
ファイル: filter.py プロジェクト: LibrinnoTeam/LibraryHelpBot
 def filter(self, message):
     return (self.user_type == Controller().user_type(
         message.chat_id)) != self.invert
コード例 #16
0
from Controller.controller import Controller

WIDTH = 1000
HEIGHT = 800
FPS = 60

SPEED = 10

PLAYER_X = 300
PLAYER_Y = 610

controller = Controller(WIDTH, HEIGHT, FPS, SPEED, PLAYER_X, PLAYER_Y)
controller.run()
コード例 #17
0
from Repository.repository import Repository
from Controller.controller import Controller
from UI.ui import UI

while True:
    commands = ["1k.txt", "10k.txt", "100k.txt", "example.txt"]
    fileName = input("Insert filename: ")
    if fileName in commands:
        break

repo = Repository(fileName)
repo.readFromFile()
controller = Controller(repo)
new_ui = UI(controller)

new_ui.menu()
new_ui.startapp()
コード例 #18
0
from Controller.controller import Controller

c = Controller()
c.start()
コード例 #19
0
 def test_controller_instantiate(self):
     controller = Controller()
     self.assertIsNotNone(controller)
     self.assertIsNotNone(controller.user_profiles)
コード例 #20
0
ファイル: main.py プロジェクト: shoshirizel/traffic-lights
from Controller.controller import Controller

if __name__ == "__main__":
    ctrl = Controller("Model/playlist.pls")
    ctrl.run()
コード例 #21
0
 def test_get_user_car_seats(self):
     controller = Controller()
     controller.login("*****@*****.**", "password")
     self.assertIsNotNone(controller.active_user.car_seats)
     self.assertEqual(controller.active_user.car_seats[0].serial_number,
                      "123ABC")
コード例 #22
0
 def test_login(self):
     controller = Controller()
     loggedIn = controller.login("*****@*****.**", "p@ssw0rd")
     self.assertEqual(loggedIn, 1)
     self.assertIsNotNone(controller.active_user)
     self.assertEqual(controller.active_user.email, "*****@*****.**")
コード例 #23
0
 def test_register(self):
     controller = Controller()
     controller.register("*****@*****.**", "john", "doe", "p@ssw0rd")
     self.assertIsNotNone(controller.active_user)
     self.assertEqual(controller.active_user.email, "*****@*****.**")
コード例 #24
0
from CNN.customModel import CustomModel
from Observation.observation import Observation
from Controller.controller import Controller
from UI.gui import Gui
from TrainingsDataManager.imageDataManager import ImageDataManager

if __name__ == '__main__':
    model_name = 'model_name'  # TODO
    categories = ["Caffe Americano", "Cappuccino", "Latte Macchiato"]  # TODO
    epochs = 10  # TODO
    image_width = 800  # TODO
    image_height = 600  # TODO

    model = CustomModel(model_name, categories, epochs)
    observation = Observation(image_width, image_height)
    manager = ImageDataManager(image_width, image_height)
    controller = Controller(model, observation, manager)
    gui = Gui(controller)

    gui.root.mainloop()
コード例 #25
0
class View:
	cc = Controller()
	db = DB()
	print("Добро пожаловать")
	def polling(self):
		try:
			a = int(input("Выберете действие: \n 1.Показать данные \n 2.Изменить данные \n 3.Удалить данные \n 4.Добавить данные\n 5.Проверить на наличие новых записей\n"))
			pass
		except ValueError:
			print("Укажите действие цифрой")
			return self.polling()
		if a == 1:
			b = int(input("Введите номер в списке или 666 что-бы показать всë \n"))
			self.cc.show(b)
		elif a == 2:
			b = int(input("Введите номер в списке\n"))
			c = input("Введите новое значение\n")
			self.cc.update(b,c)
		elif a == 0:
			print("Хорошего дня")
			return False
		elif a == 3:
			b = int(input("Вы хотите удалить больше одного значения?\n 1.Да\n 2.Нет\n 3.Удалить всё\n"))
			if b == 1:
				while True:
					c = int(input("Укажите индекс записи, которую нужно удалить, или введите 666 для выхода."))
					if c == 666:
						break
					else:
						try:
							self.cc.delete(c)
						except IndexError:
							print("Нет значения по указанному индексу")
			elif b == 2:
				c = int(input("Укажите индекс записи, которую нужно удалить."))
				try:
					self.cc.delete(c)
				except IndexError:
					print("Нет значения по указанному индексу")
					self.b = 2
			elif b == 3:
				try:
					self.db.myArray.remove()
				except:
					print("2")
		elif a == 4:
			c = int(input("Вы хотите добавить больше одного значения?\n 1.Да \n 2.Нет\n"))
			if c == 1:
				while True:
					b = input("Введите значение или 0 для остановки\n")
					if b == "0":
						break
					else:
						self.cc.create(b)
			elif c == 2:
				b = input("Введите значение\n")
				self.cc.create(b)
			else:
				print("Не указана команда")
		elif a == 5:
			self.cc.check()
		else:
			print("Ничего не выбрано, чтобы выйти укажите 0")

	def beggining(self):
		try:
			a = int(input("Выберите действие: \n 1.Начать \n 0.Выйти\n"))
			pass
		except ValueError:
			print("Укажите действие цифрой.")
			return self.beggining()
		if a == 1:
			while True:
				a = self.polling()
				if a == False:
					return
		elif a == 0:
			return print("Хорошего дня")
		else:
			print("Не выбрано действие")
			self.beggining()
コード例 #26
0
def main():
    """This function creates and initializes the controller.
    """
    controller = Controller()
    controller.init()
コード例 #27
0
      'status': 'Professor', 'phone': '30002', 'history': [], 'current_docs': []}

p3 = {'id': 1100, 'name': 'Elvira Espindola', 'address': 'Via del Corso, 22',
      'status': 'Professor', 'phone': '30003', 'history': [], 'current_docs': []}

s = {'id': 1101, 'name': 'Andrey Velo', 'address': 'Avenida Mazatlan 250',
     'status': 'Student', 'phone': ': 30004', 'history': [], 'current_docs': []}

v = {'id': 1110, 'name': 'Veronika Rama', 'address': 'Stret Atocha, 27',
     'status': 'Visiting Professor', 'phone': ': 30005', 'history': [], 'current_docs': []}

l1 = {'id': 1, 'phone': 12345, 'name': 'Lib1', 'address': 'Inno', 'status': 'patron', 'privileges': 1}
l2 = {'id': 2, 'phone': 12345, 'name': 'Lib2', 'address': 'Inno', 'status': 'patron', 'privileges': 2}
l3 = {'id': 3, 'phone': 12345, 'name': 'Lib3', 'address': 'Inno', 'status': 'patron', 'privileges': 3}

c = Controller(testing=True)

m = Manager(logging=True, controller=c)


def clear_tables():
    m.drop_tables()


'''
Priv1: Access to/Modification of documents and patrons’ information.
Priv2: In addition to Priv1, addition of documents and patrons to
the library.
Priv3: In addition to Priv2, deletion of documents and patrons of
the library.
'''
コード例 #28
0
ファイル: main.py プロジェクト: Deadecho95/SMARTES
from Cloud.uploadDrive import UploadDrive
from Controller.controller import Controller
from Modbus.clientModBus import ClientModBus
from Controller.localDataBase import LocalDataBase
import time

# --------------------------------------------------------------------------- #
# Main
# --------------------------------------------------------------------------- #

client_modbus = ClientModBus("153.109.14.172", 502)  # the clientmodbus
client_cloud = UploadDrive()  # the client cloud
database = LocalDataBase()
controller = Controller(
    client_modbus, client_cloud,
    database)  # create new controller with clients to connect

while True:
    controller.start_cycle()  # start the program
    time.sleep(15)
コード例 #29
0
ファイル: Lab2.py プロジェクト: melingus99/UbbAi2020
    def menu(self):
        f=open("EulerSquare.txt","r")
        problem=1
        while(problem!=0):
            print("avaible problems are:\n 1.Latin Square \n 2.EulerSquare")
            problem=int(input("provide the number of the problem that you want to be solved: "))
            if(problem==1):
                n=int(input("provide the size of the matrix: "))
                matrix=[]
                for i in range(0,n):
                    matrix.append([])
                    for j in range(0,n):
                        matrix[i].append(0)
                problem=LatinSquare(matrix)
                self.controller=Controller(problem)
                print("the problem can be solved in 2 ways: \n 1.Greedy \n 2.DFS ")
                option=int(input("provide the number of the method "))
                if(option==1):
                    res,matrix=self.controller.Greedy()
                    if(res==True):
                        print("Great Succes")
                        for i in range(0,len(matrix)):
                            for j in range(0, len(matrix[i])):
                                print(matrix[i][j],end=" ")
                            print()
                    elif(res==False):
                        print("Not Great Succes")
                        for i in range(0,len(matrix)):
                            for j in range(0, len(matrix[i])):
                                print(matrix[i][j],end=" ")
                            print()
                elif(option==2):
                    matrix=self.controller.DFS()
                    for i in range(0,len(matrix)):
                        for j in range(0, len(matrix[i])):
                            print(matrix[i][j],end=" ")
                        print()
            elif(problem==2):
                f1=f.read().split("\n")
                n=int(f1[0])
                firstSet=f1[1].split(" ")
                secondSet=f1[2].split(" ")
                pop=int(f1[3])
                iterations=int(f1[4])
                print("the problem can be solved in 2 ways: \n 1.HC \n 2.EA 3.PSO")
                option=int(input("provide the number of the method "))
                if(option==1):
                    matrix=[]
                    for i in range(0,n):
                        matrix.append([])
                        for j in range(0,n):
                            first=rnd.randint(0,n-1)
                            second=rnd.randint(0,n-1)
                            matrix[i].append([firstSet[first],secondSet[second]])
                    problem=EulerSquare(matrix,firstSet,secondSet)
                    self.controller=Controller(problem)
                    for res,matrix in self.controller.HillClimbing():
                        print("Great Succes")
                        for i in range(0,len(matrix)):
                            for j in range(0,len(matrix)):
                                print("("+matrix[i][j][0]+","+matrix[i][j][1]+")",end=" ")
                            print()

                elif(option==2):
                    mutation=float(f1[3])
                    crossover=float(f1[4])
                    pop=int(f1[5])
                    generations=int(f1[6])
                    population=self.populate(pop,n,firstSet,secondSet)
                    problem=EulerSquare(population,firstSet,secondSet)
                    self.controller=Controller(problem)
                    res,matrix=self.controller.EA(pop,mutation,crossover,generations)
                    if(res==True):
                        print("Great Succes")
                        for i in range(0,len(matrix)):
                            for j in range(0, len(matrix[i])):
                                print(matrix[i][j],end=" ")
                            print()
                    else:
                        print("Not Great Succes")
                        for i in range(0,len(matrix)):
                            for j in range(0, len(matrix[i])):
                                print(matrix[i][j],end=" ")
                            print()

                elif(option==3):
                    w=float(f1[5])
                    c1=float(f1[6])
                    c2=float(f1[7])
                    neighborhoodSize=int(f1[8])
                    population=self.populatePSO(pop,n,firstSet,secondSet)
                    problem=EulerSquare(population,firstSet,secondSet)
                    self.controller=Controller(problem)
                    for res,matrix,score in self.controller.PSO(neighborhoodSize,c1,c2,w,iterations):
                        if(res==True):
                            print("Finished")
                        else:
                            print("Not Finished Yet")
                        print("score is: -"+str(score))
                        for i in range(0,len(matrix)):
                            for j in range(0, len(matrix[i])):
                                print(matrix[i][j],end=" ")
                            print()
コード例 #30
0
 def test_delete_car_seat(self):
     controller = Controller()
     controller.login("*****@*****.**", "password")
     controller.delete_car_seat("CD80D789SD8090S")
     self.assertEqual(len(controller.active_user.car_seats), 1)