You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
7 months ago
|
import os
|
||
|
import sys
|
||
|
from peewee import *
|
||
|
|
||
|
from utils.DBModels.BaseModel import *
|
||
|
from utils.DBModels.ClientModels import Project, ClientDB
|
||
|
from utils import Globals
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
class Client(object):
|
||
|
"""客户端逻辑类"""
|
||
|
def __init__(self):
|
||
|
super(Client, self).__init__()
|
||
|
|
||
|
@classmethod
|
||
|
def initDB(self):
|
||
|
dbPath = os.path.join('db', 'client.db')
|
||
|
if os.path.isfile(dbPath):
|
||
|
self.clientDB = SqliteDatabase(dbPath)
|
||
|
client_proxy.initialize(self.clientDB)
|
||
|
self.clientDB.connect()
|
||
|
else:
|
||
|
self.clientDB = SqliteDatabase(dbPath)
|
||
|
client_proxy.initialize(self.clientDB)
|
||
|
modelsArr = [Project, ClientDB]
|
||
|
self.clientDB.connect()
|
||
|
self.clientDB.create_tables(modelsArr, safe = True)
|
||
|
|
||
|
|
||
|
@classmethod
|
||
|
def close(self):
|
||
|
from model.ProjectModel.ProjectManage import ProjectManage
|
||
|
popen = Globals.getValue('popen')
|
||
|
popenBeat = Globals.getValue('beatPopen')
|
||
|
if popen:
|
||
|
popen.kill()
|
||
|
if popenBeat:
|
||
|
popenBeat.kill()
|
||
|
proType = Globals.getValue('currentProType')
|
||
|
ProjectManage.closePopen()
|
||
|
if proType == '7':
|
||
|
Globals.getValue('FFThread').quitThread()
|
||
|
return
|
||
|
elif proType == '5':
|
||
|
RTDTCThread= Globals.getValue('RTDTCThread')
|
||
|
RTDTCThread.quitThread()
|
||
|
return
|
||
|
elif proType in ['6']:
|
||
|
AnalogThread = Globals.getValue('AnalogThread')
|
||
|
AnalogThread.quitThread()
|
||
|
return
|
||
|
elif proType in ['8']:
|
||
|
FFSimulateThread = Globals.getValue('FFSimulateThread')
|
||
|
FFSimulateThread.quitThread()
|
||
|
return
|
||
|
elif proType in ['9']:
|
||
|
HartSimulateThread = Globals.getValue('HartSimulateThread')
|
||
|
HartSimulateThread.quitThread()
|
||
|
return
|
||
|
|
||
|
# Client.initDB()
|