コード例 #1
0
        /// <summary>
        /// 获取当前油量(4011协议)
        /// </summary>
        /// <param name="status"></param>
        /// <param name="AccState"></param>
        /// <param name="data"></param>
        private static void GetOilBearling(IStatusEx status, int AccState, ref YouWeiGPSData data)
        {
            if (AccState == 1)
            {
                try
                {
                    if (status.wOilValue < 500)
                    {
                        status.wOilValue = 500;
                    }

                    data.BaseData.OilBearing = (status.wOilValue - 500) / 10;
                }
                catch
                {
                    data.BaseData.OilBearing = (decimal)0.00;
                }
            }
            else
            {
                data.BaseData.OilBearing = (decimal)0.00;
            }
        }
コード例 #2
0
        /// <summary>
        /// 解析GPS上传的数据----车辆状态信息
        /// </summary>
        /// <param name="status"></param>
        /// <param name="data"></param>
        public static void ParseGPSData_StatusEx_ToEntity(IStatusEx status, ref YouWeiGPSData data)
        {
            int bitStatus = (int)status.wCtrlStatus & (byte)GPSYouWei_Flag.Flag2;

            if (bitStatus > 0)//断油
            {
                data.BaseData.OilState = 0;
            }
            else
            {
                data.BaseData.OilState = 1;
            }            

            int accFlag = (int)status.wInputLevel & (byte)GPSYouWei_Flag.Flag4;
            if (accFlag > 0)
            {
                data.BaseData.ACCState = 1;//点火
            }

            GetOilBearling(status, data.BaseData.ACCState, ref data);

            //int powerState = (int)status.wInputLevel & (byte)GPSYouWei_Flag.Flag3;
            //if (powerState > 0)
            //{
            //    data.PowerState = 1;//掉电
            //}
            //else
            //{
            //    data.PowerState = 0;
            //}

            int antennaeState = (int)status.wInputLevel & 512;
            if (antennaeState > 0)
            {
                data.BaseData.AntennaState = 1;
            }
            else
            {
                data.BaseData.AntennaState = 0;
            }
            

            int powerState = (int)status.wAlarmStatus & (byte)GPSYouWei_Flag.Flag6;
            if (powerState > 0)
            {
                data.BaseData.PowerState = 1;//掉电
            }
            else
            {
                data.BaseData.PowerState = 0;
            }

            //int doorFlag = (int)status.wStateFlags & (byte)GPSYouWei_Flag.Flag1;
            int doorFlag = (int)status.wCtrlStatus & (byte)GPSYouWei_Flag.Flag3;
            if (doorFlag <= 0)
            {
                //updated for lixun on 2012/12/16 调整过后默认为0--关门,当低电接负线后更改为1--开门
                //data.BaseData.DoorStatus = 1;//门开
                data.BaseData.DoorStatus = 0;
                data.BaseData.IsOnCar = false;
            }
            else
            {
                data.BaseData.DoorStatus = 1;
                data.BaseData.IsOnCar = true;
            }



            //data.OilOdometer = (int)status.dwOilOdometer;
            //data.Odometer = (int)status.dwOdometer;
        }