main
parent
f1a2e675a1
commit
f1fe3cbc13
30
T7_client.py
30
T7_client.py
|
|
@ -2,7 +2,6 @@ import json
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
import sys
|
|
||||||
|
|
||||||
import PySimpleGUI as sg
|
import PySimpleGUI as sg
|
||||||
|
|
||||||
|
|
@ -23,7 +22,7 @@ def recvdata(conn, filepath):
|
||||||
recv_len += len(correntrecv)
|
recv_len += len(correntrecv)
|
||||||
|
|
||||||
|
|
||||||
def senddata(conn, path, librarynum):
|
def senddata(conn, path, librarynum, is_use_balance, is_use_max):
|
||||||
name = os.path.basename(os.path.realpath(path))
|
name = os.path.basename(os.path.realpath(path))
|
||||||
try:
|
try:
|
||||||
with open(path, 'rb') as file:
|
with open(path, 'rb') as file:
|
||||||
|
|
@ -31,7 +30,9 @@ def senddata(conn, path, librarynum):
|
||||||
headerdic = dict(
|
headerdic = dict(
|
||||||
contentlen=len(content),
|
contentlen=len(content),
|
||||||
contentname=name,
|
contentname=name,
|
||||||
librarynum=librarynum
|
librarynum=librarynum,
|
||||||
|
is_use_balance=is_use_balance,
|
||||||
|
is_use_max=is_use_max
|
||||||
)
|
)
|
||||||
headerjson = json.dumps(headerdic)
|
headerjson = json.dumps(headerdic)
|
||||||
headerbytes = headerjson.encode('utf-8')
|
headerbytes = headerjson.encode('utf-8')
|
||||||
|
|
@ -45,15 +46,15 @@ def senddata(conn, path, librarynum):
|
||||||
|
|
||||||
def connect():
|
def connect():
|
||||||
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
dest_ip = '192.168.11.121'
|
dest_ip = '192.168.38.90'
|
||||||
dest_port = int(8191)
|
dest_port = int(8191)
|
||||||
client.connect((dest_ip, dest_port))
|
client.connect((dest_ip, dest_port))
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
|
||||||
def transclient(sendfile, resfile, librarynum):
|
def transclient(sendfile, resfile, librarynum, is_use_balance, is_use_max):
|
||||||
conn = connect()
|
conn = connect()
|
||||||
senddata(conn, sendfile, librarynum)
|
senddata(conn, sendfile, librarynum, is_use_balance, is_use_max)
|
||||||
recvdata(conn, resfile)
|
recvdata(conn, resfile)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -63,6 +64,14 @@ def make_gui():
|
||||||
layout = [
|
layout = [
|
||||||
[sg.Text('排样管数'), sg.Spin([i for i in range(150)], initial_value=130, size=(3, 1), key='_LIBRARYNUM_')],
|
[sg.Text('排样管数'), sg.Spin([i for i in range(150)], initial_value=130, size=(3, 1), key='_LIBRARYNUM_')],
|
||||||
[sg.Text()],
|
[sg.Text()],
|
||||||
|
|
||||||
|
[sg.Text('使用平衡文库'), sg.Radio("是", "is_use_balance", key='is_use_balance', default=True),
|
||||||
|
sg.Radio("否", "is_use_balance", key='is_not_use_balance')],
|
||||||
|
|
||||||
|
[sg.Text('使用扩容平衡性'), sg.Radio("是", "is_use_max", key='is_use_max'),
|
||||||
|
sg.Radio("否", "is_use_max", key='is_not_use_max', default=True)],
|
||||||
|
[sg.Text()],
|
||||||
|
|
||||||
[
|
[
|
||||||
sg.Text('导入排样excel')],
|
sg.Text('导入排样excel')],
|
||||||
[
|
[
|
||||||
|
|
@ -75,17 +84,20 @@ def make_gui():
|
||||||
[sg.Text()],
|
[sg.Text()],
|
||||||
[
|
[
|
||||||
sg.OK('生成'), sg.Cancel('取消')]]
|
sg.OK('生成'), sg.Cancel('取消')]]
|
||||||
iconpath = os.path.join(os.path.abspath(sys.path[0]), 'other', 'icon.ico')
|
# iconpath = os.path.join(os.path.abspath(sys.path[0]), 'other', 'icon.ico')
|
||||||
print(iconpath)
|
|
||||||
window = sg.Window('解码排样T7程序', layout, font='Helvetica 11', icon=r'D:\project\autulayout\other\icon.ico')
|
window = sg.Window('解码排样T7程序', layout, font='Helvetica 11', icon=r'D:\project\autulayout\other\icon.ico')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
event, values = window.read()
|
event, values = window.read()
|
||||||
|
is_use_balance = 1 if values['is_use_balance'] else 0
|
||||||
|
is_use_max = 1 if values['is_use_max'] else 0
|
||||||
|
|
||||||
if event == '生成':
|
if event == '生成':
|
||||||
if not values['_FILE1_'] or not values['_FILE2_']:
|
if not values['_FILE1_'] or not values['_FILE2_']:
|
||||||
sg.popup_non_blocking('请正确提供参数')
|
sg.popup_non_blocking('请正确提供参数')
|
||||||
else:
|
else:
|
||||||
transclient(values['_FILE1_'], os.path.join(values['_FILE2_']), values['_LIBRARYNUM_'])
|
transclient(values['_FILE1_'], os.path.join(values['_FILE2_']), values['_LIBRARYNUM_'],
|
||||||
|
is_use_balance, is_use_max)
|
||||||
sg.Popup('排样成功!')
|
sg.Popup('排样成功!')
|
||||||
window.Close()
|
window.Close()
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -290,7 +290,6 @@ class AutoLayout:
|
||||||
chipname = f'chip{self.loc_chip_num}'
|
chipname = f'chip{self.loc_chip_num}'
|
||||||
nextera_size = self.chip_speciallib_nextera_size[chipname]
|
nextera_size = self.chip_speciallib_nextera_size[chipname]
|
||||||
huada_size = self.chip_speciallib_huada_size[chipname]
|
huada_size = self.chip_speciallib_huada_size[chipname]
|
||||||
print(chipname, huada_size, nextera_size)
|
|
||||||
flag = True
|
flag = True
|
||||||
if 0 < nextera_size < 50:
|
if 0 < nextera_size < 50:
|
||||||
# 有nextera文库,但是不满足50G 去除
|
# 有nextera文库,但是不满足50G 去除
|
||||||
|
|
@ -323,7 +322,6 @@ class AutoLayout:
|
||||||
self.chip_size[chipname] -= huada_size
|
self.chip_size[chipname] -= huada_size
|
||||||
flag = False
|
flag = False
|
||||||
if flag:
|
if flag:
|
||||||
print(self.loc_chip_num)
|
|
||||||
self.loc_chip_num += 1
|
self.loc_chip_num += 1
|
||||||
|
|
||||||
def assign_samples(self):
|
def assign_samples(self):
|
||||||
|
|
@ -355,7 +353,7 @@ class AutoLayout:
|
||||||
ori_library_df.loc[~numeric_mask, 'note'] = 'data_needed 列非数字'
|
ori_library_df.loc[~numeric_mask, 'note'] = 'data_needed 列非数字'
|
||||||
ori_library_df.loc[~time_mask, 'note'] = 'time 列非日期'
|
ori_library_df.loc[~time_mask, 'note'] = 'time 列非日期'
|
||||||
ori_library_df.loc[status_mask, 'note'] = '暂不排样'
|
ori_library_df.loc[status_mask, 'note'] = '暂不排样'
|
||||||
# ori_library_df.loc[barcode_mask, 'note'] = '非16位barcode'
|
ori_library_df.loc[barcode_mask, 'note'] = '非16位barcode'
|
||||||
|
|
||||||
no_ori_data = ori_library_df[~(numeric_mask & time_mask) | status_mask | barcode_mask]
|
no_ori_data = ori_library_df[~(numeric_mask & time_mask) | status_mask | barcode_mask]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue