示例#1
0
 /// <summary>
 ///根据条件查询列表 
 /// </summary>
 public List<a_dianliang> SearchList(a_dianliang Query)
 {
     #region 关键字过滤 ;
     //string 类型需要过滤 ;
     //Query.name = "%" + StaticBase.KeyFilter(Query.name) + "%";
     #endregion ;
     ResultView rv = respository.GetList<a_dianliang>(" where id = @id ", Query);
     if (rv.Result == 1)
     {
         return rv.Info;
     }
     return null;
 }
示例#2
0
 /// <summary>
 ///根据条件查询对象 
 /// </summary>
 public a_dianliang SearchModel(a_dianliang Query)
 {
     #region 关键字过滤 ;
     //string 类型需要过滤 ;
     //Query.name = "%" + StaticBase.KeyFilter(Query.name) + "%";
     #endregion ;
     ResultView rv = respository.GetModel<a_dianliang>(" select * from a_dianliang where id= @id   ", Query);
     if (rv.Result == 1)
     {
         return rv.Info;
     }
     return null;
 }
示例#3
0
 /// <summary>
 ///根据条件删除 
 /// </summary>
 public bool DeleteList(a_dianliang Query)
 {
     #region 关键字过滤 ;
     //string 类型需要过滤 ;
     //Query.name = "%" + StaticBase.KeyFilter(Query.name) + "%";
     #endregion ;
     ResultView rv = respository.DeleteList<a_dianliang>(" where id = @id  ", Query);
     if (rv.Result == 1) 
     { 
        return true; 
      } 
      return false; 
 }
示例#4
0
        /// <summary>
        /// 设备数据域上传
        /// </summary>
        private byte[] ModbusUpload(byte[] data)
        {
            if (data[5] == data[7] && data[5] == 0x31 && data[9] == data[8] && data[8] == 0x28 && data[11] == 0x03)
            {
                ADianliangRepository dlrep = new ADianliangRepository();
                a_dianliang          model = new a_dianliang();
                int    index = 10;
                string dz    = data[index].ToString();
                index++;
                index++;
                string zjs = data[index].ToString();
                index++;
                string dybh = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 2));
                index += 2;
                string dlbh = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 2));
                index += 2;
                string nxwd = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 2));
                index += 2;
                string sjrq = ("20" + data[index + 5].ToString("X")) + "-" + data[index + 4].ToString("X") + "-" + data[index + 3].ToString("X") + " " + data[index + 2].ToString("X") + ":" + data[index + 1].ToString("X") + ":" + data[index].ToString("");

                index += 6;
                string ady = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 2));
                index += 2;
                string bdy = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 2));
                index += 2;
                string cdy = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 2));

                index += 8;
                string adl = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 2));
                index += 2;
                string bdl = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 2));
                index += 2;
                string cdl = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 2));

                try
                {
                    model.date = DateTime.Parse(sjrq).ToString("yyyy-MM-dd HH:mm:ss");
                }
                catch
                {
                    model.date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                }
                model.xdy1 = Convert.ToDecimal(int.Parse(ady) / 10.0);
                model.xdy2 = Convert.ToDecimal(int.Parse(bdy) / 10.0);
                model.xdy3 = Convert.ToDecimal(int.Parse(cdy) / 10.0);

                model.dl1 = Convert.ToDecimal(int.Parse(adl) / 100.00);
                model.dl2 = Convert.ToDecimal(int.Parse(bdl) / 100.00);
                model.dl3 = Convert.ToDecimal(int.Parse(cdl) / 100.00);
                TxtLogHelper.WriteLog("解析命令:A电压" + ady + " B电压" + bdy + " C电压 " + cdy + " A电流" + adl + " B电流" + bdl + " C电流" + cdl, "TCP", 1);
                index = 12 + int.Parse(zjs) + 14;
                if (data.Length > (index + 68))
                {
                    zjs    = data[index + 2].ToString();
                    index += 3;
                    string zdn = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 4));
                    index += 20;
                    string adn = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 4));
                    index += 4;
                    index += 16;
                    string bdn = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 4));
                    index += 4;
                    index += 16;
                    string cdn = ByteHelper.HexToTen(ByteHelper.ByteToString(data, index, 4));


                    model.zydl = Convert.ToDecimal(int.Parse(zdn) / 100.00);
                    model.aydl = Convert.ToDecimal(int.Parse(adn) / 100.00);
                    model.bydl = Convert.ToDecimal(int.Parse(bdn) / 100.00);
                    model.cydl = Convert.ToDecimal(int.Parse(cdn) / 100.00);
                    TxtLogHelper.WriteLog("解析命令: A电能" + adn + " B电能" + bdn + " C电能" + cdn + " 总电能" + zdn, "TCP", 1);
                }

                //dlrep.Insert(model);
            }
            TxtLogHelper.WriteLog("设备数据域上传回复命令内容:" + "7b 7b 91 7e ec 7d 7d", "TCP", 1);
            ConsoleWriteLine("设备数据域上传回复命令内容:7b 7b 91 7e ec 7d 7d", 1);
            return(ByteHelper.StringToByte("7b 7b 91 7e ec 7d 7d"));//固定值
        }