In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to write a gas safety management system in Qt". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to write a gas safety management system in Qt".
I. Preface
In various software systems, data printing is also one of the commonly used functions. Generally speaking, the data results of the query will be exported to excel, and the data results of the query will be printed directly. The printer class QPrinter is provided in Qt. In the printsupport component, you can transfer the text content into QTextDocument, and then call the print method of QTextDocument to print the data. QTextDocument supports text in html format, so it is very extensible. We know the color of the table border, etc., can be expressed in html syntax, but it seems to support the content of html is not many, only part, the style is also the supporting part, but also enough, commonly used tables, borders, colors, margins, fonts, etc., are available, then ok.
In the previous article, the data was exported in xml format, while the export of pdf used to print to a pdf file in the print class, using html format data. Similarly, the only difference between printing data and exporting to pdf is to export to pdf and set the output format to PDF,printer.setOutputFormat (QPrinter::PdfFormat); then set the output file save location printer.setOutputFileName (fileName) In fact, the content of the organization is exactly the same. It is said that the new version of qt intends to encapsulate an independent QtPdf module. I don't know if the next version will be released, so that pdf files can be edited across platforms.
II. Functional features
Collect data port, support serial port + network port, serial port support free setting of serial number + baud rate, network support free setting of IP address + communication port, each port supports collection cycle, default one address per second, support setting communication timeout times, default 3 times, support maximum reconnection time, used to re-read offline devices.
Controller information, you can add the controller name, select the controller address + controller model, and set the number of detectors under the controller.
Detector information, can add tag, free to choose detector type, gas type, gas symbol, high reported value, low reported value, buffer value, clear zero value, whether enabled, alarm sound, background map, storage cycle, numerical conversion decimal places, alarm delay time, alarm type (HH,LL,HL) and so on.
Controller model + detector type + gas type + gas symbol, all can be configured freely.
Maps can be imported and deleted, and all detectors can be dragged and saved freely.
Port information + controller information + detector information, support import and export + export to excel+ printing.
Run record + alarm record + user record, support multi-condition combination query, such as time period + controller + detector, etc., all records can be exported to excel+ printing.
Records exported to excel support all versions of table files such as excel+wps and do not rely on software such as excel.
You can delete data within a specified time range, support automatic cleaning of early data, and set the maximum number of saved records.
Support alarm short message forwarding, support multiple receiving mobile phone numbers, you can set the sending interval, such as instant sending or sending all alarm messages once every 6 hours, the text message content is too long, automatically split multiple text messages.
Support alarm email forwarding, support multiple receiving mailboxes, can set sending interval, such as immediate sending or sending all alarm messages once every 6 hours, support attachment sending.
Overreport color + underreport color + normal color + 0 value color + curve background + curve color, etc., are free to choose.
The Chinese title + English title + logo path + copyright of the software can be set freely.
Provide switch settings for boot operation + alarm sound + automatic login + remember password and so on.
Alarm sound can be set to play the number of times, the interface provides 17 kinds of skin file selection.
Cloud data synchronization is supported, and the information of cloud database can be set, such as database name, user name + password, etc.
Support network forwarding and network reception, after the network reception is turned on, the software receives data from udp for analysis. Network forwarding supports multiple target IP, so it realizes the software of local collection, and freely transfers the data to the client to view the detector data at any time.
Automatically remember the user's last stay in the interface + other information, restart and apply automatically.
The alarm automatically switches to the corresponding map, and the detector button flashes.
Double-click the detector icon to control it back.
Support user rights management, administrator + operator two categories, user login + user exit, can remember the password and automatic login, more than three error messages and close the program.
Support four monitoring modes, equipment panel monitoring + map monitoring + table data monitoring + curve data monitoring, free to switch, four synchronous applications.
Support alarm relay linkage, a tag can link multiple modules and relay numbers across serial ports, and support many-to-many.
The local data store supports sqlite+mysql and remote data synchronization to the cloud database. Automatically reconnect.
The data collected by the local device is uploaded to the cloud in real time so that it can be extracted by other methods such as APP or web.
Two kinds of data sources are supported, one is serial port and network to collect equipment data through protocol, the other is database collection. The database acquisition mode can be used as a general system.
Comes with a device simulation tool that supports 16 device data simulations, as well as database data simulations to test data when there is no device.
The default communication protocol uses modbus protocol, and later increases the support of mqtt and other Internet of things protocols to make a general system.
Supports all windows operating systems + linux operating systems and other operating systems.
Third, effect picture
Core code # include "printapi.h" # include "qmutex.h" # include "qprintpreviewdialog.h" # include "qtextdocument.h" # include "qtextobject.h" QScopedPointer PrintAPI::self;PrintAPI * PrintAPI::Instance () {if (self.isNull ()) {static QMutex mutex; QMutexLocker locker (& mutex); if (self.isNull ()) {self.reset (new PrintAPI);}} return self.data () } PrintAPI::PrintAPI (QObject * parent): QObject (parent) {} void PrintAPI::print (const QString & title, const QString & subTitle, const QList & columnNames, const QList & columnWidths, const QStringList & content, bool landscape, bool check, int checkColumn, const QString & checkType, const QString & checkValue, const QPrinter::PageSize & pageSize) {/ / calculate rows and columns int columnCount = columnNames.count (); int rowCount = content.count () / / clear the original data to make sure that the new data is html.clear () each time; / / start the table with html.append (""); / / the title is on one line, centered on if (title.length () > 0) {html.append (QString (") .arg (columnCount)); html.append (title); html.append (") } / / subtitle on one line, left aligned display if (subTitle.length () > 0) {html.append (QString (") .arg (columnCount)); html.append (subTitle); html.append (");} / / write field name in a loop, field name on one line, center on if (columnCount > 0) {html.append (") For (int I = 0; I
< columnCount; i++) { html.append(QString("").arg(columnWidths.at(i))); html.append(columnNames.at(i)); html.append(""); } html.append(""); } //循环一行行构建数据 for (int i = 0; i < rowCount; i++) { QStringList value = content.at(i).split(";"); html.append(""); //过滤内容,如果启用了过滤数据,则将符合条件的数据突出颜色显示 bool existCheck = false; if (check) { if (checkType == "==") { if (value.at(checkColumn) == checkValue) { existCheck = true; } } else if (checkType == ">") {if (value.at (checkColumn) > checkValue) {existCheck = true;}} else if (checkType = =" > = ") {if (value.at (checkColumn) > = checkValue) {existCheck = true }} else if (checkType = = "") {if (value.at (checkColumn) > checkValue) {existCheck = true }} else if (checkType = = "> =") {if (value.at (checkColumn) > = checkValue) {existCheck = true;}} else if (checkType = "
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.