Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write Gas Safety Management system to realize short message alarm in Qt

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to write Qt to realize SMS alarm in gas safety management system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. Preface

The SMS alarm module has been used in many projects, such as the previously done security system, temperature and humidity alarm system, etc. The main process is to organize the SMS string content after receiving the data and judge that it belongs to some kind of alarm, and send it to the designated multiple mobile phone numbers, using SMS cat hardware equipment, in fact, it is a SMS module, and there is no network api for sending SMS. After all, most software application scenarios can not be connected to the external network, security considerations, so it is necessary to use local hardware to send text messages. This SMS cat device was first used 8 years ago, when C# was used to write a pure protocol parsing message to send and receive messages, and then rewrote it in Qt. Specially wrote a class SendMsgThread to encapsulate all the operations, so it can be used in any development environment, mastering the principle, starting from the underlying principle, there are still a lot of benefits. I think many beginners are keen to call the SDK encapsulated by third-party manufacturers. Once the operating system is changed, it is over, what about the SDK development package without embedded linux system.

Features of the general SMS receiving component:

The mode of sending and receiving SMS can be set.

Can send SMS messages in batch and support long SMS messages.

You can read SMS messages with specified serial number.

All SMS messages can be deleted

It can check whether the SMS cat device is normal.

Support for sending short messages in Chinese

Support to make a call + hang up the phone + answer an incoming call + identify user button feedback

Support to send to multiple numbers in batch

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 "sendserver.h" # include "quiwidget.h" # include "dbhelper.h" # include "devicehelper.h" # include "sendmsgthread.h" # include "sendemailthread.h" QScopedPointer SendServer::self;SendServer * SendServer::Instance () {if (self.isNull ()) {static QMutex mutex; QMutexLocker locker (& mutex); if (self.isNull ()) {self.reset (new SendServer) }} return self.data ();} SendServer::SendServer (QObject * parent): QObject (parent) {/ / initialize the timer for sending alarm messages timerMsg = new QTimer (this); connect (timerMsg, SIGNAL (timeout ()), this, SLOT (checkMsg (); changeMsgInterval (); / / initialize the timer for sending alarm messages timerEmail = new QTimer (this) Connect (timerEmail, SIGNAL (timeout ()), this, SLOT (checkEmail ()); changeEmailInterval ();} SendServer::~SendServer () {this- > stop ();} void SendServer::receiveMsgResult (const QString & result) {if (App::MsgInterval! = 10000) {/ / DeviceHelper::addMsg (result, 0); DBHelper::addUserLog (device escalation, result) If (result.contains ("failure")) {QUIHelper::showMessageBoxError (result, 3);} else {QUIHelper::showMessageBoxInfo (result, 3);} void SendServer::receiveEmailResult (const QString & result) {if (App::EmailInterval! = 10000) {/ / DeviceHelper::addMsg (result, 0); DBHelper::addUserLog (device escalation, result) If (result.contains ("failure")) {QUIHelper::showMessageBoxError (result, 3);} else {QUIHelper::showMessageBoxInfo (result, 3);} void SendServer::start () {if (App::MsgInterval! = 10000) {QStringList tels = App::MsgTel.split (";") Foreach (QString tel, tels) {if (! QUIHelper::isTel (tel)) {/ / DeviceHelper::addMsg ("error forwarding mobile phone number", 0); break } / / start the thread to send alarm SMS messages to prevent the interface from jamming if (SendMsgThread::Instance ()-> open (App::MsgPortName)) {connect (SendMsgThread::Instance (), SIGNAL (receiveResult (QString)), this, SLOT (receiveMsgResult (QString); SendMsgThread::Instance ()-> init (); SendMsgThread::Instance ()-> start () / / DeviceHelper::addMsg ("SMS port opened successfully", 0); DBHelper::addUserLog ("device reporting", "SMS port opened successfully");} else {if (App::MsgInterval! = 10000) {/ / DeviceHelper::addMsg ("SMS port opening failed", 0) DBHelper::addUserLog ("device reporting", "SMS port opening failed");}} if (App::MsgInterval! = 10000) {if (! QUIHelper::isEmail (App::SendEmailAddr)) {/ / DeviceHelper::addMsg ("incorrect sender mailbox format", 0) DBHelper::addUserLog ("device reporting", "incorrect sender mailbox format");} QStringList emails = App::ReceiveEmailAddr.split (";"); foreach (QString email, emails) {if (! QUIHelper::isEmail (email)) {/ / DeviceHelper::addMsg ("recipient mailbox format error", 0) DBHelper::addUserLog ("device reporting", "recipient mailbox format error"); break;} / / start the sending alarm email thread to send email to prevent the interface from jamming connect (SendEmailThread::Instance (), SIGNAL (receiveEmailResult (QString)), this, SLOT (receiveEmailResult (QString) SendEmailThread::Instance ()-> setEmialTitle (App::LogoCn + "alarm email"); SendEmailThread::Instance ()-> setSendEmailAddr (App::SendEmailAddr); SendEmailThread::Instance ()-> setSendEmailPwd (App::SendEmailPwd); SendEmailThread::Instance ()-> setReceiveEmailAddr (App::ReceiveEmailAddr); SendEmailThread::Instance ()-> start ();} void SendServer::stop () {timerMsg- > stop (); timerEmail- > stop () } void SendServer::changeMsgInterval () {/ / if the interval is 0, it is sent at a 10-second interval. If it is 10000, if is not started (App::MsgInterval = = 0) {timerMsg- > start (10000);} else if (App::MsgInterval = = 10000) {timerMsg- > stop ();} else {timerMsg- > start (App::MsgInterval * 60 * 1000) }} void SendServer::changeEmailInterval () {/ / if the interval is 0 seconds, it will be sent at an interval of 10 seconds. If it is 10000, it will not start if (App::EmailInterval = = 0) {timerEmail- > start (10000);} else if (App::EmailInterval = = 10000) {timerEmail- > stop ();} else {timerEmail- > start (App::EmailInterval * 60 * 1000) }} void SendServer::appendMsg (const QString & msg) {if (App::MsgInterval append (listContent.join ("

"), listFileName.join ("; ");}" Qt how to write gas safety management system to achieve SMS alarm "content is introduced here, thank you for reading. If you want to know more industry-related knowledge can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report