Commit c91fcd1e 刘韬

添加旧API支持

1 个父辈 3f5fc694
正在显示 338 个修改的文件 包含 3235 行增加326 行删除
<?xml version="1.0" encoding="UTF-8"?>
<config ver="10">
<item key="ipstart" ver="10" value="192.168.101.50" />
<item key="ipend" ver="10" value="60" />
</config>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<config ver="10">
<item key="ipstart" ver="10" value="192.168.101.50" />
<item key="ipend" ver="10" value="2" />
</config>
\ No newline at end of file
{"192.168.101.56":{"IP":"192.168.101.56","Mac":"","Host":null,"BoardType":3,"Ver":0.0,"MCAddr":null,"PingDelay":21,"shelfState":{"isupdate":false,"state":"na","msg":null,"ipconfig":null,"version":null,"serial_state":"na","ad_serial":null},"memo":null},"192.168.101.53":{"IP":"192.168.101.53","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":15,"shelfState":{"isupdate":true,"state":"on","msg":"未进行测试动作","ipconfig":{"post":"wait","ip":"http://192.168.101.77/smf-core","cid":"002"},"version":"1.3","serial_state":null,"ad_serial":null},"memo":null},"192.168.101.52":{"IP":"192.168.101.52","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":62,"shelfState":{"isupdate":true,"state":"on","msg":"未进行测试动作","ipconfig":{"post":"wait","ip":"http://192.168.101.77/smf-core","cid":"003"},"version":"1.3","serial_state":null,"ad_serial":null},"memo":null},"192.168.101.51":{"IP":"192.168.101.51","Mac":"","Host":null,"BoardType":0,"Ver":0.0,"MCAddr":null,"PingDelay":12,"shelfState":{"isupdate":true,"state":"on","msg":"未进行测试动作","ipconfig":{"post":"wait","ip":"http://192.168.101.77/smf-core","cid":"001"},"version":"1.3","serial_state":null,"ad_serial":null},"memo":null},"192.168.101.50":{"IP":"192.168.101.50","Mac":"","Host":null,"BoardType":3,"Ver":0.0,"MCAddr":null,"PingDelay":218,"shelfState":{"isupdate":false,"state":"na","msg":null,"ipconfig":null,"version":null,"serial_state":"na","ad_serial":null},"memo":null}}
\ No newline at end of file
此文件类型无法预览
此文件类型无法预览
<?xml version="1.0"?>
<doc>
<assembly>
<name>ConfigHelper</name>
</assembly>
<members>
<member name="F:ConfigHelper.AdvanceConfigEdit.CustomEditor">
<summary>
自定义编辑器
</summary>
</member>
<member name="F:ConfigHelper.AdvanceConfigEdit.components">
<summary>
必需的设计器变量。
</summary>
</member>
<member name="M:ConfigHelper.AdvanceConfigEdit.Dispose(System.Boolean)">
<summary>
清理所有正在使用的资源。
</summary>
<param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
</member>
<member name="M:ConfigHelper.AdvanceConfigEdit.InitializeComponent">
<summary>
设计器支持所需的方法 - 不要修改
使用代码编辑器修改此方法的内容。
</summary>
</member>
<member name="M:ConfigHelper.AdvanceConfigForm.AddCustomEditor``1(System.String)">
<summary>
添加自定义编辑器
</summary>
<typeparam name="T"></typeparam>
<param name="name"></param>
</member>
<member name="M:ConfigHelper.AdvanceConfigForm.ShowEditDialog(System.Windows.Forms.IWin32Window,System.Boolean)">
<summary>
显示配置界面,2秒内调用约6次后显示
</summary>
<param name="owner"></param>
<param name="TopMost"></param>
</member>
<member name="F:ConfigHelper.AdvanceConfigForm.components">
<summary>
Required designer variable.
</summary>
</member>
<member name="M:ConfigHelper.AdvanceConfigForm.Dispose(System.Boolean)">
<summary>
Clean up any resources being used.
</summary>
<param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
</member>
<member name="M:ConfigHelper.AdvanceConfigForm.InitializeComponent">
<summary>
Required method for Designer support - do not modify
the contents of this method with the code editor.
</summary>
</member>
<member name="T:ConfigHelper.Config">
<summary>
自定义配置存取
</summary>
</member>
<member name="F:ConfigHelper.Config.hasChange">
<summary>
指示配置文件是否存在变化
</summary>
</member>
<member name="P:ConfigHelper.Config.SaveToAppdata">
<summary>
将设置保存至appdata目录
</summary>
</member>
<member name="M:ConfigHelper.Config.ReloadConfig">
<summary>
重载配置
</summary>
</member>
<member name="M:ConfigHelper.Config.SetComment(System.String,System.String)">
<summary>
设置备注
</summary>
<param name="key"></param>
<param name="Comment"></param>
</member>
<member name="M:ConfigHelper.Config.Get(System.String)">
<summary>
读取配置
</summary>
<param name="key"></param>
<returns></returns>
</member>
<member name="M:ConfigHelper.Config.Get(System.Object)">
<summary>
读取配置
</summary>
<param name="key">传入一个枚举值</param>
<returns></returns>
</member>
<member name="M:ConfigHelper.Config.Get``1(System.Object,``0)">
<summary>
读取配置
</summary>
<typeparam name="T">返回类型</typeparam>
<param name="key">传入一个枚举值</param>
<param name="defaultvalue">失败默认值</param>
<returns></returns>
</member>
<member name="M:ConfigHelper.Config.Get``1(System.String,``0)">
<summary>
读取配置
</summary>
<typeparam name="T">返回类型</typeparam>
<param name="key">key</param>
<param name="defaultvalue">失败默认值</param>
<returns></returns>
</member>
<member name="M:ConfigHelper.Config.Set(System.String,System.String)">
<summary>
设置配置
</summary>
<param name="key"></param>
<param name="value"></param>
</member>
<member name="M:ConfigHelper.Config.Set(System.Object,System.String)">
<summary>
设置配置
</summary>
<param name="key">配置枚举值</param>
<param name="value"></param>
</member>
<member name="M:ConfigHelper.Config.Set``1(System.Object,``0)">
<summary>
设置配置
</summary>
<param name="key">配置枚举值</param>
<param name="value"></param>
</member>
<member name="M:ConfigHelper.Config.Set``1(System.String,``0)">
<summary>
设置配置
</summary>
<typeparam name="T">值类型</typeparam>
<param name="key"></param>
<param name="value"></param>
</member>
<member name="M:ConfigHelper.Config.SaveChangeDebounce">
<summary>
保存设置
</summary>
</member>
<member name="M:ConfigHelper.Config.SaveChange">
<summary>
保存设置
</summary>
</member>
<member name="M:ConfigHelper.Config.PropertyBind(System.Object,System.Object,System.String,System.String,System.String)">
<summary>
绑定UI属性
</summary>
<param name="key">配置key</param>
<param name="uiobj">ui对象</param>
<param name="Property">绑定属性</param>
<param name="SaveEvent">绑定事件(object s, EventArgs x),可以为空</param>
<param name="defaultvalue">默认值</param>
</member>
<member name="M:ConfigHelper.Config.PropertyBind``1(System.Object,System.Object,System.String,System.String,``0)">
<summary>
绑定UI属性
</summary>
<param name="key">配置key</param>
<param name="uiobj">ui对象</param>
<param name="Property">绑定属性</param>
<param name="SaveEvent">绑定事件(object s, EventArgs x),可以为空</param>
<param name="defaultvalue">默认值</param>
</member>
<member name="M:ConfigHelper.Config.LoadMyConfig(System.Type)">
<summary>
转换自定义配置类
</summary>
<param name="ConfigClassType"></param>
<returns>加载到的配置Key数量</returns>
</member>
<member name="T:ConfigHelper.ICustEditor">
<summary>
自定义编辑器接口
</summary>
</member>
<member name="M:ConfigHelper.ICustEditor.ValueEdit(System.Object)">
<summary>
自己的编辑方法或界面
</summary>
<param name="value">传入的值</param>
<returns>传出的值</returns>
</member>
<member name="T:ConfigHelper.MyConfig`1">
<summary>
自动化我的配置
</summary>
</member>
<member name="F:ConfigHelper.MyConfig`1.Key">
<summary>
配置的Key
</summary>
</member>
<member name="P:ConfigHelper.MyConfig`1.Val">
<summary>
配置的值
</summary>
</member>
<member name="M:ConfigHelper.MyConfig`1.ToString">
<summary>
获取配置数据的文本
</summary>
<returns></returns>
</member>
<member name="M:ConfigHelper.MyConfig`1.op_Implicit(ConfigHelper.MyConfig{`0})~`0">
<summary>
隐式转换
</summary>
<param name="m1"></param>
</member>
<member name="M:ConfigHelper.MyConfig`1.op_Implicit(`0)~ConfigHelper.MyConfig{`0}">
<summary>
隐式转换
</summary>
<param name="v1"></param>
</member>
<member name="T:ConfigHelper.MyConfigComment">
<summary>
自定义配置描述
</summary>
</member>
<member name="M:ConfigHelper.MyConfigComment.#ctor(System.String)">
<summary>
配置的说明
</summary>
<param name="comment"></param>
</member>
</members>
</doc>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
\ No newline at end of file
此文件的差异太大,无法显示。
此文件类型无法预览
此文件的差异太大,无法显示。
此文件太大,无法显示。
from flask import Flask
from flask_babel import Babel
from config import Config
import logging
from logging.handlers import RotatingFileHandler,TimedRotatingFileHandler
# from flask_socketio import SocketIO
is_start=False
def setup_log():
# 设置日志的记录等级
logging.basicConfig(level=Config.LOG_LEVEL) # 调试debug级
# 创建日志记录器,指明日志保存的路径、每个日志文件的最大大小、保存的日志文件个数上限
file_log_handler = RotatingFileHandler(Config.LOG_FOLDER, maxBytes=1024 * 1024 * 100, backupCount=10)
# 创建日志记录的格式 日志等级 输入日志信息的文件名 行数 日志信息
# log_file_handler = TimedRotatingFileHandler(filename='logs/smartshelf.log', when="D", interval=1, backupCount=3)
formatter = logging.Formatter('%(asctime)s : %(message)s')
# 为刚创建的日志记录器设置日志记录格式
file_log_handler.setFormatter(formatter)
# 为全局的日志工具对象(flask app使用的)添加日志记录器
logging.getLogger().addHandler(file_log_handler)
setup_log()
app = Flask(__name__)
babel = Babel(app)
app.config.from_object(Config)
LANGUAGES = {
"zh": "Chinese",
"en": "English",
"ja": "Japanese"
}
@babel.localeselector
def get_locale():
return request.accept_languages.best_match(LANGUAGES.keys())
from app import config_ip,routes,post,led_strip,driver_gpio,autoback,qr_code
# return app
import requests
import threading
import time
def s():
data = {'key1':'value1','key2':'value2'}
time.sleep(2)
requests.post("http://127.0.0.1:5000/stoppost",data)
#if testCidExists():
time.sleep(2)
requests.post("http://127.0.0.1:5000/startpost",data)
logging.warning("启动完成")
t =threading.Thread(target=s)
t.start()
\ No newline at end of file
# codinf:utf-8
import os
import time
from flask import render_template, Response, request,redirect,url_for
from werkzeug.utils import secure_filename
from app import app
import logging
import pexpect
import json
import zipfile
import shutil
import csv
import requests
import re
from config import Config
basepath = os.path.dirname(__file__)
def backup():
try:
source_dir = '/prog/backup/'
today = source_dir + time.strftime('%Y%m%d')
if not os.path.exists(today):
os.mkdir(today)
cmd = "cp -rf /prog/smartshelf/* /prog/backup/{}/".format(time.strftime('%Y%m%d'))
run = pexpect.spawn('su -c "%s" root' %cmd)
time.sleep(2)
run.sendline('xxx')
logging.warning("备份成功")
except Exception as e:
logging.warning("备份失败:{}".format(e))
def read_ip():
uploads_path = basepath + Config.STATE_PATH
with open(uploads_path + 'ipconfig.csv','r') as f:
reader = csv.reader(f)
current = [row for row in reader]
ip = current[0][0]
return ip
def read_version():
uploads_path = basepath + Config.STATE_PATH
with open(uploads_path + "version.txt","r") as f:
s_version=f.readline()
return s_version
def confirm_version(version):
logging.warning("写入最新版本号:{}".format(version))
uploads_path = basepath + Config.STATE_PATH
with open(uploads_path + "version.txt","w") as f:
f.write(str(version))
f.close()
@app.route('/upgrade',methods=['POST'])
def upgrade():
ip = read_ip()
ip = ip.replace('/smdbox', '')
# ip = 'http://192.168.1.99'
download_url = '{}/download/version.txt'.format(ip)
logging.warning("服务器最新版本信息:{}".format(download_url))
try:
response = requests.get(download_url)
if response.status_code == 200:
version = response.json()
s_version = read_version()
logging.warning("当前版本:{},最新版本:{}".format(s_version,version))
if str(s_version) == str(version):
info = {'operation':'当前版本已是最新版本!'}
else:
download_zip(ip,version)
backup()
time.sleep(2)
process_file()
time.sleep(2)
confirm_version(version)
reboot()
info = {'operation':'已升级到最新版本'}
else:
info = {'operation':'服务器地址错误'}
except Exception as e:
logging.warning("发生错误:{}".format(e))
info = {'operation':'发生错误'}
return json.dumps(info)
def download_zip(ip,version):
zip_url = '{}/download/{}.zip'.format(ip,version)
logging.warning("服务器最新文件:{}".format(zip_url))
target_path = '/prog/upgrade_cach/smartshelf.zip'
File=requests.get(zip_url, stream=True)
with open(target_path,'wb+') as f:
for chunk in File.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
f.close()
def process_file():
zfile = zipfile.ZipFile('/prog/upgrade_cach/smartshelf.zip','r')
path2 = '/prog/update/smartshelf/'
n_train = 0
for filename in zfile.namelist():
if filename.endswith('/'):
n_train += 1
os.makedirs(os.path.join(path2, filename))
else:
data = zfile.read(filename)
file = open(os.path.join(path2, filename), 'w+b')
file.write(data)
file.close()
time.sleep(5)
py_source = '/prog/update/smartshelf/app/'
templates_source = '/prog/update/smartshelf/app/templates/'
py_target = '/prog/smartshelf/app/'
template_target = '/prog/smartshelf/app/templates/'
templates_lis = os.listdir(path=templates_source)
py_lis = os.listdir(path=py_source)
logging.warning("待更新文件:{},{}".format(py_lis,templates_lis))
for t_file in templates_lis:
t_filename = os.path.join(templates_source,t_file)
if os.path.isfile(t_filename):
try:
shutil.copy(t_filename, template_target)
except IOError as e:
logging.warning("Unable to copy file. %s" % e)
# print("Unable to copy file. %s" % e)
except Exception as e:
logging.warning("Unexpected error: %s" % e)
for p_file in py_lis:
p_filename = os.path.join(py_source,p_file)
if os.path.isfile(p_filename):
try:
shutil.copy(p_filename, py_target)
except IOError as e:
logging.warning("Unable to copy file. %s" % e)
except Exception as e:
logging.warning("Unexpected error: %s" % e)
shutil.rmtree(path2)
os.remove('/prog/upgrade_cach/smartshelf.zip')
# shutil.rmtree('/prog/upgrade_cach/')
logging.warning("templates upgrade success")
def reboot():
os.system('/prog/./restart.sh')
def openteam():
# os.system('/usr/bin/./teamviwer')
cmd = "nohub /opt/teamviewer/tv_bin/TeamViewer"
run = pexpect.spawn('su -c "%s" root' %cmd)
time.sleep(0.5)
run.sendline('xxx')
# cmd1 = "./teamviwer"
# run1 = pexpect.spawn('su -c "%s" root' %cmd1)
# time.sleep(0.5)
# run1.sendline('xxx')
logging.warning("teamview open")
@app.route('/openteamview',methods=['POST'])
def openteamview():
openteam()
info = {'operation':'已打开teamview'}
return json.dumps(info)
[python: **.py]
[jinja2: **/templates/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.with_
\ No newline at end of file
import os
from flask import Flask, render_template, request, Response
from app import app
import time
from threading import Thread
#app = Flask(__name__)
@app.route('/ipconfig')
def shelfconfigA():
print("begin ip flask")
return render_template('ipconfig.html')
def Config_DHCP():
with open('/etc/dhcpcd.conf.bak', 'r') as f:
file_lines = f.readlines()
f.close()
with open('/etc/dhcpcd.conf', 'w') as f:
# for line in file_lines:
f.writelines(file_lines)
f.flush()
f.close()
def Config_StaticIP(IPAddress, Router_IP):
with open('/etc/dhcpcd.conf.bak', 'r') as f:
file_lines = f.readlines()
f.close()
with open('/etc/dhcpcd.conf', 'w') as f:
# for line in file_lines:
f.writelines(file_lines)
# f.write("static ip_address=" + str(request.args.get('new_ip')))
# interface eth0
#IPAddress = str(request.args.get('new_ip')
#Router_IP = str(request.args.get('new_ip')
f.write("interface eth0" + "\n")
if len(IPAddress) > 0:
f.write("static ip_address=" + IPAddress + "\n")
if len(Router_IP) > 0:
f.write("static routers=" + Router_IP + "\n")
# f.write("")
f.flush()
f.close()
def reboot_after_delay():
# Wait for 5 seconds before rebooting
time.sleep(5)
os.system('sudo reboot')
def Reenable_NetworkService():
#os.system('sudo systemctl stop networking')
#os.system('sudo systemctl start networking')
#os.system('sudo systemctl stop dhcpcd.service')
#print("services stop")
#os.system('sudo ip addr flush dev eth0')
#os.system('sudo systemctl start dhcpcd.service')
# Wait for 3 seconds before rebooting
reboot_thread = Thread(target=reboot_after_delay)
reboot_thread.start()
return "Apply Successfully, System will reboot in 5 seconds"
#return "Raspberry Pi will reboot in 3 seconds"
#os.system('sudo reboot')
def netmask_to_length(netmask):
# Convert the netmask to a list of integers
netmask = [int(x) for x in netmask.split(".")]
# Count the number of set bits in the netmask
length = 0
for octet in netmask:
while octet > 0:
length += octet & 1
octet >>= 1
return length
@app.route('/ip_config',methods=['POST'])
def IP_Config():
dhcp_enabled = request.form.get('dhcp')
if dhcp_enabled:
Config_DHCP()
print("DHCP ENABLED")
else:
IP_ADDR = str(request.form.get('new_ip'))
print("input:",str(request.form.get('new_ip')))
Router_ADDR = str(request.form.get('router_ip'))
NET_MASK = str(request.form.get('new_mask'))
IP_ADDR +="/"+str(netmask_to_length(NET_MASK))
print(IP_ADDR)
print(Router_ADDR)
Config_StaticIP(IP_ADDR,Router_ADDR)
print(IP_ADDR,Router_ADDR)
print("IP CHANGED")
#Reenable_NetworkService()
#Response('Apply Successfully', status=200, mimetype='text/plain')
return Reenable_NetworkService()
#return #'Apply Successfully ' #{} with DHCP enabled: {}'.format(IP_ADDR, 'True' if dhcp_enabled else 'False')
#Config_StaticIP("192.168.1.59/24", "192.168.1.1")
#Reenable_NetworkService()
import os
if os.name is not 'nt':
import RPi.GPIO as GPIO
import time
def init(gpiox):
GPIO.setmode(GPIO.BCM)
GPIO.setup(gpiox,GPIO.OUT)
def gpio_high(gpiox):
GPIO.output(gpiox, GPIO.HIGH)
def gpio_low(gpiox):
GPIO.output(gpiox, GPIO.LOW)
def clean():
GPIO.cleanup()
else:
def init(gpiox):
print(gpiox)
def gpio_high(gpiox):
print(gpiox)
def gpio_low(gpiox):
print(gpiox)
def clean():
print("clean")
\ No newline at end of file
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
config and init 24-LEDs-stripe
"""
import os
from matplotlib.pyplot import cla
LED_COUNT = 1000 # 要控制LED的数量.
# LED_PIN = 18 # GPIO接口 (PWM编码).
LED_BRIGHTNESS = 100 # 设置LED亮度 (0-255)
#以下LED配置无需修改
LED_FREQ_HZ = 800000 # LED信号频率(以赫兹为单位)(通常为800khz)
LED_DMA = 10 # 用于生成信号的DMA通道(尝试5)
LED_INVERT = False # 反转信号(使用NPN晶体管电平移位时)
LED_CHANNEL = 0
stop_flag = None
stripStore={}
if os.name != 'nt':
from neopixel import *
from rpi_ws281x import Adafruit_NeoPixel, Color as ColorA,PixelStrip
#Color=ColorA
def Color(red,green, blue, white=0):
return ColorA(green,red,blue)
def get_strip(pin=12):
LED_PIN = pin
if stripStore.get(LED_PIN) is None:
stripStore[LED_PIN] = PixelStrip(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS,LED_CHANNEL)
stripStore[LED_PIN].begin()
# Initialize the library (must be called once before other functions).
# log.debug("Initialize: " + str(strip))
return stripStore[LED_PIN]
def color_wipe_full(strip, color, wait_ms=50):
"""Wipe color across display a pixel at a time."""
for i in range(strip.numPixels()):
strip.setPixelColor(i, color)
strip.show()
# time.sleep(wait_ms/1000.0)
def reset_strip(strip):
strip.setBrightness(LED_BRIGHTNESS)
color_wipe_full(strip, Color(0,0,0), 20)
# log.debug('LED stripe cleared.')
return
# noinspection PyProtectedMember
def _cleanup_strip(strip: Adafruit_NeoPixel):
strip._cleanup()
else:
class strip:
def numPixels():
return 1
def setPixelColor(i,c):
return
def show():
return
def Color(red,green, blue, white=0):
return (white << 24) | (red << 16) | (green << 8) | blue
def get_strip(pin=12):
if stripStore.get(pin) is None:
stripStore[pin] = strip
print('new_strip:'+str(pin))
print('get_strip:'+str(pin))
return stripStore[pin]
def color_wipe_full(strip, color, wait_ms=50):
print(color)
# time.sleep(wait_ms/1000.0)
def reset_strip(strip):
print('reset_strip:\/')
print(strip)
# log.debug('LED stripe cleared.')
return
# noinspection PyProtectedMember
def _cleanup_strip(strip):
print(strip)
def setcolor(color):
color = color.lower()
if color == 'red':
return Color(255,0,0)
elif color == 'green':
return Color(0,255,0)
elif color == 'yellow':
return Color(255,255,0)
elif color == 'off':
return Color(0,0,0)
elif color == 'blue':
return Color(0,0,255)
elif color == 'orange':
return Color(255,97,0)
elif color == 'cyan':
return Color(0,255,255)
elif color == 'firebrick':
return Color(178,34,34)
elif color == 'purple':
return Color(128,0,128)
elif color == 'forestgreen':
return Color(34,139,34)
elif color == 'lightblue':
return Color(173,216,230)
elif color == 'indianred':
return Color(205,92,92)
elif color == 'darkgreen':
return Color(0,100,0)
elif color == 'white':
return Color(255,255,255)
elif color == 'magenta':
return Color(255,0,255)
else:
return Color(255,255,255)
\ No newline at end of file
# Translations template for PROJECT.
# Copyright (C) 2022 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-05-11 16:02+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
#: post.py:290
msgid "关闭成功"
msgstr ""
#: post.py:293
msgid "无需关闭"
msgstr ""
#: post.py:397
msgid "未进行测试动作"
msgstr ""
#: routes.py:53 routes.py:382
msgid "加载成功"
msgstr ""
#: routes.py:56
msgid "加载失败,请在配置页面上传配置文件"
msgstr ""
#: routes.py:139 templates/ledtest.html:30 templates/ledtest.html:86
msgid "通道"
msgstr ""
#: routes.py:139
msgid "状态灯"
msgstr ""
#: routes.py:246
msgid "灯地址:{},已点亮"
msgstr ""
#: routes.py:292
msgid "灯地址:{},已关闭"
msgstr ""
#: routes.py:306
msgid "灯条已重置"
msgstr ""
#: routes.py:386
msgid "重新加载失败,请在配置页面上传配置文件"
msgstr ""
#: routes.py:421
msgid "灯条:{},颜色:{},已开启"
msgstr ""
#: routes.py:437
msgid "灯条:{}已关闭"
msgstr ""
#: templates/base.html:6 templates/ledtest.html:6 templates/shelfconfig.html:6
msgid "智能料架系统"
msgstr ""
#: templates/base.html:25 templates/ledtest.html:22
#: templates/shelfconfig.html:78
msgid "料架系统"
msgstr ""
#: templates/base.html:30
msgid "开关"
msgstr ""
#: templates/base.html:33
msgid "启动"
msgstr ""
#: templates/base.html:34
msgid "停止"
msgstr ""
#: templates/base.html:42 templates/ledtest.html:136
#: templates/shelfconfig.html:132
msgid "提醒消息"
msgstr ""
#: templates/base.html:47 templates/ledtest.html:141
#: templates/shelfconfig.html:137
msgid "运行状态"
msgstr ""
#: templates/base.html:52 templates/ledtest.html:151
#: templates/shelfconfig.html:142
msgid "配置文件加载状态"
msgstr ""
#: templates/base.html:57 templates/shelfconfig.html:101
#: templates/shelfconfig.html:147
msgid "服务器地址"
msgstr ""
#: templates/base.html:62 templates/shelfconfig.html:107
#: templates/shelfconfig.html:152
msgid "料架编号"
msgstr ""
#: templates/base.html:67
msgid "服务器连接状态"
msgstr ""
#: templates/base.html:76 templates/ledtest.html:130
#: templates/shelfconfig.html:126
msgid "运行日志&状态信息"
msgstr ""
#: templates/base.html:81
msgid "日志下载"
msgstr ""
#: templates/base.html:84
msgid "下载日志"
msgstr ""
#: templates/base.html:91
msgid "日志"
msgstr ""
#: templates/base.html:118 templates/base.html:142 templates/base.html:165
#: templates/ledtest.html:197 templates/ledtest.html:209
#: templates/shelfconfig.html:181 templates/shelfconfig.html:262
msgid "运行中"
msgstr ""
#: templates/base.html:119 templates/base.html:143 templates/base.html:166
#: templates/ledtest.html:198 templates/shelfconfig.html:263
msgid "已关闭"
msgstr ""
#: templates/base.html:120 templates/base.html:144 templates/base.html:167
#: templates/ledtest.html:199 templates/shelfconfig.html:264
msgid "未初始化"
msgstr ""
#: templates/base.html:125
msgid "启动失败"
msgstr ""
#: templates/base.html:149
msgid "停止失败"
msgstr ""
#: templates/base.html:173 templates/ledtest.html:204
#: templates/shelfconfig.html:273
msgid "未获取到状态信息"
msgstr ""
#: templates/head.html:29
msgid "亮灯料架"
msgstr ""
#: templates/head.html:33
msgid "控制"
msgstr ""
#: templates/head.html:34
msgid "测试"
msgstr ""
#: templates/head.html:35
msgid "料架配置"
msgstr ""
#: templates/ledtest.html:27
msgid "灯条测试"
msgstr ""
#: templates/ledtest.html:37 templates/ledtest.html:65
#: templates/ledtest.html:93
msgid "颜色"
msgstr ""
#: templates/ledtest.html:47
msgid "灯条全开"
msgstr ""
#: templates/ledtest.html:48
msgid "灯条关闭"
msgstr ""
#: templates/ledtest.html:54
msgid "库位操作测试"
msgstr ""
#: templates/ledtest.html:57
msgid "库位"
msgstr ""
#: templates/ledtest.html:75 templates/ledtest.html:102
msgid "亮灯"
msgstr ""
#: templates/ledtest.html:76 templates/ledtest.html:103
msgid "灭灯"
msgstr ""
#: templates/ledtest.html:77
msgid "重置"
msgstr ""
#: templates/ledtest.html:83
msgid "状态灯测试"
msgstr ""
#: templates/ledtest.html:110
msgid "下载库位二维码"
msgstr ""
#: templates/ledtest.html:122
msgid "下载二维码"
msgstr ""
#: templates/ledtest.html:124
msgid "单个二维码尺寸(含白色底框)尺寸为16*16mm,黑码尺寸为10*10mm"
msgstr ""
#: templates/ledtest.html:146
msgid "测试消息"
msgstr ""
#: templates/ledtest.html:210 templates/shelfconfig.html:182
msgid "料架运行中,请关闭后再进行测试"
msgstr ""
#: templates/shelfconfig.html:83
msgid "配置文件"
msgstr ""
#: templates/shelfconfig.html:87
msgid "选择文件"
msgstr ""
#: templates/shelfconfig.html:90
msgid "上传"
msgstr ""
#: templates/shelfconfig.html:96
msgid "服务器配置"
msgstr ""
#: templates/shelfconfig.html:102
msgid "请填入服务器地址"
msgstr ""
#: templates/shelfconfig.html:108
msgid "请填入料架编号"
msgstr ""
#: templates/shelfconfig.html:111
msgid "保存"
msgstr ""
#: templates/shelfconfig.html:116
msgid "控制器备份&升级"
msgstr ""
#: templates/shelfconfig.html:120
msgid "料架升级"
msgstr ""
#: templates/shelfconfig.html:121
msgid "teamview"
msgstr ""
#: templates/shelfconfig.html:157
msgid "操作提醒"
msgstr ""
#: templates/shelfconfig.html:162
msgid "软件版本"
msgstr ""
#: templates/shelfconfig.html:192
msgid "请选择文件"
msgstr ""
#: templates/shelfconfig.html:196
msgid "文件限制最大"
msgstr ""
#: templates/shelfconfig.html:212
msgid "上传完成!"
msgstr ""
#: templates/shelfconfig.html:215
msgid "上传失败!"
msgstr ""
#: templates/shelfconfig.html:228
msgid "不能提交空数据"
msgstr ""
#: templates/shelfconfig.html:240
msgid "保存成功"
msgstr ""
#: templates/shelfconfig.html:280
msgid "检查并升级最新最新版本"
msgstr ""
#: templates/shelfconfig.html:292 templates/shelfconfig.html:314
msgid "升级成功,请刷新浏览器"
msgstr ""
#: templates/shelfconfig.html:297 templates/shelfconfig.html:319
msgid "已取消"
msgstr ""
#: templates/shelfconfig.html:302
msgid "确认打开"
msgstr ""
import os
import sys
import qrcode
# from PIL import Image
from PIL import Image, ImageDraw, ImageFont, ImageFilter
import numpy
from app import app
from flask import jsonify,render_template,request,send_from_directory
import matplotlib.font_manager as fm
import logging
code_path = '/prog/smartshelf/app/static/uploads'
def make_qrcode(file_code):
# for line in all_data:
# A_NUMBER = line[0]
# c_start = int(line[1])
# c_stop = int(line[2])
# dirs_str = deal_line_code(project_number,A_NUMBER,c_start,c_stop)
# resize(project_number,dirs_str)
# current_path_file=os.path.join(code_path,t_file)
qr = qrcode.QRCode(version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=0)
qr.add_data(file_code)
qr.make(fit=True)
img = qr.make_image()
file = "{}/{}.png".format(code_path,file_code)
img.save(file)
# img1.save("./{}_qr_jpg/{}/{}.jpg".format(project_number,dirs_str,filename[:-4]))
return True
def resize(file_code):
# path = './{}_qr_png/{}'.format(project_number,dirs_str)
# path_list = os.listdir(path)
img1 = Image.open("{}/{}.png".format(code_path,file_code))
# img1 = Image.open("E:/qr_png/code/0/{}.png".format(filename))
img1 = img1.resize((300, 300),Image.ANTIALIAS)
# print (filename[:-4])
img1.save("{}/{}.jpg".format(code_path,file_code))
def deal_number(file_code):
print (file_code)
color = "White"
img_str = Image.new("RGB",(480,90),color)
img_str.save("{}/temp_number.jpg".format(code_path))
im = Image.open("{}/temp_number.jpg".format(code_path))
# font = ImageFont.truetype('simsun.ttc',55)
# font = ImageFont.truetype(fm.findfont(fm.FontProperties(family='DejaVu Sans')),63)
if os.path.isfile("/usr/share/fonts/truetype/dejavu/simsun.ttf"):
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/simsun.ttf",75)
draw = ImageDraw.Draw(im)
draw.text((50,20), file_code, font=font, fill='#000')
else:
font = ImageFont.truetype(fm.findfont(fm.FontProperties(family='DejaVu Sans')),75)
draw = ImageDraw.Draw(im)
draw.text((30,20), file_code, font=font, fill='#000')
# draw.text((60,13), filename, font=font, fill='#000') #602项目改动
im.save("{}/temp_number.jpg".format(code_path))
def paste(file_code):
color = 'white'
target = Image.new("RGB",(300,390),color)
# qr = Image.open("E:/qr_png/jpg_code/B/{}".format(filename))
# qr = Image.open("E:/code_tool/{}/{}/{}.jpg".format(source_path,path_str,filename))
qr = Image.open('{}/{}.jpg'.format(code_path,file_code))
im = Image.open('{}/temp_number.jpg'.format(code_path))
a = 0 # 图片距离左边的大小
b = 0 # 图片距离上边的大小
c = 300 # 图片距离左边的大小 + 图片自身宽度
d = 300 # 图片距离上边的大小 + 图片自身高度
target.paste(qr, (a, b, c, d))
e = 0
f = 300
# target.paste(im, (e, f))
target.save("{}/code_img_str.jpg".format(code_path))
targeta = Image.new("RGB",(480,480),color)
targetb = Image.open("{}/code_img_str.jpg".format(code_path))
targeta.paste(targetb, (90, 60))
targeta.paste(im, (0, 360))
targeta.save("{}/{}.jpg".format(code_path,file_code))
logging.warning("库位二维码生成成功:{}".format(file_code))
@app.route('/downqrcode/', methods=['GET','POST'], strict_slashes=False)
def downqrcode():
# file_code = '001-01-001'
file_code = str(request.args.get("code"))
make_qrcode(file_code)
resize(file_code)
deal_number(file_code)
paste(file_code)
c_path = '/prog/smartshelf/app/static/uploads/'
filename = '{}.jpg'.format(file_code)
if request.method == "GET":
if os.path.isfile(os.path.join(c_path, filename)):
return send_from_directory(c_path, filename, as_attachment=True)
\ No newline at end of file
/*
* Globals
*/
/* Links */
a,
a:focus,
a:hover {
color: #fff;
}
/* Custom default button */
.btn-default,
.btn-default:hover,
.btn-default:focus {
color: #333;
text-shadow: none; /* Prevent inheritance from `body` */
background-color: #fff;
border: 1px solid #fff;
}
/*
* Base structure
*/
html,
body {
height: 100%;
background-color: #333;
}
body {
color: #fff;
text-align: center;
text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
/* Extra markup and styles for table-esque vertical and horizontal centering */
.site-wrapper {
display: table;
width: 100%;
height: 100%; /* For at least Firefox */
min-height: 100%;
-webkit-box-shadow: inset 0 0 100px rgba(0,0,0,.5);
box-shadow: inset 0 0 100px rgba(0,0,0,.5);
}
.site-wrapper-inner {
display: table-cell;
vertical-align: top;
}
.cover-container {
margin-right: auto;
margin-left: auto;
}
/* Padding for spacing */
.inner {
padding: 30px;
}
/*
* Header
*/
.masthead-brand {
margin-top: 10px;
margin-bottom: 10px;
}
.masthead-nav > li {
display: inline-block;
}
.masthead-nav > li + li {
margin-left: 20px;
}
.masthead-nav > li > a {
padding-right: 0;
padding-left: 0;
font-size: 16px;
font-weight: bold;
color: #fff; /* IE8 proofing */
color: rgba(255,255,255,.75);
border-bottom: 2px solid transparent;
}
.masthead-nav > li > a:hover,
.masthead-nav > li > a:focus {
background-color: transparent;
border-bottom-color: #a9a9a9;
border-bottom-color: rgba(255,255,255,.25);
}
.masthead-nav > .active > a,
.masthead-nav > .active > a:hover,
.masthead-nav > .active > a:focus {
color: #fff;
border-bottom-color: #fff;
}
@media (min-width: 768px) {
.masthead-brand {
float: left;
}
.masthead-nav {
float: right;
}
}
/*
* Cover
*/
.cover {
padding: 0 20px;
}
.cover .btn-lg {
padding: 10px 20px;
font-weight: bold;
}
/*
* Footer
*/
.mastfoot {
color: #999; /* IE8 proofing */
color: rgba(255,255,255,.5);
}
/*
* Affix and center
*/
@media (min-width: 768px) {
/* Pull out the header and footer */
.masthead {
position: fixed;
top: 0;
}
.mastfoot {
position: fixed;
bottom: 0;
}
/* Start the vertical centering */
.site-wrapper-inner {
vertical-align: middle;
}
/* Handle the widths */
.masthead,
.mastfoot,
.cover-container {
width: 100%; /* Must be percentage or pixels for horizontal alignment */
}
}
@media (min-width: 992px) {
.masthead,
.mastfoot,
.cover-container {
width: 700px;
}
}
/*!
* IE10 viewport hack for Surface/desktop Windows 8 bug
* Copyright 2014-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*
* See the Getting Started docs for more information:
* http://getbootstrap.com/getting-started/#support-ie10-width
*/
@-ms-viewport { width: device-width; }
@-o-viewport { width: device-width; }
@viewport { width: device-width; }
/*!
* IE10 viewport hack for Surface/desktop Windows 8 bug
* Copyright 2014-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
// See the Getting Started docs for more information:
// http://getbootstrap.com/getting-started/#support-ie10-width
(function () {
'use strict';
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement('style')
msViewportStyle.appendChild(
document.createTextNode(
'@-ms-viewport{width:auto!important}'
)
)
document.querySelector('head').appendChild(msViewportStyle)
}
})();
// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
require('../../js/transition.js')
require('../../js/alert.js')
require('../../js/button.js')
require('../../js/carousel.js')
require('../../js/collapse.js')
require('../../js/dropdown.js')
require('../../js/modal.js')
require('../../js/tooltip.js')
require('../../js/popover.js')
require('../../js/scrollspy.js')
require('../../js/tab.js')
require('../../js/affix.js')
\ No newline at end of file
<span style="font-size:18px;"><!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<title>{{ _('智能料架系统') }}</title>
<!-- <link rel="icon" href="/static/favicon.ico"> -->
<!-- <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}"> -->
<link rel="icon" href="/static/favicon.ico">
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
{% set index=1 %}
{% import 'head.html' as head with context%}
{{ head }}
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<h2>{{ _('料架系统') }}</h2>
<hr class="divider">
<!-- 料架启动关闭 -->
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('开关') }}</h3>
</div>
<div class="panel-body">
<input type="button" value={{ _('启动') }} class="btn btn-info" onclick="startpost()"/>
<input type="button" value={{ _('停止') }} class="btn btn-warning" onclick="stoppost()"/>
</div>
</div>
<div id="panel-group">
<!-- 1 -->
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">{{ _('提醒消息') }}</h3>
</div>
<div class="panel-body">
<div class="alert alert-info" role="alert">
<p>
{{ _('运行状态') }}:<span id="shelfstate"></span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('配置文件加载状态') }}:<span id="testinfo">{{ _('加载成功') if config_state else _('加载失败,请在配置页面上传配置文件') }}</span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('服务器地址') }}:<span id="ipconfig"></span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('料架编号') }}:<span id="ccid"></span>
</p>
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('服务器连接状态') }}:<span id="poststate"></span>
</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<h2>{{ _('运行日志&状态信息') }}</h2>
<hr class="divider">
<!-- 日志下载 -->
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('日志下载') }}</h3>
</div>
<div class="panel-body">
<a type="button" class="btn btn-warning" href="{{ url_for('download') }}">{{ _('下载日志') }}</a>
</div>
</div>
<!-- 日志显示 -->
<div class="panel panel-info">
<div class="panel-heading">
<h3 class="panel-title">{{ _('日志') }}</h3>
</div>
<div class="panel-body">
<div id="logmsg" style="overflow:auto;height: 400px;background:#000; color:green"></div>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function () {
getstate();
taillog();
console.log('success');
});
function startpost(){
$.ajax({
url:"/startpost",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
// console.log(data)
alert (data[0].msg)
},
error:function(e){
alert("{{ _('启动失败') }}");
}
})
}
function stoppost(){
// var form= new FormData(document.getElementById("test_form"));
var shelfstate = document.getElementById("shelfstate").value
console.log(shelfstate)
$.ajax({
url:"/stoppost",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
console.log(data)
alert (data[0].msg)
},
error:function(e){
alert("{{ _('停止失败') }}");
}
})
}
// 获取开机关机状态
function getstate(){
// var form= new FormData(document.getElementById("test_form"));
$.ajax({
url:"/getstate",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
console.log(data)
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
// $("#gpioconfig").html(data[0].gpio)
$("#ipconfig").html(data[0].ipconfig['ip'])
$("#ccid").html(data[0].ipconfig['cid'])
},
error:function(e){
alert("{{ _('未获取到状态信息') }}");
}
})
}
// 获取开机关机状态
function taillog(){
// var form= new FormData(document.getElementById("test_form"));
$.ajax({
url:"/taillog",
type:"post",
// data:form,
dataType: 'json',
processData:false,
contentType:false,
success:function(data){
$("#logmsg").html(data.msg)
$("#poststate").html(data.poststate)
},
error:function(e){
}
})
}
setInterval(function(){
taillog();
}, 3000);
</script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</body>
</html>
\ No newline at end of file
<script>
function switchLanguage(language) {
$.ajax({
url: "/language/" + language,
type: "get",
//data: JSON.stringify(ionum),
//contentType: "application/json",
//dataType: 'json',
success: function (data) {
location.reload();
},
error: function (e) {
window.reload();
}
});
return false;
}
</script>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">{{ _('亮灯料架') }}</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li{{ " class=active" if index==1 }}><a href="{{ url_for('index') }}">{{ _('控制') }}</a></li>
<li{{ " class=active" if index==2 }}><a href="{{ url_for('ledtest') }}">{{ _('测试') }}</a> </li>
<li{{ " class=active" if index==3 }}><a href="{{ url_for('shelfconfig') }}">{{ _('料架配置') }}</a></li>
</ul>
<ul class="nav navbar-nav navbar-right" style="font-size: 14px;"">
<li><a href=" #" onclick="return switchLanguage('zh');">简体中文</a></li>
<li><a href="#" onclick="return switchLanguage('en');">English</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
<div style="clear:both;"></div>
\ No newline at end of file
# English translations for PROJECT.
# Copyright (C) 2021 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2022-05-11 16:02+0800\n"
"PO-Revision-Date: 2021-04-08 16:25+0800\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
"Language-Team: en <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"
#: post.py:290
msgid "关闭成功"
msgstr "Closed successfully"
#: post.py:293
msgid "无需关闭"
msgstr "No need to close"
#: post.py:397
msgid "未进行测试动作"
msgstr "No test action"
#: routes.py:53 routes.py:382
msgid "加载成功"
msgstr "Loading succeeded"
#: routes.py:56
msgid "加载失败,请在配置页面上传配置文件"
msgstr ""
"Loading failed, please upload the configuration file on the configuration"
" page"
#: routes.py:139 templates/ledtest.html:30 templates/ledtest.html:86
msgid "通道"
msgstr "Channel"
#: routes.py:139
msgid "状态灯"
msgstr "Status light test"
#: routes.py:246
msgid "灯地址:{},已点亮"
msgstr ""
#: routes.py:292
msgid "灯地址:{},已关闭"
msgstr "Light address: {}, off"
#: routes.py:306
msgid "灯条已重置"
msgstr "Light bar reset"
#: routes.py:386
msgid "重新加载失败,请在配置页面上传配置文件"
msgstr ""
"Reload failed, please upload the configuration file on the configuration "
"page"
#: routes.py:421
msgid "灯条:{},颜色:{},已开启"
msgstr "Light bar: {}, color: {}, turned on"
#: routes.py:437
msgid "灯条:{}已关闭"
msgstr "Light bar: {} turned off"
#: templates/base.html:6 templates/ledtest.html:6 templates/shelfconfig.html:6
msgid "智能料架系统"
msgstr "SmartShelf"
#: templates/base.html:25 templates/ledtest.html:22
#: templates/shelfconfig.html:78
msgid "料架系统"
msgstr "Material rack system"
#: templates/base.html:30
msgid "开关"
msgstr "switch"
#: templates/base.html:33
msgid "启动"
msgstr "Start"
#: templates/base.html:34
msgid "停止"
msgstr "Stop"
#: templates/base.html:42 templates/ledtest.html:136
#: templates/shelfconfig.html:132
msgid "提醒消息"
msgstr "Reminder message"
#: templates/base.html:47 templates/ledtest.html:141
#: templates/shelfconfig.html:137
msgid "运行状态"
msgstr "Running status"
#: templates/base.html:52 templates/ledtest.html:151
#: templates/shelfconfig.html:142
msgid "配置文件加载状态"
msgstr "Configuration file loading status"
#: templates/base.html:57 templates/shelfconfig.html:101
#: templates/shelfconfig.html:147
msgid "服务器地址"
msgstr "Server address"
#: templates/base.html:62 templates/shelfconfig.html:107
#: templates/shelfconfig.html:152
msgid "料架编号"
msgstr "Material rack number"
#: templates/base.html:67
msgid "服务器连接状态"
msgstr "Server connection status"
#: templates/base.html:76 templates/ledtest.html:130
#: templates/shelfconfig.html:126
msgid "运行日志&状态信息"
msgstr "Run log & status information"
#: templates/base.html:81
msgid "日志下载"
msgstr "Log"
#: templates/base.html:84
msgid "下载日志"
msgstr "Download log"
#: templates/base.html:91
msgid "日志"
msgstr "Running log"
#: templates/base.html:118 templates/base.html:142 templates/base.html:165
#: templates/ledtest.html:197 templates/ledtest.html:209
#: templates/shelfconfig.html:181 templates/shelfconfig.html:262
msgid "运行中"
msgstr "Running"
#: templates/base.html:119 templates/base.html:143 templates/base.html:166
#: templates/ledtest.html:198 templates/shelfconfig.html:263
msgid "已关闭"
msgstr "Closed"
#: templates/base.html:120 templates/base.html:144 templates/base.html:167
#: templates/ledtest.html:199 templates/shelfconfig.html:264
msgid "未初始化"
msgstr "Uninitialized"
#: templates/base.html:125
msgid "启动失败"
msgstr "Start failed"
#: templates/base.html:149
msgid "停止失败"
msgstr "Stop failed"
#: templates/base.html:173 templates/ledtest.html:204
#: templates/shelfconfig.html:273
msgid "未获取到状态信息"
msgstr "No status information was obtained"
#: templates/head.html:29
msgid "亮灯料架"
msgstr "Lighting material rack"
#: templates/head.html:33
msgid "控制"
msgstr "Control"
#: templates/head.html:34
msgid "测试"
msgstr "Test"
#: templates/head.html:35
msgid "料架配置"
msgstr "Material rack configuration"
#: templates/ledtest.html:27
msgid "灯条测试"
msgstr "Light bar test"
#: templates/ledtest.html:37 templates/ledtest.html:65
#: templates/ledtest.html:93
msgid "颜色"
msgstr "color"
#: templates/ledtest.html:47
msgid "灯条全开"
msgstr "light"
#: templates/ledtest.html:48
msgid "灯条关闭"
msgstr "off"
#: templates/ledtest.html:54
msgid "库位操作测试"
msgstr "Location operation test"
#: templates/ledtest.html:57
msgid "库位"
msgstr "Location"
#: templates/ledtest.html:75 templates/ledtest.html:102
msgid "亮灯"
msgstr "On"
#: templates/ledtest.html:76 templates/ledtest.html:103
msgid "灭灯"
msgstr "Off"
#: templates/ledtest.html:77
msgid "重置"
msgstr "Reset"
#: templates/ledtest.html:83
msgid "状态灯测试"
msgstr "Status light test"
#: templates/ledtest.html:110
msgid "下载库位二维码"
msgstr "Download location QR code"
#: templates/ledtest.html:122
msgid "下载二维码"
msgstr "Download QR code"
#: templates/ledtest.html:124
msgid "单个二维码尺寸(含白色底框)尺寸为16*16mm,黑码尺寸为10*10mm"
msgstr ""
"Single QR code size(including white bottom frame) size is 16*16mm,black "
"code size is 10*10mm"
#: templates/ledtest.html:146
msgid "测试消息"
msgstr "Test message"
#: templates/ledtest.html:210 templates/shelfconfig.html:182
msgid "料架运行中,请关闭后再进行测试"
msgstr "When the material rack is running, please stop it before testing"
#: templates/shelfconfig.html:83
msgid "配置文件"
msgstr "Config file"
#: templates/shelfconfig.html:87
msgid "选择文件"
msgstr "Select file"
#: templates/shelfconfig.html:90
msgid "上传"
msgstr "Upload"
#: templates/shelfconfig.html:96
msgid "服务器配置"
msgstr "Server configuration"
#: templates/shelfconfig.html:102
msgid "请填入服务器地址"
msgstr "Server address"
#: templates/shelfconfig.html:108
msgid "请填入料架编号"
msgstr "Material rack number"
#: templates/shelfconfig.html:111
msgid "保存"
msgstr "Save"
#: templates/shelfconfig.html:116
msgid "控制器备份&升级"
msgstr "Controller backup & upgrade"
#: templates/shelfconfig.html:120
msgid "料架升级"
msgstr "Software upgrade"
#: templates/shelfconfig.html:121
msgid "teamview"
msgstr ""
#: templates/shelfconfig.html:157
msgid "操作提醒"
msgstr "Operation reminder"
#: templates/shelfconfig.html:162
msgid "软件版本"
msgstr "Software version"
#: templates/shelfconfig.html:192
msgid "请选择文件"
msgstr "Select file"
#: templates/shelfconfig.html:196
msgid "文件限制最大"
msgstr "Maximum file limit"
#: templates/shelfconfig.html:212
msgid "上传完成!"
msgstr "Upload complete"
#: templates/shelfconfig.html:215
msgid "上传失败!"
msgstr "上传失败"
#: templates/shelfconfig.html:228
msgid "不能提交空数据"
msgstr "Cannot submit empty data"
#: templates/shelfconfig.html:240
msgid "保存成功"
msgstr "Saved successfully"
#: templates/shelfconfig.html:280
msgid "检查并升级最新最新版本"
msgstr "Check and upgrade the latest version"
#: templates/shelfconfig.html:292 templates/shelfconfig.html:314
msgid "升级成功,请刷新浏览器"
msgstr "Upgrade succeeded, please refresh the browser"
#: templates/shelfconfig.html:297 templates/shelfconfig.html:319
msgid "已取消"
msgstr "Cancelled"
#: templates/shelfconfig.html:302
msgid "确认打开"
msgstr "Confirm open"
import os
import logging
# from dotenv import load_dotenv
basedir = os.path.abspath(os.path.dirname(__file__))
# load_dotenv(os.path.join(basedir, '.env'))
class Config(object):
SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
'sqlite:///' + os.path.join(basedir, 'app.db')
SQLALCHEMY_TRACK_MODIFICATIONS = False
URL = 'http://192.168.1.100:8080/service/store/communication'
UPLOAD_FOLDER = '/static/uploads'
STATE_PATH = '/state/'
ALLOWED_EXTENSIONS = set(['csv']) #限制上传文件格式
LOG_LEVEL = logging.WARNING
LOG_FOLDER = 'logs/smart.log'
DEFAULT_COLOR = 'green'
\ No newline at end of file
from app import app,db
from app.models import State
@app.shell_context_processor
def make_shell_context():
return {'db': db, 'State': State}
\ No newline at end of file
此文件类型无法预览
{
"info": {
"_postman_id": "e2a264df-d61f-48fa-938c-d5011ec87639",
"name": "NEOLightShelfApi",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "api/open",
"request": {
"method": "POST",
"header": [
{
"key": "content-type",
"value": "application/json",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"params\": \"statusA=red;1=red;2=green\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{hosturl}}/api/open",
"host": [
"{{hosturl}}"
],
"path": [
"api",
"open"
]
}
},
"response": [
{
"name": "open led index in 1000,1001,1002",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "content-type",
"value": "application/json",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"params\": \"1000;1001;1002\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{hosturl}}/api/open",
"host": [
"{{hosturl}}"
],
"path": [
"api",
"open"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "html",
"header": [
{
"key": "Content-Type",
"value": "text/html; charset=utf-8"
},
{
"key": "Content-Length",
"value": "31"
},
{
"key": "Server",
"value": "Werkzeug/1.0.1 Python/3.10.2"
},
{
"key": "Date",
"value": "Wed, 30 Mar 2022 06:06:02 GMT"
}
],
"cookie": [],
"body": "{\"status\": 0, \"msg\": \"success\"}"
},
{
"name": "open status light and led",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "content-type",
"value": "application/json",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"params\": \"statusA=red;statusB=green;1=red;2=green\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{hosturl}}/api/open",
"host": [
"{{hosturl}}"
],
"path": [
"api",
"open"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "html",
"header": [
{
"key": "Content-Type",
"value": "text/html; charset=utf-8"
},
{
"key": "Content-Length",
"value": "31"
},
{
"key": "Server",
"value": "Werkzeug/1.0.1 Python/3.10.2"
},
{
"key": "Date",
"value": "Wed, 30 Mar 2022 06:06:02 GMT"
}
],
"cookie": [],
"body": "{\"status\": 0, \"msg\": \"success\"}"
}
]
},
{
"name": "api/close",
"request": {
"method": "POST",
"header": [
{
"key": "content-type",
"value": "application/json",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"params\": \"statusA=red;700;701;702\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{hosturl}}/api/close",
"host": [
"{{hosturl}}"
],
"path": [
"api",
"close"
]
}
},
"response": [
{
"name": "close all status light",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "content-type",
"value": "application/json",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"params\": \"statusA;statusB\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{hosturl}}/api/close",
"host": [
"{{hosturl}}"
],
"path": [
"api",
"close"
]
}
},
"_postman_previewlanguage": null,
"header": null,
"cookie": [],
"body": null
},
{
"name": "close led index in 1,2,3,100,101",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "content-type",
"value": "application/json",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"params\": \"1;2;3;100;101\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{hosturl}}/api/close",
"host": [
"{{hosturl}}"
],
"path": [
"api",
"close"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "html",
"header": [
{
"key": "Content-Type",
"value": "text/html; charset=utf-8"
},
{
"key": "Content-Length",
"value": "31"
},
{
"key": "Server",
"value": "Werkzeug/1.0.1 Python/3.10.2"
},
{
"key": "Date",
"value": "Wed, 30 Mar 2022 06:05:56 GMT"
}
],
"cookie": [],
"body": "{\"status\": 0, \"msg\": \"success\"}"
}
]
},
{
"name": "opAll",
"request": {
"method": "POST",
"header": [
{
"key": "content-type",
"value": "application/json",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"op\":\"on\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{hosturl}}/opAll",
"host": [
"{{hosturl}}"
],
"path": [
"opAll"
]
}
},
"response": [
{
"name": "close all led",
"originalRequest": {
"method": "POST",
"header": [
{
"key": "content-type",
"value": "application/json",
"type": "default"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"op\":\"off\"\r\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{hosturl}}/opAll",
"host": [
"{{hosturl}}"
],
"path": [
"opAll"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "html",
"header": [
{
"key": "Content-Type",
"value": "text/html; charset=utf-8"
},
{
"key": "Content-Length",
"value": "13"
},
{
"key": "Server",
"value": "Werkzeug/1.0.1 Python/3.10.2"
},
{
"key": "Date",
"value": "Wed, 30 Mar 2022 06:06:07 GMT"
}
],
"cookie": [],
"body": "{\"status\": 0}"
}
]
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "hosturl",
"value": "http://127.0.0.1:5000",
"type": "default"
}
]
}
\ No newline at end of file
此文件类型无法预览
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Flask",
"type": "python",
"request": "launch",
"module": "flask",
"env": {
"FLASK_APP": "app",
"FLASK_ENV": "development"
},
"args": [
"run",
"--no-debugger"
],
"jinja": true,
"justMyCode": true
}
]
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ from config import Config
import logging
from logging.handlers import RotatingFileHandler,TimedRotatingFileHandler
# from flask_socketio import SocketIO
is_start=False
def setup_log():
# 设置日志的记录等级
logging.basicConfig(level=Config.LOG_LEVEL) # 调试debug级
......@@ -34,5 +34,18 @@ def get_locale():
return request.accept_languages.best_match(LANGUAGES.keys())
from app import routes,post,led_strip,driver_gpio,autoback,qr_code
# return app
\ No newline at end of file
from app import config_ip,routes,post,led_strip,driver_gpio,autoback,qr_code
# return app
import requests
import threading
import time
def s():
data = {'key1':'value1','key2':'value2'}
time.sleep(2)
requests.post("http://127.0.0.1:5000/stoppost",data)
#if testCidExists():
time.sleep(2)
requests.post("http://127.0.0.1:5000/startpost",data)
logging.warning("启动完成")
t =threading.Thread(target=s)
t.start()
\ No newline at end of file
......@@ -39,14 +39,14 @@ def read_ip():
return ip
def read_version():
uploads_path = basepath + Config.STATE_PATH
uploads_path = basepath + "/"
with open(uploads_path + "version.txt","r") as f:
s_version=f.readline()
return s_version
def confirm_version(version):
logging.warning("写入最新版本号:{}".format(version))
uploads_path = basepath + Config.STATE_PATH
uploads_path = basepath + "/"
with open(uploads_path + "version.txt","w") as f:
f.write(str(version))
f.close()
......@@ -54,7 +54,7 @@ def confirm_version(version):
@app.route('/upgrade',methods=['POST'])
def upgrade():
ip = read_ip()
ip = ip.replace('/myproject', '')
ip = ip.replace('/smdbox', '')
# ip = 'http://192.168.1.99'
download_url = '{}/download/version.txt'.format(ip)
logging.warning("服务器最新版本信息:{}".format(download_url))
......
import os
from flask import Flask, render_template, request, Response
from app import app
import time
from threading import Thread
#app = Flask(__name__)
@app.route('/ipconfig')
def shelfconfigA():
print("begin ip flask")
return render_template('ipconfig.html')
def Config_DHCP():
with open('/etc/dhcpcd.conf.bak', 'r') as f:
file_lines = f.readlines()
f.close()
with open('/etc/dhcpcd.conf', 'w') as f:
# for line in file_lines:
f.writelines(file_lines)
f.flush()
f.close()
def Config_StaticIP(IPAddress, Router_IP):
with open('/etc/dhcpcd.conf.bak', 'r') as f:
file_lines = f.readlines()
f.close()
with open('/etc/dhcpcd.conf', 'w') as f:
# for line in file_lines:
f.writelines(file_lines)
# f.write("static ip_address=" + str(request.args.get('new_ip')))
# interface eth0
#IPAddress = str(request.args.get('new_ip')
#Router_IP = str(request.args.get('new_ip')
f.write("interface eth0" + "\n")
if len(IPAddress) > 0:
f.write("static ip_address=" + IPAddress + "\n")
if len(Router_IP) > 0:
f.write("static routers=" + Router_IP + "\n")
# f.write("")
f.flush()
f.close()
def reboot_after_delay():
# Wait for 5 seconds before rebooting
time.sleep(5)
os.system('sudo reboot')
def Reenable_NetworkService():
#os.system('sudo systemctl stop networking')
#os.system('sudo systemctl start networking')
#os.system('sudo systemctl stop dhcpcd.service')
#print("services stop")
#os.system('sudo ip addr flush dev eth0')
#os.system('sudo systemctl start dhcpcd.service')
# Wait for 3 seconds before rebooting
reboot_thread = Thread(target=reboot_after_delay)
reboot_thread.start()
return "Apply Successfully, System will reboot in 5 seconds"
#return "Raspberry Pi will reboot in 3 seconds"
#os.system('sudo reboot')
def netmask_to_length(netmask):
# Convert the netmask to a list of integers
netmask = [int(x) for x in netmask.split(".")]
# Count the number of set bits in the netmask
length = 0
for octet in netmask:
while octet > 0:
length += octet & 1
octet >>= 1
return length
@app.route('/ip_config',methods=['POST'])
def IP_Config():
dhcp_enabled = request.form.get('dhcp')
if dhcp_enabled:
Config_DHCP()
print("DHCP ENABLED")
else:
IP_ADDR = str(request.form.get('new_ip'))
print("input:",str(request.form.get('new_ip')))
Router_ADDR = str(request.form.get('router_ip'))
NET_MASK = str(request.form.get('new_mask'))
IP_ADDR +="/"+str(netmask_to_length(NET_MASK))
print(IP_ADDR)
print(Router_ADDR)
Config_StaticIP(IP_ADDR,Router_ADDR)
print(IP_ADDR,Router_ADDR)
print("IP CHANGED")
#Reenable_NetworkService()
#Response('Apply Successfully', status=200, mimetype='text/plain')
return Reenable_NetworkService()
#return #'Apply Successfully ' #{} with DHCP enabled: {}'.format(IP_ADDR, 'True' if dhcp_enabled else 'False')
#Config_StaticIP("192.168.1.59/24", "192.168.1.1")
#Reenable_NetworkService()
import RPi.GPIO as GPIO
import time
def init(gpiox):
GPIO.setmode(GPIO.BCM)
GPIO.setup(gpiox,GPIO.OUT)
def gpio_high(gpiox):
GPIO.output(gpiox, GPIO.HIGH)
def gpio_low(gpiox):
GPIO.output(gpiox, GPIO.LOW)
def clean():
GPIO.cleanup()
\ No newline at end of file
import os
if os.name is not 'nt':
import RPi.GPIO as GPIO
import time
def init(gpiox):
GPIO.setmode(GPIO.BCM)
GPIO.setup(gpiox,GPIO.OUT)
def gpio_high(gpiox):
GPIO.output(gpiox, GPIO.HIGH)
def gpio_low(gpiox):
GPIO.output(gpiox, GPIO.LOW)
def clean():
GPIO.cleanup()
else:
def init(gpiox):
print(gpiox)
def gpio_high(gpiox):
print(gpiox)
def gpio_low(gpiox):
print(gpiox)
def clean():
print("clean")
\ No newline at end of file
......@@ -3,12 +3,12 @@
"""
config and init 24-LEDs-stripe
"""
from neopixel import *
# import logger
from rpi_ws281x import Adafruit_NeoPixel, Color,PixelStrip
import os
LED_COUNT = 750 # 要控制LED的数量.
from matplotlib.pyplot import cla
LED_COUNT = 1000 # 要控制LED的数量.
# LED_PIN = 18 # GPIO接口 (PWM编码).
LED_BRIGHTNESS = 100 # 设置LED亮度 (0-255)
#以下LED配置无需修改
......@@ -18,30 +18,119 @@ LED_INVERT = False # 反转信号(使用NPN晶体管电平移位时)
LED_CHANNEL = 0
stop_flag = None
stripStore={}
if os.name != 'nt':
from neopixel import *
from rpi_ws281x import Adafruit_NeoPixel, Color as ColorA,PixelStrip
#Color=ColorA
def Color(red,green, blue, white=0):
return ColorA(green,red,blue)
def get_strip(pin=12):
LED_PIN = pin
if stripStore.get(LED_PIN) is None:
stripStore[LED_PIN] = PixelStrip(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS,LED_CHANNEL)
stripStore[LED_PIN].begin()
# Initialize the library (must be called once before other functions).
# log.debug("Initialize: " + str(strip))
return stripStore[LED_PIN]
def color_wipe_full(strip, color, wait_ms=50):
"""Wipe color across display a pixel at a time."""
for i in range(strip.numPixels()):
strip.setPixelColor(i, color)
strip.show()
# time.sleep(wait_ms/1000.0)
def reset_strip(strip):
strip.setBrightness(LED_BRIGHTNESS)
color_wipe_full(strip, Color(0,0,0), 20)
# log.debug('LED stripe cleared.')
return
# noinspection PyProtectedMember
def _cleanup_strip(strip: Adafruit_NeoPixel):
strip._cleanup()
else:
class strip:
def numPixels():
return 5
def setPixelColor(i,c):
return
def show():
return
def Color(red,green, blue, white=0):
return (white << 24) | (red << 16) | (green << 8) | blue
def get_strip(pin=12):
if stripStore.get(pin) is None:
stripStore[pin] = strip
print('new_strip:'+str(pin))
print('get_strip:'+str(pin))
return stripStore[pin]
def color_wipe_full(strip, color, wait_ms=50):
print(color)
# time.sleep(wait_ms/1000.0)
def reset_strip(strip):
print('reset_strip:\/')
print(strip)
# log.debug('LED stripe cleared.')
return
def get_strip(pin=12):
LED_PIN = pin
strip = PixelStrip(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS,LED_CHANNEL)
# Initialize the library (must be called once before other functions).
# log.debug("Initialize: " + str(strip))
strip.begin()
return strip
def color_wipe_full(strip, color, wait_ms=50):
"""Wipe color across display a pixel at a time."""
for i in range(strip.numPixels()):
strip.setPixelColor(i, color)
strip.show()
# time.sleep(wait_ms/1000.0)
# noinspection PyProtectedMember
def _cleanup_strip(strip):
print(strip)
def reset_strip(strip):
strip.setBrightness(LED_BRIGHTNESS)
color_wipe_full(strip, Color(0,0,0), 20)
# log.debug('LED stripe cleared.')
return
def setcolor(color):
color = color.lower()
if color.startswith('#'):
rgb = tuple(int(color[i:i+2], 16) for i in (1, 3, 5))
return Color(rgb[0],rgb[1],rgb[2])
elif color == 'red':
return Color(255,0,0)
elif color == 'green':
return Color(0,255,0)
elif color == 'yellow':
return Color(255,255,0)
elif color == 'off':
return Color(0,0,0)
elif color == 'blue':
return Color(0,0,255)
elif color == 'orange':
return Color(255,97,0)
elif color == 'cyan':
return Color(0,255,255)
elif color == 'firebrick':
return Color(178,34,34)
elif color == 'purple':
return Color(128,0,128)
elif color == 'forestgreen':
return Color(34,139,34)
elif color == 'lightblue':
return Color(173,216,230)
elif color == 'indianred':
return Color(205,92,92)
elif color == 'skyblue':
return Color(135,206,235)
elif color == 'pink':
return Color(255,192,203)
elif color == 'darkgreen':
return Color(0,100,0)
elif color == 'white':
return Color(255,255,255)
elif color == 'magenta':
return Color(255,0,255)
else:
return Color(255,255,255)
# noinspection PyProtectedMember
def _cleanup_strip(strip: Adafruit_NeoPixel):
strip._cleanup()
\ No newline at end of file
#setcolor('#eeFeee')
\ No newline at end of file
# Translations template for PROJECT.
# Copyright (C) 2021 ORGANIZATION
# Copyright (C) 2022 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2021-04-19 15:19+0800\n"
"POT-Creation-Date: 2022-05-11 16:02+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.0\n"
"Generated-By: Babel 2.9.1\n"
#: templates/base.html:6 templates/ledtest.html:6 templates/shelfconfig.html:6
msgid "智能料架系统"
#: post.py:290
msgid "关闭成功"
msgstr ""
#: templates/base.html:26 templates/ledtest.html:24
#: templates/shelfconfig.html:80
msgid "亮灯料架"
#: post.py:293
msgid "无需关闭"
msgstr ""
#: templates/base.html:30 templates/ledtest.html:28
#: templates/shelfconfig.html:84
msgid "控制"
#: post.py:397
msgid "未进行测试动作"
msgstr ""
#: templates/base.html:31 templates/ledtest.html:29
#: templates/shelfconfig.html:85
msgid "测试"
#: routes.py:53 routes.py:382
msgid "加载成功"
msgstr ""
#: templates/base.html:32 templates/ledtest.html:30
#: templates/shelfconfig.html:86
msgid "料架配置"
#: routes.py:56
msgid "加载失败,请在配置页面上传配置文件"
msgstr ""
#: templates/base.html:58 templates/ledtest.html:46
#: templates/shelfconfig.html:102
#: routes.py:139 templates/ledtest.html:30 templates/ledtest.html:86
msgid "通道"
msgstr ""
#: routes.py:139
msgid "状态灯"
msgstr ""
#: routes.py:246
msgid "灯地址:{},已点亮"
msgstr ""
#: routes.py:292
msgid "灯地址:{},已关闭"
msgstr ""
#: routes.py:306
msgid "灯条已重置"
msgstr ""
#: routes.py:386
msgid "重新加载失败,请在配置页面上传配置文件"
msgstr ""
#: routes.py:421
msgid "灯条:{},颜色:{},已开启"
msgstr ""
#: routes.py:437
msgid "灯条:{}已关闭"
msgstr ""
#: templates/base.html:6 templates/ledtest.html:6 templates/shelfconfig.html:6
msgid "智能料架系统"
msgstr ""
#: templates/base.html:25 templates/ledtest.html:22
#: templates/shelfconfig.html:78
msgid "料架系统"
msgstr ""
#: templates/base.html:63
#: templates/base.html:30
msgid "开关"
msgstr ""
#: templates/base.html:66
#: templates/base.html:33
msgid "启动"
msgstr ""
#: templates/base.html:67
#: templates/base.html:34
msgid "停止"
msgstr ""
#: templates/base.html:75 templates/ledtest.html:159
#: templates/shelfconfig.html:155
#: templates/base.html:42 templates/ledtest.html:136
#: templates/shelfconfig.html:132
msgid "提醒消息"
msgstr ""
#: templates/base.html:80 templates/ledtest.html:164
#: templates/shelfconfig.html:160
#: templates/base.html:47 templates/ledtest.html:141
#: templates/shelfconfig.html:137
msgid "运行状态"
msgstr ""
#: templates/base.html:85 templates/ledtest.html:174
#: templates/shelfconfig.html:165
#: templates/base.html:52 templates/ledtest.html:151
#: templates/shelfconfig.html:142
msgid "配置文件加载状态"
msgstr ""
#: templates/base.html:90 templates/shelfconfig.html:125
#: templates/shelfconfig.html:170
#: templates/base.html:57 templates/shelfconfig.html:101
#: templates/shelfconfig.html:147
msgid "服务器地址"
msgstr ""
#: templates/base.html:95 templates/shelfconfig.html:131
#: templates/shelfconfig.html:175
#: templates/base.html:62 templates/shelfconfig.html:107
#: templates/shelfconfig.html:152
msgid "料架编号"
msgstr ""
#: templates/base.html:100
#: templates/base.html:67
msgid "服务器连接状态"
msgstr ""
#: templates/base.html:109 templates/ledtest.html:153
#: templates/shelfconfig.html:149
#: templates/base.html:76 templates/ledtest.html:130
#: templates/shelfconfig.html:126
msgid "运行日志&状态信息"
msgstr ""
#: templates/base.html:114
#: templates/base.html:81
msgid "日志下载"
msgstr ""
#: templates/base.html:117
#: templates/base.html:84
msgid "下载日志"
msgstr ""
#: templates/base.html:124
#: templates/base.html:91
msgid "日志"
msgstr ""
#: templates/ledtest.html:51
msgid "灯条测试"
#: templates/base.html:118 templates/base.html:142 templates/base.html:165
#: templates/ledtest.html:197 templates/ledtest.html:209
#: templates/shelfconfig.html:181 templates/shelfconfig.html:262
msgid "运行中"
msgstr ""
#: templates/ledtest.html:54 templates/ledtest.html:110
msgid "通道"
#: templates/base.html:119 templates/base.html:143 templates/base.html:166
#: templates/ledtest.html:198 templates/shelfconfig.html:263
msgid "已关闭"
msgstr ""
#: templates/base.html:120 templates/base.html:144 templates/base.html:167
#: templates/ledtest.html:199 templates/shelfconfig.html:264
msgid "未初始化"
msgstr ""
#: templates/base.html:125
msgid "启动失败"
msgstr ""
#: templates/base.html:149
msgid "停止失败"
msgstr ""
#: templates/base.html:173 templates/ledtest.html:204
#: templates/shelfconfig.html:273
msgid "未获取到状态信息"
msgstr ""
#: templates/head.html:29
msgid "亮灯料架"
msgstr ""
#: templates/head.html:33
msgid "控制"
msgstr ""
#: templates/head.html:34
msgid "测试"
msgstr ""
#: templates/head.html:35
msgid "料架配置"
msgstr ""
#: templates/ledtest.html:27
msgid "灯条测试"
msgstr ""
#: templates/ledtest.html:61 templates/ledtest.html:89
#: templates/ledtest.html:117
#: templates/ledtest.html:37 templates/ledtest.html:65
#: templates/ledtest.html:93
msgid "颜色"
msgstr ""
#: templates/ledtest.html:71
#: templates/ledtest.html:47
msgid "灯条全开"
msgstr ""
#: templates/ledtest.html:72
#: templates/ledtest.html:48
msgid "灯条关闭"
msgstr ""
#: templates/ledtest.html:78
#: templates/ledtest.html:54
msgid "库位操作测试"
msgstr ""
#: templates/ledtest.html:81
#: templates/ledtest.html:57
msgid "库位"
msgstr ""
#: templates/ledtest.html:99 templates/ledtest.html:125
#: templates/ledtest.html:75 templates/ledtest.html:102
msgid "亮灯"
msgstr ""
#: templates/ledtest.html:100 templates/ledtest.html:126
#: templates/ledtest.html:76 templates/ledtest.html:103
msgid "灭灯"
msgstr ""
#: templates/ledtest.html:101
#: templates/ledtest.html:77
msgid "重置"
msgstr ""
#: templates/ledtest.html:107
#: templates/ledtest.html:83
msgid "状态灯测试"
msgstr ""
#: templates/ledtest.html:133
#: templates/ledtest.html:110
msgid "下载库位二维码"
msgstr ""
#: templates/ledtest.html:145
#: templates/ledtest.html:122
msgid "下载二维码"
msgstr ""
#: templates/ledtest.html:147
#: templates/ledtest.html:124
msgid "单个二维码尺寸(含白色底框)尺寸为16*16mm,黑码尺寸为10*10mm"
msgstr ""
#: templates/ledtest.html:169
#: templates/ledtest.html:146
msgid "测试消息"
msgstr ""
#: templates/shelfconfig.html:107
#: templates/ledtest.html:210 templates/shelfconfig.html:182
msgid "料架运行中,请关闭后再进行测试"
msgstr ""
#: templates/shelfconfig.html:83
msgid "配置文件"
msgstr ""
#: templates/shelfconfig.html:111
#: templates/shelfconfig.html:87
msgid "选择文件"
msgstr ""
#: templates/shelfconfig.html:114
#: templates/shelfconfig.html:90
msgid "上传"
msgstr ""
#: templates/shelfconfig.html:120
#: templates/shelfconfig.html:96
msgid "服务器配置"
msgstr ""
#: templates/shelfconfig.html:135
#: templates/shelfconfig.html:102
msgid "请填入服务器地址"
msgstr ""
#: templates/shelfconfig.html:108
msgid "请填入料架编号"
msgstr ""
#: templates/shelfconfig.html:111
msgid "保存"
msgstr ""
#: templates/shelfconfig.html:140
#: templates/shelfconfig.html:116
msgid "控制器备份&升级"
msgstr ""
#: templates/shelfconfig.html:144
#: templates/shelfconfig.html:120
msgid "料架升级"
msgstr ""
#: templates/shelfconfig.html:180
#: templates/shelfconfig.html:121
msgid "teamview"
msgstr ""
#: templates/shelfconfig.html:157
msgid "操作提醒"
msgstr ""
#: templates/shelfconfig.html:185
#: templates/shelfconfig.html:162
msgid "软件版本"
msgstr ""
#: templates/shelfconfig.html:192
msgid "请选择文件"
msgstr ""
#: templates/shelfconfig.html:196
msgid "文件限制最大"
msgstr ""
#: templates/shelfconfig.html:212
msgid "上传完成!"
msgstr ""
#: templates/shelfconfig.html:215
msgid "上传失败!"
msgstr ""
#: templates/shelfconfig.html:228
msgid "不能提交空数据"
msgstr ""
#: templates/shelfconfig.html:240
msgid "保存成功"
msgstr ""
#: templates/shelfconfig.html:280
msgid "检查并升级最新最新版本"
msgstr ""
#: templates/shelfconfig.html:292 templates/shelfconfig.html:314
msgid "升级成功,请刷新浏览器"
msgstr ""
#: templates/shelfconfig.html:297 templates/shelfconfig.html:319
msgid "已取消"
msgstr ""
#: templates/shelfconfig.html:302
msgid "确认打开"
msgstr ""
......@@ -5,7 +5,7 @@ from app import app
import json
import time
import pexpect
import neopixel
#import neopixel
import os
import requests
import threading
......@@ -13,13 +13,14 @@ import re
import csv
from time import sleep
from config import Config
from rpi_ws281x import Adafruit_NeoPixel, Color,PixelStrip
import RPi.GPIO as GPIO
from app.led_strip import get_strip
#from rpi_ws281x import Adafruit_NeoPixel, Color,PixelStrip
#import RPi.GPIO as GPIO
from app.led_strip import get_strip, Color,setcolor
from app.routes import config_dict,SET_CHANNEL,SET_LED_CHANNEL
from app import driver_gpio
import logging
import random
from flask_babel import Babel, gettext as _
basepath = os.path.dirname(__file__)
statusgreenA = False
......@@ -50,7 +51,7 @@ def read_state():
return state
def read_version():
uploads_path = basepath + Config.STATE_PATH
uploads_path = basepath + "/"
with open(uploads_path + "version.txt","r") as f:
s_version=f.readline()
return s_version
......@@ -72,7 +73,8 @@ def confirm_ip(data):
def confirm_autostart():
server_add = ip_config['ip'] + '/accshelf/' + ip_config['cid']
#server_add = ip_config['ip'] + '/storage/accShelf/' + ip_config['cid']
server_add =ip_config['ip'].rstrip("/").rstrip("-core")
line1 = "Comment = star chrome and enter the website for \"{}\"".format(server_add)
line2 = "Exec = chromium-browser -kiosk \"{}\"".format(server_add)
strs=["[Desktop Entry]","Name = Chrome Autostar","Type = Application"]
......@@ -85,7 +87,7 @@ def confirm_autostart():
cmd = "chmod 777 " + filename
run = pexpect.spawn('su -c "%s" root' %cmd)
time.sleep(0.5)
run.sendline('xxx')
run.sendline('123')
time.sleep(0.1)
with open("/home/pi/.config/autostart/auto.desktop","a") as f:
for i in strs:
......@@ -96,7 +98,7 @@ def confirm_autostart():
cmd = "chmod 777 " + filename
run = pexpect.spawn('su -c "%s" root' %cmd)
time.sleep(0.5)
run.sendline('xxx')
run.sendline('123')
time.sleep(0.1)
with open("/home/pi/.config/autostart/auto.desktop","a") as f:
for i in strs:
......@@ -134,10 +136,10 @@ def process_open_post(single,channel,led_index):
if channel == '1' or channel == '2':
if len(single) == 1:
post_leds[channel][led_index] = Config.DEFAULT_COLOR
logging.warning("库位灯开启:{},灯索引:{},颜色:red".format(single[0],led_index))
logging.warning("库位灯开启s1:{},灯索引:{},颜色:{}".format(single[0],led_index,Config.DEFAULT_COLOR))
elif len(single) == 2:
post_leds[channel][led_index] = single[1]
logging.warning("库位灯开启:{},灯索引:{},颜色:{}".format(single[0],led_index,single[1]))
logging.warning("库位灯开启s2:{},灯索引:{},颜色:{}".format(single[0],led_index,single[1]))
else:
post_leds[channel][led_index] = single[1] + '@blink'
logging.warning("库位灯开启闪烁:{},灯索引:{},颜色:{}".format(single[0],led_index,single[1]))
......@@ -204,7 +206,7 @@ def resolve_data(datajson):
else:
channels += ['1','2']
else:
logging.warning("未找到库位:{}".format(config_dict.get(single[0])))
logging.warning("未找到库位:{},{}".format(stock,config_dict.get(single[0])))
logging.warning("库位灯有open指令")
if 'close' in operation.keys():
offstock = operation['close'].split("|")
......@@ -219,7 +221,7 @@ def resolve_data(datajson):
else:
channels += ['1','2']
else:
logging.warning("未找到库位:{}".format(config_dict.get(single[0])))
logging.warning("未找到库位:{},{}".format(stock,config_dict.get(single[0])))
logging.warning("库位灯有关闭指令")
if 'closeAll' in operation.keys():
process_closeall_post()
......@@ -249,16 +251,21 @@ def light_led(channels,wait=50):
def startpost():
global is_start
state = read_state()
if state == 'off':
confirm_state('on')
is_start = True
threads = []
threads.append(threading.Thread(target=serverpost))
for t in threads:
t.start()
msg = '启动成功'
current_state = 'on'
logging.warning("启动成功")
if state != 'on':
if ip_config['ip'].strip()=='':
msg = '启动失败'
current_state = 'off'
logging.warning("启动失败,没有服务器地址")
else:
confirm_state('on')
is_start = True
threads = []
threads.append(threading.Thread(target=serverpost))
for t in threads:
t.start()
msg = '启动成功'
current_state = 'on'
logging.warning("启动成功")
else:
msg = '正在运行状态'
current_state = 'on'
......@@ -274,17 +281,17 @@ def startpost():
def stoppost():
global is_start
state = read_state()
if state == 'on':
if state != 'off':
confirm_state('off')
is_start=False
# status_light('off')
reset_strip()
ip_config['post'] = 'wait'
logging.warning("关闭成功")
msg = '关闭成功'
msg = _('关闭成功')
current_state = 'off'
else:
msg = '无需关闭'
msg = _('无需关闭')
current_state = 'off'
logging.warning("无需关闭")
info = []
......@@ -388,7 +395,7 @@ def getstate():
current_state = read_state()
state_info = []
version = read_version()
c_dict = {'state':current_state,'msg':'未进行测试动作','ipconfig':ip_config,'version':version}
c_dict = {'state':current_state,'msg':_('未进行测试动作'),'ipconfig':ip_config,'version':version}
state_info.append(c_dict)
return json.dumps(state_info)
......@@ -427,24 +434,10 @@ def reset_strip():
check_leds()
def setcolor(color):
color = color.lower()
if color == 'red':
return Color(0,255,0)
elif color == 'green':
return Color(255,0,0)
elif color == 'yellow':
return Color(255,255,0)
elif color == 'off':
return Color(0,0,0)
elif color == 'blue':
return Color(0,0,255)
else:
return Color(0,255,255)
# 开机启动请求服务器动作
'''
state = read_state()
if state == 'off':
confirm_state('on')
......@@ -454,7 +447,10 @@ threads = []
threads.append(threading.Thread(target=serverpost))
for t in threads:
t.start()
logging.warning("启动成功")
'''
http://192.168.1.115:8080,8484
,8484
......
.ew-alpha-slider-bg,.ew-alpha-slider-thumb,.ew-alpha-slider-wrapper,.ew-color-black-panel,.ew-color-cursor,.ew-color-drop-btn-group,.ew-color-picker,.ew-color-picker-arrow,.ew-color-picker-no,.ew-color-slider-thumb,.ew-color-white-panel{position:absolute}.ew-alpha-slider-bar,.ew-color-drop-container,.ew-color-mode-container .ew-color-mode-down,.ew-color-mode-container .ew-color-mode-up,.ew-color-panel,.ew-color-picker-arrow-left,.ew-color-picker-arrow-right,.ew-color-picker-box,.ew-color-slider,.ew-color-slider-bar{position:relative}.ew-alpha-slider-thumb,.ew-color-drop-btn,.ew-color-input,.ew-color-slider,.ew-color-slider-thumb{-webkit-box-sizing:border-box;box-sizing:border-box}.ew-alpha-slider-bar,.ew-alpha-slider-thumb,.ew-color-drop-btn,.ew-color-panel,.ew-color-picker-box,.ew-color-slider-bar,.ew-color-slider-thumb,.ew-pre-define-color{cursor:pointer}.ew-color-input,.ew-color-picker,.ew-color-picker-arrow-left,.ew-color-picker-arrow-right,.ew-color-picker-box,.ew-color-sure{background-color:#fff}.ew-color-drop-btn,.ew-color-input,.ew-color-picker-box,.ew-pre-define-color{outline:none}.ew-color-drop-btn,.ew-color-input,.ew-color-picker-arrow-left,.ew-color-picker-arrow-right,.ew-color-picker-box{display:inline-block}.ew-color-picker .ew-color-picker-content:after,.ew-pre-define-color-container:after{content:"";display:table;clear:both}.ew-color-slider.ew-is-vertical .ew-alpha-slider-bar,.ew-color-slider.ew-is-vertical .ew-color-slider-bar,.ew-pre-define-color{float:left}.ew-color-drop-btn,.ew-color-picker-no{text-align:center}.ew-color-picker{min-width:320px;-webkit-box-sizing:content-box;box-sizing:content-box;border:1px solid #ebeeff;-webkit-box-shadow:0 4px 15px rgba(0,0,0,.2);box-shadow:0 4px 15px rgba(0,0,0,.2);border-radius:5px;z-index:10;padding:7px;text-align:left;display:none}.ew-color-picker.ew-color-picker-disabled *{cursor:not-allowed}.ew-color-picker-content{margin-bottom:6px}.ew-color-panel{width:280px;height:180px}.ew-alpha-slider-bg,.ew-alpha-slider-wrapper,.ew-color-black-panel,.ew-color-picker-arrow,.ew-color-picker-no,.ew-color-white-panel{left:0;right:0;top:0;bottom:0}.ew-color-white-panel{background:-webkit-gradient(linear,left top,right top,from(#fff),to(hsla(0,0%,100%,0)));background:linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.ew-color-black-panel{background:-webkit-gradient(linear,left bottom,left top,from(#000),to(transparent));background:linear-gradient(0deg,#000,transparent)}.ew-color-slider.ew-is-vertical{width:27px;height:180px;float:right}.ew-color-slider.ew-is-horizontal{width:100%;height:14px}.ew-color-slider.ew-is-vertical .ew-color-slider-bar{background:-webkit-gradient(linear,left top,left bottom,color-stop(0,red),color-stop(17%,#ff0),color-stop(33%,#0f0),color-stop(50%,#0ff),color-stop(67%,#00f),color-stop(83%,#f0f),to(red));background:linear-gradient(180deg,red,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red);margin-left:3px}.ew-color-slider.ew-is-horizontal .ew-color-slider-bar{background:-webkit-gradient(linear,left top,right top,color-stop(0,red),color-stop(17%,#ff0),color-stop(33%,#0f0),color-stop(50%,#0ff),color-stop(67%,#00f),color-stop(83%,#f0f),to(red));background:linear-gradient(90deg,red,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.ew-color-slider.ew-is-vertical .ew-alpha-slider-bar,.ew-color-slider.ew-is-vertical .ew-color-slider-bar{width:12px;height:100%}.ew-color-slider.ew-is-horizontal .ew-alpha-slider-bar,.ew-color-slider.ew-is-horizontal .ew-color-slider-bar{width:100%;height:12px}.ew-color-slider.ew-is-horizontal .ew-alpha-slider-bar{margin-top:3px}.ew-alpha-slider-wrapper,.ew-pre-define-color.ew-has-alpha{background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==")}.ew-alpha-slider-thumb,.ew-color-slider-thumb{left:0;top:0;border-radius:1px;background:#fff;border:1px solid #f0f0f0;-webkit-box-shadow:0 0 2px rgba(0,0,0,.6);box-shadow:0 0 2px rgba(0,0,0,.6)}.ew-color-slider.ew-is-horizontal .ew-alpha-slider-thumb,.ew-color-slider.ew-is-horizontal .ew-color-slider-thumb{width:4px;height:100%}.ew-color-slider.ew-is-vertical .ew-alpha-slider-thumb,.ew-color-slider.ew-is-vertical .ew-color-slider-thumb{width:12px;height:4px}.ew-color-cursor{left:100%;top:0;cursor:default;width:4px;height:4px;-webkit-transform:translate(-2px,-2px);transform:translate(-2px,-2px);border-radius:50%;-webkit-box-shadow:0 0 0 3px #fff,inset 0 0 2px 2px rgba(0,0,0,.4),0 0 2px 3px rgba(0,0,0,.5);box-shadow:0 0 0 3px #fff,inset 0 0 2px 2px rgba(0,0,0,.4),0 0 2px 3px rgba(0,0,0,.5);-webkit-transform:translate(-6px,-6px);transform:translate(-6px,-6px)}.ew-color-drop-container{margin-top:6px;padding-top:4px;min-height:28px;border-top:1px solid #cdcdcd}.ew-has-mode-container .ew-color-input{width:210px}.ew-has-mode-container .ew-color-mode-container{margin-left:3px}.ew-color-input{width:160px;height:28px;line-height:28px;border:1px solid #dcdfe6;padding:0 5px;-webkit-transition:border-color .2s cubic-bezier(.175,.885,.32,1.275);transition:border-color .2s cubic-bezier(.175,.885,.32,1.275);border-radius:5px}.ew-color-input:not(.ew-input-disabled):focus{border-color:#239fe6}.ew-color-drop-btn{padding:5px;font-size:12px;border-radius:3px;-webkit-transition:.1s;transition:.1s;font-weight:500;margin:0;white-space:nowrap;color:#606266;border:1px solid #dcdfe6;letter-spacing:1px}.ew-color-drop-btn-group{right:0;top:5px}.ew-color-clear{color:#4096ef;border-color:transparent;background-color:transparent;padding-left:0;padding-right:0}.ew-color-clear:active,.ew-color-clear:hover{color:#66b1ff}.ew-color-sure{margin-left:10px}.ew-color-sure:active,.ew-color-sure:hover{border-color:#4096ef;color:#4096ef}.ew-pre-define-color-container{width:280px;font-size:12px;margin-top:8px}.ew-pre-define-color-container:after{visibility:hidden;height:0}.ew-pre-define-color{margin:0 0 8px 8px;width:20px;height:20px;border-radius:4px;border:1px solid #9b979b}.ew-pre-define-color-item{height:100%;border-radius:3px}.ew-pre-define-color.ew-pre-define-color-disabled{cursor:not-allowed}.ew-pre-define-color:nth-child(10n+1){margin-left:0}.ew-pre-define-color:not(.ew-pre-define-color-disabled):active,.ew-pre-define-color:not(.ew-pre-define-color-disabled):hover{opacity:.8}.ew-pre-define-color-active{-webkit-box-shadow:0 0 3px 2px #409eff;box-shadow:0 0 3px 2px #409eff}.ew-color-picker-box{border:1px solid #dcdee2;color:#535353;border-radius:4px;padding:4px 7px;line-height:1.5;font-size:14px;-webkit-transition:border-color .2s cubic-bezier(.175,.885,.32,1.275);transition:border-color .2s cubic-bezier(.175,.885,.32,1.275)}.ew-color-input.ew-input-disabled,.ew-color-picker-box-disabled{background-color:#ebe7e7;cursor:not-allowed}.ew-color-picker-arrow,.ew-color-picker-no{width:20px;height:20px;margin:auto;z-index:3}.ew-color-picker-no{width:40px;height:40px;font-size:20px;line-height:40px;color:#5e535f;border:1px solid #e2dfe2;border-radius:2px}.ew-color-picker-arrow{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.ew-color-picker-arrow-left,.ew-color-picker-arrow-right{width:12px;height:1px}.ew-color-picker-arrow-left{-webkit-transform:rotate(45deg);transform:rotate(45deg)}.ew-color-picker-arrow-right{-webkit-transform:rotate(-45deg);transform:rotate(-45deg);right:3px}.ew-color-mode-container{display:inline-block;vertical-align:middle;padding:6px;border-radius:2px}.ew-color-mode-container:hover{background-color:#ebe7e7}.ew-color-mode-container .ew-color-mode-down,.ew-color-mode-container .ew-color-mode-up{width:0;height:0;border-width:6px;border-style:solid;cursor:pointer}.ew-color-mode-container .ew-color-mode-up{bottom:5px;border-color:transparent transparent #606266}.ew-color-mode-container .ew-color-mode-down{top:5px;border-color:#606266 transparent transparent}.ew-color-mode-title{color:#535455;font-size:16px;display:inline-block;padding-right:2px}.ew-color-mode-title:after{content:":";display:inline-block}
\ No newline at end of file
......@@ -14,42 +14,9 @@
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">{{ _('亮灯料架') }}</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">{{ _('控制') }}</a></li>
<li><a href="{{ url_for('ledtest') }}">{{ _('测试') }}</a> </li>
<li><a href="{{ url_for('shelfconfig') }}">{{ _('料架配置') }}</a> </li>
</ul>
<ul class="navbar-nav navbar-right">
<div>
<a href="{{ url_for('set_language', language='zh') }}" >简体中文</a>
<a href="{{ url_for('set_language', language='en') }}" >English</a>
</div>
<!-- <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li> -->
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
{% set index=1 %}
{% import 'head.html' as head with context%}
{{ head }}
<div class="container-fluid">
<div class="row">
......@@ -82,7 +49,7 @@
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('配置文件加载状态') }}:<span id="testinfo">{{ config_state }}</span>
{{ _('配置文件加载状态') }}:<span id="testinfo">{{ _('加载成功') if config_state else _('加载失败,请在配置页面上传配置文件') }}</span>
</p>
</div>
<div class="alert alert-info" role="alert">
......@@ -148,14 +115,14 @@
processData:false,
contentType:false,
success:function(data){
if (data[0].state == 'on') {$("#shelfstate").html("运行中");}
else if (data[0].state == 'off') {$("#shelfstate").html("已关闭");}
else {$("#shelfstate").html("未初始化");}
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
// console.log(data)
alert (data[0].msg)
},
error:function(e){
alert("启动失败");
alert("{{ _('启动失败') }}");
}
})
}
......@@ -172,14 +139,14 @@
processData:false,
contentType:false,
success:function(data){
if (data[0].state == 'on') {$("#shelfstate").html("运行中");}
else if (data[0].state == 'off') {$("#shelfstate").html("已关闭");}
else {$("#shelfstate").html("未初始化");}
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
console.log(data)
alert (data[0].msg)
},
error:function(e){
alert("停止失败");
alert("{{ _('停止失败') }}");
}
})
}
......@@ -195,15 +162,15 @@
contentType:false,
success:function(data){
console.log(data)
if (data[0].state == 'on') {$("#shelfstate").html("运行中");}
else if (data[0].state == 'off') {$("#shelfstate").html("已关闭");}
else {$("#shelfstate").html("未初始化");}
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
// $("#gpioconfig").html(data[0].gpio)
$("#ipconfig").html(data[0].ipconfig['ip'])
$("#ccid").html(data[0].ipconfig['cid'])
},
error:function(e){
alert("未获取到状态信息");
alert("{{ _('未获取到状态信息') }}");
}
})
}
......
<script>
function switchLanguage(language) {
$.ajax({
url: "/language/" + language,
type: "get",
//data: JSON.stringify(ionum),
//contentType: "application/json",
//dataType: 'json',
success: function (data) {
location.reload();
},
error: function (e) {
window.reload();
}
});
return false;
}
</script>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">{{ _('亮灯料架') }}</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li{{ " class=active" if index==1 }}><a href="{{ url_for('index') }}">{{ _('控制') }}</a></li>
<li{{ " class=active" if index==2 }}><a href="{{ url_for('ledtest') }}">{{ _('测试') }}</a> </li>
<li{{ " class=active" if index==3 }}><a href="{{ url_for('shelfconfig') }}">{{ _('料架配置') }}</a></li>
</ul>
<ul class="nav navbar-nav navbar-right" style="font-size: 14px;"">
<li><a href=" #" onclick="return switchLanguage('zh');">简体中文</a></li>
<li><a href="#" onclick="return switchLanguage('en');">English</a></li>
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
<div style="clear:both;"></div>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="/static/js/ipvalidate.js"></script>
<script>
function validateForm() {
var ipAddress = document.getElementById("new_ip").value;
var netmask = document.getElementById("new_mask").value;
var router = document.getElementById("router_ip").value;
var dhcp_check = document.getElementById("dhcp").checked
if (dhcp_check)
{
return true
}
// Check if the IP address and netmask are valid
if (!isValidIpAddress(ipAddress)) {
alert("Invalid IP address");
return false;
}
if (!isValidNetmask(netmask)) {
alert("Invalid netmask");
return false;
}
if (!isValidIpAddress(router)) {
alert("Invalid router address");
return false;
}
return true;
}
</script>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
}
form {
display: flex;
flex-direction: column;
margin:50px auto
}
div p {
font-size: 24px;
#font-weight: bold;
display: block;
margin: 20px auto;
}
input[type="text"], textarea {
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}
input[type="submit"] {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
display: block;
margin: 0 auto;
}
label, input, textarea {
margin-bottom: 10px;
}
label.remark-label {
font-size: 14px;
color: #999;
}
</style>
<title> </title>
</head>
<body>
<div >
<p> Network Configure</p>
<form action="/ip_config" method="post" onsubmit="return validateForm()">
IP Address: <input type="text" id="new_ip" name="new_ip"><label class="remark-label">For Example:192.168.10.10</label><br>
Network Mask: <input type="text" id="new_mask" name="new_mask"><label class="remark-label">For Example:255.255.255.0</label><br>
Default GateWay: <input type="text" id="router_ip" name="router_ip"><label class="remark-label">For Example:192.168.10.1</label><br>
<label for="dhcp">Enable DHCP:
<input type="checkbox" name="dhcp" id="dhcp"></label><br>
<div style="margin:50px auto;width:200px;">
<input type="submit" value="Submit">
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
......@@ -8,37 +8,16 @@
<link href="/static/css/bootstrap.min.css" rel="stylesheet">
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<!-引入颜色选择器的css样式-->
<link rel="stylesheet" href="/static/js/ew-color-picker.min.css">
<!--引入插件JavaScript-->
<script src="/static/js/ew-color-picker.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">{{ _('亮灯料架') }}</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="{{ url_for('index') }}">{{ _('控制') }}</a></li>
<li class="active"><a href="{{ url_for('ledtest') }}">{{ _('测试') }}</a> </li>
<li><a href="{{ url_for('shelfconfig') }}">{{ _('料架配置') }}</a> </li>
</ul>
<ul class="nav navbar-nav navbar-right">
<div>
<a href="{{ url_for('set_language', language='zh') }}" >简体中文</a>
<a href="{{ url_for('set_language', language='en') }}" >English</a>
</div>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
{% set index=2 %}
{% import 'head.html' as head with context%}
{{ head }}
<div class="container-fluid">
<div class="row">
......@@ -65,6 +44,16 @@
<option>green</option>
<option>blue</option>
<option>yellow</option>
<option>orange</option>
<option>cyan</option>
<option>firebrick</option>
<option>purple</option>
<option>forestgreen</option>
<option>lightblue</option>
<option>indianred</option>
<option>darkgreen</option>
<option>white</option>
<option>magenta</option>
</select>
</div>
<div class="col-sm-4">
......@@ -93,9 +82,21 @@
<option>green</option>
<option>blue</option>
<option>yellow</option>
<option>orange</option>
<option>cyan</option>
<option>firebrick</option>
<option>purple</option>
<option>forestgreen</option>
<option>lightblue</option>
<option>indianred</option>
<option>darkgreen</option>
<option>white</option>
<option>magenta</option>
<option>custom</option>
</select>
</div>
<div class="col-sm-4">
<color style=" float: left; margin: 0 5px 0 0;"></color>
<input type="button" value={{ _('亮灯') }} class="btn btn-warning" onclick="ledopen()"/>
<input type="button" value={{ _('灭灯') }} class="btn btn-info" onclick="ledoff()"/>
<input type="button" value={{ _('重置') }} class="btn btn-info" onclick="resetled()"/>
......@@ -172,7 +173,7 @@
</div>
<div class="alert alert-info" role="alert">
<p>
{{ _('配置文件加载状态') }}:<span>{{ config_state }}</span>
{{ _('配置文件加载状态') }}:<span>{{ _('加载成功') if config_state else _('加载失败,请在配置页面上传配置文件') }}</span>
</p>
</div>
<!-- <div class="alert alert-info" role="alert">
......@@ -202,7 +203,27 @@
</div>
<script>
const color = ewColorPicker.createColorPicker('color');
var custcolor="";
color.$Dom.rootElement.hidden=true;
color.config.sure = function(color){
custcolor=color;
console.log(color);
}
$('#indexcolor').change(function(obj){
var ic = document.getElementById("indexcolor").value;
if(ic == 'custom')
{
color.$Dom.rootElement.hidden=false;
}else{
color.$Dom.rootElement.hidden=true;
}
});
$(document).ready(function () {
getstate();
console.log('success');
});
......@@ -218,23 +239,29 @@
contentType:false,
success:function(data){
console.log(data)
if (data[0].state == 'on') {$("#shelfstate").html("运行中");}
else if (data[0].state == 'off') {$("#shelfstate").html("已关闭");}
else {$("#shelfstate").html("未初始化");}
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
// $("#shelfstate").html("<b>已关闭</b>")
$("#testinfo").html(data[0].msg)
},
error:function(e){
alert("未获取到状态信息");
alert("{{ _('未获取到状态信息') }}");
}
})
}
function statecheck(shelfstate){
if (shelfstate == "{{ _('运行中') }}") {
alert("{{ _('料架运行中,请关闭后再进行测试') }}")
return false;
}else
return true;
}
// 灯条测试
function lineledon(){
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == '运行中') {alert("料架运行中,请关闭后再进行测试")
}else {
if (statecheck(shelfstate))
{
var data = {"channel_num":document.getElementById("linechannel").value,
"channel_color":document.getElementById("linecolor").value}
console.log(data)
......@@ -256,8 +283,8 @@
function lineledoff(){
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == '运行中') {alert("料架运行中,请关闭后再进行测试")
} else {
if (statecheck(shelfstate))
{
var data = {"channel_num":document.getElementById("linechannel").value,
"channel_color":document.getElementById("linecolor").value}
// var form= new FormData(document.getElementById("test_form"));
......@@ -280,10 +307,18 @@
}
// 库位灯测试
function ledopen(){
var ic = document.getElementById("indexcolor").value;
var sendcolor = document.getElementById("indexcolor").value;
if(ic == 'custom')
{
sendcolor=custcolor;
}
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == '运行中') {alert("料架运行中,请关闭后再进行测试")
} else {
var data = {"light_led_color":document.getElementById("indexcolor").value,
if (statecheck(shelfstate)) {
var data = {"light_led_color":sendcolor,
"light_led":document.getElementById("led_address").value}
$.ajax({
url:"/ledopen",
......@@ -304,8 +339,7 @@
// 库位灯测试
function ledoff(){
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == '运行中') {alert("料架运行中,请关闭后再进行测试")
} else {
if (statecheck(shelfstate)) {
var data = {
"off_led":document.getElementById("led_address").value}
// console.log(data)
......@@ -328,8 +362,7 @@
// 状态灯测试
function workinglight(){
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == '运行中') {alert("料架运行中,请关闭后再进行测试")
} else {
if (statecheck(shelfstate)) {
var data = {
"workchannel":document.getElementById("workchannel").value,
"workcolor":document.getElementById("workcolor").value}
......@@ -353,8 +386,7 @@
function workingoff(){
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == '运行中') {alert("料架运行中,请关闭后再进行测试")
} else {
if (statecheck(shelfstate)) {
var data = {
"workchannel":document.getElementById("workchannel").value,
"workcolor":document.getElementById("workcolor").value}
......@@ -379,8 +411,7 @@
// 库位灯重置
function resetled(){
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == '运行中') {alert("料架运行中,请关闭后再进行测试")
} else {
if (statecheck(shelfstate)) {
$.ajax({
url:"/resetled",
type:"post",
......
......@@ -68,33 +68,9 @@
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">{{ _('亮灯料架') }}</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="{{ url_for('index') }}">{{ _('控制') }}</a></li>
<li><a href="{{ url_for('ledtest') }}">{{ _('测试') }}</a> </li>
<li class="active"><a href="{{ url_for('shelfconfig') }}">{{ _('料架配置') }}</a> </li>
</ul>
<ul class="nav navbar-nav navbar-right">
<div>
<a href="{{ url_for('set_language', language='zh') }}" >简体中文</a>
<a href="{{ url_for('set_language', language='en') }}" >English</a>
</div>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
{% set index=3 %}
{% import 'head.html' as head with context%}
{{ head }}
<div class="container-fluid">
<div class="row">
......@@ -123,13 +99,13 @@
<!-- <label for="cha" class="col-sm-3">服务器地址</label> -->
<div class="input-group">
<span class="input-group-addon">{{ _('服务器地址') }}:</span>
<input type="text" class="form-control" id="ip" placeholder="请填入服务器地址"/>
<input type="text" class="form-control" id="ip" placeholder="{{ _('请填入服务器地址') }}"/>
</div>
<br>
<!-- <label for="cha1" class="col-sm-3">料架编号</label> -->
<div class="input-group">
<span class="input-group-addon">{{ _('料架编号') }}:</span>
<input type="text" class="form-control" id="cid" placeholder="请填入料架编号"/>
<input type="text" class="form-control" id="cid" placeholder="{{ _('请填入料架编号') }}"/>
</div>
<br>
<input type="button" value={{ _('保存') }} class="btn btn-info" onclick="updateip()"/>
......@@ -200,18 +176,24 @@
// jsondata();
console.log('success');
});
function statecheck(shelfstate){
if (shelfstate == "{{ _('运行中') }}") {
alert("{{ _('料架运行中,请关闭后再进行测试') }}")
return false;
}else
return true;
}
function upfile() {
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == '运行中') {alert("料架运行中,请关闭后再进行配置")
}
else {
if (statecheck(shelfstate)) {
var fileObj = document.getElementById("FileUpload").files[0];
if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
alert("请选择文件");
alert("{{ _('请选择文件') }}");
return;
}if(fileObj.size>5242880)
{
alert("文件限制最大 5Mb");
alert("{{ _('文件限制最大') }} 5Mb");
return;
}
var formFile = new FormData();
......@@ -227,10 +209,10 @@
processData: false,//用于对data参数进行序列化处理 这里必须false
contentType: false, //必须
success: function (result) {
alert("上传完成!");
alert("{{ _('上传完成!') }}");
},
error: function (xmlrequest, textStatus, errorThrown) {
alert("上传失败!");
alert("{{ _('上传失败!') }}");
//alert("error:" + textStatus + errorThrown + ":" + JSON.stringify(xmlrequest));
console.log("error:" + textStatus + errorThrown + ":" + JSON.stringify(xmlrequest));
}
......@@ -240,12 +222,10 @@
function updateip(){
var shelfstate = document.getElementById("shelfstate").innerHTML
if (shelfstate == '运行中') {alert("料架运行中,请关闭后再进行配置")
}
else {
if (statecheck(shelfstate)) {
var data = {"ip":document.getElementById("ip").value,
"cid":document.getElementById("cid").value}
if (data['ip'] == ""&&data['cid'] == "") {alert("不能提交空数据")}
if (data['ip'] == ""&&data['cid'] == "") {alert("{{ _('不能提交空数据') }}")}
else {
$.ajax({
url:"/updateip",
......@@ -257,7 +237,7 @@
console.log(data)
$("#ipconfig").html(data[0].ip)
$("#ccid").html(data[0].cid)
alert("保存成功");
alert("{{ _('保存成功') }}");
},
error:function(e){
alert("error");
......@@ -279,9 +259,9 @@
contentType:false,
success:function(data){
console.log(data)
if (data[0].state == 'on') {$("#shelfstate").html("运行中");}
else if (data[0].state == 'off') {$("#shelfstate").html("已关闭");}
else {$("#shelfstate").html("未初始化");}
if (data[0].state == 'on') {$("#shelfstate").html("{{ _('运行中') }}");}
else if (data[0].state == 'off') {$("#shelfstate").html("{{ _('已关闭') }}");}
else {$("#shelfstate").html("{{ _('未初始化') }}");}
// $("#shelfstate").html("<b>已关闭</b>")
// $("#testinfo").html(data[0].msg)
// $("#gpioconfig").html(data[0].gpio)
......@@ -290,35 +270,14 @@
$("#version").html(data[0].version)
},
error:function(e){
alert("未获取到状态信息");
alert("{{ _('未获取到状态信息') }}");
}
})
}
// function backup(){
// if (confirm("确认备份")) {
// $.ajax({
// url:"/backup",
// type:"post",
// // data:JSON.stringify(data),
// contentType: "application/json",
// dataType: 'json',
// success:function(data){
// $("#operation").html(data.operation)
// alert("backup success");
// },
// error:function(e){
// alert("error");
// }
// })
// }
// else {
// alert("已取消");
// }
// }
function upgrade(){
if (confirm("检查并升级最新最新版本")) {
if (confirm("{{ _('检查并升级最新最新版本') }}")) {
$.ajax({
url:"/upgrade",
type:"post",
......@@ -330,17 +289,17 @@
alert(data.operation);
},
error:function(e){
alert("升级成功,请刷新浏览器");
alert("{{ _('升级成功,请刷新浏览器') }}");
}
})
}
else {
alert("已取消");
alert("{{ _('已取消') }}");
}
}
function openteamview(){
if (confirm("确认打开")) {
if (confirm("{{ _('确认打开') }}")) {
$.ajax({
url:"/openteamview",
type:"post",
......@@ -352,12 +311,12 @@
alert(data.operation);
},
error:function(e){
alert("升级成功,请刷新浏览器");
alert("{{ _('升级成功,请刷新浏览器') }}");
}
})
}
else {
alert("已取消");
alert("{{ _('已取消') }}");
}
}
......
1.51
\ No newline at end of file
......@@ -18,4 +18,4 @@ class Config(object):
ALLOWED_EXTENSIONS = set(['csv']) #限制上传文件格式
LOG_LEVEL = logging.WARNING
LOG_FOLDER = 'logs/smart.log'
DEFAULT_COLOR = 'red'
\ No newline at end of file
DEFAULT_COLOR = 'green'
\ No newline at end of file
此文件的差异太大,无法显示。
此文件类型无法预览
from flask import Flask
from flask_babel import Babel
from config import Config
import logging
from logging.handlers import RotatingFileHandler,TimedRotatingFileHandler
# from flask_socketio import SocketIO
def setup_log():
# 设置日志的记录等级
logging.basicConfig(level=Config.LOG_LEVEL) # 调试debug级
# 创建日志记录器,指明日志保存的路径、每个日志文件的最大大小、保存的日志文件个数上限
file_log_handler = RotatingFileHandler(Config.LOG_FOLDER, maxBytes=1024 * 1024 * 100, backupCount=10)
# 创建日志记录的格式 日志等级 输入日志信息的文件名 行数 日志信息
# log_file_handler = TimedRotatingFileHandler(filename='logs/smartshelf.log', when="D", interval=1, backupCount=3)
formatter = logging.Formatter('%(asctime)s : %(message)s')
# 为刚创建的日志记录器设置日志记录格式
file_log_handler.setFormatter(formatter)
# 为全局的日志工具对象(flask app使用的)添加日志记录器
logging.getLogger().addHandler(file_log_handler)
setup_log()
app = Flask(__name__)
babel = Babel(app)
app.config.from_object(Config)
LANGUAGES = {
"zh": "Chinese",
"en": "English",
"ja": "Japanese"
}
@babel.localeselector
def get_locale():
return request.accept_languages.best_match(LANGUAGES.keys())
from app import routes,post,led_strip,driver_gpio,autoback,qr_code
# return app
\ No newline at end of file
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件的差异太大,无法显示。
此文件类型无法预览
此文件的差异太大,无法显示。
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
此文件的差异太大,无法显示。
此文件类型无法预览
此文件的差异太大,无法显示。
此文件太大,无法显示。
此文件的差异太大,无法显示。
此文件太大,无法显示。
此文件类型无法预览
此文件类型无法预览
此文件的差异太大,无法显示。
此文件类型无法预览
此文件的差异太大,无法显示。
此文件类型无法预览
此文件的差异太大,无法显示。
此文件类型无法预览
此文件的差异太大,无法显示。
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!