kevinxusz / QSimpleScada

Qt based simple SCADA framework, with dashboard, static and dynamic components

Home Page:https://indeema.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QSimpleScada

Qt/C++ based simple SCADA framework, with dashboard, static and dynamic components. By using QSimpleScada framework you can build complex SCADA uis for your needs.

Minimum requirements

Qt 5.8

Installing with qpm

Just use qpm (https://www.qpm.io/) to install QSimpleScada in your project. Run qpm install com.indeema.QSimpleScada . in *.pro file include(vendor/Vendor.pri)

Or Compile QSimpleScada with QSimpleScada pro file, you will receive QSimpleScadaLib folder with compiled windows or macos libs.

Sample

You can check example that uses QSimpleScada https://github.com/IndeemaSoftware/QSimpleScadaSample

Sample in action

How to start

Create editable QScadaBoard

QScadaBoard *mBoard = new QScadaBoard(this);
mBoard->setEditable(true);

You can connect to signals, to handle events

signals:
    void objectDoubleClicked(QScadaObject*);
    void objectSelected(QScadaObject *);

So now you can create some default QScadaObject on the board

mBoard->createNewObject();

Or create object with specific parameters

QScadaObjectInfo *lInfo = new QScadaObjectInfo();
lInfo->setId(2);
lInfo->setBackGroundImage(":/resources/some_structure.png");
lInfo->setShowBackgroundImage(true);
lInfo->setShowMarkers(false);

Creating object with specific parameters could be useful when restoring dashboard from project file.

Also you have possibility to send object to front or to back

void MainWindow::bringToFront()
{
    if (!mBoard->getSeletedObjects().isEmpty()) {
        QScadaObject *lObject = mBoard->getSeletedObjects().first();
        mBoard->bringToFront(lObject);
    }
}

void MainWindow::sendToBack()
{
    if (!mBoard->getSeletedObjects().isEmpty()) {
        QScadaObject *lObject = mBoard->getSeletedObjects().first();
        mBoard->sendToBack(lObject);
    }
}

Also save and open project file

void MainWindow::save()
{
    QFileDialog lDialog(this);
    lDialog.setFileMode(QFileDialog::AnyFile);
    lDialog.setAcceptMode(QFileDialog::AcceptSave);
    lDialog.setDirectory(QDir::currentPath());
    lDialog.setWindowTitle(tr("Save Project"));
    lDialog.setNameFilter(tr("iReDS Project (*.irp)"));

    QScadaBoardInfo *lBoardInfo = new QScadaBoardInfo();
    QScadaBoardController *lController = new QScadaBoardController();
    QScadaDeviceInfo lDeviceInfo;

    if (lDialog.exec() == QDialog::Accepted) {
        QStringList lFiles = lDialog.selectedFiles();
        if (lFiles.count() > 0) {
            QString lFileName = lFiles.at(0);
            if (!lFileName.contains(".irp")) {
                lFileName.append(".irp");
            }
            QStringList lIps;
            for (QScadaObject *object :*mBoard->objects()) {
                lBoardInfo->appendObjectInfo(object->info());
            }
            QList<QScadaBoardInfo*> lBoardInfoList;
            lBoardInfoList.append(lBoardInfo);

            lController->initConnectedDevices(lBoardInfoList);

            lDeviceInfo.setName("Test Device");
            lDeviceInfo.setIp(QHostAddress("127.0.0.0"));
            QList<QScadaDeviceInfo> lList;
            lList.append(lDeviceInfo);
            QString lDevices = VConnectedDeviceInfo::XMLFromDeviceInfo(lList, lController);   //<----;

            //create xml for boards of each device

            QFile lFile(lFileName);
            if (lFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
                QTextStream lOut(&lFile);
                lOut.setCodec("UTF-8");
                lOut << lDevices;
            } else {
                QString lMessage(tr("Something went wrong while trying to create file"));
                lMessage.append(" ").append(lFileName);

                QMessageBox lMsgBox;
                lMsgBox.setText(lMessage);
                lMsgBox.exec();
            }
            lFile.close();
            qDeleteAll(lBoardInfoList);
        }
    }
    delete lController;
    mBoard->setEditable(true);
}

void MainWindow::open()
{
    QString lFileName = QFileDialog::getOpenFileName(this,
        tr("Open Project"), QDir::currentPath(), tr("iReDS Project (*.irp)"));

    if (!lFileName.isEmpty()) {
        mObjectInfoDialog->updateWithObjectInfo(nullptr);

        for (QScadaObject *object : *mBoard->objects()) {
                mBoard->deleteObject(object);
        }

        VConnectedDeviceInfo* lConnectedDevceInfo = new VConnectedDeviceInfo();
        QByteArray lRawData;
        QFile lFile(lFileName);
        if (lFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
            QTextStream lStreamFileOut(&lFile);
            lStreamFileOut.setCodec("UTF-8");
            lRawData = lStreamFileOut.readAll().toUtf8();
            lFile.close();

            lConnectedDevceInfo->initFromXml(lRawData);

            for (int i = 0; i < lConnectedDevceInfo->connecteDeviceList.count(); ++i) {
                for (QScadaBoardInfo *boardInfo : lConnectedDevceInfo->connecteDeviceList.at(i)->boardList) {
                    if (boardInfo != nullptr) {
                        mBoard->setEditable(false);
                        for (QScadaObjectInfo *info : boardInfo->objectList()) {
                            mBoard->createNewObject(info);
                        }
                    }
                }
            }

            mBoard->update();
            mBoard->setEditable(true);
        } else {
            qDebug() << "       - Error open preferences file -> " << lFile.fileName();
        }

        delete lConnectedDevceInfo;
    }
}

Communication and Support

If you encounter an issue or you have any comments or propositions with using the QSimpleScada library then you can reach us in several different ways:

  • Having difficulties with using QSimpleScada you can write at Stackoverflow or at Qt forum. Don't forget about specifing the QSimpleScada tag. You will be helped by the community of this resource or our specialists will help you with an answer.

  • If you find a bug and want to tell us about it - specify it in the section Issues. In this section, we only consider bugs and ignore any questions relating to the support.

  • For additional assistance with your project - please contact us at support@indeema.com and specify QSimpleScada in the subject line.

  • You can also follow our news at @IndeemaSoftware or on our blog.

  • For further questions on cooperation, simply email us at support@indeema.com.

License

QSimpleScada works under the MIT license. For more information see here.

Terms

QSimpleScada is released for testing purposes only. We make no guarantees with respect to its function. By using this software you agree that Indeema is not liable for any damage to your system and data.

To know more about us and our IoT expertise, visit our website http://indeema.com

About

Qt based simple SCADA framework, with dashboard, static and dynamic components

https://indeema.com

License:MIT License


Languages

Language:C++ 95.7%Language:QMake 1.9%Language:C 1.8%Language:Prolog 0.6%