Commit 1f63bd37 by hanjixin

init

parents
File added
{
"python.pythonPath": "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/bin/python3"
}
\ No newline at end of file
import argparse
import json
from pythonosc import osc_message_builder
from pythonosc import udp_client
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="192.168.43.44",
help="The ip of the OSC server")
parser.add_argument("--port", type=int, default=5006,
help="The port the OSC server is listening on")
args = parser.parse_args()
client = udp_client.SimpleUDPClient(args.ip, args.port)
client.send_message("/section", [0])
\ No newline at end of file
from flask import Flask, request, jsonify, make_response
from flask_cors import CORS
import random
import socket
import os
import argparse
import json
from pythonosc import osc_message_builder
from pythonosc import udp_client
# localIP = socket.gethostbyname(socket.gethostname()) # 得到本地ip
localIP = '0.0.0.0'
app = Flask(__name__)
CORS(app, supports_credentials=True)
books = [
dict(id=1, isdn=random.randrange(1, 1000), title='a python book', author=dict(
name='l0set', city='hunan'
)),
dict(id=2, isdn=random.randrange(1, 1000), title='a golang book', author=dict(
name='zwhset', city='beijing'
))
]
def sendMessage(message):
parser = argparse.ArgumentParser()
parser.add_argument("--ip", default="172.16.1.113",
help="The ip of the OSC server")
parser.add_argument("--port", type=int, default=7000,
help="The port the OSC server is listening on")
args = parser.parse_args()
client = udp_client.SimpleUDPClient(args.ip, args.port)
print(json.dumps(message))
client.send_message("/ctr", json.dumps(message))
# error action
@app.errorhandler(405)
def page_not_found(e):
return jsonify(dict(code=1, message='method error.')), 405
# get all books
@app.route('/api/slider')
def handle_books():
return jsonify(books)
# get a book
@app.route('/api/slider/<int:id>')
def handle_book(id):
for i, book in enumerate(books):
if book['id'] == id:
return jsonify(book)
return jsonify(dict(code=2, message="don't fund the book"))
# create a new book
# 综合页 [{"page":"0"}]
# 丹寨热力 [{"page":"1"}]
# 动线 [{"page":"2"}]
# 客群画像 [{"page":"3"}]
# 客群来源 [{"page":"4"}]
# 丹寨实景 [{"page":"5"}]
# 客流销售 [{"page":"6"}]
# 万达bi [{"page":"bi"}]
# 万达视频 [{"page":"vid"}]
# 自动播放 [{"page":"bi"},{"page":"vid"},{"page":"1"}...]
@app.route('/api/slider', methods=['POST'])
def create_slider():
print(request.json)
result = request.json
if(result['index'] == 0):
sendMessage([{"page": "6"}]) # 客流销售
if(result['index'] == 1):
if (result['type'] == 'slider'):
sendMessage([{"page": "0"}]) # 丹寨综合
if (result['type'] == 'home'):
sendMessage([{"page": "0"}]) # 丹寨综合
if (result['type'] == 'homeSence'):
sendMessage([{"page": "5"}]) # 丹寨场景
if(result['index'] == 2):
sendMessage([{"page": "bi"}]) # BIM
return jsonify(code=0, message='success')
if __name__ == '__main__':
app.run(host=localIP, port=8900)
This source diff could not be displayed because it is too large. You can view the blob instead.
File added
This diff is collapsed. Click to expand it.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body,
html,
#allmap {
width: 100vh;
height: 100vh;
overflow: hidden;
margin: 0;
font-family: '微软雅黑';
}
.BMap_cpyCtrl {
display: none;
}
.anchorBL {
display: none;
}
</style>
<script
type="text/javascript"
src="http://api.map.baidu.com/api?v=2.0&ak=orRAyNA22FrzmG9B61BkNQZPI1KR41tO"
></script>
<script src="http://api.map.baidu.com/library/AreaRestriction/1.2/src/AreaRestriction.js"></script>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<title>地图展示</title>
</head>
<body>
<!-- <img src="bus.png" alt=""> -->
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
// 百度地图API功能
// 创建地图实例
var map = new BMap.Map("allmap",{enableMapClick: false});
//以四川省为地图中心,显示层级为13
map.centerAndZoom("四川省", 8);
//允许滚动鼠标缩放地图
map.enableScrollWheelZoom(true);
setTimeout(function() {
map.enableDragging(); //两秒后开启拖拽
}, 2000);
map.setMapType(BMAP_HYBRID_MAP);
var index = 0;
var myGeo = new BMap.Geocoder();
//需要批量解析显示的地址
var adds = [
"煎茶镇",
"新兴镇",
"永安镇",
"白家沟",
"正兴镇",
"万安镇",
"南湖湿地公园"
];
var blist = [];
var districtLoading = 0;
function getBoundary() {
//设置指定显示区域双流、龙泉驿
addDistrict("成都市");
// addDistrict("成都市龙泉驿区");
}
function addDistrict(districtName) {
//使用计数器来控制加载过程
districtLoading++;
var bdary = new BMap.Boundary();
bdary.get(districtName, function(rs) { //获取行政区域
var count = rs.boundaries.length; //行政区域的点有多少个
if(count === 0) {
alert('未能获取当前输入行政区域');
return;
}
for(var i = 0; i < count; i++) {
blist.push({ points: rs.boundaries[i], name: districtName });
};
//加载完成区域点后计数器-1
districtLoading--;
if(districtLoading == 0) {
//全加载完成后画端点
drawBoundary();
}
});
}
function drawBoundary() {
//包含所有区域的点数组
var pointArray = [];
/*画遮蔽层的相关方法
*思路: 首先在中国地图最外画一圈,圈住理论上所有的中国领土,然后再将每个闭合区域合并进来,并全部连到西北角。
* 这样就做出了一个经过多次西北角的闭合多边形*/
//定义中国东南西北端点,作为第一层
var pNW = { lat: 59.0, lng: 73.0 }
var pNE = { lat: 59.0, lng: 136.0 }
var pSE = { lat: 3.0, lng: 136.0 }
var pSW = { lat: 3.0, lng: 73.0 }
//向数组中添加一次闭合多边形,并将西北角再加一次作为之后画闭合区域的起点
var pArray = [];
pArray.push(pNW);
pArray.push(pSW);
pArray.push(pSE);
pArray.push(pNE);
pArray.push(pNW);
//循环添加各闭合区域
for(var i = 0; i < blist.length; i++) {
//添加显示用标签层
var label = new BMap.Label(blist[i].name, { offset: new BMap.Size(20, -10) });
label.hide();
map.addOverlay(label);
//添加多边形层并显示
var ply = new BMap.Polygon(blist[i].points, { strokeWeight: 2, strokeColor: "#5185E6", fillOpacity: 0.01, fillColor: " #FFFFFF" }); //建立多边形覆盖物
ply.name = blist[i].name;
ply.label = label;
map.addOverlay(ply);
//将点增加到视野范围内
var path = ply.getPath();
pointArray = pointArray.concat(path);
//将闭合区域加到遮蔽层上,每次添加完后要再加一次西北角作为下次添加的起点和最后一次的终点
pArray = pArray.concat(path);
pArray.push(pArray[0]);
}
//限定显示区域,需要引用api库
var boundply = new BMap.Polygon(pointArray);
BMapLib.AreaRestriction.setBounds(map, boundply.getBounds());
map.setViewport(pointArray); //调整视野
//添加遮蔽层(描边线条,遮罩层颜色)
var plyall = new BMap.Polygon(pArray, { strokeOpacity: 0.0000001, strokeColor: "#fff", strokeWeight: 0.00001, fillColor: "#ffffff", fillOpacity: 1 }); //建立多边形覆盖物
map.addOverlay(plyall);
}
function bdGEO() {
var add = adds[index];
geocodeSearch(add);
index++;
}
getBoundary();
function geocodeSearch(add) {
if(index < adds.length) {
setTimeout(window.bdGEO, 400);
}
myGeo.getPoint(add, function(point) {
if(point) {
var address = new BMap.Point(point.lng, point.lat);
// addMarker(address, new BMap.Label(add, { offset: new BMap.Size(20, -10) }));
}
}, "成都市");
}
// 编写自定义函数,创建标注
function addMarker(point, label) {
//使用自定义图标做标注点,宽高为8 10
var myIcon = new BMap.Icon("marker_red_sprite2.png", new BMap.Size(8, 10));
var marker = new BMap.Marker(point,{icon: myIcon});
map.addOverlay(marker);
marker.setLabel(label);
label.setStyle({
display:"none"
})
marker.addEventListener("mouseover",function(e){
var label = this.getLabel();
//设置label的样式,这里没有过多要求,能显示出来就行
label.setStyle({
display:"block",
borderRadius:"2px",
border:"1px solid #5185E6",
padding:"2px 4px"
})
});
marker.addEventListener("mouseout",function(e){
var label = this.getLabel();
label.setStyle({
display:"none"
})
});
}
bdGEO();
</script>
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
import argparse
import math
import json
from pythonosc import dispatcher
from pythonosc import osc_server
import requests
import socket
import os
print(socket.gethostname())
# localIP = socket.gethostbyname(socket.gethostname()) # 得到本地ip
print('127.0.0.1')
def print_volume_handler(unused_addr, args, volume):
print(volume.decode('utf-8'))
print("[{0}] ~ {1}".format(args[0], volume))
def print_compute_handler(unused_addr, args, volume):
print(args)
try:
print("[{0}] ~ {1}".format(args[0], args[1](volume)))
except ValueError:
pass
def ctrLamp(id, open):
url = "http://iotadmin.bgycc.com/v2/diagnosis/device/set/"+id
payload = "{\r\n\"datapoint\":[\r\n\r\n\r\n{\r\n\"index\":0,\r\n\"value\":"+open+"\r\n\r\n}\r\n]\r\n}"
headers = {
'Content-Type': "application/json",
'Access-Token': "OTZDOEQwREZBN0Y4RjY0NUFGRkY0NzQwMUU1NjFDNjQxNUM3MEE4QzY4N0E1QjBFQTNBM0U2QzU5OUVGNENGQw=="
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
def pot1open(p):
print('pot1open')
ctrLamp('1684316145', '1')
def pot1close(p):
print('pot1close')
ctrLamp('1684316145', '0')
def pot2open(p):
print('pot2open')
ctrLamp('1684315223', '1')
def pot2close(p):
print('pot2close')
ctrLamp('1684315223', '0')
def pot3open(p):
print('pot3open')
ctrLamp('1684311829', '1')
def pot3close(p):
print('pot3close')
ctrLamp('1684311829', '0')
def goPage(p):
url = "http://127.0.0.1:8089/" + \
str(json.loads(p)['p'])+"/"+str(json.loads(p)['n'])
print(url)
response = requests.request("GET", url)
print(response.text)
def section(unused_addr, args):
print(args)
goPage(args)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--ip",
default='127.0.0.1', help="The ip to listen on")
parser.add_argument("--port",
type=int, default=5006, help="The port to listen on")
args = parser.parse_args()
dispatcher = dispatcher.Dispatcher()
# dispatcher.map("/Page", print)
# dispatcher.map("/section", print)
dispatcher.map("/section", print)
print(args)
server = osc_server.ThreadingOSCUDPServer(
(args.ip, args.port), dispatcher)
print("Serving on {}".format(server.server_address))
server.serve_forever()
\ No newline at end of file
// let obj = {
// name: 'lyn',
// age: 20
// }
// let proxy = new Proxy(obj, {
// get: function(target, propsKey) {
// console.log(target, propsKey)
// return 15
// }
// } )
// console.log(proxy.name, proxy.age, proxy.sex)
// console.log(obj.name, obj.age, obj.sex)
// var it = makeIterator(['a', 'b']);
// // it.next() // { value: "a", done: false }
// // it.next() // { value: "b", done: false }
// // it.next() // { value: undefined, done: true }
// console.log(
// it.next(),it.next(), it.next())
// function makeIterator(array) {
// var nextIndex = 0;
// return {
// next: function() {
// return nextIndex < array.length ?
// {value: array[nextIndex++], done: false} :
// {value: undefined, done: true};
// }
// };
// }
function* helloWorldGenerator() {
yield 'hello';
yield 'world';
return 'ending';
}
var hw = helloWorldGenerator();
console.log(hw.next(),hw.next(),hw.next(),hw.next())
\ No newline at end of file
import sys
print(sys.path)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment