public static void Data_operation(object datatemp)
        {
            Lift_send_frame lift_Send_Frame = JsonConvert.DeserializeObject <Lift_send_frame>(datatemp.ToString());

            if (lift_Send_Frame != null)
            {
                Zhgd_iot_lift_current data = new Zhgd_iot_lift_current();
                data.sn             = lift_Send_Frame.sn;
                data.is_warning     = lift_Send_Frame.is_warning;
                data.warning_type   = lift_Send_Frame.warning_type;
                data.@timestamp     = lift_Send_Frame.@timestamp;
                data.weight         = lift_Send_Frame.weight;
                data.height         = lift_Send_Frame.height;
                data.floor          = lift_Send_Frame.floor;
                data.peoples        = lift_Send_Frame.peoples;
                data.speed          = lift_Send_Frame.speed;
                data.wind_grade     = lift_Send_Frame.wind_grade;
                data.wind_speed     = lift_Send_Frame.wind_speed;
                data.dip_x          = lift_Send_Frame.dip_x;
                data.dip_y          = lift_Send_Frame.dip_y;
                data.floor_height   = lift_Send_Frame.floor_height;
                data.door_status    = lift_Send_Frame.door_status;
                data.driver_id_code = lift_Send_Frame.driver_id_code;

                //进行数据put
                DPC.Lift_operation.Send_Lift_Current(data);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 实时数据
        /// </summary>
        /// <param name="b"></param>
        /// 7A7A0103000144003132333435363738000000000000000000000000000102000841000000000000000000000000000000000F0000000000000000000000000000000000000000000000000006637B7B7A7A010300000E003132333435363738000102000841DC7F7B7B
        public static Byte[] OnResolveRealData(byte[] b, int bCount)
        {
            string tStr = ConvertData.ToHexString(b, 0, 2);

            if (tStr != "7A7A")
            {
                return(null);
            }
            Zhgd_iot_lift_current data = new Zhgd_iot_lift_current();

            //设备编号
            byte[] t = new byte[8];
            for (int i = 8, j = 0; i < 16; i++, j++)
            {
                t[j] = b[i];
            }
            data.sn = Encoding.ASCII.GetString(t);
            string str1 = b[19].ToString("X2") + b[18].ToString("X2") + b[17].ToString("X2") + b[16].ToString("X2");

            //司机工号
            for (int i = 20, j = 0; i < 28; i++, j++)
            {
                t[j] = b[i];
            }
            //日期
            tStr = ConvertData.ToHexString(b, 28, 6);
            try
            {
                data.timestamp = DPC.DPC_Tool.GetTimeStamp(DateTime.ParseExact(tStr, "yyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture));
            }
            catch
            {
                data.timestamp = DPC.DPC_Tool.GetTimeStamp(DateTime.Now);
            }
            //重量 吨
            UShortValue s      = new UShortValue();
            string      str    = b[35].ToString("X2") + b[34].ToString("X2");
            int         result = int.Parse(str, System.Globalization.NumberStyles.HexNumber);

            data.weight = double.Parse((result / 1000.00).ToString("0.00"));//设备发送单位:吨
            //当前额定载荷
            str    = b[37].ToString("X2") + b[36].ToString("X2");
            result = int.Parse(str, System.Globalization.NumberStyles.HexNumber);
            //data.RatedWeight = (result / 1000.00).ToString("0.00");//设备发送单位:吨
            //高度 m
            s.bValue1   = b[38];
            s.bValue2   = b[39];
            data.height = double.Parse((s.sValue / 10.00).ToString("0.00"));//设备发送单位:分米
            //速度 m/秒
            s.bValue1  = b[40];
            s.bValue2  = b[41];
            data.speed = double.Parse((s.sValue / 10.00).ToString("0.00"));//设备发送单位:分米//设备发送单位:分米/秒
            //楼层
            s.bValue1  = b[42];
            data.floor = int.Parse(s.sValue.ToString("0"));
            //人数
            s.bValue1    = b[43];
            data.peoples = int.Parse(s.sValue.ToString("0"));
            //传感器状态
            s.bValue1 = b[44];
            s.bValue2 = b[45];
            // data.SensorSet = Convert.ToString(s.sValue, 2).PadLeft(16, '0');
            //报警码
            s.bValue1 = b[46];
            s.bValue2 = b[47];
            //2字节: 0-重量预警 1-重量报警 2-顶层预警 3-顶层报警 4-蹲底 5-门打开 6-风速预警 7-风速报警 9-人数报警 10-防坠器报警
            //data.AlarmType = Convert.ToString(s.sValue, 2).PadLeft(16, '0');//2字节:0-顶层预警 1-底层预警 2-顶层报警 3-底层报警 4-重量预警 5-重量报警 6-偏载 7-风速预警 8-风速报警 9-门未关好
            string        alarm = Convert.ToString(s.sValue, 2).PadLeft(16, '0');
            List <string> vs    = new List <string>();

            data.is_warning = "N";
            if (alarm[14] == '1')
            {
                vs.Add(Warning_type.重量告警); data.is_warning = "Y";
            }
            if (alarm[8] == '1')
            {
                vs.Add(Warning_type.风速报警); data.is_warning = "Y";
            }
            if (alarm[7] == '1')
            {
                vs.Add(Warning_type.人数报警); data.is_warning = "Y";
            }
            if (alarm[6] == '1')
            {
                vs.Add(Warning_type.防坠器报警); data.is_warning = "Y";
            }
            data.warning_type = vs.ToArray();
            //继电器状态
            s.bValue1 = b[48];
            //  data.PowerStatu = s.sValue.ToString("0");
            //GPRS信号强度
            //  data.GprsSignal = ((sbyte)b[49]).ToString();
            ///门状态
            data.door_status = (b[50] + Convert.ToByte(64)).ToString();//b[50].ToString();/// 加192 Convert.ToInt32("11000000",2)

            //风力等级
            data.wind_grade = b[51];
            //风速
            s.bValue1       = b[52];
            s.bValue2       = b[53];
            data.wind_speed = double.Parse((s.sValue / 100.00).ToString("0.00")); //设备发送单位:cm/s 除以100得出m/s
            //倾角X
            short X = Convert.ToInt16(("0x" + b[55].ToString("X2") + b[54].ToString("X2")), 16);

            data.dip_x = double.Parse((X / 100.00).ToString("0.00"));  //倾角X 协议要求除以100
            //倾角Y
            short Y = Convert.ToInt16(("0x" + b[57].ToString("X2") + b[56].ToString("X2")), 16);

            data.dip_y = double.Parse((Y / 100.00).ToString("0.00"));  //倾角Y 协议要求除以100
            tStr       = ConvertData.ToHexString(b, 78, 2);
            //身份证号处理
            byte[] d = new byte[18];
            for (int i = 58, j = 0; i < 76; i++, j++)
            {
                d[j] = b[i];
            }
            data.driver_id_code = Encoding.ASCII.GetString(d).Replace("\0", "");
            if (tStr != "7B7B")
            {
                return(null);
            }

            //进行数据put
            Lift_operation.Send_Lift_Current(data);
            return(null);
        }