Exemple #1
0
    def creatrad(self):

        self.othertrack()
        #for i in range (len(self.Q_Centre)):
        distance = [x[7] for x in self.Q_Centre] #主舰离原点距离
        shiprad=Radar.datac('母舰',len(self.Q_Centre))
        #主舰的雷达数据
        for i in range(self.radarnum):#雷达数量
            shiprad.shipradata(100*(i+1),distance)
            for ii in range (len(self.Q_all[0])):
                for iii in shiprad.Q[ii]:
                    self.Q_all[0][ii].append(iii)
        # 驱逐舰的雷达数据
        shiprad.com='驱逐舰'
        for i in range(self.num[0]):
            distance = [x[7] for x in self.Q_all[i + 1]]
            for j in range(self.radarnum):
                shiprad.shipradata(100*(j+1),distance)
                for ii in range(len(self.Q_all[0])):
                    for iii in shiprad.Q[ii]:
                        self.Q_all[i+1][ii].append(iii)
        # 护卫舰的雷达数据
        shiprad.com='护卫舰'
        for i in range(self.num[1]):
            distance = [x[7] for x in self.Q_all[i +self.num[0]+ 1]]
            for j in range(self.radarnum):
                shiprad.shipradata(100*(j+1),distance)
                for ii in range(len(self.Q_all[0])):
                    for iii in shiprad.Q[ii]:
                        self.Q_all[i+self.num[0]+1][ii].append(iii)
Exemple #2
0
def main():
    global server
    global run
    print(hex(id(server)))
    radar_queue = queue.Queue()
    interrupt_queue = queue.Queue()
    # heart_rate_queue = queue.Queue()
    # resp_rate_queue = queue.Queue()

    radar = Radar.Radar(radar_queue, interrupt_queue)
    radar.start()
    timeout = time.time() + 10 * 60

    # signalprocessing = signalprocessing.HeartRate(radar_queue,heart_rate_queue,resp_rate_queue)
    # signalprocessing.start()

    # bluetooth = Bluetooth(heart_rate_queue,resp_rate_queue)
    # bluetooth.start()
    # bluetooth send data
    # for i in range(1, 2000):
    #     time.sleep(1)
    #     while len(clientList) == 0 and run == True:
    #         pass
    #     data = addData(sinvalue)
    #     # print('Write data: ' + data)
    #     data_pulse, data_breath = data.split(' ')
    #     write_data_to_app(data_pulse, 'heart rate')
    #     write_data_to_app(data_breath, 'breath rate')
    #     sinvalue += 0.157
    for i in range(1, 2000):
        time.sleep(1)
        if time.time() > timeout:
            interrupt_queue.put(1)
        while len(clientList) == 0 and go == True:
            pass
        data = getDatafromQueue(test_queue)
        print('Write data: ' + data)
        data_pulse, data_breath = data.split(' ')
        write_data_to_app(data_pulse, 'heart rate')
        write_data_to_app(data_breath, 'breath rate')
        #sinvalue += 0.157

    server.close()
    print("S**T")
    #TODO Stänga ner raspberry
    ConnectDevicesThread.join(
    )  # Waits for the thread to close. Implies all ReadDeviceThreads are also closed.
    subprocess.call(["sudo", "shutdown", "-h",
                     "now"])  # shutdown of Raspberry Pi
Exemple #3
0
if __name__ == "__main__":

    ## 1 Data pre-processing ##
    Labels = ['EXP', 'SFM', 'HM']  # empirical and model result labels
    Ori_Fps = 25  # flames per second in original trajectories
    Adj_Fps = 5  # flames per second in adjustment trajectories
    Folder_Name = r'BaseData'
    Trajectories_List_List_List = []
    for i in range(0, len(Labels)):
        # Trajectories_List_List = InputTrajectories(os.path.join(Folder_Name, Labels[i]))
        Trajectories_List_List_List.append(
            InputTrajectories(os.path.join(Folder_Name, Labels[i])))
    Trajectories_List_List_List = FPSAdjustment(Trajectories_List_List_List,
                                                Ori_Fps, Adj_Fps)

    ## 2 Evaluation ##
    Scores_List = []
    Cutoff_Distance = 1  # cut-off distance
    for i in range(0, len(Trajectories_List_List_List)):
        scores = Evaluation(Trajectories_List_List_List[0],
                            Trajectories_List_List_List[i], Cutoff_Distance,
                            Adj_Fps)
        Scores_List.append(scores)
    Scores_List = ScoreNormalization(Scores_List)

    ## 3 Radar figure ##
    Line_Styles = ['k--', 'b^-.', 'gs--', 'ro-', 'yv:`']
    Radar.RadarFigure(Scores_List, Line_Styles, Labels)
    Radar.SoloRadarFigure(Scores_List, Line_Styles, Labels)
    print("Finished!!!")
Exemple #4
0
    return str(data[0]) + ' ' + str(data[1])


def getDataFromQueue():
    test_queue.put(addData(1))
    return test_queue.get()

        for thread in readThreadList:       # Makes sure that all our client threads are closed before exiting thread
            thread.join()
            print(thread + " is closed")


connectDevices = ConnectDevicesThread()
connectDevices.start()

radar = Radar.Radar(radar_queue, interrupt_queue)
radar.start()

for i in range(1, 2000):
    time.sleep(1)
    while len(clientList) == 0:
        pass
    #data = addData(sinvalue)
    data = getDataFromQueue()
    #print('Write data: ' + data)
    data_pulse, data_breath = data.split(' ')
    write_data_to_app(data_pulse, 'heart rate')
    write_data_to_app(data_breath, 'breath rate')
    #sinvalue += 0.157

interrupt_queue.put(1)
Exemple #5
0
    def startPlot(self):
        self.c = pyqtSignal()
        planeNum = self.checkedNum  #飞机数量
        # 随机产生飞机初始坐标
        x = Plane.random.uniform(1000 * self.num, 5000 * self.num)
        y = Plane.random.uniform(1000 * self.num, 5000 * self.num)
        z = Plane.random.uniform(5000, 15000)
        if self.sig1 == 0:  #输入自定义坐标,则使用输入的坐标
            if self.lineEdit.text() != '':
                x = int(self.lineEdit.text())
            if self.lineEdit_2.text() != '':
                y = int(self.lineEdit_2.text())
            if self.lineEdit_3.text() != '':
                z = int(self.lineEdit_3.text())
        #飞机初始位置数据
        p0 = [
            x, y, z,
            Plane.random.uniform(0, math.pi), 0,
            Plane.random.uniform(150, 200), 0, 0
        ]

        x2 = Plane.random.uniform(1000 * self.num, 5000 * self.num)
        y2 = Plane.random.uniform(1000 * self.num, 5000 * self.num)
        if self.sig2 == 0:  #航母初始位置自定义
            if self.lineEdit_4.text() != '':
                x2 = int(self.lineEdit_4.text())
            if self.lineEdit_5.text() != '':
                y2 = int(self.lineEdit_5.text())
        #航母初始位置数据
        p1 = [x2, y2, 0, Plane.random.uniform(0, math.pi), 10, 0, 0, 0]
        planedata = []
        shipdata = []
        transdata = []
        #航母数据生成
        if len(self.shipActionArray) > 0:
            ship = Ship(self.shipActionArray, self.destroyer, self.frigate, p1)
            ship.creatrad()
            shipdata = copy.deepcopy(ship.Q_all)
        #飞机数据生成
        if len(self.actionArray) > 0 and planeNum > 0:
            data = Plane.datac(self.actionArray, self.planetype.currentText(),
                               p0, self.num)
            data.trackall()
            form = Formation()
            gap = self.planeGap  #飞机间间隔
            #判断编队方式
            if self.formation.currentText() == "跟随编队":
                planedata = form.linearFormation(data.Q, planeNum, gap)
            if self.formation.currentText() == "菱形编队":
                planedata = form.diamondFormation(data.Q, planeNum, gap)
        if len(planedata) != 0:
            transdata = copy.deepcopy(self.F.dtransf(planedata))  #飞机数据转换
            self.planedata.append(transdata)  #把当前生成的数据加入到数组中,保存
        self.shipdata.append(shipdata)
        #更新图像
        self.gridlayout2.removeWidget(self.F)
        sip.delete(self.F)
        self.F = matplot.MyFigure([], [])
        self.F.plot(self.planedata, self.shipdata)
        self.gridlayout2.addWidget(self.F, 0, 1)
        #飞机的雷达数据
        if len(transdata) != 0:
            radatai = []
            for kk in range(len(transdata)):  #遍历每一架飞机
                distance = [x[3] for x in transdata[kk]]  ##当前飞机对我方的距离
                rad = Radar.datac(self.planetype.currentText(),
                                  len(transdata[kk]))
                rad.eledata(distance)
                radatai.append(rad.Q)
            self.raddata.append(radatai)  #将雷达数据加入到数组保存
        self.num = self.num + 1  #计数加一