Qt Write Gas Safety Management System 7-Device Monitoring

1. Preface

The device monitoring module is an extension of the map monitoring module, just make the device into a separate panel display, like the screen, display more information, such as the name and model of the device, how many devices there are how many such device panels, this is mainly for different user preferences, some users want to see tables, and so on.You can see a lot of device data on one screen. Some users want to see a map with a more stereoscopic look. Some users want to see a device panel, pull a scrollbar, or switch the number of devices to switch the corresponding subdevice.

The device panel is a custom control, it is actually a widget, and then there are some label s and layouts inside. Any widget can be newcome out as a custom control and put into other widgets. In order to make any panel component flexible in one container, set the number of columns, stretch the display automatically, and deliberately encapsulate a custom control to do thisYou can customize the scrollbar to generate a pointer to the panel control that is passed in from newer, and it will be taken over by him.

Skin Open Source: https://gitee.com/feiyangqingyun/QWidgetDemo https://github.com/feiyangqingyun/QWidgetDemo File name: styledemo

Experience address: https://gitee.com/feiyangqingyun/QWidgetExe https://github.com/feiyangqingyun/QWidgetExe File name: bin_sams.zip

2. Functional features

  1. Collect data port, support serial port + network port, support free serial port + baud rate, network support free set IP address + communication port, each port supports collection cycle, default 1 second address, support set communication timeout, default 3 times, support maximum reconnection time, for re-reading offline devices.
  2. Controller information, the ability to add a controller name, select a controller address + controller model, and set the number of detectors under the controller.
  3. Detector information, can add bit number, freely select the type of detector, gas type, gas symbol, high report value, low report value, buffer value, zero value, whether enabled, alarm sound, background map, storage period, numeric conversion of decimal places, alarm delay time, alarm type (HH,LL,HL), etc.
  4. Controller model + detector model + gas type + gas symbol, can be freely configured.
  5. Maps support import and delete, and all detectors are free to drag and save map locations.
  6. Port information + Controller information + Detector information, support import export + export to excel + print.
  7. Run records + alarm records + user records, support multi-conditional combination queries, such as time period + controller + detector, all records support export to excel + print.
  8. Records exported to excel support all forms file versions such as excel+wps and do not rely on software such as excel.
  9. Data within a specified time range can be deleted, early data can be automatically cleaned up, and the maximum number of records can be saved.
  10. Supports alarm text message forwarding, supports multiple receiving mobile phone numbers, and can set the sending interval, such as sending all alarm messages instantly or once in 6 hours, the text message content is too long, and automatically splits multiple text messages.
  11. Supports alarm mail forwarding, supports multiple receiving mailboxes, and can set sending intervals, such as sending all alarm messages instantly or once in six hours, and supports attachment sending.
  12. High report color + low report color + normal color + 0 value color + curve background + curve color, etc., can be chosen freely.
  13. The Chinese title, English title, logo path and copyright of the software can be set freely.
  14. Provides switch settings for on-off operation + alarm sound + automatic logon + password remembering, etc.
  15. The alarm sound sets the number of playback times and the interface provides 17 skin file choices.
  16. Supports cloud data synchronization by setting up information about cloud databases, such as database name, user name + password, etc.
  17. Supports network forwarding and network reception. After network reception is turned on, the software receives data from udp for analysis.Network forwarding supports multiple target IP, which enables locally collected software to freely transfer data to the client and view detector data at any time.
  18. Automatically remember the user's last remaining interface + other information and apply it automatically after restart.
  19. The alarm automatically switches to the corresponding map, and the detector button flashes.
  20. Double-click the detector icon for control.
  21. Support user rights management, administrator + operator two categories, user login + user exit, can remember password and automatic login, more than three error prompts and close the program.
  22. Supports four monitoring modes, device panel monitoring + map monitoring + tabular data monitoring + curve data monitoring, can switch freely, and four simultaneous applications.
  23. Supports alarm relay linkage, a bit number can link multiple modules and relay numbers across the serial port, supporting many-to-many.
  24. Local data stores support sqlite+mysql and remote data synchronization to cloud databases.Automatic reconnection.
  25. Data collected by local devices is uploaded to the cloud in real time for extraction by other means such as mobile APP or web.
  26. Two kinds of data sources are supported, one is serial port and network to collect device data through protocol, the other is database collection.The database collection mode can be used as a common system.
  27. The built-in device emulation tool supports 16 device data emulation as well as database data emulation to test data when there is no device.
  28. The default communication protocol uses the modbus protocol, and later adds the support of Internet of Things protocols such as mqtt to make a universal system.
  29. Supports all windows operating systems + linux operating systems and other operating systems.

3. Effect Charts

4. Core Code

void DeviceHelper::initDevicePanel()
{
    if (devicePanel == NULL) {
        return;
    }

    qDeleteAll(widgets);
    qDeleteAll(devices);
    widgets.clear();
    devices.clear();
    devices2.clear();

    bool autoWidth = (DBData::NodeInfo_Count >= App::DeviceColumn);
    if (App::PanelMode == 0) {
        for (int i = 0; i < DBData::NodeInfo_Count; i++) {
            frmDeviceNode *widget = new frmDeviceNode;
            widget->setPositionID(DBData::NodeInfo_PositionID.at(i));
            widget->setDeviceName(DBData::NodeInfo_DeviceName.at(i));
            widget->setNodeName(DBData::NodeInfo_NodeName.at(i));
            widget->setNodeType(DBData::NodeInfo_NodeType.at(i));
            widget->setNodeSign(DBData::NodeInfo_NodeSign.at(i));
            widget->setOnline(false);

            if (autoWidth) {
                widget->setMinimumWidth(150);
            } else {
                widget->setFixedWidth(150);
            }

            widget->setFixedHeight(widget->sizeHint().height() + 15);
            widgets << widget;
            devices << widget;
        }
    } else if (App::PanelMode == 1) {
        for (int i = 0; i < DBData::NodeInfo_Count; i++) {
            frmDeviceNode2 *widget = new frmDeviceNode2;
            widget->setPositionID(DBData::NodeInfo_PositionID.at(i));
            widget->setDeviceName(DBData::NodeInfo_DeviceName.at(i));
            widget->setNodeName(DBData::NodeInfo_NodeName.at(i));
            widget->setNodeType(DBData::NodeInfo_NodeType.at(i));
            widget->setNodeSign(DBData::NodeInfo_NodeSign.at(i));
            widget->setOnline(false);

            if (autoWidth) {
                widget->setMinimumWidth(200);
            } else {
                widget->setFixedWidth(200);
            }

            widget->setFixedHeight(widget->sizeHint().height() - 20);
            widgets << widget;
            devices2 << widget;
        }
    } else {
        for (int i = 0; i < DBData::DeviceInfo_Count; i++) {
            frmDevicePanel *widget = new frmDevicePanel;
            widget->setPortName(DBData::DeviceInfo_PortName.at(i));
            widget->setDeviceName(DBData::DeviceInfo_DeviceName.at(i));
            widget->setDeviceAddr(DBData::DeviceInfo_DeviceAddr.at(i));
            widget->setDeviceType(DBData::DeviceInfo_DeviceType.at(i));
            widget->setNodeNumber(DBData::DeviceInfo_NodeNumber.at(i));
            widgets << widget;
        }
    }

    devicePanel->setMargin(3);
    devicePanel->setSpace(3);
    devicePanel->setAutoWidth(autoWidth);
    devicePanel->setWidget(widgets, App::DeviceColumn);
}

void DeviceHelper::initDeviceStyle()
{
    if (App::PanelMode == 0) {
        foreach (frmDeviceNode *device, devices) {
            device->initStyle();
        }
    } else if (App::PanelMode == 1) {
        foreach (frmDeviceNode2 *device, devices2) {
            device->initStyle();
        }
    }
}

void DeviceHelper::deviceOnline(const QString &deviceName, bool online)
{
    //Processing equipment panel
    if (App::PanelMode == 0) {
        foreach (frmDeviceNode *device, devices) {
            if (device->getDeviceName() == deviceName) {
                device->setOnline(online);
            }
        }
    } else if (App::PanelMode == 1) {
        foreach (frmDeviceNode2 *device, devices2) {
            if (device->getDeviceName() == deviceName) {
                device->setOnline(online);
            }
        }
    }

    //Processing device button
    foreach (ButtonDefence *btn, btns) {
        if (btn->property("deviceName").toString() == deviceName) {
            if (online) {
                btn->setButtonStatus(ButtonDefence::ButtonStatus_Arming);
            } else {
                btn->setButtonStatus(ButtonDefence::ButtonStatus_Error);
                btn->setText(btn->property("positionID").toString());
            }

            //Cloud data synchronization
            if (App::UseNetDB) {
                QString positionID = btn->property("positionID").toString();
                QString sql = QString("update NodeData set NodeStatus='%1' where PositionID='%2'").arg(online ? 1 : 0).arg(positionID);
                DbTcpClientThread::Instance()->append(sql);
            }
        }
    }

    //Processing equipment table
    int count = deviceData->rowCount();
    for (int i = 0; i < count; i++) {
        QString name = deviceData->item(i, 2)->text();
        if (name == deviceName) {
            setColor(deviceData->item(i, 7), deviceData->item(i, 9), online ? 1 : 4);
        }
    }
}

Keywords: network Excel Database github

Added by webbwbb on Fri, 15 Nov 2019 03:48:59 +0200