Exemple #1
0
def run():

    db = pymysql.connect("192.168.0.102", "root", "root", "star")
    cursor = db.cursor()
    print('Data base Connected')
    while True:
        frequency = gl.get_value('frequency')
        if gl.get_value('flag'):
            #print('Breaking loop')
            # Break when flag = True
            break

        cursor.execute("SELECT * FROM data8802 where Id=1")
        data = cursor.fetchone()
        x = -data[2] / 1000 + 3
        x = float('{0:.2f}'.format(x))
        y = 6 - data[3] / 1000
        y = float('{0:.2f}'.format(y))
        # print(x,y)
        gl.set_value('x', x)
        gl.set_value('y', y)

        time.sleep(1 / frequency)


# run()
Exemple #2
0
def run():
    counter=0
    print(' connecting to Data base')
    db = pymysql.connect("192.168.0.105","root","root","star")
    cursor = db.cursor()
    print('Data base Connected')
    while True:
        counter+=1
        frequency=gl.get_value('frequency')
        if gl.get_value('flag'):
                #print('Breaking loop')
                # Break when flag = True
            break
        
        cursor.execute("SELECT * FROM data8802 where Id=1")
        data = cursor.fetchone()
        x=-data[3]/1000+3
        x=float('{0:.2f}'.format(x))
        y=6+data[2]/1000
        y=float('{0:.2f}'.format(y))
        # print(x,y)
        gl.set_value('x',x)
        gl.set_value('y',y)
        # print(x,y)
        # if counter%10==0:
        #     print('data',[data[2]/1000,data[3]/1000])
        # print('data',data[3])

        time.sleep(0.04)
# run()
    def group_build(self, group_version):

        group_folder = 'GROUP_' + group_version

        if group_folder not in os.listdir(gl.get_value('GROUP_BAK_PATH')):

           #os.mkdir(gl.get_value('GROUP_BAK_PATH') + group_folder)

           group_sep = re.split(r'\.', group_version)

           shutil.copytree(gl.get_value('GROUP_BUILD_PATH') + 'DE' + group_sep[0] + 'S/',
                           gl.get_value('GROUP_BAK_PATH') + group_folder + '/DE' + group_sep[0] + 'S/')

           #gl.set_value('GROUP_RUN_PATH',  gl.get_value('GROUP_BAK_PATH') + group_folder + '/bin/nastran')

           rte_build_path = gl.get_value('GROUP_RTE_PATH') + group_version + '/em64tL/'

           rte_local_path = gl.get_value('GROUP_BAK_PATH') + group_folder + '/rte/'

           os.mkdir(rte_local_path)

           shutil.copy(rte_build_path + 'analysis', rte_local_path)

           shutil.copy(rte_build_path + 'SSS.MASTERA', rte_local_path)

           shutil.copy(rte_build_path + 'SSS.MSCOBJ', rte_local_path)

           shutil.copy(rte_build_path + 'SSS.MSCSOU', rte_local_path)
    def __init__(self, model, vocab, is_train=True):

        train_data = gl.get_value('train_data')
        dev_data = gl.get_value('dev_data')
        test_data = gl.get_value('test_data')

        self.model = model
        self.report = True

        if is_train:
            self.train_data = get_examples(train_data, model.word_encoder,
                                           vocab)
            self.batch_num = int(
                np.ceil(len(self.train_data) / float(train_batch_size)))
            self.dev_data = get_examples(dev_data, model.word_encoder, vocab)
        self.test_data = get_examples(test_data, model.word_encoder, vocab)

        # criterion
        self.criterion = nn.CrossEntropyLoss()

        # label name
        self.target_names = vocab.target_names

        # optimizer
        if is_train:
            self.optimizer = Optimizer(model.all_parameters,
                                       steps=self.batch_num * epochs)

        # count
        self.step = 0
        self.early_stop = -1
        self.best_train_f1, self.best_dev_f1 = 0, 0
        self.last_epoch = epochs
    def case_modification(self, perf_check, index):

        template_name = index[:-5]

        template_name_all = 'nxnperf_' + template_name

        template = open(gl.get_value('TEMPLATE_PATH') + template_name_all + '.dat')

        out = open(gl.get_value('OUT_CASE_PATH') + self.tp_name + '_' + index + '.dat', 'w')

        if not os.path.exists(gl.get_value('OUT_CASE_PATH') + 'element_' + template_name + '.dat'):

            shutil.copy(gl.get_value('TEMPLATE_PATH') + 'element_' + template_name + '.dat',
                        gl.get_value('OUT_CASE_PATH') + 'element_' + template_name + '.dat')

        for line in template.readlines():

            if not re.search(r'\$PERF_CHECK_[0-9]', line, re.I) is None:

                check_nm = re.search(r'[0-9]', line).group()

                try:

                    line = re.sub(r'\$PERF_CHECK_' + str(check_nm), perf_check[int(check_nm)], line)

                except Exception:

                    line = line

            out.writelines(line)

        out.close()

        return self.tp_name + '_' + index
Exemple #6
0
def franck_turnbull(point):
    '''Define the Franck-Turnbull mechanism'''
    # Import parameters
    Rm = gl.get_value('Rm')
    Rbk = gl.get_value('Rbk')
    Rft = gl.get_value('Rft')
    temperature = gl.get_value('temperature')
    defect = gl.get_value('defect')

    # Order in list Rft
    i = point - len(Rm) - len(Rbk)

    # Order in list defect, means the jth defect is to F-T
    j = Rft[i][1]

    # Append the defect generated by breaking-up to the end of the list and migrate random walk
    a = MP(ID=int(idmanager()),
           defect_type='V',
           x=defect[j].x,
           y=defect[j].y,
           z=defect[j].z)
    defect.append(a)
    gl.set_value('defect', defect)
    mesh(defect[len(defect) - 1])
    Rm.append([defect[len(defect) - 1].rate(temperature)[0], len(defect) - 1])
    gl.set_value('Rm', Rm)
    migrate(len(Rm) - 1)

    pass
Exemple #7
0
def click(name, sleep):
    size = globalvar.get_value('size')
    sites = globalvar.get_value('sites')
    win32api.SetCursorPos([size[0] + sites[name][0], size[1] + sites[name][1]])
    win32api.mouse_event(
        win32con.MOUSEEVENTF_LEFTUP | win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
    time.sleep(sleep)
Exemple #8
0
def add_beam():
    spectrum = glv.get_value('spectrum file')
    angular = glv.get_value('angular file')
    spatial = glv.get_value('spatial file')
    beam_name = glv.get_value('new beam name')
    beam_value = [spectrum, angular, spatial]
    beam_dict.add_beam(beam_name, beam_value)
Exemple #9
0
def getMysqlQps():
    '''
        获取mysql qps
        QPS的计算方法
        QPS:每秒的查询数
        Questions = SHOW GLOBAL STATUS LIKE 'Questions';
        Uptime = SHOW GLOBAL STATUS LIKE 'Uptime';
        QPS=Questions/Uptime
    '''
    status,Questions  = commands.getstatusoutput("mysql -u"+ str(globalvar.get_value('mysqlUser')) +" -p"+ str(globalvar.get_value('mysqlpassword'))  \
            +' -hlocalhost -e ' + "\" SHOW GLOBAL STATUS LIKE 'Questions'; \"")
    status,Uptime   = commands.getstatusoutput("mysql -u"+ str(globalvar.get_value('mysqlUser')) +" -p"+ str(globalvar.get_value('mysqlpassword'))  \
            +' -hlocalhost -e ' + "\" SHOW GLOBAL STATUS LIKE 'Uptime'; \"")

    Questions = Questions.split("\n")
    Questionsdata = Questions[2].split("\t")[1]

    Uptime = Uptime.split("\n")
    Uptimedata = Uptime[2].split("\t")[1]

    QPS = float(Questionsdata) / float(Uptimedata)
    qpsData = {
        "hostIp": globalvar.get_value("hostIp"),
        "date": strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())),
        "qps": round(QPS, 3)
    }
    return qpsData
Exemple #10
0
 def run(self):
     while True:
         message = self.getMessage()
         message_v = message['vision']
         if message_v.__contains__('predator'):
             self.stm.sensor_add(label='predator')
         if message_v.__contains__('prey'):
             self.stm.sensor_add(label='prey')
         timestamp = time.time()
         # print(message)
         self.stm.process_message(message)
         if time.time() - timestamp < 1:
             time.sleep(1)
         die = False
         if gl.get_value('tired') < 0:
             die = True
         if gl.get_value('hungry') < 0:
             die = True
         if gl.get_value('thirsty') < 0:
             die = True
         if gl.get_value('pain') < 0:
             die = True
         if gl.get_value('sexy') < 0:
             die = True
         if die == True:
             break
     return
Exemple #11
0
def _4gSendThreadFunc():
    time.sleep(1)
    sk_send = socket.socket()
    sk_send.connect(("127.0.0.1", 14612))

    # 上报x,y,h,w--来自计算线程,维护线程
    my_lock.pMain_calc_4gSend_lock.acquire()
    o_min_flg = gl.get_value("o_min_flg")
    x_send = gl.get_value("x_send")  # 毫米
    y_send = gl.get_value("y_send")
    h_send = gl.get_value("h_send")
    my_lock.pMain_calc_4gSend_lock.release()

    my_lock.pMain_win_4gSend_lock.acquire()
    w_send = gl.get_value("o_w_4g")
    my_lock.pMain_win_4gSend_lock.release()

    _4g_send_dict = {
        "o_min_flg": o_min_flg,
        "x_send": x_send,
        "y_send": y_send,
        "h_send": h_send,
        "w_send": w_send,
    }

    _4g_send_bytes = json.dumps(_4g_send_dict)
    sk_send.send(bytes(_4g_send_bytes.encode('utf-8')))
Exemple #12
0
def lmprint(t):
    '''Print data'''
    defect = gl.get_value('defect')
    bound = gl.get_value('bound')
    defectype = gl.get_value('defectype')
    defectlist = defectype['MP'] + defectype['ED']
    order = {}
    with open('data/output.txt', 'a') as output:
        print('ITEM: TIMESTEP', file=output)
        print(t, file=output)
        print('ITEM: NUMBER OF ATOMS', file=output)
        print(len(defect), file=output)
        print('ITEM: BOX BOUNDS', file=output)
        print('%5.2f %5.2f\n%5.2f %5.2f\n%5.2f %5.2f' %
              (bound[0], bound[1], bound[2], bound[3], bound[4], bound[5]),
              file=output)
        print('ITEM: ATOMS id type x y z', file=output)
        for i in range(len(defectlist)):
            order[defectlist[i]] = (i + 1) * 20
        for i in range(len(defect)):
            temtype = order[defect[i].defect_type]
            print('%d   %d  %f  %f  %f' %
                  (i + 1, temtype, defect[i].x, defect[i].y, defect[i].z),
                  file=output)

    pass
Exemple #13
0
def over(method):
    """
    结束某skill
    :param method: 将要结束的skill
    :return:None
    """
    # 读取当前的控制命令
    file = open(gl.get_value('agentControlPath'), 'r')
    dic = json.load(file)
    file.close()
    # 将method从控制命令中取消
    # print('over',dic)
    for tmp in dic['operation']:
        if tmp.__contains__(method):
            dic['operation'].remove(tmp)
    # print('over',dic)
    # 为method添加取消控制命令,然后写回文件
    # dic['over'].append(method)
    dic = json.dumps(dic)
    file = open(gl.get_value('agentControlPath'), "w")
    file.write(str(dic))
    file.close()
    # # file = open(gl.get_value('agentControlPath'), "r")
    # # # print('over',file.readline())
    # file.close()
    # 取消命令在文件中保存1s之后去掉
    # time.sleep(1)
    # dic = json.loads(dic)
    # dic['over'].remove(method)
    # dic = json.dumps(dic)
    # file = open(gl.get_value('agentControlPath'), "w")
    # file.write(str(dic))
    # file.close()
    return
Exemple #14
0
    def query_and_serialize_data(session_id):

        df1 = gl.get_value('dfpl')
        df2 = gl.get_value('dfcs')
        df3 = gl.get_value('dfmn')
        df4 = gl.get_value('dfnl3')

        df = df1.copy()

        group_sorted = df.sort_values(by="GROUP", ascending=False)

        latest_group = group_sorted.max().GROUP

        baseline_group = group_sorted.min().GROUP

        prev_group = group_sorted.loc[
            group_sorted['GROUP'] < latest_group].GROUP[0]

        latest_case_number = df.loc[df['GROUP'] == latest_group].shape[0]

        return {
            'PLAN': df1.to_json(),
            'CASE': df2.to_json(),
            'MAIN': df3.to_json(),
            'NLTRD3': df4.to_json()
        }
Exemple #15
0
def init():
    """
    初始化文件格式
    :return:
    """
    file = open(gl.get_value('agentControlPath'), 'r')
    try:
        dic = json.load(file)
        lis = dic["operation"]
        for tmp in lis:
            if type(tmp) is not type(''):
                x = 1 / 0
        lis = dic["over"]
        for tmp in lis:
            if type(tmp) is not type(''):
                x = 1 / 0
        if len(dic) > 2:
            x = 1 / 0
        file.close()
    except:
        file.close()
        file = open(gl.get_value('agentControlPath'), 'w')
        dic = {}
        dic['operation'] = []
        dic['over'] = []
        file.write(str(json.dumps(dic)))
        file.close()
        return
def rotate_file():
    globalvar.set_value('pulley_flag_global', 'rotate')
    single_case_flag = globalvar.get_value('single_case_flag_global')
    fra = globalvar.get_value('show_parameter_win_global')
    index = 3
    if single_case_flag[index] is None:
        item = []
        light_ = tk.Scale(fra,
                          label='旋转',
                          orient=tk.HORIZONTAL,
                          from_=0,
                          to=360,
                          length=200,
                          tickinterval=60,
                          resolution=1,
                          command=do_pulley)
        light_.set(0)
        item.append(light_)

        ok_b = tk.Button(fra,
                         text='确定',
                         width=10,
                         command=lambda: ok_button_method())
        item.append(ok_b)

        single_case_flag[index] = item
        globalvar.set_value('single_case_flag_global', single_case_flag)

    clearfr()
    showfr(single_case_flag[index])
Exemple #17
0
def getMysqlKeyBuffer():
    '''
        获取mysql Key Buffer 命中率
        mysql Key Buffer 命中率 
        key_buffer_read_hits = (1 - Key_reads / Key_read_requests) * 100% 
        key_buffer_write_hits= (1 - Key_writes / Key_write_requests) * 100% 
    '''
    status,data = commands.getstatusoutput("mysql -u"+ str(globalvar.get_value('mysqlUser')) +" -p"+ str(globalvar.get_value('mysqlpassword'))  \
            +' -hlocalhost -e ' + "\"show global status like 'key_read%';\"")
    data = data.split("\n")
    Key_reads = data[3].split("\t")[1]
    Key_read_requests = data[2].split("\t")[1]
    key_buffer_read_hits = 1 - float(Key_reads) / float(Key_read_requests)

    status,data = commands.getstatusoutput("mysql -u"+ str(globalvar.get_value('mysqlUser')) +" -p"+ str(globalvar.get_value('mysqlpassword'))  \
            +' -hlocalhost -e ' + "\"show global status like 'key_write%';\"")
    data = data.split("\n")
    Key_writes = data[2].split("\t")[1]
    Key_write_requests = data[2].split("\t")[1]

    if Key_write_requests == '0':
        key_buffer_write_hits = 1
    else:
        key_buffer_write_hits = 1 - float(Key_writes) / float(
            Key_write_requests)

    KeyBufferData = {
        "hostIp": globalvar.get_value("hostIp"),
        "date": strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())),
        "key_buffer_read_hits": round(key_buffer_read_hits, 3),
        "key_buffer_write_hits": round(key_buffer_write_hits, 3)
    }
    return KeyBufferData
Exemple #18
0
def getMysqlConnectionNumber():
    '''
        获取当前连接数
        +-----------+-------------+
        | host      | count(host) |
        +-----------+-------------+
        | localhost |           1 |
        +-----------+-------------+
    '''
    data = dict()
    status,connectionlist = commands.getstatusoutput("mysql -u"+ str(globalvar.get_value('mysqlUser')) +" -p"+ str(globalvar.get_value('mysqlpassword'))  \
        +' -hlocalhost -e \"select host,count(host) from processlist group by host;\" information_schema')
    connectionlist = connectionlist.split("\n")
    if (len(connectionlist) > 2):
        for i in range(2, len(connectionlist), 1):
            temp = connectionlist[i].split("\t")
            host = temp[0]
            count = temp[1]
            datatemp = {"host": host, "count": count}
            data.update({host: datatemp})
    connectionNumberData = {
        "hostIp": globalvar.get_value("hostIp"),
        "date": strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())),
        "data": data
    }
    return connectionNumberData
 def handleSave(self):
     log = gl.get_value('log_func')
     SN = gl.get_value('SN')
     log_path = gl.get_value('path')  # "D:\station_log\\" + serial_number + "\\"
     csv_name = log_path + SN + ".csv"
     log.logger.info("开始记录全部测试结果,路径为: " + log_path)
     All_update_data = []
     # 写入csv log
     with open(csv_name, 'w', newline="") as stream:
         writer = csv.writer(stream)
         writer.writerow(header_lines)
         for row in range(self.rowCount()):
             rowdata = []
             for column in range(self.columnCount()):
                 item = self.item(row, column)
                 if item is not None:
                     rowdata.append(
                         item.text())
                 else:
                     rowdata.append('')
             log.logger.info(rowdata)
             All_update_data.append(rowdata)
             writer.writerow(rowdata)
     up_to_sum_data = handle_summary_log(All_update_data, SN)
     # 写入summary csv log
     print(up_to_sum_data)
     add_log_summary(up_to_sum_data)
Exemple #20
0
def getMysqlTPS():
    '''
        TPS的计算方法
        Com_commit = SHOW GLOBAL STATUS LIKE 'Com_commit';
        Com_rollback = SHOW GLOBAL STATUS LIKE 'Com_rollback';
        Uptime = SHOW GLOBAL STATUS LIKE 'Uptime';
        TPS=(Com_commit + Com_rollback)/Uptime
    '''
    status,Com_commit = commands.getstatusoutput("mysql -u"+ str(globalvar.get_value('mysqlUser')) +" -p"+ str(globalvar.get_value('mysqlpassword'))  \
            +' -hlocalhost -e ' + "\" SHOW GLOBAL STATUS LIKE 'Com_commit'; \"")

    status,Com_rollback  = commands.getstatusoutput("mysql -u"+ str(globalvar.get_value('mysqlUser')) +" -p"+ str(globalvar.get_value('mysqlpassword'))  \
            +' -hlocalhost -e ' + "\" SHOW GLOBAL STATUS LIKE 'Com_rollback'; \"")

    status,Uptime = commands.getstatusoutput("mysql -u"+ str(globalvar.get_value('mysqlUser')) +" -p"+ str(globalvar.get_value('mysqlpassword'))  \
            +' -hlocalhost -e ' + "\" SHOW GLOBAL STATUS LIKE 'Uptime'; \"")

    Com_commit = Com_commit.split("\n")
    Com_commit = Com_commit[2].split("\t")[1]

    Com_rollback = Com_rollback.split("\n")
    Com_rollback = Com_rollback[2].split("\t")[1]

    Uptime = Uptime.split("\n")
    Uptime = Uptime[2].split("\t")[1]

    TPS = (float(Com_commit) + float(Com_commit)) / float(Uptime)
    tpsData = {
        "hostIp": globalvar.get_value("hostIp"),
        "date": strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())),
        "tps": round(TPS, 3)
    }
    return tpsData
Exemple #21
0
    def __init__(self, parent=None):
        super(MyDialog, self).__init__(parent)
        self.setupUi(self)

        #全局变量初始化...
        self.lineEdit_Server_IP.setText(globalvar.get_value("Server_IP"))
        self.lineEdit_Server_PORT.setText(globalvar.get_value("Server_PORT"))
        self.lineEdit_Send_Message.setText(globalvar.get_value("send_Message"))

        self.lineEdit_Server_IP.textChanged.connect(
            self.lineEdit_Server_IP_Func)
        self.lineEdit_Server_PORT.textChanged.connect(
            self.lineEdit_Server_PORT_Func)
        self.lineEdit_Send_Message.textChanged.connect(
            self.lineEdit_Send_Message_Func)

        self.pushButton_TCP_select.clicked.connect(
            self.pushButton_TCP_select_Func)
        self.pushButton_Connect.clicked.connect(self.pushButton_Connect_Func)
        self.pushButton_Close.clicked.connect(self.pushButton_Close_Func)
        self.pushButton_Send.clicked.connect(self.pushButton_Send_Func)

        self.MyQtimer = QTimer(self)
        self.MyQtimer.start(100)
        self.MyQtimer.timeout.connect(self.Real_time_Display_Func)
Exemple #22
0
def get_defect_data(filename, unitconvert=1):
    '''Import data of defect, return a list of defect objects'''
    # Read and split the data from text
    with open('data/' + filename) as f:
        N = int(f.readline())
        lines = f.readlines()
    gl.set_value('defectdata', [lines[i].strip().split() for i in range(N)])

    # Generate defect objects and put them in a list
    defect = []
    defectype = gl.get_value('defectype')
    defectdata = gl.get_value('defectdata')
    for i in range(N):
        if defectdata[i][1] in defectype['MP']:
            a = MP(ID=int(defectdata[i][0]),
                   defect_type=defectdata[i][1],
                   x=float(defectdata[i][2]) * unitconvert,
                   y=float(defectdata[i][3]) * unitconvert,
                   z=float(defectdata[i][4]) * unitconvert)
            defect.append(a)
        elif defectdata[i][1] in defectype['ED']:
            a = ED(ID=int(defectdata[i][0]),
                   defect_type=defectdata[i][1],
                   x=float(defectdata[i][2]) * unitconvert,
                   y=float(defectdata[i][3]) * unitconvert,
                   z=float(defectdata[i][4]) * unitconvert)
            defect.append(a)
    gl.set_value('defect', defect)

    pass
Exemple #23
0
def profile_calc():
    measured_data = glv.get_value('Measured data filepath')
    measured_data_array = np.loadtxt(measured_data, delimiter=',')
    x_measured = measured_data_array[:, 0]
    y_measured = measured_data_array[:, 1]
    x_output = glv.get_value('Output X')
    y_output = glv.get_value('Output normalized Y')
    index_min = 0
    index_max = 0

    if x_measured[0] < -200:
        for i in range(0, len(x_measured) - 1):
            if x_measured[i] == -200:
                index_min = i + 1
                index_max = len(x_measured) - i - 1
        x_new = x_measured[index_min:index_max]
        y_measured_new = y_measured[index_min:index_max]
        y_diff = (y_measured_new - y_output) / y_measured_new
    elif x_measured[0] == 200:
        y_diff = (y_measured - y_output) / y_measured
        x_new = x_measured
        y_measured_new = y_measured
    elif x_measured[0] > -200:
        for i in range(0, int(len(x_output) / 2)):
            if x_output[i] == x_measured[0]:
                index_min = i
                index_max = len(x_measured) + i
        x_new = x_measured
        y_measured_new = y_measured
        y_output_new = y_output[index_min:index_max]
        y_diff = (y_measured_new - y_output_new) / y_measured_new

    glv.set_value('Measured X', x_new)
    glv.set_value('Measured Y', y_measured_new)
    glv.set_value('Y diff', y_diff)
Exemple #24
0
    def __init__(self, parent=None):
        super(MyDialog, self).__init__(parent)
        self.setupUi(self)

        #全局变量初始化...
        self.lineEdit_Server_IP.setText(globalvar.get_value("Server_IP"))
        self.lineEdit_Server_PORT.setText(globalvar.get_value("Server_PORT"))
        self.lineEdit_Send_Message.setText(globalvar.get_value("send_Message"))

        #self.lineEdit.textChanged.connect(self.label.setText)
        #LineEdit_Text作为槽函数self.label.setText(...)的参数。
        self.lineEdit_Server_IP.textChanged.connect(
            self.lineEdit_Server_IP_Func)
        self.lineEdit_Server_PORT.textChanged.connect(
            self.lineEdit_Server_PORT_Func)
        self.lineEdit_Send_Message.textChanged.connect(
            self.lineEdit_Send_Message_Func)
        #self.lineEdit_sys_log.textChanged.connect(self.lineEdit_sys_log_Func)#textBrowser_sys_log

        self.pushButton_TCP_select.clicked.connect(
            self.pushButton_TCP_select_Func)
        self.pushButton_Connect.clicked.connect(self.pushButton_Connect_Func)
        self.pushButton_Close.clicked.connect(self.pushButton_Close_Func)
        self.pushButton_Send.clicked.connect(self.pushButton_Send_Func)
        #self.MyQtimer()#PyQt5.QtCore_QTimer_Real-time Show
        self.MyQtimer = QTimer(self)
        self.MyQtimer.start(100)  #100ms
        self.MyQtimer.timeout.connect(self.Real_time_Display_Func)
Exemple #25
0
def operate(method, params):
    """
    执行操作命令
    :param method: 要执行的skill
    :param params: skill的参数
    :return:None
    """
    # 读取当前命令
    file = open(gl.get_value('agentControlPath'), 'r')
    dic = json.load(file)
    file.close()
    # print('operation',dic)
    flag = False
    for command in dic['operation']:
        # command = ''
        if command.__contains__(method):
            flag = True
    if flag == True:
        return
    # 将method添加到当前命令中
    tmp = method
    for param in params:
        tmp += '\t' + str(param)
    dic['operation'].append(tmp)
    # 将控制命令写回文件
    dic = json.dumps(dic)
    file = open(gl.get_value('agentControlPath'), "w")
    file.write(str(dic))
    file.close()
    print(gl.get_value('name') + ' ' + str(dic))
    # file = open(gl.get_value('agentControlPath'), "r")
    # print('operation',file.readline())
    # file.close()
    return
Exemple #26
0
def search(obj):
    '''For neighborhood search'''
    # Find out the position information
    bound = gl.get_value('bound')
    lattice_size = gl.get_value('lattice size')
    defect_mesh = gl.get_value('defect_mesh')
    interface = gl.get_value('interface')
    lx = int(bound[1]/lattice_size)
    ly = int(bound[3]/lattice_size)
    lz = int(bound[5]/lattice_size)
    j = updateID(obj.ID)
    n = index(j)[0]
    cz = n // (lx * ly)
    cy = (n - cz * lx *ly) // lx
    cx = (n - cz * lx *ly) % lx

    # List of all neighbor defects
    roommate = defect_mesh[n]

    neighsur = defect_mesh[lx*ly*cz + lx*cy + (cx+1)%lx] + defect_mesh[lx*ly*cz + lx*cy + (cx-1)%lx] + \
               defect_mesh[lx*ly*cz + lx*((cy+1)%ly) + cx] + defect_mesh[lx*ly*cz + lx*((cy-1)%ly) + cx] + \
               defect_mesh[lx*ly*((cz+1)%lz) + lx*cy + cx] + defect_mesh[lx*ly*((cz-1)%lz) + lx*cy + cx]

    neighedg = defect_mesh[lx*ly*cz + lx*((cy+1)%ly) + (cx+1)%lx] + defect_mesh[lx*ly*cz + lx*((cy+1)%ly) + (cx-1)%lx] + \
               defect_mesh[lx*ly*cz + lx*((cy-1)%ly) + (cx+1)%lx] + defect_mesh[lx*ly*cz + lx*((cy-1)%ly) + (cx-1)%lx] + \
               defect_mesh[lx*ly*((cz+1)%lz) + lx*cy + (cx+1)%lx] + defect_mesh[lx*ly*((cz+1)%lz) + lx*cy + (cx-1)%lx] + \
               defect_mesh[lx*ly*((cz-1)%lz) + lx*cy + (cx+1)%lx] + defect_mesh[lx*ly*((cz-1)%lz) + lx*cy + (cx-1)%lx] + \
               defect_mesh[lx*ly*((cz+1)%lz) + lx*((cy+1)%ly) + cx] + defect_mesh[lx*ly*((cz+1)%lz) + lx*((cy-1)%ly) + cx] + \
               defect_mesh[lx*ly*((cz-1)%lz) + lx*((cy+1)%ly) + cx] + defect_mesh[lx*ly*((cz-1)%lz) + lx*((cy-1)%ly) + cx]

    neighcor = defect_mesh[lx*ly*((cz+1)%lz) + lx*((cy+1)%ly) + (cx+1)%lx] + defect_mesh[lx*ly*((cz+1)%lz) + lx*((cy+1)%ly) + (cx-1)%lx] + \
               defect_mesh[lx*ly*((cz+1)%lz) + lx*((cy-1)%ly) + (cx+1)%lx] + defect_mesh[lx*ly*((cz+1)%lz) + lx*((cy-1)%ly) + (cx-1)%lx] + \
               defect_mesh[lx*ly*((cz-1)%lz) + lx*((cy+1)%ly) + (cx+1)%lx] + defect_mesh[lx*ly*((cz-1)%lz) + lx*((cy+1)%ly) + (cx-1)%lx] + \
               defect_mesh[lx*ly*((cz-1)%lz) + lx*((cy-1)%ly) + (cx+1)%lx] + defect_mesh[lx*ly*((cz-1)%lz) + lx*((cy-1)%ly) + (cx-1)%lx]

    neighbor = roommate + neighsur + neighedg + neighcor

    # Search for defects that are close to each other
    close = []
    for i in range(len(neighbor)):
        distancesq = (obj.x - neighbor[i].x) ** 2 + (obj.y - neighbor[i].y) ** 2 + (obj.z - neighbor[i].z) ** 2
        if (distancesq <= obj.l ** 2) and (distancesq != 0):
            close.append(neighbor[i])
    
    closeinter = []
    if interindex('x', cx, cy, cz) != None:
        closeinter.append(interface[interindex('x', cx, cy, cz)])
    if interindex('x', (cx+1)%lx, cy, cz) != None:
        closeinter.append(interface[interindex('x', (cx+1)%lx, cy, cz)])
    if interindex('y', cx, cy, cz) != None:
        closeinter.append(interface[interindex('y', cx, cy, cz)])
    if interindex('y', cx, (cy+1)%ly, cz) != None:
        closeinter.append(interface[interindex('y', cx, (cy+1)%ly, cz)])
    if interindex('z', cx, cy, cz) != None:
        closeinter.append(interface[interindex('z', cx, cy, cz)])
    if interindex('z', cx, cy, (cz+1)%lz) != None:
        closeinter.append(interface[interindex('z', cx, cy, (cz+1)%lz)])
    
    return [close, closeinter]
Exemple #27
0
def home(request):
    attributes = gl.get_value("attributes")
    annotated_entities = gl.get_value("annotated_entities")
    return render(
        request, 'home.html', {
            'List': json.dumps(annotated_entities),
            'attributes': json.dumps(attributes)
        })
Exemple #28
0
def _4gProcess():
    gl.gl_init()
    global COM_ID_4G, TYPE_HEART, TYPE_SEND, com_4g, diggerId
    if SWITCH_DEVICE:
        COM_ID_4G = "com13"
    else:
        COM_ID_4G = "com4"
    TYPE_HEART = 1  # 消息类型。1:心跳,2:上报
    TYPE_SEND = 2
    diggerId = 566609996553388032
    com_4g = SerialPortCommunication(COM_ID_4G, 115200, 0.1)
    # 上报消息socket
    sk_send = socket.socket()
    sk_send.bind(("127.0.0.1", 14612))
    sk_send.listen()
    conn_send, addr_send = sk_send.accept()
    sk_send.setblocking(False)

    # 接收任务socket
    sk_recv_tsk = socket.socket()
    sk_recv_tsk.connect(("127.0.0.1", 9000))

    _4g_recv_thread = threading.Thread(target=_4RecFunc, daemon=True).start()
    _4g_send_thread = threading.Thread(target=_4SendFunc, daemon=True).start()
    """ 4g 主线程 """
    while True:
        time.sleep(0.2)

        my_lock.p4g_rec_main_lock.acquire()
        _4g_recv_flg = gl.get_value("_4g_recv_flg")
        my_lock.p4g_rec_main_lock.release()

        if _4g_recv_flg:
            my_lock.p4g_rec_main_lock.acquire()
            gl.set_value("_4g_recv_flg", False)
            _4g_data_dict = {
                "_4g_data_valid_flg": gl.get_value("_4g_data_valid_flg"),
                "g_start_x_list": gl.get_value('g_start_x_list'),
                "g_start_y_list": gl.get_value('g_start_y_list'),
                "g_start_h_list": gl.get_value('g_start_h_list'),
                "g_start_w_list": gl.get_value('g_start_w_list'),
                "g_end_x_list": gl.get_value('g_end_x_list'),
                "g_end_y_list": gl.get_value('g_end_y_list'),
                "g_end_h_list": gl.get_value('g_end_h_list'),
                "g_end_w_list": gl.get_value('g_end_w_list'),
            }
            my_lock.p4g_rec_main_lock.release()

            _4g_data_bytes = json.dumps(_4g_data_dict)
            sk_recv_tsk.send(bytes(_4g_data_bytes.encode('utf-8')))

        # 上报
        _4g_send_bytes = conn_send.recv(1024)
        if _4g_send_bytes:
            _4g_send_dict = json.loads(_4g_send_bytes)
            my_lock.p4g_main_send_lock.acquire()
            gl.set_value("_4g_send_dict", _4g_send_dict)
            my_lock.p4g_main_send_lock.release()
Exemple #29
0
 def pushButton_TCP_select_Func(self):
     if globalvar.get_value("TCP_select") == "As TCP Server":
         globalvar.set_value("TCP_select", "As TCP Client")
         self.pushButton_TCP_select.setText("As TCP Client")
         self.printf_sys_log_Func("TCP_select:As TCP Client")
     elif globalvar.get_value("TCP_select") == "As TCP Client":
         globalvar.set_value("TCP_select", "As TCP Server")
         self.pushButton_TCP_select.setText("As TCP Server")
         self.printf_sys_log_Func("TCP_select:As TCP Server")
Exemple #30
0
def check_status(ticket):
    #global username,password
    #username,password=transfer_variable()
    username = gl.get_value('username')
    password = gl.get_value('password')
    jira = JIRA(basic_auth=(username, password),
                options={'server': 'http://142.104.193.65:8080'})
    new_issue = jira.issue(ticket)
    return new_issue.fields.status.name