1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #include "PCANBasic.h"
- #include "message_queue.h"
- #include "auto_sensor.h"
- #include "message.h"
- CAutoSensor::CAutoSensor(CMessageQueue * q):_message(q)
- {
-
- }
- bool CAutoSensor::Start()
- {
- return true;
- }
- void CAutoSensor::Notify(int8_t* data,int32_t size)
- {
- MessageHead head;
- head.Deserialize(data);
- auto ptr=data+sizeof(MessageHead);
- switch (head.Command)
- {
- case AR::AR_Finish/* constant-expression */:
- {
- ARFinish * node=(ARFinish *)ptr;
- _message->OnGoalFinish((WorkArea)node->area,node->no);
- RemoNet::CSMoveEnd Req;
- Req.set_area(node->area);
- Req.set_no(node->no);
- Req.set_uid(0);
- CIOBuffer buffer;
- MessageHead Head;
- Head.Command=RemoNet::CS_MoveEnd;
- Head.Length=Req.ByteSize();
- Head.Serialize(buffer.Buffer);
- auto ptr=buffer.Buffer+MessageHead::Size();
- Req.SerializeToArray(ptr,Head.Length);
- buffer.Length=MessageHead::Size()+Head.Length;
- _message->WriteBuffer(buffer);
- _message->SetAutomous(false,0);
-
- }
- break;
- case AR::AR_NDTPos:
- {
- ARNdtPos* node=(ARNdtPos *)ptr;
- _message->SetNdtPos(node);
- /*
- RemoNet::NDTPos Req;
- Req.set_x(node->x);
- Req.set_y(node->y);
- Req.set_z(node->z);
- Req.set_rx(node->rx);
- Req.set_ry(node->ry);
- Req.set_rz(node->rz);
- Req.set_rw(node->rw);
- CIOBuffer buffer;
- MessageHead Head;
- Head.Command=RemoNet::CC_NDTPOS;
- Head.Length=Req.ByteSize();
- Head.Serialize(buffer.Buffer);
- auto ptr=buffer.Buffer+MessageHead::Size();
- Req.SerializeToArray(ptr,Head.Length);
- buffer.Length=MessageHead::Size()+Head.Length;
- _message->WriteBuffer(ChannelType::CHANNEL_CAR,buffer);
- */
-
- }
- break;
- default:
- break;
- }
- }
- void CAutoSensor::SetSensorSocket(SensorSocket<CAutoSensor>* can)
- {
- _socket=can;
- }
-
|