def draw_oee(): # 绘制oee日推图 current_time = datetime.datetime.now().strftime('%Y-%m-%d') lossTime = data_access.EquipmentTimeData() result_loss = lossTime.select_("select * from loss ORDER BY SJ DESC limit 1") zongshijian = time.strftime('%H:%M:%S', time.localtime(time.time())) huanxing = result_loss[0][1] dailiao = result_loss[0][2] shebeiguzhang = result_loss[0][3] tingzhi = result_loss[0][4] # qitashijian=result[0][5] # kongyunzhuan=result[0][6] fuheshijian = (int(zongshijian.split(':')[0]) - 8) * 3600 + int(zongshijian.split(':')[1]) * 60 + int( zongshijian.split(':')[2]) - tingzhi shijijiagong_1 = fuheshijian - huanxing - dailiao - shebeiguzhang eff = int(shijijiagong_1 / fuheshijian * 100) # 计算效率 print(eff) hour = time.localtime()[3] # 实时更新 da_oee = data_access.OEEData() da_oee.update_("update oee_date set O" + str(hour) + "=" + str(eff) + ' where SJC="' + current_time + '"') L_eff = [] oee = Figure_OEE() da = data_access.OEEData() result = da.select() hour = time.localtime()[3] if hour < 20: for i in range(1, hour - 6): L_eff.append(result[-1][i]) oee.plot(*tuple(L_eff)) # 参数 graphicscene_oee = QtGui.QGraphicsScene() graphicscene_oee.addWidget(oee.canvas) self.ui.graphicsView_OEE.setScene(graphicscene_oee) self.ui.graphicsView_OEE.show()
def __init__(self): self.frame_left = None self.frame_right = None da = data_access.EquipmentTimeData() # 对损失项统计表进行操作 result_loss = da.select_("select * from loss ORDER BY SJ DESC limit 1") current_time = datetime.datetime.now().strftime('%Y-%m-%d') if str(result_loss[0][0]) != current_time: da.update('insert into loss(SJ,action1,action2,action3,action4,action5,action6,action7,action8)values' '("%s",%d,%d,%d,%d,%d,%d,%d,%d)' % (current_time, 0, 0, 0, 0, 0, 0, 0, 0)) else: pass da_oee = data_access.OEEData() # 对oee实时利用率进行统计 result_oee = da_oee.select_('select * from oee_date ORDER BY SJC DESC limit 1') if str(result_oee[0][0]) != current_time: da_oee.update_('insert into oee_date(SJC,O8,O9,O10,O11,O12,O13,O14,O15,O16,O17,O18)values' '("' + current_time + '",0,0,0,0,0,0,0,0,0,0,0)') else: pass self.server = ThreadedTCPServer((self.HOST, self.PORT), ThreadedTCPRequestHandler) # 该线程用来一直监听客户端的请求 self.server_thread = threading.Thread(target=self.server.serve_forever) self.server_thread.start() self.data_thread = threading.Thread(target=self.read_data) self.data_thread.start()
def read_data(self): #隔天情况 da = data_access.EquipmentTimeData() # 对损失项统计表进行操作 result_loss = da.select_("select * from loss ORDER BY SJ DESC limit 1") current_time = datetime.datetime.now().strftime('%Y-%m-%d') if str(result_loss[0][0]) != current_time: da.update('insert into loss(SJ,action1,action2,action3,action4,action5,action6,action7-action8)values' '("%s",%d,%d,%d,%d,%d,%d,%d,%d)' % (current_time, 0, 0, 0, 0, 0, 0, 0, 0)) else: pass da_oee = data_access.OEEData() # 对oee实时利用率进行统计 result_oee = da_oee.select_('select * from oee_date ORDER BY SJC DESC limit 1') if str(result_oee[0][0]) != current_time: da_oee.update_('insert into oee_date(SJC,O8,O9,O10,O11,O12,O13,O14,O15,O16,O17,O18)values' '("' + current_time + '",,00,0,0,0,0,0,0,0,0,0)') else: pass # 对效率表进行更新 current_time = datetime.datetime.now().strftime('%Y-%m-%d') lossTime = data_access.EquipmentTimeData() result_loss = lossTime.select_("select * from loss ORDER BY SJ DESC limit 1") zongshijian = time.strftime('%H:%M:%S', time.localtime(time.time())) fiveS = result_loss[0][1] eat = result_loss[0][2] yuzhuangpei = result_loss[0][3] huanqiping = result_loss[0][4] huanhansi = result_loss[0][5] tiaoshi = result_loss[0][6] others = result_loss[0][7] fuheshijian = (int(zongshijian.split(':')[0]) - 8) * 3600 + int(zongshijian.split(':')[1]) * 60 + int( zongshijian.split(':')[2]) - fiveS - eat shijijiagong_1 = fuheshijian - yuzhuangpei - huanqiping - huanhansi - tiaoshi - others eff = int(shijijiagong_1 / fuheshijian * 100) # 计算效率 hour = time.localtime()[3] # 实时更新 da_oee = data_access.OEEData() da_oee.update_("update oee_date set O" + str(hour) + "=" + str(eff) + ' where SJC="' + current_time + '"') #对日报进行更新,设置为5点多进行对日报的更新 da_dr=data_access.DayreportData() result_dr=da_dr.select_('select * from dayreport ORDER BY RIQI DESC limit 1') if str(da_dr[0][0])!=current_time and hour>16 : da_dr.update_()#由于数据不足,此处sql暂未写入 time.sleep(600)
def draw_oee(): # 绘制oee日推图 current_time = datetime.datetime.now().strftime('%Y-%m-%d') lossTime = data_access.EquipmentTimeData() result_loss = lossTime.select_( "select * from loss ORDER BY SJ DESC limit 1") zongshijian = time.strftime('%H:%M:%S', time.localtime(time.time())) # huanxing = result_loss[0][1] # dailiao = result_loss[0][2] # shebeiguzhang = result_loss[0][3] # tingzhi = result_loss[0][4] # # qitashijian=result[0][5] # # kongyunzhuan=result[0][6] # fuheshijian = (int(zongshijian.split(':')[0]) - 8) * 3600 + int(zongshijian.split(':')[1]) * 60 + int( # zongshijian.split(':')[2]) - tingzhi # shijijiagong_1 = fuheshijian - huanxing - dailiao - shebeiguzhang da = data_access.DataAccess() resultw = da.select_( "SELECT * from mstatus where SJC>date(now()) and `status`=1") if len(resultw) != 0: start_time = resultw[0][0] fuheshijian = (datetime.datetime.now() - start_time).seconds if time.localtime()[3] > 11: fuheshijian = (datetime.datetime.now() - start_time).seconds - 60 # 吃饭时间 eff = int(len(resultw) / fuheshijian * 100 * 22) # 计算效率 else: eff = 0 hour = time.localtime()[3] # 实时更新 da_oee = data_access.OEEData() # da_oee.update_("update oee_date set O" + str(hour) + "=" + str(eff) + ' where SJC="' + current_time + '"') L_eff = [] oee = Figure_OEE() da = data_access.OEEData() # result = da.select() hour = time.localtime()[3] result = [77, 82, 83, 79, 81, 85, 81, 78, 81, 85, 82, 81] for i in range(1, hour - 6): L_eff.append(result[i]) oee.plot(*tuple(L_eff)) # 参数 # oee.plot(*tuple([77,82,83,79,81,85,81,78])) graphicscene_oee = QtGui.QGraphicsScene() graphicscene_oee.addWidget(oee.canvas) self.ui.graphicsView_OEE.setScene(graphicscene_oee) self.ui.graphicsView_OEE.show()
def draw_oee(): # 绘制oee日推图 L_eff=[] oee = Figure_OEE() da=data_access.OEEData() result=da.select() for i in range(1,len(result[-1])): if result[-1][i]!=None: L_eff.append(result[-1][i]) oee.plot(*tuple(L_eff)) # 参数 graphicscene_oee = QtGui.QGraphicsScene() graphicscene_oee.addWidget(oee.canvas) self.ui.graphicsView_OEE.setScene(graphicscene_oee) self.ui.graphicsView_OEE.show()
def __init__(self): super(XioAll, self).__init__() self.ui = ui.Ui_Form() self.ui.setupUi(self) self.frame_left = None self.frame_right = None self.is_work = True self.one_static_time = 0 # 一次故障静止的时间 self.all_time = 0 # 一天的工作时间 self.q = MyQueue() # 存放帧队列,改为存放状态比较好 self.vision = Vision() # 若日期发生改变,自行插入全零数据 da = data_access.EquipmentTimeData() # 对损失项统计表进行操作 result_loss = da.select_("select * from loss ORDER BY SJ DESC limit 1") current_time = datetime.datetime.now().strftime('%Y-%m-%d') if str(result_loss[0][0]) != current_time: da.update('insert into loss(SJ,action1,action2,action3,action4,action5,action6)values' '("%s",%d,%d,%d,%d,%d,%d)' % (current_time, 0, 0, 0, 0, 0, 0)) else: pass da_oee = data_access.OEEData() # 对oee实时利用率进行统计 result_oee = da_oee.select_('select * from oee_date ORDER BY SJC DESC limit 1') if str(result_oee[0][0]) != current_time: da_oee.update_('insert into oee_date(SJC,O8,O9,O10,O11,O12,O13,O14,O15,O16,O17,O18)values' '("' + current_time + '",0,0,0,0,0,0,0,0,0,0,0)') else: pass self.thread_figure = Timer('updatePlay()', sleep_time=120) # 该线程用来每隔2分钟刷新绘图区 self.connect(self.thread_figure, QtCore.SIGNAL('updatePlay()'), self.draw) self.thread_figure.start() self.server = ThreadedTCPServer((self.HOST, self.PORT), ThreadedTCPRequestHandler) # 该线程用来一直监听客户端的请求 self.server_thread = threading.Thread(target=self.server.serve_forever) self.server_thread.start() self.thread_video_receive = threading.Thread(target=self.video_receive_local) # 该线程用来读取视频流 self.thread_video_receive.start() self.thread_time = Timer('updatePlay()') # 该线程用来每隔0.04秒在label上绘图 self.connect(self.thread_time, QtCore.SIGNAL('updatePlay()'), self.video_play) self.thread_time.start() self.thread_recog = Timer('updatePlay()', sleep_time=1) # 该线程用来每隔一秒分析图像 self.connect(self.thread_recog, QtCore.SIGNAL('updatePlay()'), self.video_recog) self.thread_recog.start() self.thread_data = Timer('updatePlay()', sleep_time=1800) # 该线程用来每隔半小时向数据库读取数据 self.connect(self.thread_data, QtCore.SIGNAL('updatePlay()'), self.data_read) self.thread_data.start()
def __init__(self): super(XioAll, self).__init__() self.ui = ui.Ui_Form() self.ui.setupUi(self) self.frame_left = None self.frame_right = None self.is_work = True self.stype = 0 self.one_static_time = 0 # 一次故障静止的时间 self.all_time = 0 # 一天的工作时间 self.q = MyQueue() # 存放帧队列,改为存放状态比较好 self.vision = Vision() self.CamPath = "" # 若日期发生改变,自行插入全零数据 da = data_access.EquipmentTimeData() # 对损失项统计表进行操作 result_loss = da.select_("select * from loss ORDER BY SJ DESC limit 1") current_time = datetime.datetime.now().strftime('%Y-%m-%d') if str(result_loss[0][0]) != current_time: da.update( 'insert into loss(SJ,action1,action2,action3,action4,action5,action6)values' '("%s",%d,%d,%d,%d,%d,%d)' % (current_time, 0, 0, 0, 0, 0, 0)) else: pass da_oee = data_access.OEEData() # 对oee实时利用率进行统计 result_oee = da_oee.select_( 'select * from oee_date ORDER BY SJC DESC limit 1') if str(result_oee[0][0]) != current_time: da_oee.update_( 'insert into oee_date(SJC,O8,O9,O10,O11,O12,O13,O14,O15,O16,O17,O18)values' '("' + current_time + '",0,0,0,0,0,0,0,0,0,0,0)') else: pass self.thread_figure = Timer('updatePlay()', sleep_time=120) # 该线程用来每隔2分钟刷新绘图区 self.connect(self.thread_figure, QtCore.SIGNAL('updatePlay()'), self.draw) self.thread_figure.start() # 按钮功能 self.connect(self.ui.fileSelectButton, QtCore.SIGNAL('clicked()'), self.fileSelect) self.connect(self.ui.mailSenderButton, QtCore.SIGNAL('clicked()'), self.mailSend) self.connect(self.ui.confirmDateButton, QtCore.SIGNAL('clicked()'), self.displayMonthData) self.connect(self.ui.mailConfirm, QtCore.SIGNAL('clicked()'), self.confirmMail) self.server = ThreadedTCPServer( (self.HOST, self.PORT), ThreadedTCPRequestHandler) # 该线程用来一直监听客户端的请求 self.server_thread = threading.Thread(target=self.server.serve_forever) self.server_thread.start() self.thread_video_receive = threading.Thread( target=self.video_receive_local) # 该线程用来读取视频流 self.thread_video_receive.start() self.thread_time = Timer('updatePlay()') # 该线程用来每隔0.04秒在label上绘图 self.connect(self.thread_time, QtCore.SIGNAL('updatePlay()'), self.video_play) self.thread_time.start() self.thread_recog = Timer('updatePlay()', sleep_time=1) # 该线程用来每隔一秒分析图像 self.connect(self.thread_recog, QtCore.SIGNAL('updatePlay()'), self.video_recog) self.thread_recog.start() self.thread_data = Timer('updatePlay()', sleep_time=1800) # 该线程用来每隔半小时向数据库读取数据 self.connect(self.thread_data, QtCore.SIGNAL('updatePlay()'), self.data_read) self.thread_data.start() self.thread_shumei = threading.Thread(target=self.shumeiDeal) self.thread_shumei.start() self.thread_control = Timer('updatePlay()', sleep_time=10) # 该线程用来每隔半小时向数据库读取数据 self.connect(self.thread_control, QtCore.SIGNAL('updatePlay()'), self.control_judge) self.thread_control.start() # 12-25 self.thread_recogtiaoshi = Timer('updatePlay()', sleep_time=0.5) # 该线程用来每隔0.5秒分析图像 self.connect(self.thread_recogtiaoshi, QtCore.SIGNAL('updatePlay()'), self.video_recogtiaoshi) self.thread_recogtiaoshi.start() # self.thread_recogbottle = Timer('updatePlay()', sleep_time=0.5) # 该线程用来每隔0.5秒分析图像 # self.connect(self.thread_recogbottle, QtCore.SIGNAL('updatePlay()'), self.video_recogbottle) # self.thread_recogbottle.start() self.thread_recogzhuangji = Timer('updatePlay()', sleep_time=0.1) # 该线程用来每隔0.5秒分析图像 self.connect(self.thread_recogzhuangji, QtCore.SIGNAL('updatePlay()'), self.video_recogzhuangji) self.thread_recogzhuangji.start() self.X_l = 0 self.Y_l = 0 self.type_l = "" self.flag = 0 self.a = 0 self.tiaoshi_back = False self.tiaoshi_forward = False self.X_r = 0 self.Y_r = 0 self.type_r = "" self.firstFrame = None self.chaiji_left = False self.chaiji_right = False self.cltime = 0 self.crtime = 0 self.totaltime = 0 # 用于面板进行输出 self.work_time = 0 self.tf_time = 0 self.tb_time = 0 # 调试 self.machinedown_base = cv2.imread( "images/tiaoshiimages/machinedown_base.jpg") self.machineup_base = cv2.imread( "images/tiaoshiimages/machineup_base.jpg") self.machineup_mask = cv2.imread("images/tiaoshiimages/up1.jpg") self.machinedown_mask = cv2.imread("images/tiaoshiimages/down1.jpg") self.peopleup_mask = cv2.imread("images/tiaoshiimages/handsup.jpg", 0) self.peopledown_mask = cv2.imread("images/tiaoshiimages/handsdown.jpg", 0) self.peopleup_base = cv2.imread( "images/tiaoshiimages/handsup_base.jpg", 0) self.peopledown_base = cv2.imread( "images/tiaoshiimages/handsdown_base.jpg", 0) self.Ldown = [0] * 10 self.Lup = [0] * 10 # 队列操作 self.Lhandsdown = [0] * 10 self.Lhandsup = [0] * 10 self.isJudgeMachineT = True self.tiaoshitime = 0 self.isUpStart = False self.isDownStart = False self.machineLocation = "" self.downStartTime = 0 self.upStartTime = 0 # 换瓶操作 # self.bottle_area = cv2.imread("images/bottleimages/bottle.jpg", 0) # self.bottle_area = cv2.resize(self.bottle_area, (1280, 720)) # self.nobottle_base = cv2.imread("images/bottleimages/nobottle_base.jpg", 0) # self.nobottle_base = cv2.resize(self.nobottle_base, (1280, 720)) # self.Lbottle = [0] * 10 # self.isBottleStart = False # self.isJudgeMachineB = True self.bottletime = 0 # 装机操作 self.mask_right = cv2.imread("images/zhuangjiimages/right.jpg") self.mask_left = cv2.imread("images/zhuangjiimages/maskleft.jpg") self.left_base = cv2.imread("images/zhuangjiimages/left_base.jpg", 0) self.redLower = np.array([26, 43, 46]) self.redUpper = np.array([34, 255, 255]) self.Lright = [0] * 10 self.Lleft = [0] * 10 self.is_JudgeRL = True self.isRightStart = False self.isLeftStart = False self.zhuangjitime = 0