예제 #1
0
 /// <summary>
 /// 查询线圈当前状态
 /// </summary>
 /// <param name="coilAddr"></param>
 /// <returns></returns>
 public bool this[String coilAddr]
 {
     get
     {
         if (String.IsNullOrEmpty(coilAddr))
         {
             return(false);
         }
         int start = ScanStartIndex;
         int end   = int.Parse(coilAddr.Substring(1));
         try
         {
             if (end >= start)
             {
                 return(this.RunResult[end - start]);
             }
         }
         catch (Exception ex)
         {
             Tool.AppLogError(ex);
         }
         return(false);
     }
     set
     {
         if (String.IsNullOrEmpty(coilAddr))
         {
             return;
         }
         int start = int.Parse(Constants.OutputStartAddr.Substring(1));
         int end   = int.Parse(coilAddr.Substring(1));
         try
         {
             if (end >= start)
             {
                 this.RunResult[end - start] = value;
             }
         }
         catch (Exception ex)
         {
             Tool.AppLogDebug(ex);
         }
     }
 }