33,009
社区成员
发帖
与我相关
我的任务
分享
struct tagGPS_QUEUE GPS_QUEUE;
void GPS_QUEUE_Init(void)
{
GPS_QUEUE.rear = 0;
GPS_QUEUE.front = 0;
}
BOOL GPS_QUEUE_EMPTY(void)
{
if (GPS_QUEUE.rear == GPS_QUEUE.front)
return (TRUE);
return (FALSE);
}
BOOL GPS_QUEUE_FULL(void)
{
if ((GPS_QUEUE.rear+1) % GPS_QUEUE_MAX_LENGTH == GPS_QUEUE.front)
return (TRUE);
return (FALSE);
}
BOOL GPS_QUEUE_In(GPS_STRUCT GPs , uint8_t Func , uint16_t stop_time)
{
if (!GPS_QUEUE_FULL())
{
GPS_QUEUE.rear = (GPS_QUEUE.rear + 1) % GPS_QUEUE_MAX_LENGTH;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].Func = Func;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].X1 = GPs.modbus_X1;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].X2 = GPs.modbus_X2;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].Y1 = GPs.modbus_Y1;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].Y2 = GPs.modbus_Y2;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].Z1 = GPs.modbus_Z1;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].Z2 = GPs.modbus_Z2;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].speed1 = GPs.modbus_speed1;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].speed2 = GPs.modbus_speed2;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].pos_status = GPs.pos_status;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].year = GPs.year;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].month = GPs.month;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].day = GPs.day;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].hour = GPs.hour;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].minute = GPs.minute;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].second = GPs.second;
GPS_QUEUE.GPS_element[GPS_QUEUE.rear].stop_time = stop_time;
return (TRUE);
}
return (FALSE);
}
BOOL GPS_QUEUE_Out(GPS_QUEUE_ELEMENT *element)
{
if (!GPS_QUEUE_EMPTY())
{
GPS_QUEUE.front = (GPS_QUEUE.front + 1) % GPS_QUEUE_MAX_LENGTH;
element->Func = GPS_QUEUE.GPS_element[GPS_QUEUE.front].Func;
element->X1 = GPS_QUEUE.GPS_element[GPS_QUEUE.front].X1;
element->X2 = GPS_QUEUE.GPS_element[GPS_QUEUE.front].X2;
element->Y1 = GPS_QUEUE.GPS_element[GPS_QUEUE.front].Y1;
element->Y2 = GPS_QUEUE.GPS_element[GPS_QUEUE.front].Y2;
element->Z1 = GPS_QUEUE.GPS_element[GPS_QUEUE.front].Z1;
element->Z2 = GPS_QUEUE.GPS_element[GPS_QUEUE.front].Z2;
element->speed1 = GPS_QUEUE.GPS_element[GPS_QUEUE.front].speed1;
element->speed2 = GPS_QUEUE.GPS_element[GPS_QUEUE.front].speed2;
element->pos_status = GPS_QUEUE.GPS_element[GPS_QUEUE.front].pos_status;
element->year = GPS_QUEUE.GPS_element[GPS_QUEUE.front].year;
element->month = GPS_QUEUE.GPS_element[GPS_QUEUE.front].month;
element->day = GPS_QUEUE.GPS_element[GPS_QUEUE.front].day;
element->hour = GPS_QUEUE.GPS_element[GPS_QUEUE.front].hour;
element->minute = GPS_QUEUE.GPS_element[GPS_QUEUE.front].minute;
element->second = GPS_QUEUE.GPS_element[GPS_QUEUE.front].second;
element->stop_time = GPS_QUEUE.GPS_element[GPS_QUEUE.front].stop_time;
return (TRUE);
}
return (FALSE);
}