#pragma once #include "../common/comm.h" #include "../common/notifier.h" #include "../common/iobuffer.h" #include "../common/sensor_socket.h" // typedef struct { // int16_t fire_status; //启动/熄火 // int16_t remote_forward; //远程控制前进 // int16_t remote_backward; //远程控制后退 // int16_t Brake; //刹车 // int16_t Park; //驻车 // int16_t Outrigger_status; //支腿 // int16_t Turn_angle; //转弯角度 // int16_t Left_turn; //左旋 左手柄 左信号 // int16_t Right_turn; //右旋 左手柄 右信号 // int16_t Raised; //小臂抬起 左手柄 向后 // int16_t Decrease; //小臂下降 左手柄 向前 // int16_t Stretch; //大臂伸起 右手柄 向后 // int16_t Bulls_decline ; //大臂下降 右手柄 向前 // int16_t Material ; //吸盘吸料 // int16_t Discharge; //吸盘放料 // int16_t zhua; //抓斗抓料 // int16_t fang; //抓斗放料 // int16_t Shell_rotation_left; //贝壳斗旋转 逆时针 // int16_t Shell_rotation_right; //贝壳斗旋转 顺时针 // int16_t Cabin; //驾驶室升 // int16_t Cab; //驾驶室降 // int16_t Working_signal; //作业灯开/关 ? // int16_t Turn_left_signal; //左转向 开/关 // int16_t Turn_right_signal; //右转向 开/关 // int16_t Warning_Light; //警示灯 开/关 ? // int16_t Trumpet; //喇叭 // int16_t Security_lock; //安全锁 开/关 ? // int16_t Urget_stop; //急停 // int16_t Vehicle_id ; //车辆id // } vehicle_status_t; class CMessageQueue; class CCanBusSensor { public: CCanBusSensor(CMessageQueue *q); void Notify(struct can_frame *date); void SetCanBusSensor(SensorCanBus* can); void Start(); void Stop(); void OnMessage(cannet_frame* frames, int32_t count = 4); void Emergency(); private: void Run(); void CanSendProc(); void SendStatusToMSG(); private: CMessageQueue* _message; SensorCanBus * _canbus; bool _run; std::thread _can_thread; std::mutex _last_can_lock; // struct can_frame Sendframe[4]; struct can_frame Sendframe[5]; bool _front_view = true; int16_t Direction;//方向 int16_t Hand_Throttle;//手油门 int16_t Foot_Throttle;//脚油门 int16_t Brake;//刹车 int64_t count; FeedData _data; int model;//0本地,1远程 vehicle_status can_status; };