QT-模拟电梯上下楼

news2024/11/16 6:49:17

QT-模拟电梯上下楼

  • 一、演示效果
  • 二、核心程序
  • 三、下载链接


一、演示效果

在这里插入图片描述

二、核心程序

#include "ElevatorController.h"
#include <QGridLayout>
#include <QLabel>
#include <QGroupBox>
#include <QGridLayout>
#include <QPushButton>
#include <QDebug>
#include <QChar>
#include <QGuiApplication>
#include <QScreen>
#include <queue>

ElevatorController::ElevatorController(Ui::MainWindow* u, int numElevators, int numFloors)
{
    // create/populate ui ComboBox elements
    ui = u;
    QStringList evs;
    for (int elevator = 1; elevator <= numElevators; ++elevator)
    {
        evs << QString("Elevator: %1").arg(elevator);
    }
    ui->comboElevatorBox->addItems(evs);
    connect(ui->comboElevatorBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &ElevatorController::elevatorSelected);

    evs.clear();

    for (int floorc = 1; floorc <= numFloors; ++floorc)
    {
        evs << QString("Floor: %1").arg(floorc);
    }
    ui->comboFloorBox->addItems(evs);

    // buttons connected
    connect(ui->pushElevatorButton, &QPushButton::clicked, this, &ElevatorController::buttonElevatorSubmit);
    connect(ui->pushHelpButton, &QPushButton::clicked, this, &ElevatorController::buttonElevatorHelp);
    connect(ui->pushPlaceButton, &QPushButton::clicked, this, &ElevatorController::buttonPlaceOnFloor);
    connect(ui->pushMoveButton, &QPushButton::clicked, this, &ElevatorController::buttonMoveToElevator);
    connect(ui->pushAdd10FloorButton, &QPushButton::clicked, this, &ElevatorController::add10ToEachFloor);
    connect(ui->pushBuildingEmergencyButton, &QPushButton::clicked, this, &ElevatorController::triggerBuildingEmergency);
    connect(ui->pushEmergencyResetAllButton, &QPushButton::clicked, this, &ElevatorController::resetAllElevatorsEmergency);
    connect(ui->pushLeaveButton, &QPushButton::clicked, this, &ElevatorController::buttonLeaveElevator);

    // spin box buttons:
    connect(ui->spinBoxMove, qOverload<int>(&QSpinBox::valueChanged), this, &ElevatorController::moveComboBoxChange);
    connect(ui->spinBoxLeaveElevator, qOverload<int>(&QSpinBox::valueChanged), this, &ElevatorController::moveLeaveElevatorBoxChange);

    // combo box change:
    connect(ui->comboFloorBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &ElevatorController::floorSelected);

    // keep in mind: "setWidget" and "setLayout" etc add to the ui tree, memory managed by Qt not Me :-)

    // widget to hold the grid layout
    QWidget* elevatorWidget = new QWidget();
    ui->elevatorScrollArea->setWidget(elevatorWidget); // Set the content widget of the ElevatorController

    // QGridLayout* elevatorGridLayout
    elevatorGridLayout = new QGridLayout(elevatorWidget);
    elevatorWidget->setLayout(elevatorGridLayout);



    // Add buttons or labels to the grid layout based on dimensions
    for (int floor = numFloors - 1; floor >= 0; floor--)
    {
        for (int elevator = 1; elevator <= numElevators; ++elevator)
        {
            // Create a QLabel for each position
            QLabel* cube = new QLabel;
            cube->setText(" ");
            cube->setFixedSize(CUBE_SIZE, CUBE_SIZE);
            QString color = "gray";

            if(numFloors - floor - 1 == 0) // all ev's start at 0
                color = "red";

            cube->setStyleSheet(QString("background-color: %1").arg(color));

            // Add the widget to the grid layout at the specified position
            elevatorGridLayout->addWidget(cube, floor, elevator);
        }

        Floor* flr = new Floor(floor + 1); // floor class is a part of the UI

        // Connect the signals from the Floor to the slots in the ElevatorController
        connect(flr, &Floor::upButtonPressed, this, &ElevatorController::buttonPressedUp);
        connect(flr, &Floor::downButtonPressed, this, &ElevatorController::buttonPressedDown);

        // adds the floor at the start (far left)
        elevatorGridLayout->addWidget(flr, numFloors - floor - 1, 0);
        floors.push_back(flr);
    }

    // create elevators
    for (int elevator = 1; elevator <= numElevators; ++elevator)
    {
        Elevator* ev = new Elevator(elevator);
        elevators.push_back(ev);
        updateDisplays();
        // should be connecting slot in elevator to signals in elevator controller
        connect(this, &ElevatorController::resetEmergency, ev, &Elevator::resetEmergencyInElevator);
        connect(this, &ElevatorController::sendRequestToElevator, ev, &Elevator::pressButton);
        connect(this, &ElevatorController::helpButton, ev, &Elevator::helpButtonPressed);
        connect(this, &ElevatorController::moveElevatorToFloor, ev, &Elevator::moveTofloor);
        connect(this, &ElevatorController::removeElevatorPassengers, ev, &Elevator::removePassengers);
        connect(this, &ElevatorController::addElevatorPassengers, ev, &Elevator::addPassengers);
        connect(this, &ElevatorController::buildingEmergency, ev, &Elevator::emergency);
        connect(this, &ElevatorController::pressButton, ev, &Elevator::pressButton);
        connect(this, &ElevatorController::unpressButton, ev, &Elevator::unpressButton);
        connect(ev, &Elevator::floorChanged, this, &ElevatorController::elevatorFloorChanged);
        connect(ev, &Elevator::doorOpened, this, &ElevatorController::doorOpened);
        connect(ev, &Elevator::doorClosed, this, &ElevatorController::doorClosed);
        connect(ev, &Elevator::doorBlocked, this, &ElevatorController::doorBlocked);
        connect(ev, &Elevator::overloaded, this, &ElevatorController::overloaded);
        connect(ev, &Elevator::emergencyOnBoard, this, &ElevatorController::emergency);
        connect(ev, &Elevator::updateDisplays, this, &ElevatorController::updateDisplays);

        QThread* evThread = new QThread;
        ev->moveToThread(evThread);
        evThread->start();
        threads.push_back(evThread);
    }

    requestScanTimer = new QTimer(this);
    connect(requestScanTimer, &QTimer::timeout, this, &ElevatorController::scanRequestTree);
    requestScanTimer->start(SCAN_REQUEST_TREE_SECS);  // Scan backup request tree every 15 seconds, in case overflow

    qDebug() << "Elevator Controller Initialized";
}

ElevatorController::~ElevatorController() // clean up floors
{
    for(int i = 0; i < floors.size(); i++)
        delete floors[i];

    requestScanTimer->stop();
    delete requestScanTimer;

    for(int i = 0; i < threads.size(); i++)
    {
        threads[i]->quit();
        threads[i]->wait();
        delete threads[i];
    }
}

// --- UI INPUT & CALLBACK FUNCS ---


void ElevatorController::handleScreenResized(int w, int h)
{
    int bufferGap = 10;
    ui->elevatorScrollArea->resize(w - ui->InputTerminal->width() - 3*bufferGap, h - bufferGap*6);
    qDebug() << "Reinit scale -- uiWidth: " << w << " uiHeight: " << h;

    ui->InputTerminal->move(ui->elevatorScrollArea->x() + w - ui->InputTerminal->width() - 2*bufferGap, ui->InputTerminal->y());
    ui->InputTerminal->resize(ui->InputTerminal->width(), h - bufferGap*5);
}

void ElevatorController::updateDisplays()
{
    int ev = ui->comboElevatorBox->currentText().remove(0, 10).toInt(); // stored from 0


    QString buttonList = "";
    const std::set<int>& blist = elevators[ev - 1]->getButtonsPressed();
    for(const int& a : blist)
    {
        buttonList += QString::number(a) + " ";
    }
    ui->textBrowserButtonsPressed->setPlainText(buttonList);

    const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt();
    ui->passengerOnFloorNumber->display(floors[flr - 1]->peopleOnFloor());
    ui->passengerNumber->display(elevators[ev - 1]->numPassengers());
}

void ElevatorController::buttonElevatorSubmit()
{
    // get the int values from the combo boxes
    int ev = ui->comboElevatorBox->currentText().remove(0, 10).toInt();
    int fb = ui->comboFloorBox->currentText().remove(0, 7).toInt();

    qDebug() << "BUTTON - elevator submit pressed elev: " << ev << " floor button: " << fb;

    if(elevators[ev - 1]->getButtonsPressed().count(fb) > 0)
        emit unpressButton(ev, fb);
    else
        emit pressButton(ev, fb);
}

void ElevatorController::buttonPlaceOnFloor()
{
    qDebug() << "BUTTON buttonPlaceOnFloor.... spawning ppl on floor";

    const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt() - 1;

    floors[flr]->addPeople(ui->spinBoxPlace->value());
    ui->passengerOnFloorNumber->display(floors[flr]->peopleOnFloor());

    ui->spinBoxPlace->setValue(0);
}

void ElevatorController::buttonMoveToElevator()
{
    qDebug() << "BUTTON: buttonMoveToElevator.... moving ppl ";

    const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt();
    int evweak = ui->comboElevatorBox->currentText().remove(0, 10).toInt() - 1; // if this is on the same floor its used

    Elevator* availableEv = nullptr;
    Elevator* weakEv = nullptr;
    bool potentialEvPassed = false;

    if(elevators[evweak]->currentFloor() == flr) // soft lock the current elevator
        weakEv = elevators[evweak];

    for(Elevator* ev : elevators) // unless theres one that makes more sense
    {
        if(ev->currentFloor() == flr && ev->currentState() == Elevator::DoorsOpen)
        {
            availableEv = ev;
            if(weakEv == ev && weakEv != nullptr)
            {
                availableEv = weakEv;
                break;
            }
        }
    }

    if(!availableEv)
        return;

    const int val = ui->spinBoxMove->value(); //usr input
    ui->spinBoxMove->setValue(0);

    floors[flr - 1]->removePeople(val);
    //    emit addElevatorPassengers(availableEv->getId(), flr, val);
    elevators[availableEv->getId() - 1]->addPassengers(availableEv->getId(), flr, val);
    // just set the combo box option to the one that people were put into automatically... for visibility
    ui->comboElevatorBox->setCurrentIndex(availableEv->getId() - 1);

    // update the floor on people display
    updateDisplays();
}

void ElevatorController::buttonLeaveElevator()
{

    int ev = ui->comboElevatorBox->currentText().remove(0, 10).toInt();

    qDebug() << "BUTTON: buttonLeaveElevator.... moving ppl EV: " << ev << " FLR: " << elevators[ev - 1]->currentFloor();


    const int val = ui->spinBoxLeaveElevator->value(); //usr input
    ui->spinBoxLeaveElevator->setValue(0);

    emit removeElevatorPassengers(elevators[ev - 1]->getId(), elevators[ev - 1]->currentFloor(), val);
    floors[elevators[ev - 1]->currentFloor() - 1]->addPeople(val);

    // just set the combo box option to the one that people were put into automatically... for visibility
    ui->comboFloorBox->setCurrentIndex(elevators[ev - 1]->currentFloor() - 1);
    ui->passengerNumber->display(elevators[ev-1]->numPassengers());
    updateDisplays();

    const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt();
    if(elevators[ev - 1]->currentFloor() != flr)
        return;

    // update the floor on people display
    ui->passengerOnFloorNumber->display(floors[elevators[ev - 1]->currentFloor()]->peopleOnFloor());
    updateDisplays();

    controlMoveButtonActivated();
}


void ElevatorController::add10ToEachFloor()
{
    qDebug() << "BUTTON add 10 To Each Floor.... spawning 10 ppl on each floor!";

    for(Floor* f : floors)
    {
        f->addPeople(10);
    }

    const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt() - 1;
    ui->passengerOnFloorNumber->display(floors[flr]->peopleOnFloor());
    ui->spinBoxPlace->setValue(0);
}

void ElevatorController::triggerBuildingEmergency()
{
    emit buildingEmergency(-1);
}

void ElevatorController::buttonElevatorHelp()
{
    int ev = ui->comboElevatorBox->currentText().remove(0, 10).toInt();
    emit helpButton(ev);
    updateDisplays();
}

void ElevatorController::resetAllElevatorsEmergency()
{
    emit resetEmergency(-1);
    updateDisplays();
}

void ElevatorController::controlMoveButtonActivated(Elevator* availableEv)
{
    // we want to check if there is an elevator on the floor in door open state
    // & set the control button to active or not based on it
    //qDebug() << "BUTTON ACTIVATE: Activating/Deactivating the Move Button to allow moving ppl ";

    const int flr = ui->comboFloorBox->currentText().remove(0, 7).toInt();
    const int evNum = ui->comboElevatorBox->currentText().remove(0, 10).toInt();

    for(Elevator* ev : elevators)
    {
        if(availableEv != nullptr)
            break;
        if(ev->currentFloor() == flr && ev->currentState() == Elevator::DoorsOpen || elevators[evNum - 1]->currentState() == Elevator::Overload)
            availableEv = ev;
    }

    if(elevators[evNum - 1]->currentState() == Elevator::DoorsOpen || elevators[evNum - 1]->currentState() == Elevator::Overload || elevators[evNum - 1]->currentState() == Elevator::Emergency)
        ui->pushLeaveButton->setEnabled(true);
    else if(ui->pushLeaveButton->isEnabled())
        ui->pushLeaveButton->setEnabled(false);

    if(availableEv != nullptr && flr == availableEv->currentFloor())
        ui->pushMoveButton->setEnabled(true);
    else if(ui->pushMoveButton->isEnabled())
        ui->pushMoveButton->setEnabled(false);
}

void ElevatorController::elevatorSelected(int index)
{
    ui->passengerNumber->display(elevators[index]->numPassengers());

    updateDisplays();

    controlMoveButtonActivated(elevators[index]);


    qDebug()  << "COMBO BOX: Elevator selected. Elevator: " << index;
}

void ElevatorController::floorSelected(int index)
{
    // update the segment display for passangers
    ui->passengerOnFloorNumber->display(floors[index]->peopleOnFloor());
    qDebug()  << "COMBO BOX: Floor selected. Floor: " << index;

    ui->spinBoxMove->setValue(0); // wipe this since its different # ppl
    controlMoveButtonActivated(); // potentially changes move buttons state
}

void ElevatorController::moveComboBoxChange(int index)
{
    if(index > ui->passengerOnFloorNumber->value())
    {
        ui->spinBoxMove->setValue(ui->passengerOnFloorNumber->value());
    }
}

void ElevatorController::moveLeaveElevatorBoxChange(int index)
{
    if(index > ui->passengerNumber->value())
    {
        ui->spinBoxLeaveElevator->setValue(ui->passengerNumber->value());
    }
}

// --- UI UPDATE / EV SOCKET FUNCS ---

void ElevatorController::elevatorFloorChanged(int floor, int ev, bool up)
{
    // each elevator emits this when the moved to new floor
    ev -= 1;
    qDebug() << "EV signal: Elevator floor changed, floor: " << floor << " elevator: " << ev << " up dir: " << up;
    qDebug() << "(X, Y) : " << floor << ", " << (ev + 1);


    const int x = floors.size() - floor; // as the floors decrease, x increases (flr increase, x decrease)
    const int y = ev + 1;

    QLayoutItem* layoutItem = elevatorGridLayout->itemAtPosition(x, y); // check if we are looking at a valid ev
    if (!layoutItem)
    {

        qDebug() << "No layout item at this position.";
        return;
    }

    QWidget* widget = layoutItem->widget();
    if (!widget)
    {
        qDebug() << "No widget at this position.";
        return;
    }

    const QMetaObject* metaObject = widget->metaObject();
    QString widgetType = QString::fromUtf8(metaObject->className());

    if (widgetType == "QLabel")
    {
        QLabel* square = qobject_cast<QLabel*>(widget);
        QLabel* squarePrev;
    
        squarePrev = qobject_cast<QLabel*>(elevatorGridLayout->itemAtPosition((x - 1 + floors.size()) % floors.size(), y)->widget());
        squarePrev->setStyleSheet(QString("background-color: gray;"));
    
        squarePrev = qobject_cast<QLabel*>(elevatorGridLayout->itemAtPosition((x + 1)%floors.size(), y)->widget());
        squarePrev->setStyleSheet(QString("background-color: gray;"));
    
        if(elevators[ev]->currentState() == Elevator::Emergency)
            square->setStyleSheet("background-color: yellow;");
        else
            square->setStyleSheet("background-color: red;");
    }

    qDebug() << "Widget type: " << widgetType;
}

void ElevatorController::doorOpened(int flr, int ev)
{
    // a door has opened
    qDebug()  << "EV signal: Door opened! Elevator: " << ev;
    const int x = floors.size() - flr; // as the floors decrease, x increases (flr increase, x decrease)
    const int y = ev;
    if (!elevatorGridLayout->itemAtPosition(x, y))
    {
        qDebug()  << "doorOpened(): No Item at position:  (" << x << ", " << y <<  ")";
        return;
    }
    QWidget* wdg = elevatorGridLayout->itemAtPosition(x, y)->widget();
    if(QString::fromUtf8(wdg->metaObject()->className()) != "QLabel")
    {
        qDebug()  << "doorOpened(): Item at position:  (" << x << ", " << y <<  ") " << "is a: " << QString::fromUtf8(wdg->metaObject()->className());
        return;
    }
    QLabel* squarePrev = qobject_cast<QLabel*>(wdg);
    squarePrev->setStyleSheet(QString("background-color: green;"));
    controlMoveButtonActivated(elevators[ev - 1]);
    updateDisplays();
}

void ElevatorController::doorClosed(int flr, int ev)
{
    // a door has closed
    qDebug()  << "EV signal: Door closed!! Elevator: " << ev;
    const int x = floors.size() - flr; // as the floors decrease, x increases (flr increase, x decrease)
    const int y = ev;

    if (!elevatorGridLayout->itemAtPosition(x, y))
    {
        qDebug()  << "doorClosed(): No Item at position:  (" << x << ", " << y <<  ")";
        return;
    }
    QWidget* wdg = elevatorGridLayout->itemAtPosition(x, y)->widget();
    if(QString::fromUtf8(wdg->metaObject()->className()) != "QLabel")
    {
        qDebug()  << "doorClosed(): Item at position:  (" << x << ", " << y <<  ") " << "is a: " << QString::fromUtf8(wdg->metaObject()->className());
        return;
    }
    QLabel* squarePrev = qobject_cast<QLabel*>(wdg);
    squarePrev->setStyleSheet(QString("background-color: purple;"));
}

void ElevatorController::doorBlocked(int flr, int ev)
{
    // a door has closed
    qDebug()  << "EV signal: Alert! Door blocked... reopening door... Elevator: " << ev;
    const int x = floors.size() - flr; // as the floors decrease, x increases (flr increase, x decrease)
    const int y = ev;

    if (!elevatorGridLayout->itemAtPosition(x, y))
    {
        qDebug()  << "doorBlocked(): No Item at position:  (" << x << ", " << y <<  ")";
        return;
    }
    QWidget* wdg = elevatorGridLayout->itemAtPosition(x, y)->widget();
    if(QString::fromUtf8(wdg->metaObject()->className()) != "QLabel")
    {
        qDebug()  << "doorBlocked(): Item at position:  (" << x << ", " << y <<  ") " << "is a: " << QString::fromUtf8(wdg->metaObject()->className());
        return;
    }
    QLabel* squarePrev = qobject_cast<QLabel*>(wdg);
    squarePrev->setStyleSheet(QString("background-color: blue;"));
}

void ElevatorController::overloaded(int flr, int ev)
{
    // a door has closed
    qDebug()  << "EV signal: Elevator overloaded!! Elevator: " << ev;
    const int x = floors.size() - flr; // as the floors decrease, x increases (flr increase, x decrease)
    const int y = ev;
    if (!elevatorGridLayout->itemAtPosition(x, y))
    {
        qDebug()  << "doorClosed(): No Item at position:  (" << x << ", " << y <<  ")";
        return;
    }
    QWidget* wdg = elevatorGridLayout->itemAtPosition(x, y)->widget();
    if(QString::fromUtf8(wdg->metaObject()->className()) != "QLabel")
    {
        qDebug()  << "overloaded(): Item at position:  (" << x << ", " << y <<  ") " << "is a: " << QString::fromUtf8(wdg->metaObject()->className());
        return;
    }
    QLabel* squarePrev = qobject_cast<QLabel*>(wdg);
    squarePrev->setStyleSheet(QString("background-color: orange;"));
}

void ElevatorController::emergency(int flr, int ev)
{
    // a door has closed
    qDebug()  << "EV signal: Elevator emergency!! Elevator: " << ev;

    if(flr != SAFE_FLOOR)
        return;

    QLayoutItem* layoutItem = elevatorGridLayout->itemAtPosition(floors.size() - SAFE_FLOOR, ev); // check if we are looking at a valid ev
    if (!layoutItem)
    {
        qDebug() << "No layout item at this position.";
        return;
    }
    
    QWidget* widget = layoutItem->widget();
    if (!widget)
    {
        qDebug() << "No widget at this position.";
        return;
    }
    
    const QMetaObject* metaObject = widget->metaObject();
    QString widgetType = QString::fromUtf8(metaObject->className());
    if (widgetType == "QLabel")
    {
        QLabel* square = qobject_cast<QLabel*>(widget);
    
        if(elevators[ev - 1]->currentState() == Elevator::Idle)
            square->setStyleSheet(QString("background-color: red;"));
        else
            square->setStyleSheet(QString("background-color: yellow;"));
    } 

    qDebug() << "Widget type: " << widgetType;
}

// --- EV REQUEST FUNCS ---

void ElevatorController::buttonPressedUp(int floor)
{
    // an up button on a floor has been pressed
    qDebug()  << "Floor signal: Floor up button pressed: " << floor;
    handleFlrPressed(FloorDirection(floor, true));
}

void ElevatorController::buttonPressedDown(int floor)
{
    // a down button on a floor has been pressed
    qDebug() << "Floor signal: Floor down button pressed: " << floor;
    handleFlrPressed(FloorDirection(floor, false));
}

void ElevatorController::handleFlrPressed(FloorDirection fd)
{
    // maybe this had some use in some implementtation? ev->getNumFloorsReserved();

    Elevator* bestElevator = nullptr;
    Elevator* idleEv = nullptr; // lower prio
    for(Elevator* pEv : elevators)
    {
        if(fd.up && pEv->lastDirMovingUp() && fd.num >= pEv->currentFloor())
        {
            bestElevator = pEv;
            break;
        }
        if(!fd.up && !pEv->lastDirMovingUp() && fd.num <= pEv->currentFloor())
        {
            bestElevator = pEv;
            break;
        }

        if(pEv->currentState() == Elevator::Idle)
            idleEv = pEv;
    }

    if(bestElevator)
        emit moveElevatorToFloor(bestElevator->getId(), fd.num);
    else if(idleEv)
        emit moveElevatorToFloor(idleEv->getId(), fd.num);
    else
        earliestRequestTree.push(fd);
}

void ElevatorController::scanRequestTree()
{
    // happen on a timer, scan request tree realloc elevators if free
    if(AGGRESSIVE_LOGGING && !earliestRequestTree.empty())
        qDebug() << "scanRequestTree-> Request floor:  " << earliestRequestTree.top().num << " up: " << earliestRequestTree.top().up; // << i++;
    if (earliestRequestTree.empty())
    {
        return;
    }

    FloorDirection fd = earliestRequestTree.top();
    earliestRequestTree.pop();
    handleFlrPressed(FloorDirection(fd.num, fd.up));
}
xt

三、下载链接

https://download.csdn.net/download/u013083044/88861542

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

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

相关文章

采用uniapp实现的银行卡卡片, 支持H5和微信小程序

采用uniapp-vue3实现的银行卡卡片 支持H5、微信小程序&#xff08;其他小程序未测试过&#xff0c;可自行尝试&#xff09; 可用于参考学习 可到插件市场下载尝试&#xff1a; https://ext.dcloud.net.cn/plugin?id16736 使用示例

crontab history查看命令的执行时间

crontab crontab学习网站&#xff08;19. crontab 定时任务 — Linux Tools Quick Tutorial&#xff09; 例子 今天实际工作里用到的&#xff08;已经进行了防信息泄露处理 比如我现在希望每周三上午10:00之行一个php脚本 --gpt生成 00 10 * * 3 cd /home/user/project/r…

5、电源管理入门之 arm-scmi和mailbox核间通信

目录 1. 整体架构介绍 2 Linux中reset模块 2.1 Reset consumer 2.2 Reset provider 3. Linux SCMI reset通信 3.1 SCMI reset协议初始化 3.2 SCMI reset消息收发 4. SCP中reset 4.1 固件新增module 4.2 scmi_reset_domain初始化 4.3 scmi_reset_domain消息处理 4.3…

Windows / Linux dir 命令

Windows / Linux dir 命令 1. dir2. dir *.* > data.txt3. dir - list directory contentsReferences 1. dir 显示目录的文件和子目录的列表。 Microsoft Windows [版本 10.0.18363.900] (c) 2019 Microsoft Corporation。保留所有权利。C:\Users\cheng>dir驱动器 C 中…

《图解设计模式》笔记(一)适应设计模式

图灵社区 - 图解设计模式 - 随书下载 评论区 雨帆 2017-01-11 16:14:04 对于设计模式&#xff0c;我个人认为&#xff0c;其实代码和设计原则才是最好的老师。理解了 SOLID&#xff0c;如何 SOLID&#xff0c;自然而然地就用起来设计模式了。Github 上有一个 tdd-training&…

Android的ViewModel

前言 在Compose的学习中&#xff0c;我们在可组合函数中使用rememberSaveable​​​​​​​保存应用数据&#xff0c;但这可能意味着将逻辑保留在可组合函数中或附近。随着应用体量不断变大&#xff0c;您应将数据和逻辑从可组合函数中移出。 而在之前的应用架构学习中&…

Duilib显示gif颜色背景与原图不符GifUI

//xml <GifUI name"gif_option_new" float"true" pos"608,28,0,0" width"28" height"14" gif"new.gif"/>遇到两个问题。 1、图片背景只有第一帧显示&#xff0c;每一帧的背景色一样&#xff0c;字不同&…

FISCO BCOS(十七)利用脚本进行区块链系统监控

要利用脚本进行区块链系统监控&#xff0c;你可以使用各种编程语言编写脚本&#xff0c;如Python、Shell等 利用脚本进行区块链系统监控可以提高系统的稳定性、可靠性&#xff0c;并帮助及时发现和解决潜在问题&#xff0c;从而确保区块链网络的正常运行。本文可以利用脚本来解…

Redis-内存管理

Redis是基于内存存储的&#xff0c;非关系型&#xff0c;键值对数据库。因此&#xff0c;对Redis来说&#xff0c;内存空间的管理至关重要。那Redis是如何内存管理的呢&#xff1f; 一、最大内存限制 Redis 提供了 maxmemory 参数允许用户设置 Redis 可以使用的最大内存大小。…

【2024.02.22】定时执行专家 V7.0 发布 - TimingExecutor V7.0 Release - 龙年春节重大更新版本

目录 ▉ 新版本 V7.0 下载地址 ▉ V7.0 新功能 ▼2024-02-21 V7.0 - 更新日志▼ ▉ V7.0 新UI设计 ▉ 新版本 V7.0 下载地址 BoomWorks软件的最新版本-CSDN博客文章浏览阅读10w次&#xff0c;点赞9次&#xff0c;收藏41次。▉定时执行专家—毫秒精度、专业级的定时任务执行…

psp游戏存档收集SAVEDATA

不想从头开始 ppsspp存档目录 pc&#xff1a;ppsspp解压目录\memstick\PSP\SAVEDATA 安卓&#xff1a;根目录\PSP\SAVEDATA 噬神者2(日版) NPJH50832099c645531020001000 風燐-https://wwl.lanzouq.com/iI1R01owozxa 咲夜-https://wwl.lanzouq.com/id1tX1owp2uf につてのぬ…

Laravel01 课程介绍以及Laravel环境搭建

Laravel01 课程介绍 1. Laravel2. mac开发环境搭建(通过Homebrew)3. 创建一个项目 1. Laravel 公司中面临着PHP项目与Java项目并行&#xff0c;所以需要我写PHP的项目&#xff0c;公司用的框架就是Laravel&#xff0c;所以在B站上找了一门课学习。 Laravel中文文档地址 https…

(っ•̀ω•́)っ 如何在PPT中为文本框添加滚动条

本人在写技术分享的PPT时&#xff0c;遇到问题&#xff1a;有一大篇的代码&#xff0c;如何在一张PPT页面上显示&#xff1f;急需带有滚动条的文本框&#xff01;百度了不少&#xff0c;自己也来总结一篇&#xff0c;如下&#xff1a; 1、找到【文件】-【选项】 2、【自定义功…

数据库管理-第153期 Oracle Vector DB AI-05(20240221)

数据库管理153期 2024-02-21 数据库管理-第153期 Oracle Vector DB & AI-05&#xff08;20240221&#xff09;1 Oracle Vector的其他特性示例1&#xff1a;示例2 2 简单使用Oracle Vector环境创建包含Vector数据类型的表插入向量数据 总结 数据库管理-第153期 Oracle Vecto…

如何修改docker容器的端口映射

要修改 Docker 容器的端口映射&#xff0c;你需要停止并删除现有的容器&#xff0c;然后使用新的端口映射重新运行容器。以下是详细步骤&#xff1a; 停止容器&#xff1a; 使用 docker stop 命令停止正在运行的容器。替换 <container_id> 为你要停止的容器的 ID 或者容器…

物联网在智慧景区中的应用:提升游客体验与运营效率

目录 一、物联网技术概述 二、物联网在智慧景区中的应用 1、智能门票系统 2、智能导览系统 3、智能安全监控系统 4、智能环保系统 三、物联网在智慧景区中提升游客体验 1、提高游览便捷性 2、个性化服务体验 3、提升游客安全感 四、物联网在智慧景区中提升运营效率 …

Python爬虫实战入门:爬取360模拟翻译(仅实验)

文章目录 需求所需第三方库requests 实战教程打开网站抓包添加请求头等信息发送请求&#xff0c;解析数据修改翻译内容以及实现中英互译 完整代码 需求 目标网站&#xff1a;https://fanyi.so.com/# 要求&#xff1a;爬取360翻译数据包&#xff0c;实现翻译功能 所需第三方库 …

零基础学习8051单片机(十五)

本次先看书学习&#xff0c;并完成了课后习题&#xff0c;题目出自《单片机原理与接口技术》第五版—李清朝 答: &#xff08;1&#xff09;当 CPU正在处理某件事情的时候&#xff0c;外部发生的某一件事件请求 CPU 迅速去处理&#xff0c;于是&#xff0c;CPU暂时中止当前的工…

【前端】夯实基础 css/html/js 50个练手项目(持续更新)

文章目录 前言Day 1 expanding-cardsDay 2 progress-steps 前言 发现一个没有用前端框架的练手项目&#xff0c;很适合我这种纯后端开发夯实基础&#xff0c;内含50个mini project&#xff0c;学习一下&#xff0c;做做笔记。 项目地址&#xff1a;https://github.com/bradtr…

纯血鸿蒙来画龙!基于HarmonyOS ArkTS来操作SVG图片

大家好&#xff0c;龙年报喜&#xff0c;大地回春&#xff0c;作为程序员&#xff0c;以代码之名&#xff0c;表达对于龙年的祝福。本节将演示如何在基于HarmonyOS ArkTS的Image组件来实现画一条中国龙&#xff0c;祝大家“码”上“鸿”福到&#xff01; 本文涉及的所有源码&a…