Exemplo n.º 1
0
        public async Task <bool> SetForceAsync(int index, int bit, HncRegType type = HncRegType.REG_TYPE_B)
        {
            Clear(index, bit, type);
            await Task.Delay(2000);

            return(Set(index, bit, type));
        }
Exemplo n.º 2
0
 public bool Clear(int index, int bit, HncRegType type = HncRegType.REG_TYPE_B)
 {
     try
     {
         return(HNC_RegClrBit(type, index, bit));
     }
     catch (Exception)
     {
         //TODO
         //throw;
     }
     return(false);
 }
Exemplo n.º 3
0
 public bool Trigger(int index, int bit, HncRegType type = HncRegType.REG_TYPE_B)
 {
     try
     {
         return(Exist(index, bit, type) && Clear(index, bit, type));
     }
     catch (Exception)
     {
         //TODO
         //throw;
     }
     return(false);
 }
Exemplo n.º 4
0
        private bool Publish(HncRegType type, int index, int value, int NCMessageFunction)
        {
            var message = new NCMessage
            {
                Type  = "Register",
                Index = NCMessageFunction,
                Value = JsonConvert.SerializeObject(
                    new
                {
                    regType = Enum.GetName(typeof(HncRegType), type).Replace("REG_TYPE_", ""),
                    index,
                    value,
                }),
            };

            return(Publish(message.ToString()));
        }
Exemplo n.º 5
0
 /// <summary>
 /// 查询信号是否存在
 /// </summary>
 /// <param name="index">Index</param>
 /// <param name="bit">Bit</param>
 /// <param name="type">寄存器类型</param>
 /// <returns>信号值为1则返回TRUE</returns>
 public bool Exist(int index, int bit, HncRegType type = HncRegType.REG_TYPE_B)
 {
     try
     {
         int value = 0;
         if (HNC_RegGetValue(type, index, out value))
         {
             return(((value >> bit) & 1) == 1);
         }
     }
     catch (Exception)
     {
         //TODO
         //throw;
     }
     return(false);
 }
Exemplo n.º 6
0
 public bool SetForce(int index, int bit, HncRegType type = HncRegType.REG_TYPE_B)
 {
     Clear(index, bit, type);
     Thread.Sleep(2000);
     return(Set(index, bit, type));
 }
Exemplo n.º 7
0
 public bool HNC_RegClrBit(HncRegType type, int index, int bit)
 {
     return(Publish(type, index, bit, NCMessageFunction.REG_CLR));
 }
Exemplo n.º 8
0
 public bool HNC_RegSetBit(HncRegType type, int index, int bit)
 {
     return(Publish(type, index, bit, NCMessageFunction.REG_SET_BIT));
 }
Exemplo n.º 9
0
 public bool HNC_RegSetValue(HncRegType type, int index, byte value)
 {
     return(HNC_RegSetValue(type, index, Convert.ToInt32(value)));
 }
Exemplo n.º 10
0
 public bool HNC_RegSetValue(HncRegType type, int index, int value)
 {
     return(Publish(type, index, value, NCMessageFunction.PARAMAN_SET));
 }
Exemplo n.º 11
0
        public bool HNC_RegGetValue(HncRegType type, int index, out int value)
        {
            var key = "Register:" + Enum.GetName(typeof(HncRegType), type).Replace("REG_TYPE_", "");

            return(db.HashGet(key, index.ToString("D4")).TryParse(out value));
        }