3、监测数据采集物联网应用开发步骤(3)

这篇具有很好参考价值的文章主要介绍了3、监测数据采集物联网应用开发步骤(3)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

源码将于最后一遍文章给出下载

  1. 监测数据采集物联网应用开发步骤(2)

系统整体结构搭建

新建项目

3、监测数据采集物联网应用开发步骤(3),物联网,python

输入项目名称:MonitorData

所谓兵马未动粮草先行,按下图创建好对应的模块备用:

3、监测数据采集物联网应用开发步骤(3),物联网,python

com.plugins                     业务插件模块

com.zxy.adminlog            日志或文本文件读写模块

com.zxy.autoUpdate       程序版本自动更新模块

com.zxy.business             通用业务处理模块

com.zxy.common            通用函数模块

com.zxy.comport             串口通讯模块

com.zxy.db_Self               静态接口配置库(Sqlit3)模块

com.zxy.db1                     静态接口配置库(Sqlit3)模块

com.zxy.db2                     业务数据库(Sqlite3)模块

com.zxy.interfaceReflect         通用插件管理模块

com.zxy.main                   全局变量初始化模块

com.zxy.taskhandler        定时器任务模块

com.zxy.tcp                      tcp协议模块

编写主程序代码MonitorDataCmd.py,打印启动时间,sleep 5秒,然后打印结束时间

#! python3
# -*- coding: utf-8 -
'''
Created on 2023年08月28日
@author: zxyong 13738196011
'''

import time
from com.zxy.common.Com_Fun import Com_Fun

#监测数据采集物联网应用-主程序
class MonitorDataCmd(object):

    def __init__(self, params):
        pass
    
    if __name__ == '__main__':
        print("监测数据采集物联网应用软件开始:"+Com_Fun.GetTimeDef())
        time.sleep(5)
        print("监测数据采集物联网应用软件结束:"+Com_Fun.GetTimeDef())

新建通用函数代码com.zxy.common.Com_Fun.py

#! python3
# -*- coding: utf-8 -
'''
Created on 2023年08月28日
@author: zxyong 13738196011
'''

import datetime,uuid,time
from datetime import timedelta

#监测数据采集物联网应用--通用函数
class Com_Fun():
        
    def __init__(self):
        pass
    
    @staticmethod
    def NoNull(objTag):
        if objTag is None:
            return ""
        else:
            return str(objTag)
    
    @staticmethod
    def FloatNull(objTag):
        if objTag is None or objTag == "" or objTag == "-":
            return 0
        else:
            return float(objTag)
        
    @staticmethod
    def ZeroNull(objTag):
        if objTag is None or objTag == "":
            return 0
        else:
            return int(objTag)
        
    @staticmethod
    def GetLong(inputTimeFormat,inputTime):
        if len(inputTime) > 19:
            inputTime = inputTime[0:19]
        time1=datetime.datetime.strptime(inputTime.replace("T"," "),inputTimeFormat)
        return time.mktime(time1.timetuple())

    #获得当前时间戳
    @staticmethod
    def getTimeLong():
        temT = datetime.datetime.now()
        timeStamp = time.mktime(temT.timetuple())
        return timeStamp

    #日期信息格式化timeFormat : '%Y-%m-%d %H:%M:%S'
    @staticmethod
    def GetTime(inputTimeFormat):
        return datetime.datetime.now().strftime(inputTimeFormat)
    
    #日期信息格式化秒数据10整数化
    @staticmethod
    def GetTimeNum(inputTime):
        temTime = datetime.datetime.strptime(inputTime.replace("T", " "),"%Y-%m-%d %H:%M:%S")
        temSB = temTime.strftime("%Y-%m-%d %H:%M")
        temSE = temTime.strftime("%S")
        temSec = int(int(temSE) / 10)
        return temSB+":"+str(temSec)+"0"
        
    #日期信息格式化timeFormat : '%Y-%m-%d %H:%M:%S'
    @staticmethod
    def GetTimeDef():
        return str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
    
    #日期信息格式化timeFormat : '%Y-%m-%d %H:%M:%S' 字符串
    @staticmethod
    def GetTimeInput(inputTimeFormat,inputTime):
        if inputTime is None or inputTime == "":
            return "1900-01-01 00:00:00"
        time1=datetime.datetime.strptime(inputTime.replace("T", " "),inputTimeFormat)
        return time1
    
    #日期信息格式化timeFormat : '%Y-%m-%d %H:%M:%S' 字符串
    @staticmethod
    def GetStrTimeInput(inputTimeFormat,inputTime):
        if inputTime is None or inputTime == "":
            return "1900-01-01 00:00:00"
        time1=datetime.datetime.strptime(inputTime.replace("T", " "),inputTimeFormat)
        return str(time1)
        
    #返回time格式
    @staticmethod
    def GetToTimeInput(inputTimeFormat,inputTime):
        if inputTime is None or inputTime == "":
            return "1900-01-01 00:00:00"
        elif len(inputTime) <= 19:
            return datetime.datetime.strptime(inputTime.replace("T"," "),inputTimeFormat)
        else:
            return datetime.datetime.strptime(inputTime[0:19],inputTimeFormat)
        
    #日期信息格式化timeFormat : '%Y-%m-%d %H:%M:%S',返回字符串格式
    @staticmethod
    def GetDateInput(inputDateFormat,inputTimeFormat,inputTime):
        if len(inputTime) < 10 or inputTime is None or  inputTime == "":
            return "1900-01-01"
        time1=datetime.datetime.strptime(inputTime.replace("T"," "),inputTimeFormat)
        return time1.strftime(inputDateFormat)
    
    #(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)
    @staticmethod
    def DateTimeAdd(inputDate,inputDateType,inputNum):
        #%d %H:%M:%S
        delta = None
        if inputDateType == "d":
            delta = timedelta(days=inputNum)
        elif inputDateType == "W":
            delta = timedelta(weeks=inputNum)
        elif inputDateType == "H":
            delta = timedelta(hours=inputNum)
        elif inputDateType == "M":
            delta = timedelta(minutes=inputNum)
        elif inputDateType == "S":
            delta = timedelta(seconds=inputNum)
        return inputDate + delta
        
    @staticmethod
    def SetHashTable(inputHt,inputStrKey,inputStrValue):
        if inputHt is None:
            inputHt = {}
        inputHt[inputStrKey] = inputStrValue
    
    @staticmethod
    def GetHashTable(inputHt,inputStrKey):
        if inputHt is None or inputStrKey not in list(inputHt.keys()):
            return ""
        else:
            return inputHt[inputStrKey]

    @staticmethod
    def GetHashTableNone(inputHt,inputStrKey):
        if inputHt is None or inputStrKey not in list(inputHt.keys()):
            return None
        else:
            return inputHt[inputStrKey]

    @staticmethod
    def RemoveHashTable(inputHt,inputStrKey):
        if inputHt.get(inputStrKey) is not None:
            inputHt.pop(inputStrKey)
    
    @staticmethod
    def Str_To_Int(inputStr):
        if inputStr is not None and inputStr != "":
            return int(inputStr)
        else:
            return 0
    
    @staticmethod
    def Get_New_GUID():
        return str(uuid.uuid1()).upper()

运行程序,选择主程序右键:

3、监测数据采集物联网应用开发步骤(3),物联网,python

程序执行结果:

3、监测数据采集物联网应用开发步骤(3),物联网,python

恭喜你!系统整体结构搭建完成。文章来源地址https://www.toymoban.com/news/detail-679084.html

  1. 监测数据采集物联网应用开发步骤(4)

到了这里,关于3、监测数据采集物联网应用开发步骤(3)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 11、监测数据采集物联网应用开发步骤(8.2)

    监测数据采集物联网应用开发步骤(8.1) 新建TCP/IP Client线程类 com.zxy.tcp.ClientThread.py 新建tcp client数据接收插件类1 com.plugins.Usereflect.testClientReflectClass1.py 新建tcp client数据接收插件类2 com.plugins.Usereflect.testClientReflectClass2.py 在 com.zxy.main.Init_Page.py 中添加代码 TCP Client测试案例 Monit

    2024年02月10日
    浏览(35)
  • 7、监测数据采集物联网应用开发步骤(5.3)

    监测数据采集物联网应用开发步骤(5.2) 静态配置库数据库调用,新建全局变量初始化类 com.zxy.main.Init_Page.py 数据库操作测试 MonitorDataCmd.py 主文件中编写: if __name__ == \\\'__main__\\\' : 下编写 程序执行成功结果:自动生成center_data.db 打印出数据库数据 小测试:把上文的sql语句故意语法

    2024年02月10日
    浏览(32)
  • 13、监测数据采集物联网应用开发步骤(9.2)

    监测数据采集物联网应用开发步骤(9.1) TCP/IP Server开发 新建TCP/IP Server线程类 com.zxy.tcp.ServerThread.py 新建作为TCP Server接收数据拦截器插件类 com.plugins.usereflect.testServerReflectInClass1.py 新建作为TCP Server接收数据拦截器插件类 com.plugins.usereflect.testServerReflectInClass2.py 在 com.zxy.main.Init_

    2024年02月10日
    浏览(34)
  • 物联网数据采集网关在工厂数字化转型中的应用

    物联网数据采集网关能将各种传感器、执行器等设备连接在一起,通过收集、处理和传输来自各种物理设备的信息,实现数据的集成和分析,同时可通过云平台进行数据交互。它具有数据转换、数据处理、数据传输等功能,是工厂数字化转型的核心组件。随着科技的飞速发展

    2024年02月22日
    浏览(47)
  • iNeuOS工业互联网操作系统,高效采集数据配置与应用

    1. 概述 2. 通讯原理 3. 参数配置  1.   概述 某生产企业世界500强的集团能源管控平台项目建设,通过专线网络实现异地厂区数据集成, 每个终端能源仪表都有 IP 地址,总共有1000 多台能源表计,总共有将近10000 个数据点 。在集团端部署iNeuOS工业互联网操作系统,终端能源表

    2024年02月05日
    浏览(44)
  • 【雕爷学编程】MicroPython手册之 ESP32-CAM 物联网图像数据采集应用

    MicroPython是为了在嵌入式系统中运行Python 3编程语言而设计的轻量级版本解释器。与常规Python相比,MicroPython解释器体积小(仅100KB左右),通过编译成二进制Executable文件运行,执行效率较高。它使用了轻量级的垃圾回收机制并移除了大部分Python标准库,以适应资源限制的微控制

    2024年02月20日
    浏览(36)
  • 嵌入式物联网单片机项目开发实例-4G DTU边缘数据采集网关开发

    链接:https://pan.baidu.com/s/163D-kElFqXov629YaSrWDw?pwd=1688 提取码:1688 [1.EC200S_STM32F103_4G CAT1网络TCP和UDP的透传字符串] [2.EC200S_STM32F103_4G CAT1网络TCP和UDP的透传十六进制包含0x00] [3.EC200S_STM32F103_4G CAT1通过外置MQTT协议发送定位和固定数据到ONENET] [4.EC200S_STM32F103_4G CAT1通过外置MQTT协议发送

    2024年01月16日
    浏览(43)
  • 【IoT物联网】IoT小程序在展示中央空调采集数据和实时运行状态上的应用

      利用前端语言实现跨平台应用开发似乎是大势所趋,跨平台并不是一个新的概念,“一次编译、到处运行”是老牌服务端跨平台语言Java的一个基本特性。随着时代的发展,无论是后端开发语言还是前端开发语言,一切都在朝着减少工作量,降低工作成本的方向发展。  

    2024年02月16日
    浏览(33)
  • 水库安全监测方案(实时数据采集、高速数据传输)

    ​ 一、引言 水库的安全监测对于防止水灾和保障人民生命财产安全至关重要。为了提高水库安全监测的效率和准确性,本文将介绍一种使用星创易联DTU200和SG800 5g工业路由器部署的水库安全监测方案。 二、方案概述 本方案主要通过使用星创易联DTU200和SG800 5g工业路由器实现

    2024年02月08日
    浏览(41)
  • 桥梁安全监测系统中数据采集上传用 什么?

    背景 2023年7月6日凌晨时分,G5012恩广高速达万段230公里加80米处6号大桥部分桥面发生垮塌,导致造成2车受损后自燃,3人受轻伤。目前,四川省公安厅交通警察总队高速公路五支队十四大队民警已对现场进行双向管制。 作为世界第一桥梁大国,目前我国公路桥梁数量超过100万

    2024年02月12日
    浏览(32)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包