-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
259 additions
and
90 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,66 @@ | ||
from flask import Flask, render_template,jsonify,request | ||
from flask import Flask, render_template,jsonify,request,redirect | ||
import time | ||
import threading | ||
import inspect | ||
import ctypes | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/demo", methods=["POST"]) | ||
# | ||
# def _async_raise(tid, exctype): | ||
# """raises the exception, performs cleanup if needed""" | ||
# tid = ctypes.c_long(tid) | ||
# if not inspect.isclass(exctype): | ||
# exctype = type(exctype) | ||
# res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype)) | ||
# if res == 0: | ||
# raise ValueError("invalid thread id") | ||
# elif res != 1: | ||
# # """if it returns a number greater than one, you're in trouble, | ||
# # and you should call it again with exc=NULL to revert the effect""" | ||
# ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None) | ||
# raise SystemError("PyThreadState_SetAsyncExc failed") | ||
# | ||
# | ||
# def stop_thread(thread): | ||
# _async_raise(thread.ident, SystemExit) | ||
# @app.route("/", methods=["GET","POST"]) | ||
# def hh(): | ||
# if request.method == "POST": | ||
# print("sssssssssssss") | ||
# return redirect("a") | ||
# else: | ||
# while 1: | ||
# pass | ||
# return render_template("th.html") | ||
|
||
@app.route("", methods=["GET","POST"]) | ||
def demo(): | ||
nick_name = request.form.get("nick_name") | ||
print(nick_name) | ||
return "ok" | ||
def fun2(): | ||
i=0 | ||
while 1: | ||
i+=1 | ||
time.sleep(1) | ||
print(i) | ||
|
||
def fun1(): | ||
# a=1 | ||
if request.method == "POST": | ||
print("sssssssssssss") | ||
|
||
|
||
t1 = threading.Thread(target=fun1, args=()) | ||
t2 = threading.Thread(target=fun2, args=()) | ||
t2.setDaemon(True) | ||
t1.start() | ||
t2.start() | ||
# if request.method=="POST": | ||
# stop_thread(myThread) | ||
return render_template("th.html") | ||
|
||
@app.route("/b", methods=["GET","POST"]) | ||
def a(): | ||
return "Stop" | ||
|
||
if __name__ == "__main__": | ||
app.run() | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Title</title> | ||
<!-- Required meta tags --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
|
||
<!-- Bootstrap CSS --> | ||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | ||
</head> | ||
|
||
<form class="form-group" style="margin: 50px;" method="POST"> | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</form> | ||
|
||
<body> | ||
|
||
<!-- Optional JavaScript --> | ||
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | ||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> | ||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import threading | ||
import time | ||
|
||
|
||
def run(): | ||
time.sleep(2) | ||
print('当前线程的名字是: ', threading.current_thread().name) | ||
time.sleep(2) | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
start_time = time.time() | ||
|
||
print('这是主线程:', threading.current_thread().name) | ||
thread_list = [] | ||
for i in range(5): | ||
t = threading.Thread(target=run) | ||
thread_list.append(t) | ||
|
||
for t in thread_list: | ||
t.setDaemon(True) | ||
t.start() | ||
|
||
print('主线程结束了!', threading.current_thread().name) | ||
print('一共用时:', time.time() - start_time) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pandas as pd | ||
import numpy as np | ||
|
||
file="D:\Taglist 2020-03-27 15-59-12.xlsx" | ||
data2 = pd.read_excel(file) ##输出为DataFrame格式 后续剔除未知类型 | ||
# data2=data2.dropna() ##剔除异常的nan | ||
data2 = data2[data2['TagType'].isin( | ||
["BOOL", "REAL","AB:Embedded_DiscreteIO:O:0","AB:Embedded_DiscreteIO:I:0"])] ##可以读取的类型 ["BOOL", "TIMER", "REAL","AB:Embedded_DiscreteIO:O:0","AB:Embedded_DiscreteIO:I:0"] | ||
##剔除程序名和已知类型之外的数据 | ||
data2 = data2['TagName'] | ||
print(data2) | ||
|
||
data2.replace("Local:1:I","Local:1:I.Data",inplace=True) | ||
data2.replace("Local:1:O","Local:1:O.Data",inplace=True) | ||
|
||
print(data2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters