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

📄 systemmanager.lst

📁 通过车载终端采集GPS数据
💻 LST
字号:
C51 COMPILER V7.09   SYSTEMMANAGER                                                         09/17/2008 16:33:44 PAGE 1   


C51 COMPILER V7.09, COMPILATION OF MODULE SYSTEMMANAGER
OBJECT MODULE PLACED IN .\output\systemmanager.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main\systemmanager.c LARGE BROWSE INCDIR(audio\;eeprom\;extendUART\;flash\;
                    -gps\;inter\;key\;mcu\;menu\;usb\;gprs\;main\;1wire\) DEBUG OBJECTEXTEND PRINT(.\output\systemmanager.lst) OBJECT(.\outpu
                    -t\systemmanager.obj)

line level    source

   1          /********************************************
   2          *    系统变量初始化文件
   3          *    主要初始化变量包括:
   4          ********************************************/
   5          #include "typedef.h"
   6          #include "global.h"
   7          #include "systemmanager.h"
   8          #include <string.h>
   9          #include "menubuffer.h"
  10          #include "nf_config.h"
  11          #include "nvram.h"
  12          #include "nf_file.h"
  13          #include "position.h"
  14          #include "msm9841.h"
  15          #include "gps.h"
  16          #include "playsound.h"
  17          #include "common_function.h"
  18          #include <stdio.h>
  19          #include "16c554.h"
  20          xdata SYSTEM_INFO systemInfo;
  21          xdata DEVICEINFO deviceInfo;
  22          xdata SIMCARD_INFO simInfo;
  23          extern xdata BUS_INFO busInfo;//线路当前信息
  24          bit e2changeFlag;
  25          unsigned char savedataTimeout;
  26          #define SAVEDATA_TIMEOUT 3
  27          DEVICEINFO code romDeviceInfo = {   0x01,   /*software version*/
  28                                              0x10,
  29                                              {0x11,0x22,0x33},   /*device ID*/
  30                                              {0x08,0x05,0x09},   /*software date*/
  31                                              {0x11,0x39,0x00}
  32                                          };
  33          unsigned long xdata resetFlag;
  34          ALARM_ZONE gAlarmZone;
  35          void init_systemmanager()
  36          {
  37   1          e2changeFlag = 0;
  38   1          savedataTimeout = SAVEDATA_TIMEOUT;
  39   1          memset((Byte*)&systemInfo, 0, sizeof(SYSTEM_INFO));
  40   1          memset((Byte*)&simInfo, 0, sizeof(SIMCARD_INFO));
  41   1          memset((Byte*)&systemInfo, 0, sizeof(SYSTEM_INFO));
  42   1          memset((Byte*)&gAlarmZone, 0, sizeof(ALARM_ZONE));
  43   1          simInfo.validFlag = TERM_PARA_INVALID;
  44   1          memcpy((Byte*)&deviceInfo, (Byte*)&romDeviceInfo, sizeof(DEVICEINFO) );
  45   1          
  46   1          init_nfconfigdata();
  47   1          
  48   1          init_formatbuffer();
  49   1          if( resetFlag == 0x12345678 )
  50   1          {
  51   2              systemInfo.bootStatus = 1;
  52   2              systemInfo.hotCount ++;
  53   2          }
C51 COMPILER V7.09   SYSTEMMANAGER                                                         09/17/2008 16:33:44 PAGE 2   

  54   1          else
  55   1          {
  56   2              resetFlag = 0x12345678;
  57   2              systemInfo.bootStatus = 0;
  58   2              systemInfo.hotCount = 0;
  59   2          }
  60   1          read_system_nvram();
  61   1          
  62   1          init_filedata(busInfo.lineNum-1, busInfo.modeNum, busInfo.displayCurStation, busInfo.attrStation);
  63   1          
  64   1          read_alllinename(busInfo.lineNum);
  65   1          set_position_state(busInfo.direction, 0);
  66   1          systemInfo.speedHold = 99;
  67   1          systemInfo.curSpeed = 0;
  68   1          gAlarmZone.num = 0;
  69   1          systemInfo.runMode = RUN_NORMAL;
  70   1      }
  71          
  72          void read_system_nvram()
  73          {
  74   1          Byte tmpBuf[10];
  75   1          nvram_read(NVRAM_AUTO_SEND, tmpBuf);
  76   1          if ((tmpBuf[0] == 0x56) && (tmpBuf[1] == 0x78))
  77   1          {
  78   2              systemInfo.autoSendTime = tmpBuf[2]*256+tmpBuf[3];
  79   2              systemInfo.onlineTime = tmpBuf[4];
  80   2              systemInfo.arriveMeter = tmpBuf[5];
  81   2              systemInfo.leftMeter = tmpBuf[6];
  82   2          }
  83   1          else
  84   1          {
  85   2              systemInfo.autoSendTime = 10;
  86   2              systemInfo.onlineTime = 25;
  87   2              systemInfo.arriveMeter = 90;
  88   2              systemInfo.leftMeter = 30;
  89   2          }
  90   1          
  91   1      /*    nvram_read(NVRAM_ONLINE, tmpBuf);
  92   1          if ((tmpBuf[0] == 0x58) && (tmpBuf[1] == 0x76))
  93   1              systemInfo.onlineTime = tmpBuf[2];
  94   1          else
  95   1          {
  96   1              systemInfo.onlineTime = 25;
  97   1          }
  98   1          nvram_read(NVRAM_ARRIVE_METER, tmpBuf);
  99   1          if ((tmpBuf[0] == 0x58) && (tmpBuf[1] == 0x76))
 100   1              systemInfo.arriveMeter = tmpBuf[2];
 101   1          else
 102   1          {
 103   1              systemInfo.arriveMeter = 90;
 104   1          }
 105   1          nvram_read(NVRAM_LEFT_METER, tmpBuf);
 106   1          if ((tmpBuf[0] == 0x58) && (tmpBuf[1] == 0x76))
 107   1              systemInfo.leftMeter = tmpBuf[2];
 108   1          else
 109   1          {
 110   1              systemInfo.leftMeter = 30;
 111   1          }*/
 112   1          nvram_read(NVRAM_VOICE_VOLUME, tmpBuf);
 113   1          if ((tmpBuf[0] >= 1) && (tmpBuf[0] <= 8))
 114   1              systemInfo.volume = tmpBuf[0];
 115   1          else
C51 COMPILER V7.09   SYSTEMMANAGER                                                         09/17/2008 16:33:44 PAGE 3   

 116   1              systemInfo.volume = 8;
 117   1          msm_change_volume(8-systemInfo.volume);
 118   1          nvram_read(NVRAM_BUS_LINEMODE, tmpBuf);
 119   1          if ((tmpBuf[0] >= 1) && (tmpBuf[0] <= 6))
 120   1              busInfo.modeNum = tmpBuf[0];
 121   1          else    
 122   1              busInfo.modeNum = 1;
 123   1          nvram_read(NVRAM_BUS_LINENUM, tmpBuf);
 124   1          if ((tmpBuf[0] >= 1) && (tmpBuf[0] <= 6))
 125   1              busInfo.lineNum = tmpBuf[0];
 126   1          else    
 127   1              busInfo.lineNum = 1;
 128   1          nvram_read(NVRAM_BUS_LINEDIRRECTION, tmpBuf);
 129   1          if (tmpBuf[0] <= 1)
 130   1              busInfo.direction = tmpBuf[0];
 131   1          else
 132   1              busInfo.direction = BUS_UPWARD;
 133   1          nvram_read(NVRAM_STATION_NUM, tmpBuf);
 134   1          if ((tmpBuf[0] >= 1) && (tmpBuf[0] < 128))
 135   1              busInfo.displayCurStation = tmpBuf[0];
 136   1          else
 137   1              busInfo.displayCurStation = 1;
 138   1          nvram_read(NVRAM_STATION_ATTR, tmpBuf);
 139   1          if (tmpBuf[0] <= 2)
 140   1              busInfo.attrStation = tmpBuf[0];
 141   1          else
 142   1              busInfo.attrStation = FIRST_STATION;
 143   1          busInfo.lineAttr = NORMAL_LINE;
 144   1          systemInfo.boardMode = MANUAL_BOARD;
 145   1          systemInfo.runMode = RUN_NORMAL;
 146   1          systemInfo.landFlag = 0;
 147   1          systemInfo.year   = 6;
 148   1          systemInfo.mon  = 6;
 149   1          systemInfo.day    = 9;
 150   1          systemInfo.hour   = 14;
 151   1          systemInfo.min = 10;
 152   1          systemInfo.sec = 0;
 153   1          
 154   1      }
 155          
 156          
 157          /********************************************
 158          *每隔三秒保存:用来保存那些经常变化的内容,
 159          *包括当前行车方向、当前站点序号以及当前站点属性。
 160          *由主循环一秒钟调用一次
 161          **********************************************/
 162          void save_stationdata()
 163          {
 164   1          Byte tmpBuf[3];
 165   1          if (0 == savedataTimeout)
 166   1          {
 167   2              if (1 == e2changeFlag)
 168   2              {
 169   3                  e2changeFlag = 0;
 170   3                  tmpBuf[0] = busInfo.direction;
 171   3                  tmpBuf[1] = busInfo.displayCurStation;
 172   3                  tmpBuf[2] = busInfo.attrStation;
 173   3                  nvram_writestationData(tmpBuf);
 174   3              }
 175   2              savedataTimeout = SAVEDATA_TIMEOUT;
 176   2          }
 177   1          else
C51 COMPILER V7.09   SYSTEMMANAGER                                                         09/17/2008 16:33:44 PAGE 4   

 178   1              savedataTimeout--;
 179   1      }
 180          
 181          void set_stationdata_changed()
 182          {
 183   1          e2changeFlag = 1;
 184   1      }
 185          
 186          /***以下为电子围栏的处理函数*****/
 187          
 188          
 189          //#define ALARMZONE_TIMEOUT 5
 190          //#define ALARMZONE_SPEEDTIME 6//持续30s以上超时,将进行声音提示
 191          //每5秒调用一次
 192          /*x:经度;y:纬度*/
 193          extern char debug_msg[1024];
 194          void alarmzone_process()
 195          {
 196   1      /*    GPS_DATA *gps_ptr;
 197   1          Byte i;
 198   1          long littlex, littley, largex, largey;
 199   1          if (gAlarmZone.num > 0)
 200   1          {
 201   1              gAlarmZone.timeout++;
 202   1              if (gAlarmZone.timeout >=  ALARMZONE_TIMEOUT)
 203   1              {   
 204   1                  gAlarmZone.timeout = 0;
 205   1                  get_gps_data(&gps_ptr);
 206   1                  
 207   1                  if (gps_ptr->valid != 0)
 208   1                  {
 209   1                      
 210   1                      //对每个电子围栏进行检测
 211   1                      sprintf(debug_msg, "%02bd:VALID ", gps_ptr->valid);
 212   1                      siob_send(debug_msg, strlen(debug_msg));    
 213   1                      for (i=0; i<gAlarmZone.num; i++)
 214   1                      {
 215   1                          if (gAlarmZone.zone[i].Point1X < gAlarmZone.zone[i].Point2X)
 216   1                          {
 217   1                              littlex = gAlarmZone.zone[i].Point1X;
 218   1                              largex = gAlarmZone.zone[i].Point2X;
 219   1                          }
 220   1                          else
 221   1                          {
 222   1                              littlex = gAlarmZone.zone[i].Point2X;
 223   1                              largex = gAlarmZone.zone[i].Point1X;
 224   1                          }
 225   1                          if (gAlarmZone.zone[i].Point1Y < gAlarmZone.zone[i].Point2Y)
 226   1                          {
 227   1                              littley = gAlarmZone.zone[i].Point1Y;
 228   1                              largey = gAlarmZone.zone[i].Point2Y;
 229   1                          }
 230   1                          else
 231   1                          {
 232   1                              littley = gAlarmZone.zone[i].Point2Y;
 233   1                              largey = gAlarmZone.zone[i].Point1Y;
 234   1                          }
 235   1                          if (1 == isInAlarmZone(gps_ptr->longitude, littlex, largex))
 236   1                          {
 237   1                              if (1 == isInAlarmZone(gps_ptr->latitude, littley, largey))
 238   1                              {
 239   1                                  if (systemInfo.speedHold > gAlarmZone.zone[i].menuSpeed)
C51 COMPILER V7.09   SYSTEMMANAGER                                                         09/17/2008 16:33:44 PAGE 5   

 240   1                                      systemInfo.speedHold = gAlarmZone.zone[i].menuSpeed;
 241   1                                  if (gps_ptr->speed > gAlarmZone.zone[i].speed)                            
 242   1                                      break;
 243   1                              }
 244   1                          }
 245   1                      }
 246   1                      if ((i < gAlarmZone.num) && (gAlarmZone.speedouttime < ALARMZONE_SPEEDTIME))
 247   1                          gAlarmZone.speedouttime++;
 248   1                      else if ((i >= gAlarmZone.num) && (gAlarmZone.speedouttime > 0))
 249   1                          gAlarmZone.speedouttime--;
 250   1                      if (gAlarmZone.speedouttime >= ALARMZONE_SPEEDTIME)
 251   1                      {
 252   1                          gAlarmZone.speedouttime = ALARMZONE_SPEEDTIME;
 253   1                          //播放超速提示音
 254   1                          play_littlespeaker(LITTLESPEAKER_SPEEDALARM);
 255   1                      }
 256   1                          
 257   1                  }
 258   1              }
 259   1          }*/
 260   1      }
 261          
 262          void add_alarmOneZone(Byte *pSrcBuf)
 263          {
 264   1          Byte tmpValue;
 265   1          tmpValue = gAlarmZone.num;
 266   1          memcpy((Byte*)&(gAlarmZone.zone[tmpValue].Point1X), pSrcBuf, 4);
 267   1          memcpy((Byte*)&(gAlarmZone.zone[tmpValue].Point1Y), pSrcBuf+4, 4);
 268   1          memcpy((Byte*)&(gAlarmZone.zone[tmpValue].Point2X), pSrcBuf+8, 4);
 269   1          memcpy((Byte*)&(gAlarmZone.zone[tmpValue].Point2Y), pSrcBuf+12, 4);
 270   1          gAlarmZone.zone[tmpValue].menuSpeed = pSrcBuf[16];
 271   1          swap_ulong((Byte*)&(gAlarmZone.zone[tmpValue].Point1X));
 272   1          swap_ulong((Byte*)&(gAlarmZone.zone[tmpValue].Point1Y));
 273   1          swap_ulong((Byte*)&(gAlarmZone.zone[tmpValue].Point2X));
 274   1          swap_ulong((Byte*)&(gAlarmZone.zone[tmpValue].Point2Y));
 275   1          gAlarmZone.num++;
 276   1      }
 277          
 278          void set_systemlandflag()
 279          {
 280   1          systemInfo.landFlag = 1;
 281   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    975    ----
   CONSTANT SIZE    =     11    ----
   XDATA SIZE       =    155      17
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =      1    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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