12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049 |
- #include "appmodel.h"
- #include "Ego.h"
- #define WIN23_LEAN_AND_MEAN
- #include <Windows.h>
- //#include "FishEyeWindow.h"
- // extern std::array<IRender *, 3> ar;
- 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();
- }
- class AppModelPrivate {
- public:
- QList<CarData *> car;
- QQmlListProperty<CarData> *carProp = nullptr;
- };
- static void carAppend(QQmlListProperty<CarData> *prop, CarData *val) {
- Q_UNUSED(val);
- Q_UNUSED(prop);
- }
- static CarData *carAt(QQmlListProperty<CarData> *prop, qsizetype index) {
- AppModelPrivate *d = static_cast<AppModelPrivate *>(prop->data);
- return d->car.at(index);
- }
- static qsizetype carCount(QQmlListProperty<CarData> *prop) {
- AppModelPrivate *d = static_cast<AppModelPrivate *>(prop->data);
- return d->car.size();
- }
- 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(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,int32_t)),
- this,
- SLOT(
- onRadarUpadte(int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t,int32_t,int32_t)));
- 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; }
- float AppModel::Steer() const { return m_steer; }
- 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; }
- int AppModel::radar1() const { return m_radar1; }
- int32_t AppModel::WorkPressure() const { return m_work_pressure; }
- 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; }
- int AppModel::radar9() const { return m_radar9; }
- int32_t AppModel::OilPos() const { return m_oil_pos; }
- //大冶新增
- int32_t AppModel::engineTime() const { return m_engineTime; }
- int32_t AppModel::wireSensorL() const { return m_wireSensorL; }
- int32_t AppModel::wireSensorR() const { return m_wireSensorR; }
- int32_t AppModel::fuelLevel() const { return m_fuelLevel; }
- int32_t AppModel::lockSwitchL() const { return m_lockSwitchL; }
- int32_t AppModel::lockSwitchR() const { return m_lockSwitchR; }
- int32_t AppModel::tipLimit() const { return m_tipLimit; }
- int32_t AppModel::turnLeft() const { return m_turnLeft; }
- int32_t AppModel::turnRight() const { return m_turnRight; }
- int32_t AppModel::hightBeam() const { return m_hightBeam; }
- int32_t AppModel::lowBeam() const { return m_lowBeam; }
- int32_t AppModel::parking() const { return m_parking; }
- int32_t AppModel::brake() const { return m_brake; }
- int32_t AppModel::backCar() const { return m_backCar; }
- int32_t AppModel::frontWorkLamp() const { return m_frontWorkLamp; }
- int32_t AppModel::rearWorkLamp() const { return m_rearWorkLamp; }
- int32_t AppModel::cargoWeight() const { return m_cargoWeight; }
- int32_t AppModel::systemVol() const { return m_systemVol; }
- int32_t AppModel::fGear() const { return m_fGear; }
- int32_t AppModel::gear1() const { return m_gear1; }
- int32_t AppModel::lowOilPressureAlarm() const { return m_lowOilPressureAlarm; }
- int32_t AppModel::engineWaterTemperatureAlarm() const { return m_engineWaterTemperatureAlarm; }
- int32_t AppModel::highEngineOilTemperatureAlarm() const { return m_highEngineOilTemperatureAlarm; }
- int32_t AppModel::engineWaterLevelLowAlarm() const { return m_engineWaterLevelLowAlarm; }
- int32_t AppModel::lowFuelOilAlarm() const { return m_lowFuelOilAlarm; }
- int32_t AppModel::returnOilFilterBlockedAlarm() const { return m_returnOilFilterBlockedAlarm; }
- int32_t AppModel::oilFilterBlockedAlarm() const { return m_oilFilterBlockedAlarm; }
- int32_t AppModel::controlScreenBlockageAlarm() const { return m_controlScreenBlockageAlarm; }
- int32_t AppModel::emergencyFilterBlockingAlarm() const { return m_emergencyFilterBlockingAlarm; }
- int32_t AppModel::coolingFilterBlockedAlarm() const { return m_coolingFilterBlockedAlarm; }
- int32_t AppModel::electricPumpScreenBlockedAlarm() const { return m_electricPumpScreenBlockedAlarm; }
- int32_t AppModel::brakeFilterBlockedAlarm() const { return m_brakeFilterBlockedAlarm; }
- int32_t AppModel::variableSpeedFilterBlockedAlarm() const { return m_variableSpeedFilterBlockedAlarm; }
- int32_t AppModel::lowVoltageAlarm() const { return m_lowVoltageAlarm; }
- int32_t AppModel::highTransmissionOilTemperature() const { return m_highTransmissionOilTemperature; }
- int32_t AppModel::transmissionOilPressureIsLow() const { return m_transmissionOilPressureIsLow; }
- int32_t AppModel::oilTemperatureSensor1IsFaulty() const { return m_oilTemperatureSensor1IsFaulty; }
- int32_t AppModel::oilTemperatureSensor2IsFaulty() const { return m_oilTemperatureSensor2IsFaulty; }
- int32_t AppModel::oilLevelSensorIsFaulty() const { return m_oilLevelSensorIsFaulty; }
- int32_t AppModel::frontThrottleFault() const { return m_frontThrottleFault; }
- int32_t AppModel::rearThrottleFault() const { return m_rearThrottleFault; }
- int32_t AppModel::handleOfTheUpperArmIsFaulty() const { return m_handleOfTheUpperArmIsFaulty; }
- int32_t AppModel::leftLegHandleIsFaulty() const { return m_leftLegHandleIsFaulty; }
- int32_t AppModel::rightLegHandleIsFaulty() const { return m_rightLegHandleIsFaulty; }
- int32_t AppModel::engineBusFault() const { return m_engineBusFault; }
- int32_t AppModel::transmissionBusFault() const { return m_transmissionBusFault; }
- int32_t AppModel::remoteControlBusFault() const { return m_remoteControlBusFault; }
- int32_t AppModel::rodChamberPressureSensorIsFaulty() const { return m_rodChamberPressureSensorIsFaulty; }
- int32_t AppModel::noRodChamberPressureSensorIsFaulty() const { return m_noRodChamberPressureSensorIsFaulty; }
- int32_t AppModel::brakePressureSensorIsFaulty() const { return m_brakePressureSensorIsFaulty; }
- int32_t AppModel::systemPressureSensorIsFaulty() const { return m_systemPressureSensorIsFaulty; }
- int32_t AppModel::controlPressureSensorIsFaulty() const { return m_controlPressureSensorIsFaulty; }
- int32_t AppModel::steeringPressureSensorIsFaulty() const { return m_steeringPressureSensorIsFaulty; }
- int32_t AppModel::pressureSensorOfTheLowerArmIsFaulty() const { return m_pressureSensorOfTheLowerArmIsFaulty; }
- int32_t AppModel::lockingPinDisplacementSensorLIsFaulty() const { return m_lockingPinDisplacementSensorLIsFaulty; }
- int32_t AppModel::lockingPinDisplacementSensorRIsFaulty() const { return m_lockingPinDisplacementSensorRIsFaulty; }
- int32_t AppModel::legDisplacementSensorLIsFaulty() const { return m_legDisplacementSensorLIsFaulty; }
- int32_t AppModel::legDisplacementSensorRIsFaulty() const { return m_legDisplacementSensorRIsFaulty; }
- int32_t AppModel::steeringEncoderFailure() const { return m_steeringEncoderFailure; }
- int AppModel::ping() const { return m_ping; }
- double AppModel::temp() const { return m_temp; }
- int AppModel::alertSound() const { return m_alert; }
- 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::setRadar1(const int32_t &value) {
- m_radar1 = value;
- emit radar1Changed();
- }
- void AppModel::setRadar2(const int32_t &value) {
- m_radar2 = value;
- emit radar2Changed();
- }
- void AppModel::setRadar3(const int32_t &value) {
- m_radar3 = value;
- emit radar3Changed();
- }
- void AppModel::setSteerAngle(const float& value)
- {
- if (value > 1)
- {
- m_steer = (value - 1.0) * (-10);
- }
- else if(value==1)
- {
- m_steer = 0.0;
- }
- else
- {
- m_steer = value * 10;
- }
- emit steerAngleChanged();
- //qDebug() << "角度值=============" << m_steer;
- }
- //大冶新增
- void AppModel::setEngineTime(const int32_t value){
- m_engineTime = value;
- emit engineTimeChanged();
- }
- void AppModel::setWireSensorL(const int32_t value) {
- m_wireSensorL = value;
- emit wireSensorLChanged();
- }
- void AppModel::setWireSensorR(const int32_t value) {
- m_wireSensorR = value;
- emit wireSensorRChanged();
- }
- void AppModel::setFuelLevel(const int32_t value) {
- m_fuelLevel = value;
- emit fuelLevelChanged();
- }
- void AppModel::setLockSwitchL(const int32_t value) {
- m_lockSwitchL = value;
- emit lockSwitchLChanged();
- }
- void AppModel::setLockSwitchR(const int32_t value) {
- m_lockSwitchR = value;
- emit lockSwitchRChanged();
- }
- void AppModel::setTipLimit(const int32_t value) {
- m_tipLimit = value;
- //qDebug() << "倾翻压力开关*************" << m_tipLimit;
- emit tipLimitChanged();
- }
- void AppModel::setTurnLeft(const int32_t value) {
- m_turnLeft = value;
- emit turnLeftChanged();
- }
- void AppModel::setTurnRight(const int32_t value) {
- m_turnRight = value;
- emit turnRightChanged();
- }
- void AppModel::setHightBeam(const int32_t value) {
- m_hightBeam = value;
- emit hightBeamChanged();
- }
- void AppModel::setLowBeam(const int32_t value) {
- m_lowBeam = value;
- emit lowBeamChanged();
- }
- void AppModel::setParking(const int32_t value) {
- m_parking = value;
- emit parkingChanged();
- }
- void AppModel::setBrake(const int32_t value) {
- m_brake = value;
- emit brakeChanged();
- }
- void AppModel::setBackCar(const int32_t value) {
- m_backCar = value;
- emit backCarChanged();
- }
- void AppModel::setFrontWorkLamp(const int32_t value) {
- m_frontWorkLamp = value;
- emit frontWorkLampChanged();
- }
- void AppModel::setRearWorkLamp(const int32_t value) {
- m_rearWorkLamp = value;
- emit rearWorkLampChanged();
- }
- void AppModel::setCargoWeight(const int32_t value) {
- m_cargoWeight = value;
- emit cargoWeightChanged();
- }
- void AppModel::setSystemVol(const int32_t value) {
- m_systemVol = value;
- emit systemVolChanged();
- }
- void AppModel::setFGear(const int32_t value) {
- m_fGear = value;
- emit fGearChanged();
- }
- void AppModel::setGear1(const int32_t value) {
- m_gear1 = value;
- emit gear1Changed();
- }
- void AppModel::setLowOilPressureAlarm(const int32_t value) {
- m_lowOilPressureAlarm = value;
- emit lowOilPressureAlarmChanged();
- }
- void AppModel::setEngineWaterTemperatureAlarm(const int32_t value) {
- m_engineWaterTemperatureAlarm = value;
- emit engineWaterTemperatureAlarmChanged();
- }
- void AppModel::setHighEngineOilTemperatureAlarm(const int32_t value) {
- m_highEngineOilTemperatureAlarm = value;
- emit highEngineOilTemperatureAlarmChanged();
- }
- void AppModel::setEngineWaterLevelLowAlarm(const int32_t value) {
- m_engineWaterLevelLowAlarm = value;
- emit engineWaterLevelLowAlarmChanged();
- }
- void AppModel::setLowFuelOilAlarm(const int32_t value) {
- m_lowFuelOilAlarm = value;
- emit lowFuelOilAlarmChanged();
- }
- void AppModel::setReturnOilFilterBlockedAlarm(const int32_t value) {
- m_returnOilFilterBlockedAlarm = value;
- emit returnOilFilterBlockedAlarmChanged();
- }
- void AppModel::setOilFilterBlockedAlarm(const int32_t value) {
- m_oilFilterBlockedAlarm = value;
- emit oilFilterBlockedAlarmChanged();
- }
- void AppModel::setControlScreenBlockageAlarm(const int32_t value) {
- m_controlScreenBlockageAlarm = value;
- emit controlScreenBlockageAlarmChanged();
- }
- void AppModel::setEmergencyFilterBlockingAlarm(const int32_t value) {
- m_emergencyFilterBlockingAlarm = value;
- emit emergencyFilterBlockingAlarmChanged();
- }
- void AppModel::setCoolingFilterBlockedAlarm(const int32_t value) {
- m_coolingFilterBlockedAlarm = value;
- emit coolingFilterBlockedAlarmChanged();
- }
- void AppModel::setElectricPumpScreenBlockedAlarm(const int32_t value) {
- m_electricPumpScreenBlockedAlarm = value;
- emit electricPumpScreenBlockedAlarmChanged();
- }
- void AppModel::setBrakeFilterBlockedAlarm(const int32_t value) {
- m_brakeFilterBlockedAlarm = value;
- emit brakeFilterBlockedAlarmChanged();
- }
- void AppModel::setVariableSpeedFilterBlockedAlarm(const int32_t value) {
- m_variableSpeedFilterBlockedAlarm = value;
- emit variableSpeedFilterBlockedAlarmChanged();
- }
- void AppModel::setLowVoltageAlarm(const int32_t value) {
- m_lowVoltageAlarm = value;
- emit lowVoltageAlarmChanged();
- }
- void AppModel::setHighTransmissionOilTemperature(const int32_t value) {
- m_highTransmissionOilTemperature = value;
- emit highTransmissionOilTemperatureChanged();
- }
- void AppModel::setTransmissionOilPressureIsLow(const int32_t value) {
- m_transmissionOilPressureIsLow = value;
- emit transmissionOilPressureIsLowChanged();
- }
- void AppModel::setOilTemperatureSensor1IsFaulty(const int32_t value) {
- m_oilTemperatureSensor1IsFaulty = value;
- emit oilTemperatureSensor1IsFaultyChanged();
- }
- void AppModel::setOilTemperatureSensor2IsFaulty(const int32_t value) {
- m_oilTemperatureSensor2IsFaulty = value;
- emit oilTemperatureSensor2IsFaultyChanged();
- }
- void AppModel::setOilLevelSensorIsFaulty(const int32_t value) {
- m_oilLevelSensorIsFaulty = value;
- qDebug() << "报警信息===========" << m_oilLevelSensorIsFaulty;
- emit oilLevelSensorIsFaultyChanged();
- }
- void AppModel::setFrontThrottleFault(const int32_t value) {
- m_frontThrottleFault = value;
- emit frontThrottleFaultChanged();
- }
- void AppModel::setRearThrottleFault(const int32_t value) {
- m_rearThrottleFault = value;
- emit rearThrottleFaultChanged();
- }
- void AppModel::setHandleOfTheUpperArmIsFaulty(const int32_t value) {
- m_handleOfTheUpperArmIsFaulty = value;
- emit handleOfTheUpperArmIsFaultyChanged();
- }
- void AppModel::setLeftLegHandleIsFaulty(const int32_t value) {
- m_leftLegHandleIsFaulty = value;
- emit leftLegHandleIsFaultyChanged();
- }
- void AppModel::setRightLegHandleIsFaulty(const int32_t value) {
- m_rightLegHandleIsFaulty = value;
- emit rightLegHandleIsFaultyChanged();
- }
- void AppModel::setEngineBusFault(const int32_t value) {
- m_engineBusFault = value;
- emit engineBusFaultChanged();
- }
- void AppModel::setTransmissionBusFault(const int32_t value) {
- m_transmissionBusFault = value;
- emit transmissionBusFaultChanged();
- }
- void AppModel::setRemoteControlBusFault(const int32_t value) {
- m_remoteControlBusFault = value;
- emit remoteControlBusFaultChanged();
- }
- void AppModel::setRodChamberPressureSensorIsFaulty(const int32_t value) {
- m_rodChamberPressureSensorIsFaulty = value;
- emit rodChamberPressureSensorIsFaultyChanged();
- }
- void AppModel::setNoRodChamberPressureSensorIsFaulty(const int32_t value) {
- m_noRodChamberPressureSensorIsFaulty = value;
- emit noRodChamberPressureSensorIsFaultyChanged();
- }
- void AppModel::setBrakePressureSensorIsFaulty(const int32_t value) {
- m_brakePressureSensorIsFaulty = value;
- emit brakePressureSensorIsFaultyChanged();
- }
- void AppModel::setSystemPressureSensorIsFaulty(const int32_t value) {
- m_systemPressureSensorIsFaulty = value;
- emit systemPressureSensorIsFaultyChanged();
- }
- void AppModel::setControlPressureSensorIsFaulty(const int32_t value) {
- m_controlPressureSensorIsFaulty = value;
- emit controlPressureSensorIsFaultyChanged();
- }
- void AppModel::setSteeringPressureSensorIsFaulty(const int32_t value) {
- m_steeringPressureSensorIsFaulty = value;
- emit steeringPressureSensorIsFaultyChanged();
- }
- void AppModel::setPressureSensorOfTheLowerArmIsFaulty(const int32_t value) {
- m_pressureSensorOfTheLowerArmIsFaulty = value;
- emit pressureSensorOfTheLowerArmIsFaultyChanged();
- }
- void AppModel::setLockingPinDisplacementSensorLIsFaulty(const int32_t value) {
- m_lockingPinDisplacementSensorLIsFaulty = value;
- emit lockingPinDisplacementSensorLIsFaultyChanged();
- }
- void AppModel::setLockingPinDisplacementSensorRIsFaulty(const int32_t value) {
- m_lockingPinDisplacementSensorRIsFaulty = value;
- emit lockingPinDisplacementSensorRIsFaultyChanged();
- }
- void AppModel::setLegDisplacementSensorLIsFaulty(const int32_t value) {
- m_legDisplacementSensorLIsFaulty = value;
- emit legDisplacementSensorLIsFaultyChanged();
- }
- void AppModel::setLegDisplacementSensorRIsFaulty(const int32_t value) {
- m_legDisplacementSensorRIsFaulty = value;
- emit legDisplacementSensorRIsFaultyChanged();
- }
- void AppModel::setSteeringEncoderFailure(const int32_t value) {
- m_steeringEncoderFailure = value;
- emit steeringEncoderFailureChanged();
- }
- void AppModel::setRadar4(const int32_t &value) {
- m_radar4 = value;
- emit radar4Changed();
- }
- void AppModel::setRadar5(const int32_t &value) {
- m_radar5 = value;
- emit radar5Changed();
- }
- void AppModel::setRadar6(const int32_t& value)
- {
- m_radar6 = value;
- emit radar6Changed();
- }
- void AppModel::setRadar7(const int32_t& value)
- {
- m_radar7 = value;
- emit radar7Changed();
- }
- void AppModel::setRadar8(const int32_t& value)
- {
- m_radar8 = value;
- emit radar8Changed();
- }
- void AppModel::setRadar9(const int32_t& value)
- {
- m_radar9 = value;
- emit radar9Changed();
- }
- 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::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() {
- if (m_ready == false) return;
- m_ready = false;
- m_peer = -1;
- _control->SetReady(false);
- _control->OnCarLeave();
- _control->ChangeState(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->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);
- 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,int32_t r8) {
- 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);
- if (r8 > 0)
- this->setRadar9(r8);
- 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)*/) {
- emit playAlertSound();
- }
- }
- void AppModel::onFeedData(const FeedData& data)
- {
- 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);
- //此处计算不确定(小数点前面0为正数,1为负数)
- this->setSteerAngle(data.steer_angle);
- //this->setSteerAngle(data.steer_angle/4096.f*360.f);
-
- //大冶新增的
- this->setEngineTime(data.engine_time);
- this->setWireSensorL(data.wire_sensor_l);
- this->setWireSensorR(data.wire_sensor_r);
- this->setFuelLevel(data.fuel_level);
- this->setLockSwitchL(data.lock_switch_l);
- this->setLockSwitchR(data.lock_switch_r);
- this->setTipLimit(data.tip_limit);
- this->setTurnLeft(data.turn_left);
- this->setTurnRight(data.turn_right);
- this->setHightBeam(data.hight_beam);
- this->setLowBeam(data.low_beam);
- this->setParking(data.parking);
- this->setBrake(data.brake);
- this->setBackCar(data.back_car);
- this->setFrontWorkLamp(data.front_work_lamp);
- this->setRearWorkLamp(data.rear_work_lamp);
- this->setCargoWeight(data.cargo_weight);
- this->setSystemVol(data.system_vol);
- this->setFGear(data.f_gear);
- this->setGear1(data.gear_1);
- //报警信息
- this->setLowOilPressureAlarm(data.low_oil_pressure_alarm);
- this->setEngineWaterTemperatureAlarm(data.engine_water_temperature_alarm);
- this->setHighEngineOilTemperatureAlarm(data.high_engine_oil_temperature_alarm);
- this->setEngineWaterLevelLowAlarm(data.engine_water_level_low_alarm);
- this->setLowFuelOilAlarm(data.low_fuel_oil_alarm);
- this->setReturnOilFilterBlockedAlarm(data.return_oil_filter_blocked_alarm);
- this->setOilFilterBlockedAlarm(data.oil_filter_blocked_alarm);
- this->setControlScreenBlockageAlarm(data.control_screen_blockage_alarm);
- this->setEmergencyFilterBlockingAlarm(data.emergency_filter_blocking_alarm);
- this->setCoolingFilterBlockedAlarm(data.cooling_filter_blocked_alarm);
- this->setElectricPumpScreenBlockedAlarm(data.electric_pump_screen_blocked_alarm);
- this->setBrakeFilterBlockedAlarm(data.brake_filter_blocked_alarm);
- this->setVariableSpeedFilterBlockedAlarm(data.variable_speed_filter_blocked_alarm);
- this->setLowVoltageAlarm(data.low_voltage_alarm);
- this->setHighTransmissionOilTemperature(data.high_transmission_oil_temperature);
- this->setTransmissionOilPressureIsLow(data.transmission_oil_pressure_is_low);
- this->setOilTemperatureSensor1IsFaulty(data.oil_temperature_sensor_1_is_faulty);
- this->setOilTemperatureSensor2IsFaulty(data.oil_temperature_sensor_2_is_faulty);
- this->setOilLevelSensorIsFaulty(data.oil_level_sensor_is_faulty);
- this->setFrontThrottleFault(data.front_throttle_fault);
- this->setRearThrottleFault(data.rear_throttle_fault);
- this->setHandleOfTheUpperArmIsFaulty(data.handle_of_the_upper_arm_is_faulty);
- this->setLeftLegHandleIsFaulty(data.left_leg_handle_is_faulty);
- this->setRightLegHandleIsFaulty(data.right_leg_handle_is_faulty);
- this->setEngineBusFault(data.engine_bus_fault);
- this->setTransmissionBusFault(data.transmission_bus_fault);
- this->setRemoteControlBusFault(data.remote_control_bus_fault);
- this->setRodChamberPressureSensorIsFaulty(data.rod_chamber_pressure_sensor_is_faulty);
- this->setNoRodChamberPressureSensorIsFaulty(data.no_rod_chamber_pressure_sensor_is_faulty);
- this->setBrakePressureSensorIsFaulty(data.brake_pressure_sensor_is_faulty);
- this->setSystemPressureSensorIsFaulty(data.system_pressure_sensor_is_faulty);
- this->setControlPressureSensorIsFaulty(data.control_pressure_sensor_is_faulty);
- this->setSteeringPressureSensorIsFaulty(data.steering_pressure_sensor_is_faulty);
- this->setPressureSensorOfTheLowerArmIsFaulty(data.pressure_sensor_of_the_lower_arm_is_faulty);
- this->setLockingPinDisplacementSensorLIsFaulty(data.locking_pin_displacement_sensor_L_is_faulty);
- this->setLockingPinDisplacementSensorRIsFaulty(data.locking_pin_displacement_sensor_R_is_faulty);
- this->setLegDisplacementSensorLIsFaulty(data.leg_displacement_sensor_L_is_faulty);
- this->setLegDisplacementSensorRIsFaulty(data.leg_displacement_sensor_R_is_faulty);
- this->setSteeringEncoderFailure(data.steering_encoder_failure);
- }
- void AppModel::onPing(int32_t value, double temp) { this->setPing(value); this->setTemp(temp); }
-
- 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);
- // 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();
- 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);
- }
- */
|