123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560 |
- #include "appmodel.h"
- #include "Ego.h"
- #define WIN23_LEAN_AND_MEAN
- #include <Windows.h>
- #include <QJsonObject>
- //#include "FishEyeWindow.h"
- // extern std::array<IRender *, 3> ar;
- std::atomic<int> g_iForwordState = 0;
- CarData::CarData(QObject *parent) : QObject(parent) {}
- CarData::CarData(const CarData &other)
- : QObject(nullptr), m_uid(other.m_uid), m_name(other.m_name),
- m_type(other.m_type), m_state(other.m_state) {}
- int32_t CarData::uid() const { return m_uid; }
- QString CarData::name() const { return m_name; }
- QString CarData::type() const { return m_type; }
- QString CarData::state() const { return m_state; }
- void CarData::setUid(const int32_t &value) {
- m_uid = value;
- emit dataChanged();
- }
- void CarData::setCarType(const int32_t& value)
- {
- m_carType = value;
- }
- void CarData::setName(const QString &value) {
- m_name = value;
- emit dataChanged();
- }
- void CarData::setState(const QString &value) {
- m_state = value;
- emit dataChanged();
- }
- void CarData::setType(const QString &value) {
- m_type = value;
- emit dataChanged();
- }
- /*
- car 用于存储实际的数据,而 carProp 则用于将 car 列表属性暴露给 QML 引擎。
- 通过这样的方式,可以在 C++ 代码中维护数据,同时在 QML 中直接访问和操作这些数据,而不需要直接暴露内部实现细节
- */
- class AppModelPrivate {
- public:
- QList<CarData *> car;
- QQmlListProperty<CarData> *carProp = nullptr;
- };
- //向car列表中添加元素
- static void carAppend(QQmlListProperty<CarData> *prop, CarData *val) {
- Q_UNUSED(val);
- Q_UNUSED(prop);
- }
- //获取指定索引处的 CarData 对象指针
- static CarData *carAt(QQmlListProperty<CarData> *prop, qsizetype index) {
- AppModelPrivate *d = static_cast<AppModelPrivate *>(prop->data);
- return d->car.at(index);
- }
- //获取 car 列表中元素的数量
- static qsizetype carCount(QQmlListProperty<CarData> *prop) {
- AppModelPrivate *d = static_cast<AppModelPrivate *>(prop->data);
- return d->car.size();
- }
- //清空 car 列表中的所有元素
- static void carClear(QQmlListProperty<CarData> *prop) {
- static_cast<AppModelPrivate *>(prop->data)->car.clear();
- }
- AppModel::AppModel(IEgoNotify *n, IEgoControl *c, QObject* qmlobj, QObject *parent)
- : _notify(n), _control(c), QObject(parent), d(new AppModelPrivate),m_peer(-1),m_qmlObj(qmlobj) {
- m_account = QString::fromStdString(_control->GetAccount());
- m_password = QString::fromStdString(_control->GetPassword());
- m_driveName = QString::fromStdString(_control->GetName());
- d->carProp = new QQmlListProperty<CarData>(this, d, carAppend, carCount,
- carAt, carClear);
- m_ready = false;
- // _window = std::make_unique<CFishEyeWindow>();
- //_window->Start("192.168.1.64");
- connect(dynamic_cast<QObject *>(_notify), SIGNAL(egoLoginResult(bool)), this,
- SLOT(onLoginRst(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoGearChanged(int)), this,
- SLOT(egoGearChanged(int))); /** 换挡操作 */
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoGear_DChanged(int)), this,
- SLOT(egoGear_DChanged(int))); /** 升降换挡操作 */
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoDirectionLightChanged(int)), this,
- SLOT(egoDirectionLightChanged(int))); /** 转向灯 */
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoWiperChanged(bool)), this,
- SLOT(egoWiperChanged(bool))); /** 雨刮器 */
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoFrontLightChanged(bool)), this,
- SLOT(egoFrontLightChanged(bool))); /** 前车灯 */
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoBackLightChanged(bool)), this,
- SLOT(egoBackLightChanged(bool))); /** 后车灯 */
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoBuzzerChanged(bool)), this,
- SLOT(egoBuzzerChanged(bool))); /** 喇叭 */
- //connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoEmergencyChanged(bool)), this,
- // SLOT(egoEmergencyChanged(bool))); /** 急停开关按下 */
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoCautionLightChanged(bool)), this,
- SLOT(egoCautionLightChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoLightLChanged(bool)), this,
- SLOT(egoLightLChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoLightRChanged(bool)), this,
- SLOT(egoLightRChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoGearFChanged(bool)), this,
- SLOT(egoGearFChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoGearRChanged(bool)), this,
- SLOT(egoGearRChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoCarParkChanged(bool)), this,
- SLOT(egoCarParkChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoBuzzerPlayChanged(bool)), this,
- SLOT(egoBuzzerPlayChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoLightFrontChanged(bool)), this,
- SLOT(egoLightFrontChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoLightWorkChanged(bool)), this,
- SLOT(egoLightWorkChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoEmergencyChanged(bool)), this,
- SLOT(egoEmergencyChanged(bool)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoMqttChanged(cannet_frame)), this,
- SLOT(egoMqttChanged(cannet_frame)));
- //链接Ego中的egoCarAppend信号和onCarAppend槽,传递参数
- connect(dynamic_cast<QObject *>(_notify), SIGNAL(egoCarAppend(UserCamera)),
- this, SLOT(onCarAppend(UserCamera)));
- connect(
- dynamic_cast<QObject *>(_notify),
- SIGNAL(egoRadar(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t)),
- this,
- SLOT(
- onRadarUpadte(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t,int32_t)));
-
- //传递CHANNEL_IMU通道数据到Qt前端
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoImu(float, float)), this,
- SLOT(onImuUpdate(float, float)));
-
- connect(
- dynamic_cast<QObject*>(_notify),
- SIGNAL(egoEncode(int32_t, int32_t)),
- this,
- SLOT(
- onEncodeUpdate(int32_t, int32_t)));
- connect(dynamic_cast<QObject*>(_notify),
- SIGNAL(egoFeedData(const FeedData&)),
- this,
- SLOT(onFeedData(const FeedData&)));
- connect(dynamic_cast<QObject *>(_notify), SIGNAL(egoPing(int32_t,double)), this,
- SLOT(onPing(int32_t,double)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoPosition(float, float, float)), this,
- SLOT(OnPosition(float, float, float)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoNotifyLeave(int32_t)), this,
- SLOT(onNotifyLeave(int32_t)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoNotifyFail(int32_t)), this,
- SLOT(onNotifyFail(int32_t)));
- connect(dynamic_cast<QObject *>(_notify), SIGNAL(egoNotifyDel(int32_t)), this,
- SLOT(onNotifyDel(int32_t)));
- connect(dynamic_cast<QObject *>(_notify), SIGNAL(egoKickoff()), this,
- SLOT(onKickoff()));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoMoveEnd(int32_t, WorkArea , int32_t)), this,
- SLOT(onMoveEnd(int32_t, WorkArea, int32_t)));
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoMoveRet(MoveDesc)), this,
- SLOT(onMoveRet(MoveDesc)));
-
- connect(dynamic_cast<QObject*>(_notify), SIGNAL(egoNotifyState(int32_t, UserState)), this,
- SLOT(onNotifyState(int32_t, UserState)));
- // connect(dynamic_cast<QObject *>(_notify),SIGNAL(ego)
-
-
- }
- AppModel::~AppModel() {
- if (d->carProp)
- delete d->carProp;
- if (d)
- delete d;
- }
- int AppModel::BrakePressure() const { return m_brake_pressure; }
- int AppModel::GearboxOilPressure()const { return m_gearbox_oil_pressure; }
- int AppModel::GearboxOilTemp() const { return m_gearbox_oil_temp; }
- int AppModel::EnginRpm()const { return m_engine_rpm; }
- int AppModel::Speed() const { return m_speed; }
- bool AppModel::Visible() const { return m_visible; }
- //int AppModel::Gear() const { return m_gear; }
- int AppModel::Cold() const { return m_cold_water; }
- //int AppModel::ModelX() const { return m_modelx; }
- //int AppModel::ModelY() const { return m_modely; }
- //int AppModel::ModelZ() const { return m_modelz; }
- int32_t AppModel::leftAngle() const { return m_leftAngle; }
- int32_t AppModel::rightAngle() const { return m_rightAngle; }
- int AppModel::EngineOilPressure() const { return m_engine_oil_pressure; }
- bool AppModel::ready() const
- {
- return m_ready;
- }
- QString AppModel::Account() const { return m_account; }
- QString AppModel::Password() const { return m_password; }
- QString AppModel::CarName() const { return m_carName; }
- QString AppModel::DriveName() const { return m_driveName; }
- int32_t AppModel::WorkPressure() const { return m_work_pressure; }
- int AppModel::radar1() const { return m_radar1; }
- int AppModel::radar2() const { return m_radar2; }
- int AppModel::radar3() const { return m_radar3; }
- int AppModel::radar4() const { return m_radar4; }
- int AppModel::radar5() const { return m_radar5; }
- int AppModel::radar6() const { return m_radar6; }
- int AppModel::radar7() const { return m_radar7; }
- int AppModel::radar8() const { return m_radar8; }
- int32_t AppModel::OilPos() const { return m_oil_pos; }
- int AppModel::ping() const { return m_ping; }
- double AppModel::temp() const { return m_temp; }
- float AppModel::imux() const { return int(m_imux); }
- float AppModel::imuy() const { return int(m_imuy); }
- int AppModel::alertSound() const { return m_alert; }
- bool AppModel::cautionLight() const { return m_cautionLight; }
- bool AppModel::lightL() const { return m_lightL; }
- bool AppModel::lightR() const { return m_lightR; }
- bool AppModel::gearF() const { return m_gearF; }
- bool AppModel::gearR() const { return m_gearR; }
- bool AppModel::carPark() const { return m_carPark; }
- bool AppModel::buzzerPlay() const { return m_buzzerPlay; }
- bool AppModel::lightFront() const { return m_lightFront; }
- bool AppModel::lightWork() const { return m_lightWork; }
- bool AppModel::emergency1() const { return m_emergency; }
- int AppModel::engineSpeed() const { return m_engineSpeed; }
- int AppModel::travelSpeed() const { return m_travelSpeed; }
- int AppModel::fuelLevel() const { return m_fuelLevel; }
- int AppModel::engineTemperature() const { return m_engineTemperature; }
- int AppModel::hydraulicOilTemperature() const { return m_hydraulicOilTemperature; }
- int AppModel::mainPump1Pressure() const { return m_mainPump1Pressure; }
- int AppModel::mainPump2Pressure() const { return m_mainPump2Pressure; }
- int AppModel::handGear() const { return m_handGear; }
- int AppModel::actualGear() const { return m_actualGear; }
- float AppModel::gripperHeight() const { return m_gripperHeight; }
- float AppModel::amplitude1() const { return m_amplitude; }
- int64_t AppModel::boomAngle() const { return m_boomAngle; }
- int64_t AppModel::stickAngle() const { return m_stickAngle; }
- bool AppModel::idleProtection() const { return m_idleProtection; }
- bool AppModel::frontToggle() const { return m_frontToggle; }
- bool AppModel::backToggle() const { return m_backToggle; }
- int AppModel::interLock() const { return m_interLock; }
- int AppModel::safetySwitch() const { return m_safetySwitch; }
- int AppModel::armLiftPilot() const { return m_armLiftPilot; }
- int AppModel::armLoweringPilot() const { return m_armLoweringPilot; }
- int AppModel::leverLiftingLilot() const { return m_leverLiftingLilot; }
- int AppModel::rodLoweringPilot() const { return m_rodLoweringPilot; }
- int AppModel::leftRotaryPilot() const { return m_leftRotaryPilot; }
- int AppModel::rightRotaryPilot() const { return m_rightRotaryPilot; }
- int AppModel::grabOpenPilot() const { return m_grabOpenPilot; }
- int AppModel::grabClosePilot() const { return m_grabClosePilot; }
- int AppModel::safetyValves() const { return m_safetyValves; }
- bool AppModel::liftPilotPressureSensor_F() const { return m_liftPilotPressureSensor_F; }
- bool AppModel::loweringPilotPressureSensor_F() const { return m_loweringPilotPressureSensor_F; }
- bool AppModel::leverLiftPilotPressureSensor_F() const { return m_leverLiftPilotPressureSensor_F; }
- bool AppModel::rodLoweringPilotPressurePensor_F() const { return m_rodLoweringPilotPressurePensor_F; }
- bool AppModel::leftTurnPilotPressureSensor_F() const { return m_leftTurnPilotPressureSensor_F; }
- bool AppModel::rightTurnPilotPressureSensor_F() const { return m_rightTurnPilotPressureSensor_F; }
- bool AppModel::legExtensionPilotPressureSensor_F() const { return m_legExtensionPilotPressureSensor_F; }
- bool AppModel::legRetractPilotPressureSensor_F() const { return m_legRetractPilotPressureSensor_F; }
- bool AppModel::grabOpenPilotPressureSensor_F() const { return m_grabOpenPilotPressureSensor_F; }
- bool AppModel::grabClosurePilotPressureSensor_F() const { return m_grabClosurePilotPressureSensor_F; }
- bool AppModel::mainPump1PressureSensor_F() const { return m_mainPump1PressureSensor_F; }
- bool AppModel::mainPump2PressureSensor_F() const { return m_mainPump2PressureSensor_F; }
- bool AppModel::chamberPressureSensor_F() const { return m_chamberPressureSensor_F; }
- bool AppModel::bucketRodPressureSensor_F() const { return m_bucketRodPressureSensor_F; }
- bool AppModel::parkingPressureSensor_F() const { return m_parkingPressureSensor_F; }
- bool AppModel::accumulatorPressureSensor_F() const { return m_accumulatorPressureSensor_F; }
- bool AppModel::gasPedal_F() const { return m_gasPedal_F; }
- bool AppModel::throttleKnob_F() const { return m_throttleKnob_F; }
- bool AppModel::legHandle_F() const { return m_legHandle_F; }
- bool AppModel::gripKnob_F() const { return m_gripKnob_F; }
- bool AppModel::hydraulicOilTemperatureSensor_F() const { return m_hydraulicOilTemperatureSensor_F; }
- bool AppModel::fuelLevelSensor_F() const { return m_fuelLevelSensor_F; }
- bool AppModel::boomAngleSensor_F() const { return m_boomAngleSensor_F; }
- bool AppModel::bucketLeverTiltSensor_F() const { return m_bucketLeverTiltSensor_F; }
- bool AppModel::expansionModule_F() const { return m_expansionModule_F; }
- bool AppModel::workingDistanceOverrun_F() const { return m_workingDistanceOverrun_F; }
- bool AppModel::lowOilLevel_F() const { return m_lowOilLevel_F; }
- bool AppModel::batteryLowVoltage_F() const { return m_batteryLowVoltage_F; }
- bool AppModel::batteryHighVoltage_F() const { return m_batteryHighVoltage_F; }
- bool AppModel::accumulatorPressure_F() const { return m_accumulatorPressure_F; }
- bool AppModel::highHydraulicOilTemperature_F() const { return m_highHydraulicOilTemperature_F; }
- bool AppModel::lowOilPressure_F() const { return m_lowOilPressure_F; }
- bool AppModel::coolantLevelLow_F() const { return m_coolantLevelLow_F; }
- bool AppModel::coolantTemperatureHigh_F() const { return m_coolantTemperatureHigh_F; }
- bool AppModel::systemOverload_F() const { return m_systemOverload_F; }
- bool AppModel::safebypassPressDown_F() const { return m_safebypassPressDown_F; }
- bool AppModel::engineSPN_F() const { return m_engineSPN_F; }
- bool AppModel::engineWarmUp_F() const { return m_engineWarmUp_F; }
- bool AppModel::engineWarmUpTimeout_F() const { return m_engineWarmUpTimeout_F; }
- bool AppModel::emergencyStopPress_F() const { return m_emergencyStopPress_F; }
- bool AppModel::leftFrontLegChosed() const { return m_leftFrontLegChosed; }
- bool AppModel::rightFrontLegChosed() const { return m_rightFrontLegChosed; }
- bool AppModel::leftRearLegChosed() const { return m_leftRearLegChosed; }
- bool AppModel::rightRearLegChosed() const { return m_rightRearLegChosed; }
- void AppModel::setReady(const bool value) {
- m_ready = value;
- emit readyChanged();
- }
- void AppModel::SetSpeed(const int32_t value)
- {
- m_speed = value;
- emit speedChanged();
- }
- void AppModel::SetVisible(const bool value)
- {
- m_visible = value;
- emit visibleChanged();
- }
- void AppModel::SetCold(const int32_t value)
- {
- m_cold_water = value;
- emit coldChanged();
- }
- void AppModel::SetGearBoxOilPressure(const int32_t value)
- {
- m_gearbox_oil_pressure = value;
- emit gearboxOilPressureChanged();
- }
- void AppModel::setAccount(const QString& value)
- {
- m_account = value;
- emit accountChanged();
- }
- void AppModel::setLeftAngle(const int32_t value)
- {
- m_leftAngle = value;
- emit leftAngleChanged();
- }
- void AppModel::setRightAngle(const int32_t value)
- {
- m_rightAngle = value;
- emit rightAngleChanged();
- }
- /*
- void AppModel::setModelX(const int32_t value)
- {
- m_modelx = value;
- emit modelXChanged();
- }
- void AppModel::setModelZ(const int32_t value)
- {
- m_modelz = value+200;
- emit modelZChanged();
- }
- void AppModel::setModelY(const int32_t value)
- {
- m_modely = value;
- emit modelYChanged();
- }
- */
- void AppModel::setPassword(const QString& password)
- {
- m_password = password;
- emit passwordChanged();
- }
- void AppModel::setCarName(const QString& carname)
- {
- m_carName = carname;
- emit carNameChanged();
- }
- void AppModel::setDriveName(const QString& drivename)
- {
- m_driveName = drivename;
- emit driveNameChanged();
- }
- void AppModel::setWorkPressure(const int32_t value)
- {
- m_work_pressure = value;
- emit workPressureChanged();
- }
- /*
- void AppModel::SetGear(const int32_t value)
- {
- m_gear = value;
- emit gearChanged();
- }
- */
- void AppModel::SetBrakePressure(int32_t value)
- {
- m_brake_pressure = value;
- emit brakePressureChanged();
- }
- void AppModel::SetOilPos(int32_t value)
- {
- m_oil_pos = value;
- emit oilPosChanged();
- }
-
- void AppModel::SetGearBoxOilTemp(const int32_t value)
- {
- m_gearbox_oil_temp = value;
- emit gearboxOilTempChanged();
- }
- void AppModel::SetEngingRpm(const int32_t value)
- {
- m_engine_rpm = value;
- emit engineRpmChanged();
- }
- void AppModel::SetEngineOilPressure(const int32_t value)
- {
- m_engine_oil_pressure = value;
- emit engineoilPressureChanged();
- }
- void AppModel::setForward(const int32_t& value) {
- m_forward = value;
- g_iForwordState = value;
- //m_pQTimer->start(2000);
- emit forwardChanged();
- // m_pQTimer->start(2000);
- //QThread::msleep(500);
- // QGuiApplication::processEvents();
- // QThread::msleep(100);
- // QGuiApplication::processEvents();
- }
- void AppModel::setBackward(const int32_t& value) {
- m_backward = value;
- emit backwardChanged();
- }
- void AppModel::setGear_D(const int32_t& value) {
- m_gear_d = value;
- emit gear_dChanged();
- }
- void AppModel::setDirectionLight(const int32_t& value) {
- m_light = value;
- emit directionlightChanged();
- }
- void AppModel::setWiper(const bool& value) {
- m_wiper = value;
- emit wiperChanged();
- }
- void AppModel::setFrontLight(const bool& value) {
- m_frontlight = value;
- emit frontlightChanged();
- }
- void AppModel::setBackLight(const bool& value) {
- m_backlight = value;
- emit backlightChanged();
- }
- void AppModel::setBuzzer(const bool& value) {
- m_buzzer = value;
- emit buzzerChanged();
- }
- void AppModel::setRadar1(const int32_t &value) {
- m_radar1 = value;
- emit radar1Changed();
- emit setRadar1Play(value);
- }
- void AppModel::setRadar2(const int32_t &value) {
- m_radar2 = value;
- emit radar2Changed();
- emit setRadar2Play(value);
- }
- void AppModel::setRadar3(const int32_t &value) {
- m_radar3 = value;
- emit radar3Changed();
- emit setRadar3Play(value);
- }
- void AppModel::setRadar4(const int32_t &value) {
- m_radar4 = value;
- emit radar4Changed();
- emit setRadar4Play(value);
- }
- void AppModel::setRadar5(const int32_t &value) {
- m_radar5 = value;
- emit radar5Changed();
- emit setRadar5Play(value);
- }
- void AppModel::setRadar6(const int32_t& value)
- {
- m_radar6 = value;
- emit radar6Changed();
- emit setRadar6Play(value);
- }
- void AppModel::setRadar7(const int32_t& value)
- {
- m_radar7 = value;
- emit radar7Changed();
- emit setRadar7Play(value);
- }
- void AppModel::setRadar8(const int32_t &value) {
- m_radar8 = value;
- emit radar8Changed();
- emit setRadar8Play(value);
- }
- void AppModel::setImuy(const float& value) {
- m_imuy = value;
- emit imuyChanged();
- }
- void AppModel::setImux(const float& value) {
- m_imux = value;
- emit imuxChanged();
- }
- void AppModel::setEngineSpeed(const int32_t& value) {
- m_engineSpeed = value;
- emit engineSpeedPlay(int(value));
- emit engineSpeedChanged();
- }
- void AppModel::setTravelSpeed(const int32_t& value) {
- m_travelSpeed = value;
- emit travelSpeedChanged();
- }
- void AppModel::setFuelLevel(const int32_t& value) {
- m_fuelLevel = value;
- emit fuelLevelChanged();
- }
- void AppModel::setEngineTemperature(const int32_t& value) {
- m_engineTemperature = value;
- emit engineTemperatureChanged();
- }
- void AppModel::setHydraulicOilTemperature(const int32_t& value) {
- m_hydraulicOilTemperature = value;
- emit hydraulicOilTemperatureChanged();
- }
- void AppModel::setMainPump1Pressure(const int32_t& value) {
- m_mainPump1Pressure = value;
- emit mainPump1PressureChanged();
- }
- void AppModel::setMainPump2Pressure(const int32_t& value) {
- m_mainPump2Pressure = value;
- emit mainPump2PressureChanged();
- }
- void AppModel::setHandGear(const int32_t& value) {
- m_handGear = value;
- emit handGearChanged();
- }
- void AppModel::setActualGear(const int32_t& value) {
- m_actualGear = value;
- emit actualGearChanged();
- }
- void AppModel::setGripperHeight(const float& value) {
- m_gripperHeight = value;
- emit gripperHeightChanged();
- }
- void AppModel::setAmplitude(const float& value) {
- m_amplitude = value;
- emit amplitudeChanged();
- }
- void AppModel::setBoomAngle(const int32_t& value) {
- m_boomAngle = value;
- emit boomAngleChanged();
- }
- void AppModel::setStickAngle(const int32_t& value) {
- m_stickAngle = value;
- emit stickAngleChanged();
- }
- void AppModel::setIdleProtection(const bool& value) {
- m_idleProtection = value;
- emit idleProtectionChanged();
- }
- void AppModel::setFrontToggle(const bool& value) {
- m_frontToggle = value;
- emit frontToggleChanged();
- }
- void AppModel::setBackToggle(const bool& value) {
- m_backToggle = value;
- emit backToggleChanged();
- }
- void AppModel::setInterLock(const int32_t& value) {
- m_interLock = value;
- emit interLockChanged();
- }
- void AppModel::setSafetySwitch(const int32_t& value) {
- m_safetySwitch = value;
- emit safetySwitchChanged();
- }
- void AppModel::setArmLiftPilot(const int32_t& value) {
- m_armLiftPilot = value;
- emit armLiftPilotChanged();
- }
- void AppModel::setArmLoweringPilot(const int32_t& value) {
- m_armLoweringPilot = value;
- emit armLoweringPilotChanged();
- }
- void AppModel::setLeverLiftingLilot(const int32_t& value) {
- m_leverLiftingLilot = value;
- emit leverLiftingLilotChanged();
- }
- void AppModel::setRodLoweringPilot(const int32_t& value) {
- m_rodLoweringPilot = value;
- emit rodLoweringPilotChanged();
- }
- void AppModel::setLeftRotaryPilot(const int32_t& value) {
- m_leftRotaryPilot = value;
- emit leftRotaryPilotChanged();
- }
- void AppModel::setRightRotaryPilot(const int32_t& value) {
- m_rightRotaryPilot = value;
- emit rightRotaryPilotChanged();
- }
- void AppModel::setGrabOpenPilot(const int32_t& value) {
- m_grabOpenPilot = value;
- emit grabOpenPilotChanged();
- }
- void AppModel::setGrabClosePilot(const int32_t& value) {
- m_grabClosePilot = value;
- emit grabClosePilotChanged();
- }
- void AppModel::setSafetyValves(const int32_t& value) {
- m_safetyValves = value;
- emit safetyValvesChanged();
- }
- //报警信息
- void AppModel::setLiftPilotPressureSensor_F(const bool& value) {
- m_liftPilotPressureSensor_F = value;
- emit liftPilotPressureSensor_FChanged();
- }
- void AppModel::setLoweringPilotPressureSensor_F(const bool& value) {
- m_loweringPilotPressureSensor_F = value;
- emit loweringPilotPressureSensor_FChanged();
- }
- void AppModel::setLeverLiftPilotPressureSensor_F(const bool& value) {
- m_leverLiftPilotPressureSensor_F = value;
- emit leverLiftPilotPressureSensor_FChanged();
- }
- void AppModel::setRodLoweringPilotPressurePensor_F(const bool& value) {
- m_rodLoweringPilotPressurePensor_F = value;
- emit rodLoweringPilotPressurePensor_FChanged();
- }
- void AppModel::setLeftTurnPilotPressureSensor_F(const bool& value) {
- m_leftTurnPilotPressureSensor_F = value;
- emit leftTurnPilotPressureSensor_FChanged();
- }
- void AppModel::setRightTurnPilotPressureSensor_F(const bool& value) {
- m_rightTurnPilotPressureSensor_F = value;
- emit rightTurnPilotPressureSensor_FChanged();
- }
- void AppModel::setLegExtensionPilotPressureSensor_F(const bool& value) {
- m_legExtensionPilotPressureSensor_F = value;
- emit legExtensionPilotPressureSensor_FChanged();
- }
- void AppModel::setLegRetractPilotPressureSensor_F(const bool& value) {
- m_legRetractPilotPressureSensor_F = value;
- emit legRetractPilotPressureSensor_FChanged();
- }
- void AppModel::setGrabOpenPilotPressureSensor_F(const bool& value) {
- m_grabOpenPilotPressureSensor_F = value;
- emit grabOpenPilotPressureSensor_FChanged();
- }
- void AppModel::setGrabClosurePilotPressureSensor_F(const bool& value) {
- m_grabClosurePilotPressureSensor_F = value;
- emit grabClosurePilotPressureSensor_FChanged();
- }
- void AppModel::setMainPump1PressureSensor_F(const bool& value) {
- m_mainPump1PressureSensor_F = value;
- emit mainPump1PressureSensor_FChanged();
- }
- void AppModel::setMainPump2PressureSensor_F(const bool& value) {
- m_mainPump2PressureSensor_F = value;
- emit mainPump2PressureSensor_FChanged();
- }
- void AppModel::setChamberPressureSensor_F(const bool& value) {
- m_chamberPressureSensor_F = value;
- emit chamberPressureSensor_FChanged();
- }
- void AppModel::setBucketRodPressureSensor_F(const bool& value) {
- m_bucketRodPressureSensor_F = value;
- emit bucketRodPressureSensor_FChanged();
- }
- void AppModel::setParkingPressureSensor_F(const bool& value) {
- m_parkingPressureSensor_F = value;
- emit parkingPressureSensor_FChanged();
- }
- void AppModel::setAccumulatorPressureSensor_F(const bool& value) {
- m_accumulatorPressureSensor_F = value;
- emit accumulatorPressureSensor_FChanged();
- }
- void AppModel::setGasPedal_F(const bool& value) {
- m_gasPedal_F = value;
- emit gasPedal_FChanged();
- }
- void AppModel::setThrottleKnob_F(const bool& value) {
- m_throttleKnob_F = value;
- emit throttleKnob_FChanged();
- }
- void AppModel::setLegHandle_F(const bool& value) {
- m_legHandle_F = value;
- emit legHandle_FChanged();
- }
- void AppModel::setGripKnob_F(const bool& value) {
- m_gripKnob_F = value;
- emit gripKnob_FChanged();
- }
- void AppModel::setHydraulicOilTemperatureSensor_F(const bool& value) {
- m_hydraulicOilTemperatureSensor_F = value;
- emit hydraulicOilTemperatureSensor_FChanged();
- }
- void AppModel::setFuelLevelSensor_F(const bool& value) {
- m_fuelLevelSensor_F = value;
- emit fuelLevelSensor_FChanged();
- }
- void AppModel::setBoomAngleSensor_F(const bool& value) {
- m_boomAngleSensor_F = value;
- emit boomAngleSensor_FChanged();
- }
- void AppModel::setBucketLeverTiltSensor_F(const bool& value) {
- m_bucketLeverTiltSensor_F = value;
- emit bucketLeverTiltSensor_FChanged();
- }
- void AppModel::setExpansionModule_F(const bool& value) {
- m_expansionModule_F = value;
- emit expansionModule_FChanged();
- }
- void AppModel::setWorkingDistanceOverrun_F(const bool& value) {
- m_workingDistanceOverrun_F = value;
- emit workingDistanceOverrun_FChanged();
- }
- void AppModel::setLowOilLevel_F(const bool& value) {
- m_lowOilLevel_F = value;
- emit lowOilLevel_FChanged();
- }
- void AppModel::setBatteryLowVoltage_F(const bool& value) {
- m_batteryLowVoltage_F = value;
- emit batteryLowVoltage_FChanged();
- }
- void AppModel::setBatteryHighVoltage_F(const bool& value) {
- m_batteryHighVoltage_F = value;
- emit batteryHighVoltage_FChanged();
- }
- void AppModel::setAccumulatorPressure_F(const bool& value) {
- m_accumulatorPressure_F = value;
- emit accumulatorPressure_FChanged();
- }
- void AppModel::setHighHydraulicOilTemperature_F(const bool& value) {
- m_highHydraulicOilTemperature_F = value;
- emit highHydraulicOilTemperature_FChanged();
- }
- void AppModel::setLowOilPressure_F(const bool& value) {
- m_lowOilPressure_F = value;
- emit lowOilPressure_FChanged();
- }
- void AppModel::setCoolantLevelLow_F(const bool& value) {
- m_coolantLevelLow_F = value;
- emit coolantLevelLow_FChanged();
- }
- void AppModel::setCoolantTemperatureHigh_F(const bool& value) {
- m_coolantTemperatureHigh_F = value;
- emit coolantTemperatureHigh_FChanged();
- }
- void AppModel::setSystemOverload_F(const bool& value) {
- m_systemOverload_F = value;
- emit systemOverload_FChanged();
- }
- void AppModel::setSafebypassPressDown_F(const bool& value) {
- m_safebypassPressDown_F = value;
- emit safebypassPressDown_FChanged();
- }
- void AppModel::setEngineSPN_F(const bool& value) {
- m_engineSPN_F = value;
- emit engineSPN_FChanged();
- }
- void AppModel::setEngineWarmUp_F(const bool& value) {
- m_engineWarmUp_F = value;
- emit engineWarmUp_FChanged();
- }
- void AppModel::setEngineWarmUpTimeout_F(const bool& value) {
- m_engineWarmUpTimeout_F = value;
- emit engineWarmUpTimeout_FChanged();
- }
- void AppModel::setEmergencyStopPress_F(const bool& value) {
- m_emergencyStopPress_F = value;
- emit emergencyStopPress_FChanged();
- }
- void AppModel::setLeftFrontLegChosed(const bool& value) {
- m_leftFrontLegChosed = value;
- emit leftFrontLegChosedChanged();
- }
- void AppModel::setRightFrontLegChosed(const bool& value) {
- m_rightFrontLegChosed = value;
- emit rightFrontLegChosedChanged();
- }
- void AppModel::setLeftRearLegChosed(const bool& value) {
- m_leftRearLegChosed = value;
- emit leftRearLegChosedChanged();
- }
- void AppModel::setRightRearLegChosed(const bool& value) {
- m_rightRearLegChosed = value;
- emit rightRearLegChosedChanged();
- }
- void AppModel::setCautionLight(const bool& value) {
- m_cautionLight = value;
- emit cautionLightChanged();
- }
- void AppModel::setLightL(const bool& value) {
- m_lightL = value;
- emit lightLPlay(value);
- emit lightLChanged();
- }
- void AppModel::setLightR(const bool& value) {
- m_lightR = value;
- emit lightRPlay(value);
- emit lightRChanged();
- }
- void AppModel::setGearF(const bool& value) {
- m_gearF = value;
- emit gearFChanged();
- }
- void AppModel::setGearR(const bool& value) {
- m_gearR = value;
- emit gearRPlay(value);
- emit gearRChanged();
- }
- void AppModel::setCarPark(const bool& value) {
- m_carPark = value;
- emit carParkChanged();
- }
- void AppModel::setBuzzerPlay(const bool& value) {
- m_buzzerPlay = value;
- emit buzzerPlayIt(value);
- emit buzzerPlayChanged();
- }
- void AppModel::setLightFront(const bool& value) {
- m_lightFront = value;
- emit lightFrontChanged();
- }
- void AppModel::setLightWork(const bool& value) {
- m_lightWork = value;
- emit lightWorkChanged();
- }
- void AppModel::setEmergency(const bool& value) {
- m_emergency = value;
- emit emergencyChanged();
- }
- /*void AppModel::setMqttToSever(cannet_frame* frames)
- {
- int keyStatus = ((frames[3].data[2] >> 7) & 0x01) * 2 + ((frames[3].data[3] >> 0) & 0x01) * 1;
- int gearControl= ((frames[3].data[0] >> 6) & 0x01) * 2 + ((frames[3].data[0] >> 5) & 0x01) * 1;
- int travelLight = ((frames[3].data[0] >> 0) & 0x01) * 2 + ((frames[3].data[0] >> 1) & 0x01) * 1;
- QString accPedal = QString::fromStdString(std::to_string(frames[0].data[0]) + " AND " + std::to_string(frames[0].data[1]) +
- " || " + std::to_string(frames[0].data[2]) + " AND " + std::to_string(frames[0].data[3]));
- QString brakePedal = QString::number(frames[0].data[4]) + " AND " +QString::number(frames[0].data[5]);
- QString steeringWheel = QString::number(frames[2].data[2]) + " AND " + QString::number(frames[2].data[3]);
- int turnSignal= ((frames[3].data[0] >> 4) & 0x01) * 2 + ((frames[3].data[0] >> 3) & 0x01) * 1;
- int turnMode = ((frames[3].data[3] >> 6) & 0x01) * 4 + ((frames[3].data[3] >> 5) & 0x01) * 3 +
- ((frames[3].data[3] >> 4) & 0x01) * 2 + ((frames[3].data[3] >> 3) & 0x01) * 1;
- int workLight = ((frames[3].data[2] >> 5) & 0x01) * 2 + ((frames[3].data[2] >> 4) & 0x01) * 1;
- int baseLegSwitch = ((frames[3].data[1] >> 5) & 0x01) * 8 + ((frames[3].data[1] >> 4) & 0x01) * 4 +
- ((frames[3].data[1] >> 3) & 0x01) * 2 + ((frames[3].data[1] >> 2) & 0x01) * 1;
- QString baseLegControl = QString::number(frames[0].data[6]) + " AND " + QString::number(frames[0].data[7]);
- QString taskJoint_1 = QString::number(frames[1].data[0]) + " AND " + QString::number(frames[1].data[1]);
- QString taskJoint_2 = QString::number(frames[1].data[6]) + " AND " + QString::number(frames[1].data[7]);
- QString taskJoint_3 = QString::number(frames[1].data[2]) + " AND " + QString::number(frames[1].data[3]);
- QString endJoint = QString::number(frames[2].data[0]) + " AND " + QString::number(frames[2].data[1]);
- QString toolControl = QString::number(frames[1].data[4]) + " AND " + QString::number(frames[1].data[5]);
- int cabLift = ((frames[3].data[1] >> 7) & 0x01) * 2 + ((frames[3].data[1] >> 6) & 0x01) * 1;
- int coopSignal = ((frames[3].data[4] >> 4) & 0x01) * 2 + ((frames[3].data[4] >> 3) & 0x01) * 1;
- int errAccPedal = ((frames[3].data[5] >> 7) & 0x01) * 2 + ((frames[3].data[5] >> 6) & 0x01) * 1;
- int errHandle = ((frames[3].data[5] >> 4) & 0x01) * 16+((frames[3].data[5] >> 3) & 0x01) * 8 + ((frames[3].data[5] >> 2) & 0x01) * 4 +
- ((frames[3].data[5] >> 1) & 0x01) * 2 + ((frames[3].data[5] >> 0) & 0x01) * 1;
- QJsonObject pcanObject;
- pcanObject.insert("cockpitID", "Cop001");
- pcanObject.insert("userID", "Ego");
- pcanObject.insert("vehicleID", "0538");
- pcanObject.insert("timeStamp", "11111111111");
- QJsonObject basObject;
- basObject.insert("keyStatus", keyStatus);
- basObject.insert("parkControl", frames[3].data[1] >> 0 & 0x01);
- basObject.insert("travelMode", frames[3].data[3] >> 2 & 0x01);
- basObject.insert("eStop", frames[3].data[3] >> 1 & 0x01);
- basObject.insert("directSwitch", frames[3].data[4] >> 2 & 0x01);
- basObject.insert("gearControl", gearControl);
- basObject.insert("hazardLight", frames[3].data[0] >> 2 & 0x01);
- basObject.insert("travelLight", travelLight);
- basObject.insert("vehicleHorn", frames[3].data[1] >> 1 & 0x01);
- basObject.insert("silencedAlarm", frames[3].data[2] >> 6 & 0x01);
- pcanObject.insert("basControl", basObject);
- QJsonObject driveObject;
- driveObject.insert("accPedal", accPedal);
- driveObject.insert("brakePedal", brakePedal);
- driveObject.insert("steeringWheel", steeringWheel);
- driveObject.insert("turnSignal", turnSignal);
- driveObject.insert("turnMode", turnMode);
- pcanObject.insert("driverControl", driveObject);
- QJsonObject taskObject;
- taskObject.insert("enableHydraulic", frames[3].data[2] >> 0 & 0x01);
- taskObject.insert("workLight", workLight);
- taskObject.insert("bypassSwitch", frames[3].data[2] >> 1 & 0x01);
- taskObject.insert("baseLegSwitch", baseLegSwitch);
- taskObject.insert("baseLegControl", baseLegControl);
- taskObject.insert("taskJoint_1", taskJoint_1);
- taskObject.insert("taskJoint_2", taskJoint_2);
- taskObject.insert("taskJoint_3", taskJoint_3);
- taskObject.insert("endJoint", endJoint);
- taskObject.insert("toolControl", toolControl);
- taskObject.insert("suckerSelect", frames[3].data[2] >> 2 & 0x01);
- taskObject.insert("cabLift", cabLift);
- taskObject.insert("esCabLift", frames[3].data[2] >> 3 & 0x01);
- taskObject.insert("coopSignal", coopSignal);
- pcanObject.insert("taskControl", taskObject);
- QJsonObject errObject;
- errObject.insert("errBasOperation", "");
- errObject.insert("errAccPedal", errAccPedal);
- errObject.insert("errBrakePedal", frames[3].data[6] >> 0 & 0x01);
- errObject.insert("errSteeringWheel", frames[3].data[6] >> 1 & 0x01);
- errObject.insert("errHandle", errHandle);
- errObject.insert("errEndTool", frames[3].data[5] >> 5 & 0x01);
- errObject.insert("errOther", "");
- pcanObject.insert("errCode", errObject);
- }*/
- void AppModel::setSteerAngle(const float& value)
- {
- m_steerAngle = value;
- emit steerAngleChanged();
- }
- float AppModel::Steer() const
- {
- return m_steerAngle;
- }
- void AppModel::setPing(const int32_t &value) {
- m_ping = value;
- emit pingChanged();
- }
- void AppModel::setTemp(const double& value)
- {
- m_temp = value;
- emit tempChanged();
- }
- void AppModel::onKickoff() { emit closeWin(); }
- /** 换挡 */
- void AppModel::egoGearChanged(int gear)
- {
- //qDebug() << this << "gear states " << gear << "changed!!";
- //gear == 1 是N挡
- if (gear == 1) {
- //setForward(1);
- setForward(-1);
- }
- //gear ==2 是D挡
- else if (gear == 2) {
- setForward(0);
- //setForward(1);
- }
- //gear==3 是R挡
- else if (gear == 3) {
- //setForward(0);
- setForward(1);
- }
- }
- /** 升降换挡 */
- void AppModel::egoGear_DChanged(int gear_d)
- {
- //qDebug() << this << "gear_d states " << gear << "changed!!";
- if (gear_d == 0) {
- setGear_D(gear_d);
- }
- else if (gear_d == 1) {
- setGear_D(gear_d);
- }
- else if (gear_d == 2) {
- setGear_D(gear_d);
- }
- else if (gear_d == 3) {
- setGear_D(gear_d);
- }
- else if (gear_d == 4) {
- setGear_D(gear_d);
- }
- }
- /**转向灯*/
- void AppModel::egoDirectionLightChanged(int light)
- {
- if (light == 0)
- {
- setDirectionLight(0);
- }
- else if (light == 1)
- {
- setDirectionLight(1);
- }
- else if (light == 2)
- {
- setDirectionLight(2);
- }
- }
- void AppModel::egoWiperChanged(bool wiper)
- {
- if (wiper == 0)
- {
- setWiper(1);
- }
- else if (wiper == 1)
- {
- setWiper(0);
- }
- }
- void AppModel::egoFrontLightChanged(bool frontlight)
- {
- if (frontlight == 0)
- {
- setFrontLight(1);
- }
- else if (frontlight == 1)
- {
- setFrontLight(0);
- }
- }
- void AppModel::egoBackLightChanged(bool backlight)
- {
- if (backlight == 0)
- {
- setBackLight(1);
- }
- else if (backlight == 1)
- {
- setBackLight(0);
- }
- }
- //add-wfg
- void AppModel::egoBuzzerChanged(bool buzzer)
- {
- if (buzzer == 0)
- {
- setBuzzer(1);
- }
- else if (buzzer == 1)
- {
- setBuzzer(0);
- }
- }
- void AppModel::egoCautionLightChanged(bool cautionLight)
- {
- setCautionLight(cautionLight);
- }
- void AppModel::egoLightLChanged(bool lightL)
- {
- setLightL(lightL);
- }
- void AppModel::egoLightRChanged(bool lightR)
- {
- setLightR(lightR);
- }
- void AppModel::egoGearFChanged(bool gearF)
- {
- setGearF(gearF);
- }
- void AppModel::egoGearRChanged(bool gearR)
- {
- setGearR(gearR);
- }
- void AppModel::egoCarParkChanged(bool carPark)
- {
- setCarPark(carPark);
- }
- void AppModel::egoBuzzerPlayChanged(bool buzzerPlay)
- {
- setBuzzerPlay(buzzerPlay);
- }
- void AppModel::egoLightFrontChanged(bool lightFront)
- {
- setLightFront(lightFront);
- }
- void AppModel::egoLightWorkChanged(bool lightWork)
- {
- setLightWork(lightWork);
- }
- void AppModel::egoEmergencyChanged(bool emergency)
- {
- setEmergency(emergency);
- }
- void AppModel::egoMqttChanged(cannet_frame* frames)
- {
- //setMqttToSever(frames);
- }
- void AppModel::onNotifyLeave(int32_t peer) { m_peer = -1; }
- void AppModel::onNotifyFail(int32_t peer)
- {
- m_peer = -1;
- }
- QQmlListProperty<CarData> AppModel::car() const { return *(d->carProp); }
- void AppModel::userLogin(QString useName, QString password) {
- _control->Login(useName.toStdString(), password.toStdString());
- }
- void AppModel::leaveCar(int carID) {
- if (m_ready == false) return;
- m_ready = false;
- m_peer = -1;
- _control->SetReady(false);
- _control->OnCarLeave();
- //_control->ChangeState(UserState::Idle);
- _control->ChangeState(carID,UserState::Idle);
- }
- bool AppModel::idle(int id)
- {
- for (auto& node : _users)
- {
- if (node.uid == id &&((id==m_peer)|| node.state == UserState::Idle))
- return true;
- }
- return false;
- }
- void AppModel::connectCar(int id)
- {
- for (auto& node : _users)
- {
- if (node.uid == id&&node.state==UserState::Idle)
- {
- if (m_ready == true) return;
- //_control->ChangeState(UserState::Remote);
- _control->ChangeState(id,UserState::Remote);
- _control->OnCarConnect(id);
- _control->SetReady(true);
- m_peer = id;
- SetVisible(node.carType == CarType::ZJ);
- setReady(true);
-
- this->setCarName(QString::fromStdString(node.name));
- break;
- }
- }
- }
- void AppModel::controlCar(int id)
- {
- connectCar(id);
- }
- void AppModel::cancelControl()
- {
- //_control->ChangeState(UserState::Idle);
- }
- void AppModel::showBackDlg(QString content, WorkArea area, int32_t no, int32_t uid)
- {
-
- QVariant arg_1 = content;
- QVariant arg_2 = (int32_t)area;
- QVariant arg_3 = no;
- QVariant arg_4 = uid;
- QMetaObject::invokeMethod(m_qmlObj, "popDialog",
-
- Q_ARG(QVariant, arg_1),
- Q_ARG(QVariant, arg_2),
- Q_ARG(QVariant, arg_3),
- Q_ARG(QVariant, arg_4));
- }
- void AppModel::showMoveDlg(MoveDesc desc)
- {
- QVariant arg_1 = (int32_t)desc;
- QMetaObject::invokeMethod(m_qmlObj, "moveErrorDialog", Q_ARG(QVariant, arg_1));
- }
- /*
- void AppModel::showTrackDlg()
- {
- }
- void AppModel::unTrack()
- {
- m_ready = false;
- _control->SetReady(false);
- _control->OnCarLeave();
- }
- bool AppModel::autoClose()
- {
- return _control->IsAutoClose();
- }
- */
- void AppModel::onLoginRst(bool rst) {
- qDebug() << "AppModel::loginResult >>";
- // if (rst) {
- // delete previous carList
- // foreach (CarData *inf, d->car)
- // delete inf;
- // d->car.clear();
- // req new list
- //_control->ReqCarList();
- // } else {
- // qDebug() << "AppModel::loginResult >>" << rst;
- // }
-
- }
- void AppModel::onNotifyDel(int32_t peer) {
- for (int32_t i = 0; i < d->car.count(); i++)
- {
- if (d->car.at(i)->uid() == peer)
- {
- delete d->car.at(i);
- d->car.removeAt(i);
- break;
- }
- }
- emit carChanged();
- for (auto it = _users.begin(); it != _users.end(); ++it)
- {
- if ((*it).uid == peer)
- {
- _users.erase(it);
- break;
- }
- }
- // d->car.clear();
- }
- //车辆增加管理
- void AppModel::onCarAppend(const UserCamera &info) {
- bool bFind = false;
- for (auto& node : d->car)
- {
- if (node->uid() == info.uid)
- {
- node->setType(QString::number(info.type));
- node->setName(QString::fromStdString(info.name));
- node->setState(QString::number(info.state));
- node->setCarType(info.carType);
- bFind = true;
- return;
- }
- }
- if (!bFind)
- {
- CarData* users = new CarData;// = (CarData*)malloc;
- users->setUid(info.uid);
- users->setType(QString::number(info.type));
- users->setName(QString::fromStdString(info.name));
- users->setState(QString::number(info.state));
- users->setCarType(info.carType);
- d->car.append(users);
- }
- bFind = false;
- for (auto& node : _users)
- {
- if (node.uid == info.uid)
- {
- bFind = true;
- }
- }
- if(!bFind)
- _users.push_back(info); //在 _users 中添加新的 UserCamera 对象
- emit carChanged();
- }
- void AppModel::onNotifyState(int32_t uid, UserState state)
- {
- for (auto& node : d->car)
- {
- if (node->uid() == uid)
- {
- node->setState(QString::number(state));
- break;
- }
- }
- emit carChanged();
- for (auto& node : _users)
- {
- if (node.uid == uid)
- {
- node.state = state;
- break;
- }
- }
-
-
- }
- void AppModel::onRadarUpadte(int32_t r0, int32_t r1, int32_t r2, int32_t r3,
- int32_t r4, int32_t r5,int32_t r6, int32_t r7) {
- if (r0 > 0)
- this->setRadar1(r0);
- if (r1 > 0)
- this->setRadar2(r1);
- if (r2 > 0)
- this->setRadar3(r2);
- if (r3 > 0)
- this->setRadar4(r3);
- if (r4 > 0)
- this->setRadar5(r4);
- if (r5 > 0)
- this->setRadar6(r5);
- if (r6 > 0)
- this->setRadar7(r6);
- if (r7 > 0)
- this->setRadar8(r7);
- //断点
- int32_t distance = 2000;
- if ((r0 > 0 && r0 < distance) || (r1 > 0 && r1 < distance) ||
- (r2 > 0 && r2 < distance) || (r3 > 0 && r3 < distance) ||
- (r4 > 0 && r4 < distance) || (r5 > 0 && r5 < distance) ||
- (r6 > 0 && r6 < distance) || (r7 > 0 && r7 < distance)) {
- emit playAlertSound();
- }
- }
- void AppModel::onFeedData(const FeedData& data)
- {
- this->setEngineSpeed(data.engine_speed);
- this->setTravelSpeed(data.travel_speed);
- this->setFuelLevel(data.fuel_level);
- this->setEngineTemperature(data.engine_temperature);
- this->setHydraulicOilTemperature(data.hydraulic_oil_temperature);
- this->setMainPump1Pressure(data.main_pump_1_pressure);
- this->setMainPump2Pressure(data.main_pump_2_pressure);
- this->setHandGear(data.hand_gear);
- this->setActualGear(data.actual_gear);
- this->setGripperHeight(data.gripper_height);
- this->setAmplitude(data.amplitude);
- this->setBoomAngle(data.boom_angle);
- this->setStickAngle(data.stick_angle);
- this->setIdleProtection(data.idle_protection);
- this->setFrontToggle(data.front_toggle);
- this->setBackToggle(data.back_toggle);
- this->setInterLock(data.interlock);
- this->setSafetySwitch(data.safety_switch);
- this->setArmLiftPilot(data.arm_lift_pilot);
- this->setArmLoweringPilot(data.arm_lowering_pilot);
- this->setLeverLiftingLilot(data.lever_lifting_pilot);
- this->setRodLoweringPilot(data.rod_lowering_pilot);
- this->setLeftRotaryPilot(data.left_rotary_pilot);
- this->setRightRotaryPilot(data.right_rotary_pilot);
- this->setGrabOpenPilot(data.grab_open_pilot);
- this->setGrabClosePilot(data.grab_close_pilot);
- this->setSafetyValves(data.safety_valves);
- this->setLiftPilotPressureSensor_F(data.liftpilotpressuresensor_f);
- this->setLoweringPilotPressureSensor_F(data.loweringpilotpressuresensor_f);
- this->setLeverLiftPilotPressureSensor_F(data.leverliftpilotpressuresensor_f);
- this->setRodLoweringPilotPressurePensor_F(data.rodloweringpilotpressurepensor_f);
- this->setLeftTurnPilotPressureSensor_F(data.leftturnpilotpressuresensor_f);
- this->setRightTurnPilotPressureSensor_F(data.rightturnpilotpressuresensor_f);
- this->setLegExtensionPilotPressureSensor_F(data.legextensionpilotpressuresensor_f);
- this->setLegRetractPilotPressureSensor_F(data.legretractpilotpressuresensor_f);
- this->setGrabOpenPilotPressureSensor_F(data.grabopenpilotpressuresensor_f);
- this->setGrabClosurePilotPressureSensor_F(data.grabclosurepilotpressuresensor_f);
- this->setMainPump1PressureSensor_F(data.mainpump1pressuresensor_f);
- this->setMainPump2PressureSensor_F(data.mainpump2pressuresensor_f);
- this->setChamberPressureSensor_F(data.chamberpressuresensor_f);
- this->setBucketRodPressureSensor_F(data.bucketrodpressuresensor_f);
- this->setParkingPressureSensor_F(data.parkingpressuresensor_f);
- this->setAccumulatorPressureSensor_F(data.accumulatorpressuresensor_f);
- this->setGasPedal_F(data.gaspedal_f);
- this->setThrottleKnob_F(data.throttleknob_f);
- this->setLegHandle_F(data.leghandle_f);
- this->setGripKnob_F(data.gripknob_f);
- this->setHydraulicOilTemperatureSensor_F(data.hydraulicoiltemperaturesensor_f);
- this->setFuelLevelSensor_F(data.fuellevelsensor_f);
- this->setBoomAngleSensor_F(data.boomanglesensor_f);
- this->setBucketLeverTiltSensor_F(data.bucketlevertiltsensor_f);
- this->setExpansionModule_F(data.expansionmodule_f);
- this->setWorkingDistanceOverrun_F(data.workingdistanceoverrun_f);
- this->setLowOilLevel_F(data.lowoillevel_f);
- this->setBatteryLowVoltage_F(data.batterylowvoltage_f);
- this->setBatteryHighVoltage_F(data.batteryhighvoltage_f);
- this->setAccumulatorPressure_F(data.accumulatorpressure_f);
- this->setHighHydraulicOilTemperature_F(data.highhydraulicoiltemperature_f);
- this->setLowOilPressure_F(data.lowoilpressure_f);
- this->setCoolantLevelLow_F(data.coolantlevellow_f);
- this->setCoolantTemperatureHigh_F(data.coolanttemperaturehigh_f);
- this->setSystemOverload_F(data.systemoverload_f);
- this->setSafebypassPressDown_F(data.safebypasspressdown_f);
- this->setEngineSPN_F(data.enginespn_f);
- this->setEngineWarmUp_F(data.enginewarmup_f);
- this->setEngineWarmUpTimeout_F(data.enginewarmuptimeout_f);
- this->setEmergencyStopPress_F(data.emergencystoppress_f);
- this->setLeftFrontLegChosed(data.leftfrontlegchosed);
- this->setRightFrontLegChosed(data.rightfrontlegchosed);
- this->setLeftRearLegChosed(data.leftrearlegchosed);
- this->setRightRearLegChosed(data.rightrearlegchosed);
- this->SetBrakePressure(data.brake_pressure);
- this->SetEngineOilPressure(data.engine_pressure);
- this->SetEngingRpm(data.engine_rpm);
- //this->SetGear(data.gear);
- this->SetGearBoxOilPressure(data.gearbox_oil_pressure);
- this->SetGearBoxOilTemp(data.gearbox_oil_temp);
- this->SetSpeed(data.speed);
- this->setWorkPressure(data.work_pressure);
- this->SetCold(data.cold_water);
- this->setSteerAngle(data.steer_angle/4096.f*360.f);
- }
- void AppModel::onPing(int32_t value, double temp) { this->setPing(value); this->setTemp(temp); }
- void AppModel::onImuUpdate(float x, float y) {
- //断点
- this->setImux(x);
- this->setImuy(y);
- }
- void AppModel::logout() {
- d->car.clear();
- m_ready = false;
- }
- void AppModel::moveBegin(int32_t area,int32_t no)
- {
-
- if (m_peer == -1) return;
- no -= 1;
- // _control->OnCarLeave();
- _control->OnMoveBegin(m_peer, static_cast<WorkArea>(area), no);
- }
- /*
- void AppModel::switchDriver()
- {
- if (m_peer == -1) return;
- _control->SwitchDriver(m_peer);
- }
- */
- void AppModel::onMoveEnd(int32_t rid, WorkArea area, int32_t no)
- {
- for (auto& user:_users)
- {
-
- if (user.uid == rid)
- {
- //sr text[128];
-
- //sprintf(text,"%s �Ѿ�����Ŀ��ص�\n \t ����Զ�̲ٿ�", data->name().toStdString().c_str());
- QString str = QString::fromStdString(user.name);
- showBackDlg(str, area,no,rid);
- //_control->ChangeState(UserState::AskRemote);
- _control->ChangeState(rid,UserState::AskRemote);
- // sprintf(text, "321321312" );
- }
- }
-
- }
- void AppModel::onMoveRet(MoveDesc desc)
- {
- if (desc != MoveDesc::Move_OK)
- {
- showMoveDlg(desc);
- }
- }
- /*
- void AppModel::areaChanged(int32_t area)
- {
- m_area = static_cast<WorkArea>(area);
-
-
- }
- */
- void AppModel::OnClose()
- {
- if (m_ready)
- {
- leaveCar(100);
- Sleep(5000);
-
- }
- //调用直接终止当前进程
- ::ExitProcess(0);
- }
- void AppModel::onEncodeUpdate(int32_t left, int32_t right)
- {
- setLeftAngle(left);
- setRightAngle(right);
- }
- /*
- void AppModel::OnPosition(float x, float y, float z)
- {
- setModelX(x * 100);
- setModelY(y * 100);
- setModelZ(z * 100);
- }
- */
|