⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autoboard.c

📁 通过车载终端采集GPS数据
💻 C
字号:
#include "typedef.h"
#include "global.h"
#include "trans_process.h"
#include "position.h"
#include "autoboard.h"
#include "nf_file.h"
#include "commoninterface.h"
#include "menuinterface.h"
#include "manualboard.h"
#include <string.h>

///add for debug
#include "centerinterface.h"
#include "gprs.h"
#include "16c554.h"
#include "nf_drv.h"
#include "playsound.h"
#include "display.h"
//end for add
extern xdata BUS_INFO busInfo;//线路当前信息
unsigned char position_value, position_act;
Byte getAutoPositionValue()
{
    return position_value;
}

void voice_process(void)
{
    Byte workState;

    position_value = position_process();


    if( position_value < 0x40 )
        position_act = 0;
    else
        position_act = 1;

                    
    get_cur_runmode(&workState);
    
    if( (workState == RUN_NORMAL) || (get_board_mode() == FORCE_BOARD) )
    {
        if( (position_value!=00) && (position_value!=0xFF) )
        {
            if( position_value > 0x80 )
                inform_station(position_value, 0);
            else
            {
                if( busInfo.direction == 0 )
                    busInfo.tranCurStation = position_value & 0x3F;
                else
                    busInfo.tranCurStation = position_value | 0x40;
                process_menu_station(position_act, busInfo.tranCurStation);

                if( (position_act==1) && (position_stop()==0) )
                    make_runmode_message(3, busInfo.tranCurStation);  /*溜站*/
                else
                    make_runmode_message(position_act, busInfo.tranCurStation);
            }
        }
    }

}

void process_menu_station(unsigned char action, unsigned char station)
{
    unsigned char tmp;

    tmp = station;
    if( action )
        tmp = get_nextstationNum(station);

    inform_station(tmp, action);
    
}


char *position2string(long value)
{
    unsigned int degree, coin1,coin2;
    long tmp_long;
    static char strBuffer[20];

    tmp_long = value / 10000;
    degree = tmp_long / 60;

    tmp_long = 10000;
    tmp_long *= 60 * degree;
    tmp_long = (value - tmp_long);
    coin1 = tmp_long / 10;
    coin2 = tmp_long % 10;

    sprintf(strBuffer, "%03u.%05u%u", degree, coin1, coin2);
    return strBuffer;
}

/*****for debug*************/
char debug_msg[1024];
extern GPRS_INFO_STRUCT gprsInfo;
extern IP_INFO_STRUCT ipInfo;

unsigned long debug_address = 0x00c80000;
unsigned char debug_pos_value=0;
extern POSITIONINFO positionInfo[204];
void debug_msgNeeded(unsigned char *pBuf)
{
    
/*    char *tmp_ptr;
    tmp_ptr = debug_msg;
    *tmp_ptr = 0;
    sprintf(tmp_ptr, "%02bX:%02bX,%02bX:%02bX,\r\n ", pBuf[0], pBuf[1], pBuf[2], pBuf[3]);
    siob_send(debug_msg, strlen(debug_msg));*/
/*    char *tmp_ptr;
    tmp_ptr = debug_msg;
    *tmp_ptr = 0;
    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "%X\r\n", value);

    siob_send(debug_msg, strlen(debug_msg));*/
}
extern unsigned char gPosDirction;
extern ALARM_ZONE gAlarmZone;
extern xdata SYSTEM_INFO systemInfo;

#define ALARMZONE_TIMEOUT 6
#define ALARMZONE_SPEEDTIME 7//持续30s以上超时,将进行声音提示
Byte isInAlarmZone(long longtitude, long little, long larg)
{
    if ((longtitude > little) && (longtitude < larg))
        return 1;
    else
        return 0;
}
void debug_position(void)
{
/*    if (1 == systemInfo.landFlag)
    {
        char *tmp_ptr;
        unsigned char i;
        GPS_DATA *gps_ptr;
        tmp_ptr = debug_msg;
        *tmp_ptr = 0;
        tmp_ptr = debug_msg + strlen(debug_msg);
        get_gps_data(&gps_ptr);
        sprintf(tmp_ptr, "%s, ", position2string(gps_ptr->longitude) );
    
        tmp_ptr = debug_msg + strlen(debug_msg);
        sprintf(tmp_ptr, "%s::",  position2string(gps_ptr->latitude));
    
        tmp_ptr = debug_msg + strlen(debug_msg);
        sprintf(tmp_ptr, "%bu::",  gAlarmZone.num);
        tmp_ptr = debug_msg + strlen(debug_msg);
        for (i=0; i<gAlarmZone.num; i++)
        {
            sprintf(tmp_ptr, "%s, ", position2string(gAlarmZone.zone[i].Point1X) );
    
            tmp_ptr = debug_msg + strlen(debug_msg);
            sprintf(tmp_ptr, "%s::",  position2string(gAlarmZone.zone[i].Point1Y));
        
            tmp_ptr = debug_msg + strlen(debug_msg);
            sprintf(tmp_ptr, "%s, ", position2string(gAlarmZone.zone[i].Point2X) );
    
            tmp_ptr = debug_msg + strlen(debug_msg);
            sprintf(tmp_ptr, "%s::",  position2string(gAlarmZone.zone[i].Point2Y));
        
            tmp_ptr = debug_msg + strlen(debug_msg);
        }
        sprintf(tmp_ptr, "\r\n");
    
        siob_send(debug_msg, strlen(debug_msg));
    }*/
/*   nf_read_tobuf3(debug_address, debug_msg, 128);
    siob_send(debug_msg, 128);
    debug_address += 128;
    sprintf(debug_msg, "%bu\r\n", debugTestValue);
    siob_send(debug_msg, strlen(debug_msg));*/
/*     char *tmp_ptr;
    tmp_ptr = debug_msg;
    *tmp_ptr = 0;
    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "value:%bu;", positionInfo[debug_pos_value].value);
    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "LATI:%s ", position2string(positionInfo[debug_pos_value].latitude) );

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "LONG:%s ", position2string(positionInfo[debug_pos_value].longitude) );

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "speed:%bu;", positionInfo[debug_pos_value].speed);
    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "\r\n");

    sioc_send(debug_msg, strlen(debug_msg));
    debug_pos_value++;
    if (debug_pos_value >= 204)
        debug_pos_value = 0;*/

/*    char *tmp_ptr;
    unsigned char position_state;
    unsigned char cur_position;
    long position_cur, position_next;

    GPS_DATA *gps_ptr;

    cur_position = get_cur_position();
    position_state = get_position_state();
    position_cur = get_cur_station_dis();
    position_next = get_next_station_dis();

    get_gps_data(&gps_ptr);

    tmp_ptr = debug_msg;
    *tmp_ptr = 0;

    tmp_ptr = debug_msg + strlen(debug_msg);
    get_line_id(tmp_ptr);
    *(tmp_ptr+4) = 0;

    tmp_ptr = debug_msg + strlen(debug_msg);
    if( position_state )
        sprintf(tmp_ptr, " LOCK   ");
    else
        sprintf(tmp_ptr, " UNLOCK ");


    tmp_ptr = debug_msg + strlen(debug_msg);
    if( (position_value==0) || (position_value==0xFF) )
        sprintf(tmp_ptr, "IDLE:");
    else
        sprintf(tmp_ptr, "ACT :");

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "%02bX:%02bX, ", position_value, cur_position);

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "CUR:%05ld:%05ld ", position_cur,position_next);

#if 0 
    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "AR:%bd:%bd:%bd ", 
                    voiceInfo.arriveFlag, voiceInfo.location, gPosDirction);

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "LAST:%05ld:%05ld ", 
                    voiceInfo.lastDisCur, voiceInfo.lastDisNex);

#endif

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "VALID:%02bd ", gps_ptr->valid);

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "LATI:%s ", position2string(gps_ptr->latitude) );

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "LONG:%s ", position2string(gps_ptr->longitude) );

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "SPEED:%04d TIME:%02bd:%02bd:%02bd ", 
                   gps_ptr->speed, gps_ptr->time[0], gps_ptr->time[1], gps_ptr->time[2]);

    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "GPRS:%bu TX:%u, RX:%u, RST:%bd",
            gprsInfo.state, ipInfo.txCount, ipInfo.rxCount, gprsInfo.resetCount);


    tmp_ptr = debug_msg + strlen(debug_msg);
    sprintf(tmp_ptr, "\r\n");

    siob_send(debug_msg, strlen(debug_msg));*/
    GPS_DATA *gps_ptr;
    Byte i, tmpValue;
    long littlex, littley, largex, largey;
    get_gps_data(&gps_ptr);
    set_menucurspeed(gps_ptr->speed);
    tmpValue = get_menucurspeed();
  /*  gAlarmZone.timeout++;
    if (gAlarmZone.timeout >  ALARMZONE_TIMEOUT)
    {   
        gAlarmZone.timeout = 0;
        
        
        if (gps_ptr->valid != 0)
        {  
            for (i=0; i<gAlarmZone.num; i++)
            {
                if (gAlarmZone.zone[i].Point1X < gAlarmZone.zone[i].Point2X)
                {
                    littlex = gAlarmZone.zone[i].Point1X;
                    largex = gAlarmZone.zone[i].Point2X;
                }
                else
                {
                    littlex = gAlarmZone.zone[i].Point2X;
                    largex = gAlarmZone.zone[i].Point1X;
                }
                if (gAlarmZone.zone[i].Point1Y < gAlarmZone.zone[i].Point2Y)
                {
                    littley = gAlarmZone.zone[i].Point1Y;
                    largey = gAlarmZone.zone[i].Point2Y;
                }
                else
                {
                    littley = gAlarmZone.zone[i].Point2Y;
                    largey = gAlarmZone.zone[i].Point1Y;
                }
                if (1 == isInAlarmZone(gps_ptr->longitude, littlex, largex))
                {
                    if (1 == isInAlarmZone(gps_ptr->latitude, littley, largey))
                    {
                        
                        if (systemInfo.speedHold > gAlarmZone.zone[i].menuSpeed)
                            systemInfo.speedHold = gAlarmZone.zone[i].menuSpeed;
                        if (tmpValue > gAlarmZone.zone[i].menuSpeed)                            
                            break;
                    }
                }
            }
            if ((i < gAlarmZone.num) && (gAlarmZone.speedouttime < ALARMZONE_SPEEDTIME))
                gAlarmZone.speedouttime++;
            else if ((i >= gAlarmZone.num) && (gAlarmZone.speedouttime > 0))
                gAlarmZone.speedouttime--;
            if (gAlarmZone.speedouttime >= ALARMZONE_SPEEDTIME)
            {
                gAlarmZone.speedouttime = ALARMZONE_SPEEDTIME;
                //播放超速提示音
                play_littlespeaker(LITTLESPEAKER_SPEEDALARM);
            }
                
        }
    }*/
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -