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

news2024/10/5 19:42:08
  1. 监测数据采集物联网应用开发步骤(2)

系统整体结构搭建

新建项目

输入项目名称:MonitorData

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

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()

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

程序执行结果:

恭喜你!系统整体结构搭建完成。

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/942035.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【从零开始学习JAVA | 第四十六篇】处理请求参数

前言&#xff1a; 在我们之前的学习中&#xff0c;我们已经基本学习完了JAVA的基础内容&#xff0c;从今天开始我们就逐渐进入到JAVA的时间&#xff0c;在这一大篇章&#xff0c;我们将对前后端有一个基本的认识&#xff0c;并要学习如何成为一名合格的后端工程师。今天我们介绍…

Apache Celeborn 让 Spark 和 Flink 更快更稳更弹性

摘要&#xff1a;本文整理自阿里云/数据湖 Spark 引擎负责人周克勇&#xff08;一锤&#xff09;在 Streaming Lakehouse Meetup 的分享。内容主要分为五个部分&#xff1a; Apache Celeborn 的背景Apache Celeborn——快Apache Celeborn——稳Apache Celeborn——弹Evaluation…

河湖长制综合管理信息平台建设项目总体设计方案[507页Word]

导读&#xff1a;原文《河湖长制综合管理信息平台建设项目总体设计方案[507页Word]》&#xff08;获取来源见文尾&#xff09;&#xff0c;本文精选其中精华及架构部分&#xff0c;逻辑清晰、内容完整&#xff0c;为快速形成售前方案提供参考。 部分内容&#xff1a; 1.1.1.3…

【conda install】网络慢导致报错CondaHTTPError: HTTP 000 CONNECTION FAILED for url

⭐⭐问题&#xff1a; 部署安装环境经常会出现由于网络慢问题&#xff0c;导致conda安装不了库&#xff0c;报错如下&#xff1a; Solving environment: failedCondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/…

什么是应用程序监控

应用程序监控是一项基本功能&#xff0c;可以对两者进行实时分析关键业务应用程序的前端和后端性能。应用程序监控起着至关重要的作用 通过提供对应用程序的宝贵见解来确保应用程序的不间断运行可用性、性能和最终用户体验。主动监控应用程序有助于快速识别和解决任何潜在问题&…

最新ChatGPT程序源码+AI系统+详细图文搭建教程/支持GPT4/AI绘画/H5端/完整Prompt知识库

一、AI系统 如何搭建部署人工智能源码、AI创作系统、ChatGPT系统呢&#xff1f;小编这里写一个详细图文教程吧&#xff01;SparkAi使用Nestjs和Vue3框架技术&#xff0c;持续集成AI能力到AIGC系统&#xff01; 1.1 程序核心功能 程序已支持ChatGPT3.5/GPT-4提问、AI绘画、Mi…

spring打入filter内存马+冰蝎成功

环境&#xff1a; springboot版本2.4.5 <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.4.5</version><relativePath/> <!-- lookup parent from r…

设计模式—观察者模式(Observer)

目录 思维导图 一、什么是观察者模式&#xff1f; 二、有什么优点吗&#xff1f; 三、有什么缺点吗&#xff1f; 四、什么时候使用观察者模式&#xff1f; 五、代码展示 ①、双向耦合的代码 ②、解耦实践一 ③、解耦实践二 ④、观察者模式 六、这个模式涉及到了哪些…

12.工作数字钟

效果 源码 <!doctype html> <html><head><meta charset="utf-8"><title>Digital Clock</title><link rel="stylesheet" href="style.css"></head><body><div id="time">…

开源项目的测试和质量保证

&#x1f337;&#x1f341; 博主猫头虎 带您 Go to New World.✨&#x1f341; &#x1f984; 博客首页——猫头虎的博客&#x1f390; &#x1f433;《面试题大全专栏》 文章图文并茂&#x1f995;生动形象&#x1f996;简单易学&#xff01;欢迎大家来踩踩~&#x1f33a; &a…

《Flink学习笔记》——第一章 概念及背景

​ 什么是批处理和流处理&#xff0c;然后由传统数据处理架构为背景引出什么是有状态的流处理&#xff0c;为什么需要流处理&#xff0c;而什么又是有状态的流处理。进而再讲解流处理的发展和演变。而Flink作为新一代的流处理器&#xff0c;它有什么优势&#xff1f;它的相关背…

短视频seo搜索矩阵系统源码----独立应用搭建

前言&#xff1a;抖音账号矩阵系统/抖音seo霸屏系统/抖音矩阵seo系统源码/独立部署,技术团队如何围绕抖音矩阵关键词霸屏来做开发&#xff1f;来做到抖音seo优化达到账号排名效果&#xff0c;关键词起到至关重要的作用&#xff0c;依托于抖音平台的正规权限。 当普通对象属性更…

启动项目时Service有却找不到而报错

解决方法&#xff0c;重启一下Idea&#xff0c;看是否可以&#xff0c;如果不行的话 点击File->setting中 勾上&#xff0c;重启一下。接可以了

PMAC与Modbus主站进行Modbus Tcp通讯

PMAC与Modbus主站进行Modbus Tcp通讯 创建modbus通讯参数 在项目的PMAC Script Language\Global Includes下创建一个名为00_Modbus_Para.pmh的pmh文件。 Modbus[0].Config.ServerPort 0 Modbus[0].Config.ConnectTimeOut 6000 Modbus[0].Config.SendRecvTimeOut 0 Modbu…

基于django框架的学生选课系统jsp学校教务信息java源代码Mysql

本项目为前几天收费帮学妹做的一个项目&#xff0c;Java EE JSP项目&#xff0c;在工作环境中基本使用不到&#xff0c;但是很多学校把这个当作编程入门的项目来做&#xff0c;故分享出本项目供初学者参考。 一、项目描述 基于django框架的学生选课系统 系统有2权限&#xff…

好用的电容笔有哪些推荐?适合开学季电容笔推荐

至于是用苹果原装的电容笔还是平替式电容笔&#xff0c;那就要看你自己的使用需求的了&#xff0c;例如常用于绘画上的话&#xff0c;就用苹果笔&#xff1b;如果你每天花在书写上的时间比花在画图上的时间还多&#xff0c;那么你可以考虑买一款便宜一点的平替电容笔。小编整理…

kettle的基础概念入门、下载、安装、部署

1、什么是ETL? 答&#xff1a;ETL&#xff08;Extract-Transform-Load的缩写&#xff0c;即数据抽取、转换、装载的过程&#xff09;&#xff0c;对于企业或行业应用来说&#xff0c;我们经常会遇到各种数据的处理&#xff0c;转换&#xff0c;迁移&#xff0c;所以了解并掌握…

测试人员的核心价值:Bug 要素

什么是Bug&#xff1f;只要不能满足预期的东西都可以称之为Bug。所以&#xff0c;Bug也是广义的Bug&#xff0c;可以分为功能Bug&#xff0c;性能Bug&#xff0c;安全Bug&#xff0c;甚至流程Bug。 对于一个Bug&#xff0c;优秀的测试工程师要能够定位Bug原因&#xff0c;并给…

Golang Gorm 一对多关系 表结构的建立

Belongs To belongs to 会与另一个模型建立了一对一的连接。 这种模型的每一个实例都“属于”另一个模型的一个实例。 例如&#xff0c;应用包含 user 和 company&#xff0c;并且每个 user 能且只能被分配给一个 company。 下面的类型就表示这种关系。 注意&#xff0c;在 U…

MR混合现实石油化工课堂情景实训教学演示

MR&#xff08;混合现实&#xff09;技术是一种结合了虚拟现实&#xff08;VR&#xff09;和增强现实&#xff08;AR&#xff09;优势的新型技术&#xff0c;在教育领域具有广阔的应用前景。在石油化工课堂中&#xff0c;MR混合现实情景实训教学的应用可以大大提高学生的学习效…