Beispiel #1
0
 void Handle_GNPX()
 {
     if (First_Run_POS == true && gnpx.zt == 1)
     {
         if (count_time == 0)
         {
             if (BaiduAPI.Geocoding_API(Convert.ToString((((gnpx.wxm / 60.0) + gnpx.wm) / 60.0 + gnpx.wf) / 60.0 + gnpx.wd),
                                        Convert.ToString((((gnpx.jxm / 60.0) + gnpx.jm) / 60.0 + gnpx.jf) / 60.0 + gnpx.jd), ref address) == true)
             {
                 First_Run_POS = false;
             }
             else
             {
                 count_time += BD_PRINT_GNPX_SEQ;
             }
             print_flag |= PRINT_FIRST_ADDRESS;
         }
         else
         {
             count_time += BD_PRINT_GNPX_SEQ;
             if (count_time >= 60)//如果调用API失败,控制在60秒内不再调用
             {
                 count_time = 0;
             }
         }
     }
 }
Beispiel #2
0
        void DATA_Handler(ref UCHR[] fxfdz, ref UCHR h, ref UCHR m, ref UCHR[] data, ref UINT lenth)
        {
            //TODO
            int ex_i = 0;

            if (data[0] == 1)
            {
                ex_i = 4;
            }


            int   id   = (fxfdz[0] << 16) | (fxfdz[1] << 8) | fxfdz[2];
            float temp = (float)(data[ex_i + 1] / 1.0);

            if (data[ex_i + 2] < 10)
            {
                temp += (float)(data[ex_i + 2] / 10.0);
            }
            else
            {
                temp += (float)(data[ex_i + 2] / 100.0);
            }
            float humi = (float)(data[ex_i + 3] / 1.0);

            if (data[ex_i + 4] < 10)
            {
                humi += (float)(data[ex_i + 4] / 10.0);
            }
            else
            {
                humi += (float)(data[ex_i + 4] / 100.0);
            }
            float mq135 = (float)(((Convert.ToUInt16(data[ex_i + 5]) << 8) | data[ex_i + 6]) / 10000.0);
            char  jdfw  = (data[ex_i + 11] & 0x80) == 1 ? 'W' : 'E';
            char  wdfw  = (data[ex_i + 8] & 0x80) == 1 ? 'S' : 'N';

            data[ex_i + 11] &= 0x7F;
            data[ex_i + 8]  &= 0x7F;
            DateTime time = new DateTime(Convert.ToInt32(gntx.year), gntx.month, gntx.day, gntx.hour, gntx.minute, gntx.second);

            if (!MyDataBase.CheckBDID_exist(id))//检查ID存不存在,存在则更新
            {
                if (data[0] == 1)
                {
                    MyDataBase.Insertidcard(id, time, data[1], data[2], data[3], data[4]);
                }
                else
                {
                    MyDataBase.Insertidcard(id, time);
                }
                if (!MyDataBase.IsTableExist("UserID_" + Convert.ToString(id) + "_Data"))//检查数据表存不存在,不存在则创建
                {
                    if (!MyDataBase.New_tb_for_id_data(id))
                    {
                        MessageBox.Show("", "建表失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                if (!MyDataBase.CheckAlarm_isexist(id))//检查Alarm表ID存不存在
                {
                    MyDataBase.Insertid_ToAlarm(id);
                }
            }
            else
            {
                if (data[0] == 1)
                {
                    MyDataBase.Updateidcard(id, time, data[1], data[2], data[3], data[4]);
                }
                else
                {
                    MyDataBase.Updateidcard(id, time);
                }
            }

            if (BaiduAPI.Geocoding_API(Convert.ToString((data[ex_i + 9] / 60.0 + data[ex_i + 8]) / 60.0 + data[ex_i + 7]),
                                       Convert.ToString((data[ex_i + 12] / 60.0 + data[ex_i + 11]) / 60.0 + data[ex_i + 10]), ref temp_addr) == true)
            {
                if (!MyDataBase.InsertData(id, temp, humi, mq135, data[ex_i + 7], data[ex_i + 8], data[ex_i + 9], data[ex_i + 10], data[ex_i + 11], data[ex_i + 12], wdfw, jdfw, time, temp_addr))
                {
                    MessageBox.Show("", "插入失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (!MyDataBase.InsertData(id, temp, humi, mq135, data[ex_i + 7], data[ex_i + 8], data[ex_i + 9], data[ex_i + 10], data[ex_i + 11], data[ex_i + 12], wdfw, jdfw, time, ""))
                {
                    MessageBox.Show("", "插入失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }