コード例 #1
0
 /// <summary>
 /// 根据设备名获取设备
 /// </summary>
 /// <param name="busname"></param>
 /// <param name="bus"></param>
 /// <returns></returns>
 public static bool GetModbusByName(string busname, out Modbus bus)
 {
     lock (obj)
     {
         if (ModbusDict.ContainsKey(busname))
         {
             return(ModbusDict.TryGetValue(busname, out bus));
         }
         else
         {
             bus = null;
             return(false);
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="bus"></param>
 public static bool AddModbus(Modbus bus)
 {
     lock (obj)
     {
         if (ModbusDict.ContainsKey(bus.Name))
         {
             MsgLogger.PushMsg(bus.Name, "Add", "Fail, already exist.");
             return(false);
         }
         else
         {
             ModbusDict.Add(bus.Name, bus);
             MsgLogger.PushMsg(bus.Name, "Add", "Success.");
             return(true);
         }
     }
 }