资源简介

基于Python的跨平台GUI开发框架kivy搭建了燃料电池远程监控系统。可运行于Windows, Linux, Android, IOS等平台。

资源截图

代码片段和文件信息

 # -*- coding: utf-8 -*-   
#qpy:kivy

from kivy import require
require(‘1.9.0‘) # replace with your current kivy version !
from kivy.properties import StringProperty objectProperty ListProperty NumericProperty 
from kivy.uix.screenmanager import ScreenManager Screen FadeTransition
from kivy.clock import Clock
from kivy.app import App
from kivy.lang import Builder
from kivy.garden.graph import Graph MeshLinePlot
from kivy.uix.boxlayout import BoxLayout
import mysql.connector
import threading
import datetime
import time

# GLOBAL VARIABLES HERE:
localhost = ‘fuelcelldb.mysqldb.chinacloudapi.cn‘ # Server eg: localhost
dbname    = ‘fuelcelldb‘ # SQL Database Name.
dbuser    = ‘fuelcelldb%junge8830‘ # SQL Database Username.
dbpw      = ‘junGE8830‘ # SQL Database Password.
tablename = ‘parameters‘ # SQL Table name here.
ConnFlag = 0
descripID = {‘ID‘:0 ‘voltage‘:1 ‘current‘:2 ‘temperature‘:3 ‘timestamp‘:4}

RASPBERRYPI_NAME = ‘raspberrypi‘

global realtimegraph rtgraphupdate MeasureRTPlot Outdata
realtimegraph = None
rtgraphupdate = None
global MeasureRTPlotValue # for realtimegraph measurement line value
MeasureRTPlotValue = None
Outdata = []
# for offline graph measurement line value
global offlinegraph MeasurePlotValue
offlinegraph = None
MeasurePlotValue = None

class ConnThreading(threading.Thread):
    “““
    Thread to connection to database in the background without
    disturbing user interface.
    “““
    def __init__(self threadID name):
        threading.Thread.__init__(self)
        self.threadID = threadID
        self.name = name
    def run(self):
        print (“Starting “ + self.name)
        global conn cursor ConnFlag
        try:
            conn = mysql.connector.connect(host=localhost
                                  database=dbname
                                  user=dbuser
                                  password=dbpw)
            cursor = conn.cursor()
            ConnFlag = 1 # Set Connection Flag to 1 succeed so other function can be alerted.
            print (“DB connected successfully! Exiting “ + self.name)
        except mysql.connector.Error as e:
            print(“Connection fail Error Code: \n“e)
            # quit()
            # Codes to save to log file here
class PromptSuccess(threading.Thread):
    “““
    Thread to check the ConnThreading for connection completeness
    and to give return message to the displaytext input argument.
    “““
    def __init__(self threadID name threadtojoin displaytext):
        threading.Thread.__init__(self)
        self.threadID = threadID
        self.name = name
        self.displaytext = displaytext
        self.threadtojoin = threadtojoin
    def run(self):
        print (“Starting “ + self.name)
        self.threadtojoin.join()
        self.displaytext.text = “If there is no dataplease contact the author‘s mailbox zejunwen@qq.com!“






#### Individual 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-11-09 06:27  detection-and-control-system-for-fuel-cells-master\
     文件       14319  2017-11-09 06:27  detection-and-control-system-for-fuel-cells-master\KivyDesignFile.kv
     文件         161  2017-11-09 06:27  detection-and-control-system-for-fuel-cells-master\README.md
     文件       25933  2017-11-09 06:27  detection-and-control-system-for-fuel-cells-master\main.py

评论

共有 条评论